kis_wdg_wave.cpp 3.87 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*
 * This file is part of Krita
 *
 * Copyright (c) 2006 Cyrille Berger <cberger@cberger.net>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#include "kis_wdg_wave.h"
22
#include <QSpinBox>
23

24
#include <filter/kis_filter_configuration.h>
25
#include <kis_processing_information.h>
26

27 28
#include "ui_wdgwaveoptions.h"

29
KisWdgWave::KisWdgWave(KisFilter* /*nfilter*/, QWidget* parent)
30
        : KisConfigWidget(parent)
31 32 33 34
{
    m_widget = new Ui_WdgWaveOptions();
    m_widget->setupUi(this);

35 36 37 38 39 40 41 42
    connect(widget()->intHWavelength, SIGNAL(valueChanged(int)), SIGNAL(sigConfigurationItemChanged()));
    connect(widget()->intHShift, SIGNAL(valueChanged(int)), SIGNAL(sigConfigurationItemChanged()));
    connect(widget()->intHAmplitude, SIGNAL(valueChanged(int)), SIGNAL(sigConfigurationItemChanged()));
    connect(widget()->cbHShape, SIGNAL(activated(int)), SIGNAL(sigConfigurationItemChanged()));
    connect(widget()->intVWavelength, SIGNAL(valueChanged(int)), SIGNAL(sigConfigurationItemChanged()));
    connect(widget()->intVShift, SIGNAL(valueChanged(int)), SIGNAL(sigConfigurationItemChanged()));
    connect(widget()->intVAmplitude, SIGNAL(valueChanged(int)), SIGNAL(sigConfigurationItemChanged()));
    connect(widget()->cbVShape, SIGNAL(activated(int)), SIGNAL(sigConfigurationItemChanged()));
43 44 45 46
}

KisWdgWave::~KisWdgWave()
{
47
    delete m_widget;
48 49
}

50
void KisWdgWave::setConfiguration(const KisPropertiesConfigurationSP config)
51 52
{
    QVariant value;
Boudewijn Rempt's avatar
Boudewijn Rempt committed
53 54
    if (config->getProperty("horizontalwavelength", value)) {
        widget()->intHWavelength->setValue(value.toUInt());
55
    }
Boudewijn Rempt's avatar
Boudewijn Rempt committed
56 57
    if (config->getProperty("horizontalshift", value)) {
        widget()->intHShift->setValue(value.toUInt());
58
    }
Boudewijn Rempt's avatar
Boudewijn Rempt committed
59 60
    if (config->getProperty("horizontalamplitude", value)) {
        widget()->intHAmplitude->setValue(value.toUInt());
61
    }
Boudewijn Rempt's avatar
Boudewijn Rempt committed
62 63
    if (config->getProperty("horizontalshape", value)) {
        widget()->cbHShape->setCurrentIndex(value.toUInt());
64
    }
Boudewijn Rempt's avatar
Boudewijn Rempt committed
65 66
    if (config->getProperty("verticalwavelength", value)) {
        widget()->intVWavelength->setValue(value.toUInt());
67
    }
Boudewijn Rempt's avatar
Boudewijn Rempt committed
68 69
    if (config->getProperty("verticalshift", value)) {
        widget()->intVShift->setValue(value.toUInt());
70
    }
Boudewijn Rempt's avatar
Boudewijn Rempt committed
71 72
    if (config->getProperty("verticalamplitude", value)) {
        widget()->intVAmplitude->setValue(value.toUInt());
73
    }
Boudewijn Rempt's avatar
Boudewijn Rempt committed
74 75
    if (config->getProperty("verticalshape", value)) {
        widget()->cbVShape->setCurrentIndex(value.toUInt());
76 77 78
    }
}

79
KisPropertiesConfigurationSP KisWdgWave::configuration() const
80
{
81
    KisFilterConfigurationSP config = new KisFilterConfiguration("wave", 1);
Boudewijn Rempt's avatar
Boudewijn Rempt committed
82 83 84 85 86 87 88 89
    config->setProperty("horizontalwavelength", this->widget()->intHWavelength->value());
    config->setProperty("horizontalshift", this->widget()->intHShift->value());
    config->setProperty("horizontalamplitude", this->widget()->intHAmplitude->value());
    config->setProperty("horizontalshape", this->widget()->cbHShape->currentIndex());
    config->setProperty("verticalwavelength", this->widget()->intVWavelength->value());
    config->setProperty("verticalshift", this->widget()->intVShift->value());
    config->setProperty("verticalamplitude", this->widget()->intVAmplitude->value());
    config->setProperty("verticalshape", this->widget()->cbVShape->currentIndex());
90 91
    return config;
}
92 93