• 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
SVGFEDisplacementMapElement.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2006 Oliver Hunt <oliver@nerget.com>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18  */
19 
20 
21 #include "config.h"
22 
23 #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
24 #include "SVGFEDisplacementMapElement.h"
25 
26 #include "SVGResourceFilter.h"
27 
28 namespace WebCore {
29 
30 SVGFEDisplacementMapElement::SVGFEDisplacementMapElement(const QualifiedName& tagName, Document* doc)
31  : SVGFilterPrimitiveStandardAttributes(tagName, doc)
32  , m_xChannelSelector(SVG_CHANNEL_A)
33  , m_yChannelSelector(SVG_CHANNEL_A)
34  , m_scale(0.0f)
35  , m_filterEffect(0)
36 {
37 }
38 
39 SVGFEDisplacementMapElement::~SVGFEDisplacementMapElement()
40 {
41  delete m_filterEffect;
42 }
43 
44 ANIMATED_PROPERTY_DEFINITIONS(SVGFEDisplacementMapElement, String, String, string, In1, in1, SVGNames::inAttr, m_in1)
45 ANIMATED_PROPERTY_DEFINITIONS(SVGFEDisplacementMapElement, String, String, string, In2, in2, SVGNames::in2Attr, m_in2)
46 ANIMATED_PROPERTY_DEFINITIONS(SVGFEDisplacementMapElement, int, Enumeration, enumeration, XChannelSelector, xChannelSelector, SVGNames::xChannelSelectorAttr, m_xChannelSelector)
47 ANIMATED_PROPERTY_DEFINITIONS(SVGFEDisplacementMapElement, int, Enumeration, enumeration, YChannelSelector, yChannelSelector, SVGNames::yChannelSelectorAttr, m_yChannelSelector)
48 ANIMATED_PROPERTY_DEFINITIONS(SVGFEDisplacementMapElement, float, Number, number, Scale, scale, SVGNames::scaleAttr, m_scale)
49 
50 SVGChannelSelectorType SVGFEDisplacementMapElement::stringToChannel(const String& key)
51 {
52  if (key == "R")
53  return SVG_CHANNEL_R;
54  else if (key == "G")
55  return SVG_CHANNEL_G;
56  else if (key == "B")
57  return SVG_CHANNEL_B;
58  else if (key == "A")
59  return SVG_CHANNEL_A;
60 
61  return SVG_CHANNEL_UNKNOWN;
62 }
63 
64 void SVGFEDisplacementMapElement::parseMappedAttribute(MappedAttribute* attr)
65 {
66  const String& value = attr->value();
67  if (attr->name() == SVGNames::xChannelSelectorAttr)
68  setXChannelSelectorBaseValue(stringToChannel(value));
69  else if (attr->name() == SVGNames::yChannelSelectorAttr)
70  setYChannelSelectorBaseValue(stringToChannel(value));
71  else if (attr->name() == SVGNames::inAttr)
72  setIn1BaseValue(value);
73  else if (attr->name() == SVGNames::in2Attr)
74  setIn2BaseValue(value);
75  else if (attr->name() == SVGNames::scaleAttr)
76  setScaleBaseValue(value.toFloat());
77  else
78  SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
79 }
80 
81 SVGFEDisplacementMap* SVGFEDisplacementMapElement::filterEffect(SVGResourceFilter* filter) const
82 {
83  if (!m_filterEffect)
84  m_filterEffect = new SVGFEDisplacementMap(filter);
85 
86  m_filterEffect->setXChannelSelector((SVGChannelSelectorType) xChannelSelector());
87  m_filterEffect->setYChannelSelector((SVGChannelSelectorType) yChannelSelector());
88  m_filterEffect->setIn(in1());
89  m_filterEffect->setIn2(in2());
90  m_filterEffect->setScale(scale());
91 
92  setStandardAttributes(m_filterEffect);
93  return m_filterEffect;
94 }
95 
96 }
97 
98 #endif // ENABLE(SVG)
99 
100 // vim:ts=4:noet
WebCore::SVGNames::xChannelSelectorAttr
DOM::QualifiedName xChannelSelectorAttr
Definition: SVGNames.cpp:342
WebCore::SVGNames::in2Attr
DOM::QualifiedName in2Attr
Definition: SVGNames.cpp:193
SVGFEDisplacementMapElement.h
WebCore::SVGNames::yChannelSelectorAttr
DOM::QualifiedName yChannelSelectorAttr
Definition: SVGNames.cpp:346
WebCore::SVGNames::inAttr
DOM::QualifiedName inAttr
Definition: SVGNames.cpp:192
SVGResourceFilter.h
WebCore::String
DOM::DOMString String
Definition: PlatformString.h:8
WebCore::SVGNames::scaleAttr
DOM::QualifiedName scaleAttr
Definition: SVGNames.cpp:274
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