~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to krita/plugins/filters/convolutionfilters/kis_custom_convolution_filter.cc

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2006-04-20 21:38:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060420213853-j5lxluqvymxt2zny
Tags: 1:1.5.0-0ubuntu2
UbuntuĀ uploadĀ 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of the KDE project
 
3
 *
 
4
 * Copyright (c) 2004 Cyrille Berger <cberger@cberger.net>
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; either version 2 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  This program is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *  GNU General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with this program; if not, write to the Free Software
 
18
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
19
 */
 
20
 
 
21
#include <kdebug.h>
 
22
 
 
23
#include "kis_custom_convolution_filter.h"
 
24
 
 
25
#include <qspinbox.h>
 
26
 
 
27
#include "kis_convolution_painter.h"
 
28
#include "kis_custom_convolution_filter_configuration_widget.h"
 
29
#include "kis_custom_convolution_filter_configuration_base_widget.h"
 
30
#include "kis_matrix_widget.h"
 
31
 
 
32
 
 
33
KisFilterConfigWidget * KisCustomConvolutionFilter::createConfigurationWidget(QWidget* parent, KisPaintDeviceSP)
 
34
{
 
35
    KisCustomConvolutionFilterConfigurationWidget* ccfcw = new KisCustomConvolutionFilterConfigurationWidget(this,parent, "custom convolution config widget");
 
36
    Q_CHECK_PTR(ccfcw);
 
37
    return ccfcw;
 
38
}
 
39
 
 
40
KisFilterConfiguration * KisCustomConvolutionFilter::configuration(QWidget* nwidget)
 
41
{
 
42
    KisCustomConvolutionFilterConfigurationWidget* widget = (KisCustomConvolutionFilterConfigurationWidget*) nwidget;
 
43
 
 
44
    if ( widget == 0 )
 
45
    {
 
46
        // Create the identity matrix:
 
47
        KisKernelSP kernel = new KisKernel();
 
48
        kernel->width = 3;
 
49
        kernel->height = 3;
 
50
 
 
51
        kernel->factor = 1;
 
52
        kernel->offset = 127;
 
53
 
 
54
        kernel->data = new Q_INT32[9];
 
55
        kernel->data[0] = 0;
 
56
        kernel->data[1] = 0;
 
57
        kernel->data[2] = 0;
 
58
        kernel->data[3] = 0;
 
59
        kernel->data[4] = 1;
 
60
        kernel->data[5] = 0;
 
61
        kernel->data[6] = 0;
 
62
        kernel->data[7] = 0;
 
63
        kernel->data[8] = 0;
 
64
 
 
65
        return new KisConvolutionConfiguration( "custom convolution", kernel );
 
66
        
 
67
    } else {
 
68
 
 
69
        // Create the identity matrices:
 
70
        KisKernelSP kernel = new KisKernel();
 
71
        kernel->width = 3;
 
72
        kernel->height = 3;
 
73
 
 
74
        kernel->data = new Q_INT32[9];
 
75
 
 
76
        KisCustomConvolutionFilterConfigurationBaseWidget* mw = widget->matrixWidget();
 
77
 
 
78
        kernel->data[0] = mw->matrixWidget->m11->value();
 
79
        kernel->data[1] = mw->matrixWidget->m21->value();
 
80
        kernel->data[2] = mw->matrixWidget->m31->value();
 
81
        kernel->data[3] = mw->matrixWidget->m12->value();
 
82
        kernel->data[4] = mw->matrixWidget->m22->value();
 
83
        kernel->data[5] = mw->matrixWidget->m32->value();
 
84
        kernel->data[6] = mw->matrixWidget->m13->value();
 
85
        kernel->data[7] = mw->matrixWidget->m23->value();
 
86
        kernel->data[8] = mw->matrixWidget->m33->value();
 
87
 
 
88
        kernel->factor = mw->spinBoxFactor->value();
 
89
        kernel->offset = mw->spinBoxOffset->value();
 
90
 
 
91
        return new KisConvolutionConfiguration( "custom convolution",  kernel );
 
92
    }
 
93
}