2
* Copyright (c) 2006 Cyrille Berger <cberger@cberger.net>
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published by
6
* the Free Software Foundation; version 2 of the License.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
#include "kis_size_transformation.h"
19
#include <KoIntegerMaths.h>
21
#include "kis_dynamic_shape.h"
22
#include "kis_dynamic_sensor.h"
24
#include "ui_SizeTransformationEditor.h"
26
KisSizeTransformation::KisSizeTransformation(KisDynamicSensor* hTransfoParameter, KisDynamicSensor* vTransfoParameter)
27
: KisDynamicTransformation(KisDynamicTransformation::SizeTransformationID),
28
m_horizTransfoParameter(hTransfoParameter), m_vertiTransfoParameter(vTransfoParameter),
29
m_hmax(2.0), m_hmin(0.5), m_vmax(2.0), m_vmin(0.5)
32
KisSizeTransformation::~KisSizeTransformation()
34
if (m_horizTransfoParameter != m_vertiTransfoParameter)
35
delete m_vertiTransfoParameter;
36
delete m_horizTransfoParameter;
39
void KisSizeTransformation::transformBrush(KisDynamicShape* dabsrc, const KisPaintInformation& info)
41
dabsrc->resize(m_horizTransfoParameter->parameter(info) *(m_hmax - m_hmin) + m_hmin,
42
m_vertiTransfoParameter->parameter(info) *(m_vmax - m_vmin) + m_vmin);
45
void KisSizeTransformation::transformColoring(KisDynamicColoring* coloringsrc, const KisPaintInformation& info)
47
Q_UNUSED(coloringsrc);
52
void KisSizeTransformation::setHSensor(KisDynamicSensor* sensor)
54
delete m_horizTransfoParameter;
55
m_horizTransfoParameter = sensor;
58
void KisSizeTransformation::setVSensor(KisDynamicSensor* sensor)
60
delete m_vertiTransfoParameter;
61
m_vertiTransfoParameter = sensor;
64
QWidget* KisSizeTransformation::createConfigWidget(QWidget* parent)
66
QWidget* editorWidget = new QWidget(parent);
67
Ui_SizeTransformationEditor ste;
68
ste.setupUi(editorWidget);
69
// Setup the horizontal parameter
71
connect(ste.comboBoxHorizontalSensor, SIGNAL(sensorChanged(KisDynamicSensor*)), this, SLOT(setHSensor(KisDynamicSensor*)));
72
ste.comboBoxHorizontalSensor->setCurrent(m_horizTransfoParameter);
74
ste.spinBoxHorizontalMaximum->setValue(m_hmax);
75
connect(ste.spinBoxHorizontalMaximum, SIGNAL(valueChanged(double)), this, SLOT(setHMaximum(double)));
77
ste.spinBoxHorizontalMinimum->setValue(m_hmin);
78
connect(ste.spinBoxHorizontalMinimum, SIGNAL(valueChanged(double)), this, SLOT(setHMinimum(double)));
79
// Setup the vertical parameter
81
connect(ste.comboBoxVerticalSensor, SIGNAL(sensorChanged(KisDynamicSensor*)), this, SLOT(setVSensor(KisDynamicSensor*)));
82
ste.comboBoxVerticalSensor->setCurrent(m_vertiTransfoParameter);
84
ste.spinBoxVerticalMaximum->setValue(m_hmax);
85
connect(ste.spinBoxVerticalMaximum, SIGNAL(valueChanged(double)), this, SLOT(setHMaximum(double)));
87
ste.spinBoxVerticalMinimum->setValue(m_hmin);
88
connect(ste.spinBoxVerticalMinimum, SIGNAL(valueChanged(double)), this, SLOT(setHMinimum(double)));
92
void KisSizeTransformation::setHMaximum(double v)
96
void KisSizeTransformation::setVMaximum(double v)
100
void KisSizeTransformation::setHMinimum(double v)
104
void KisSizeTransformation::setVMinimum(double v)
109
#include "kis_size_transformation.moc"