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

KHTML

SVGFEDisplacementMapElement.cpp

Go to the documentation of this file.
00001 /*
00002  Copyright (C) 2006 Oliver Hunt <oliver@nerget.com>
00003  
00004  This library is free software; you can redistribute it and/or
00005  modify it under the terms of the GNU Library General Public
00006  License as published by the Free Software Foundation; either
00007  version 2 of the License, or (at your option) any later version.
00008  
00009  This library is distributed in the hope that it will be useful,
00010  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  Library General Public License for more details.
00013  
00014  You should have received a copy of the GNU Library General Public License
00015  along with this library; see the file COPYING.LIB.  If not, write to
00016  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  Boston, MA 02110-1301, USA.
00018  */
00019 
00020 
00021 #include "config.h"
00022 
00023 #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
00024 #include "SVGFEDisplacementMapElement.h"
00025 
00026 #include "SVGResourceFilter.h"
00027 
00028 namespace WebCore {
00029 
00030 SVGFEDisplacementMapElement::SVGFEDisplacementMapElement(const QualifiedName& tagName, Document* doc)
00031     : SVGFilterPrimitiveStandardAttributes(tagName, doc)
00032     , m_xChannelSelector(SVG_CHANNEL_A)
00033     , m_yChannelSelector(SVG_CHANNEL_A)
00034     , m_scale(0.0f)
00035     , m_filterEffect(0)
00036 {
00037 }
00038 
00039 SVGFEDisplacementMapElement::~SVGFEDisplacementMapElement()
00040 {
00041     delete m_filterEffect;
00042 }
00043 
00044 ANIMATED_PROPERTY_DEFINITIONS(SVGFEDisplacementMapElement, String, String, string, In1, in1, SVGNames::inAttr, m_in1)
00045 ANIMATED_PROPERTY_DEFINITIONS(SVGFEDisplacementMapElement, String, String, string, In2, in2, SVGNames::in2Attr, m_in2)
00046 ANIMATED_PROPERTY_DEFINITIONS(SVGFEDisplacementMapElement, int, Enumeration, enumeration, XChannelSelector, xChannelSelector, SVGNames::xChannelSelectorAttr, m_xChannelSelector)
00047 ANIMATED_PROPERTY_DEFINITIONS(SVGFEDisplacementMapElement, int, Enumeration, enumeration, YChannelSelector, yChannelSelector, SVGNames::yChannelSelectorAttr, m_yChannelSelector)
00048 ANIMATED_PROPERTY_DEFINITIONS(SVGFEDisplacementMapElement, float, Number, number, Scale, scale, SVGNames::scaleAttr, m_scale)
00049 
00050 SVGChannelSelectorType SVGFEDisplacementMapElement::stringToChannel(const String& key)
00051 {
00052     if (key == "R")
00053         return SVG_CHANNEL_R;
00054     else if (key == "G")
00055         return SVG_CHANNEL_G;
00056     else if (key == "B")
00057         return SVG_CHANNEL_B;
00058     else if (key == "A")
00059         return SVG_CHANNEL_A;
00060 
00061     return SVG_CHANNEL_UNKNOWN;
00062 }
00063 
00064 void SVGFEDisplacementMapElement::parseMappedAttribute(MappedAttribute* attr)
00065 {
00066     const String& value = attr->value();
00067     if (attr->name() == SVGNames::xChannelSelectorAttr)
00068         setXChannelSelectorBaseValue(stringToChannel(value));
00069     else if (attr->name() == SVGNames::yChannelSelectorAttr)
00070         setYChannelSelectorBaseValue(stringToChannel(value));
00071     else if (attr->name() == SVGNames::inAttr)
00072         setIn1BaseValue(value);
00073     else if (attr->name() == SVGNames::in2Attr)
00074         setIn2BaseValue(value);
00075     else if (attr->name() == SVGNames::scaleAttr)
00076         setScaleBaseValue(value.toFloat());
00077     else
00078         SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
00079 }
00080 
00081 SVGFEDisplacementMap* SVGFEDisplacementMapElement::filterEffect(SVGResourceFilter* filter) const
00082 {
00083     if (!m_filterEffect)
00084         m_filterEffect = new SVGFEDisplacementMap(filter);
00085 
00086     m_filterEffect->setXChannelSelector((SVGChannelSelectorType) xChannelSelector());
00087     m_filterEffect->setYChannelSelector((SVGChannelSelectorType) yChannelSelector());
00088     m_filterEffect->setIn(in1());
00089     m_filterEffect->setIn2(in2());
00090     m_filterEffect->setScale(scale());
00091 
00092     setStandardAttributes(m_filterEffect);
00093     return m_filterEffect;
00094 }
00095 
00096 }
00097 
00098 #endif // ENABLE(SVG)
00099 
00100 // vim:ts=4:noet

KHTML

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal