Commit 99feb3b8 authored by Wolthera van Hövell's avatar Wolthera van Hövell 🛍

Merge branch 'master' into krita-testing-wolthera

parents 6f18c4c3 92c253ac
......@@ -355,6 +355,17 @@
<isCheckable>true</isCheckable>
<statusTip></statusTip>
</Action>
<Action name="disable_pressure">
<icon>transform_icons_penPressure</icon>
<text>Use Pen Pressure</text>
<whatsThis></whatsThis>
<toolTip>Use Pen Pressure</toolTip>
<iconText>Use Pen Pressure</iconText>
<activationFlags>10000</activationFlags>
<shortcut></shortcut>
<isCheckable>true</isCheckable>
<statusTip></statusTip>
</Action>
<Action name="hmirror_action">
<icon>symmetry-horizontal</icon>
<text>Horizontal Mirror Tool</text>
......@@ -2616,6 +2627,18 @@
<isCheckable>false</isCheckable>
<statusTip></statusTip>
</Action>
<Action name="waveletdecompose">
<icon></icon>
<text>Wavelet Decompose ...</text>
<whatsThis></whatsThis>
<toolTip>Wavelet Decompose</toolTip>
<iconText>Wavelet Decompose</iconText>
<activationFlags>1000</activationFlags>
<activationConditions>1</activationConditions>
<shortcut></shortcut>
<isCheckable>false</isCheckable>
<statusTip></statusTip>
</Action>
<Action name="mirrorNodeX">
<icon>symmetry-horizontal</icon>
<text>Mirror Layer Hori&amp;zontally</text>
......
......@@ -147,10 +147,15 @@ xsi:schemaLocation="http://www.kde.org/standards/kxmlgui/1.0 http://www.kde.org
<Action name="canvassize"/>
<Separator/>
<Action name="imagesplit"/>
<Action name="waveletdecompose"/>
<Action name="separate"/>
</Menu>
<Menu name="Layer">
<text>&amp;Layer</text>
<Action name="cut_layer_clipboard"/>
<Action name="copy_layer_clipboard"/>
<Action name="paste_layer_from_clipboard"/>
<Separator/>
<Menu name="LayerNew">
<text>New</text>
<Action name="add_new_paint_layer"/>
......@@ -180,6 +185,7 @@ xsi:schemaLocation="http://www.kde.org/standards/kxmlgui/1.0 http://www.kde.org
<Action name="convert_to_filter_mask"/>
<Action name="convert_to_selection_mask"/>
<Action name="convert_group_to_animated"/>
<Action name="layercolorspaceconversion"/>
</Menu>
<Separator/>
<Menu name="LayerSelect">
......@@ -190,37 +196,43 @@ xsi:schemaLocation="http://www.kde.org/standards/kxmlgui/1.0 http://www.kde.org
<Action name="select_locked_layers"/>
<Action name="select_unlocked_layers"/>
</Menu>
<Separator/>
<Action name="cut_layer_clipboard"/>
<Action name="copy_layer_clipboard"/>
<Action name="paste_layer_from_clipboard"/>
<Separator/>
<Menu name="LayerSplitAlpha">
<text>S&amp;plit Alpha</text>
<Action name="split_alpha_into_mask"/>
<Action name="split_alpha_write"/>
<Action name="split_alpha_save_merged"/>
<Menu name="LayerGroup">
<text>&amp;Group</text>
<Action name="create_quick_group"/>
<Action name="create_quick_clipping_group"/>
<Action name="quick_ungroup"/>
</Menu>
<Action name="layersplit"/>
<Separator/>
<Action name="mirrorNodeX"/>
<Action name="mirrorNodeY"/>
<Menu name="Rotate">
<text>&amp;Rotate</text>
<Action name="rotatelayer"/>
<Separator/>
<Action name="rotateLayerCW90"/>
<Action name="rotateLayerCCW90"/>
<Action name="rotateLayer180"/>
<Menu name="LayerTransform">
<text>&amp;Transform</text>
<Action name="mirrorNodeX"/>
<Action name="mirrorNodeY"/>
<Action name="layersize"/>
<Menu name="Rotate">
<text>&amp;Rotate</text>
<Action name="rotatelayer"/>
<Separator/>
<Action name="rotateLayerCW90"/>
<Action name="rotateLayerCCW90"/>
<Action name="rotateLayer180"/>
</Menu>
<Action name="shearlayer"/>
<Action name="offsetlayer"/>
</Menu>
<Menu name="LayerSplitAlpha">
<text>S&amp;plit</text>
<Menu name="LayerSplitAlpha">
<text>S&amp;plit Alpha</text>
<Action name="split_alpha_into_mask"/>
<Action name="split_alpha_write"/>
<Action name="split_alpha_save_merged"/>
</Menu>
<Action name="layersplit"/>
<Action name="clones_array"/>
</Menu>
<Action name="layersize"/>
<Action name="shearlayer"/>
<Action name="offsetlayer"/>
<Action name="clones_array"/>
<Separator/>
<Action name="EditLayerMetaData"/>
<Action name="histogram"/>
<Action name="layercolorspaceconversion"/>
<Separator/>
<Action name="merge_layer"/>
<Action name="flatten_layer"/>
......@@ -230,10 +242,7 @@ xsi:schemaLocation="http://www.kde.org/standards/kxmlgui/1.0 http://www.kde.org
<Action name="merge_selected_layers"/>
<Separator/>
<Action name="layer_style"/>
<Separator/>
<Action name="create_quick_group"/>
<Action name="create_quick_clipping_group"/>
<Action name="quick_ungroup"/>
</Menu>
<Menu name="Select">
<text>&amp;Select</text>
......
<!DOCTYPE RCC>
<RCC version="1.0">
<qresource>
<RCC>
<qresource prefix="/">
<file>dark_transform_icons_cage.png</file>
<file>dark_transform_icons_liquify_erase.png</file>
<file>dark_transform_icons_liquify_main.png</file>
......@@ -18,7 +17,6 @@
<file>dark_transform_icons_mirror_y.svg</file>
<file>dark_transform_icons_rotate_cw.svg</file>
<file>dark_transform_icons_rotate_ccw.svg</file>
<file>light_transform_icons_cage.png</file>
<file>light_transform_icons_liquify_erase.png</file>
<file>light_transform_icons_liquify_main.png</file>
......@@ -36,5 +34,7 @@
<file>light_transform_icons_mirror_y.svg</file>
<file>light_transform_icons_rotate_cw.svg</file>
<file>light_transform_icons_rotate_ccw.svg</file>
<file>dark_transform_icons_penPressure_locked.png</file>
<file>light_transform_icons_penPressure_locked.png</file>
</qresource>
</RCC>
......@@ -33,7 +33,7 @@ QString KisMimeDatabase::mimeTypeForFile(const QString &file)
fillMimeData();
QFileInfo fi(file);
QString suffix = fi.suffix();
QString suffix = fi.suffix().toLower();
Q_FOREACH(const KisMimeDatabase::KisMimeType &mimeType, s_mimeDatabase) {
if (mimeType.suffixes.contains("*." + suffix)) {
debugPlugin << "mimeTypeForFile(). KisMimeDatabase returned" << mimeType.mimeType << "for" << file;
......@@ -55,7 +55,7 @@ QString KisMimeDatabase::mimeTypeForSuffix(const QString &suffix)
fillMimeData();
QMimeDatabase db;
QString s = suffix;
QString s = suffix.toLower();
if (!s.startsWith("*.")) {
s = "*." + s;
}
......
......@@ -532,6 +532,16 @@ bool KisCanvasResourceProvider::globalAlphaLock() const
return m_resourceManager->resource(GlobalAlphaLock).toBool();
}
void KisCanvasResourceProvider::setDisablePressure(bool value)
{
m_resourceManager->setResource(DisablePressure, value);
}
bool KisCanvasResourceProvider::disablePressure() const
{
return m_resourceManager->resource(DisablePressure).toBool();
}
void KisCanvasResourceProvider::notifyLoadingWorkspace(KisWorkspaceResource* workspace)
{
emit sigLoadingWorkspace(workspace);
......
......@@ -75,6 +75,7 @@ public:
Size,
HdrGamma,
GlobalAlphaLock,
DisablePressure,
PreviousPaintOpPreset,
EffectiveZoom, ///<-Used only by painting tools for non-displaying purposes
PresetAllowsLod,
......@@ -165,6 +166,8 @@ public:
void setGlobalAlphaLock(bool lock);
bool globalAlphaLock() const;
void setDisablePressure(bool value);
bool disablePressure() const;
///Notify that the workspace is saved and settings should be saved to it
void notifySavingWorkspace(KisWorkspaceResource* workspace);
......
......@@ -156,7 +156,13 @@ KisPaintopBox::KisPaintopBox(KisViewManager *view, QWidget *parent, const char *
m_alphaLockButton->setDefaultAction(alphaLockAction);
// pen pressure
m_disablePressureButton = new KisHighlightedToolButton(this);
m_disablePressureButton->setFixedSize(iconsize, iconsize);
m_disablePressureButton->setCheckable(true);
m_disablePressureAction = m_viewManager->actionManager()->createAction("disable_pressure");
m_disablePressureButton->setDefaultAction(m_disablePressureAction);
// horizontal and vertical mirror toolbar buttons
......@@ -334,6 +340,17 @@ KisPaintopBox::KisPaintopBox(KisViewManager *view, QWidget *parent, const char *
action->setText(i18n("Brush composite"));
action->setDefaultWidget(compositeActions);
QWidget* compositePressure = new QWidget(this);
QHBoxLayout* pressureLayout = new QHBoxLayout(compositePressure);
pressureLayout->addWidget(m_disablePressureButton);
pressureLayout->setSpacing(4);
pressureLayout->setContentsMargins(0, 0, 0, 0);
action = new QWidgetAction(this);
view->actionCollection()->addAction("pressure_action", action);
action->setText(i18n("Pressure usage (small button)"));
action->setDefaultWidget(compositePressure);
action = new QWidgetAction(this);
KisActionRegistry::instance()->propertizeAction("brushslider1", action);
view->actionCollection()->addAction("brushslider1", action);
......@@ -445,7 +462,9 @@ KisPaintopBox::KisPaintopBox(KisViewManager *view, QWidget *parent, const char *
connect(m_cmbCompositeOp , SIGNAL(currentIndexChanged(int)) , SLOT(slotSetCompositeMode(int)));
connect(m_eraseAction , SIGNAL(toggled(bool)) , SLOT(slotToggleEraseMode(bool)));
connect(alphaLockAction , SIGNAL(toggled(bool)) , SLOT(slotToggleAlphaLockMode(bool)));
connect(m_disablePressureAction , SIGNAL(toggled(bool)) , SLOT(slotDisablePressureMode(bool)));
m_disablePressureAction->setChecked(true);
connect(m_hMirrorAction , SIGNAL(toggled(bool)) , SLOT(slotHorizontalMirrorChanged(bool)));
connect(m_vMirrorAction , SIGNAL(toggled(bool)) , SLOT(slotVerticalMirrorChanged(bool)));
......@@ -782,6 +801,10 @@ void KisPaintopBox::slotCanvasResourceChanged(int key, const QVariant &value)
m_eraseAction->setChecked(value.toBool());
}
if (key == KisCanvasResourceProvider::DisablePressure) {
m_disablePressureAction->setChecked(value.toBool());
}
sender()->blockSignals(false);
}
}
......@@ -1076,6 +1099,17 @@ void KisPaintopBox::slotToggleAlphaLockMode(bool checked)
m_resourceProvider->setGlobalAlphaLock(checked);
}
void KisPaintopBox::slotDisablePressureMode(bool checked)
{
if (checked) {
m_disablePressureButton->actions()[0]->setIcon(KisIconUtils::loadIcon("transform_icons_penPressure"));
} else {
m_disablePressureButton->actions()[0]->setIcon(KisIconUtils::loadIcon("transform_icons_penPressure_locked"));
}
m_resourceProvider->setDisablePressure(checked);
}
void KisPaintopBox::slotReloadPreset()
{
KisSignalsBlocker blocker(m_optionWidget);
......@@ -1168,6 +1202,12 @@ void KisPaintopBox::slotUpdateSelectionIcon()
m_eraseAction->setIcon(KisIconUtils::loadIcon("draw-eraser"));
m_reloadAction->setIcon(KisIconUtils::loadIcon("view-refresh"));
if (m_disablePressureAction->isChecked()) {
m_disablePressureButton->setIcon(KisIconUtils::loadIcon("transform_icons_penPressure"));
} else {
m_disablePressureButton->setIcon(KisIconUtils::loadIcon("transform_icons_penPressure_locked"));
}
}
void KisPaintopBox::slotLockXMirrorToggle(bool toggleLock) {
......
......@@ -153,6 +153,7 @@ private Q_SLOTS:
void slotSwitchToPreviousPreset();
void slotUnsetEraseMode();
void slotToggleAlphaLockMode(bool);
void slotDisablePressureMode(bool);
void slotReloadPreset();
void slotGuiChangedCurrentPreset();
......@@ -182,6 +183,7 @@ private:
KisCompositeOpComboBox* m_cmbCompositeOp;
QToolButton* m_eraseModeButton;
QToolButton* m_alphaLockButton;
QToolButton* m_disablePressureButton;
QToolButton* m_hMirrorButton;
QToolButton* m_vMirrorButton;
KisToolOptionsPopup* m_toolOptionsPopup;
......@@ -195,6 +197,7 @@ private:
QToolButton* m_reloadButton;
KisAction* m_eraseAction;
KisAction* m_reloadAction;
KisAction* m_disablePressureAction;
QString m_currCompositeOpID;
KisNodeWSP m_previousNode;
......
......@@ -26,6 +26,9 @@
#include "kis_cubic_curve.h"
#include "kis_speed_smoother.h"
#include <KoCanvasResourceManager.h>
#include "kis_canvas_resource_provider.h"
/***********************************************************************/
/* KisPaintingInformationBuilder */
......@@ -36,7 +39,8 @@ const int KisPaintingInformationBuilder::LEVEL_OF_PRESSURE_RESOLUTION = 1024;
KisPaintingInformationBuilder::KisPaintingInformationBuilder()
: m_speedSmoother(new KisSpeedSmoother())
: m_speedSmoother(new KisSpeedSmoother()),
m_pressureDisabled(false)
{
connect(KisConfigNotifier::instance(), SIGNAL(configChanged()),
SLOT(updateSettings()));
......@@ -58,8 +62,13 @@ void KisPaintingInformationBuilder::updateSettings()
}
KisPaintInformation KisPaintingInformationBuilder::startStroke(KoPointerEvent *event,
int timeElapsed)
int timeElapsed,
const KoCanvasResourceManager *manager)
{
if (manager) {
m_pressureDisabled = manager->resource(KisCanvasResourceProvider::DisablePressure).toBool();
}
m_startPoint = event->point;
return createPaintingInformation(event, timeElapsed);
......@@ -103,7 +112,7 @@ KisPaintInformation KisPaintingInformationBuilder::createPaintingInformation(KoP
qreal speed = m_speedSmoother->getNextSpeed(imageToView(imagePoint));
return KisPaintInformation(imagePoint,
pressureToCurve(event->pressure()),
!m_pressureDisabled ? 1.0 : pressureToCurve(event->pressure()),
event->xTilt(), event->yTilt(),
event->rotation(),
event->tangentialPressure(),
......
......@@ -30,6 +30,7 @@ class KoPointerEvent;
class KisToolFreehand;
class KisCoordinatesConverter;
class KisSpeedSmoother;
class KoCanvasResourceManager;
class KRITAUI_EXPORT KisPaintingInformationBuilder : public QObject
{
......@@ -39,7 +40,7 @@ public:
KisPaintingInformationBuilder();
~KisPaintingInformationBuilder();
KisPaintInformation startStroke(KoPointerEvent *event, int timeElapsed);
KisPaintInformation startStroke(KoPointerEvent *event, int timeElapsed, const KoCanvasResourceManager *manager);
KisPaintInformation continueStroke(KoPointerEvent *event,
int timeElapsed);
......@@ -72,6 +73,7 @@ private:
QVector<qreal> m_pressureSamples;
QPointF m_startPoint;
QScopedPointer<KisSpeedSmoother> m_speedSmoother;
bool m_pressureDisabled;
};
class KRITAUI_EXPORT KisConverterPaintingInformationBuilder : public KisPaintingInformationBuilder
......
......@@ -194,7 +194,7 @@ void KisToolFreehandHelper::initPaint(KoPointerEvent *event,
KisDefaultBoundsBaseSP bounds)
{
KisPaintInformation pi =
m_d->infoBuilder->startStroke(event, elapsedStrokeTime());
m_d->infoBuilder->startStroke(event, elapsedStrokeTime(), resourceManager);
initPaintImpl(pi,
resourceManager,
......
......@@ -504,16 +504,19 @@ void KisLayerBox::slotContextMenuRequested(const QPoint &pos, const QModelIndex
}
menu.addAction(m_colorSelectorAction);
if (singleLayer) {
menu.addSeparator();
addActionToMenu(&menu, "show_in_timeline");
}
menu.addSeparator();
addActionToMenu(&menu, "cut_layer_clipboard");
addActionToMenu(&menu, "copy_layer_clipboard");
addActionToMenu(&menu, "paste_layer_from_clipboard");
addActionToMenu(&menu, "paste_layer_from_clipboard");
menu.addAction(m_removeAction);
addActionToMenu(&menu, "duplicatelayer");
addActionToMenu(&menu, "merge_layer");
if (singleLayer) {
addActionToMenu(&menu, "flatten_image");
addActionToMenu(&menu, "flatten_layer");
}
menu.addSeparator();
QMenu *selectMenu = menu.addMenu(i18n("&Select"));
......@@ -522,19 +525,17 @@ void KisLayerBox::slotContextMenuRequested(const QPoint &pos, const QModelIndex
addActionToMenu(selectMenu, "select_invisible_layers");
addActionToMenu(selectMenu, "select_locked_layers");
addActionToMenu(selectMenu, "select_unlocked_layers");
menu.addSeparator();
addActionToMenu(&menu, "create_quick_group");
addActionToMenu(&menu, "create_quick_clipping_group");
addActionToMenu(&menu, "quick_ungroup");
menu.addSeparator();
QMenu *groupMenu = menu.addMenu(i18n("&Group"));
addActionToMenu(groupMenu, "create_quick_group");
addActionToMenu(groupMenu, "create_quick_clipping_group");
addActionToMenu(groupMenu, "quick_ungroup");
menu.addAction(m_removeAction);
addActionToMenu(&menu, "duplicatelayer");
addActionToMenu(&menu, "merge_layer");
if (singleLayer) {
addActionToMenu(&menu, "flatten_image");
addActionToMenu(&menu, "flatten_layer");
menu.addSeparator();
QMenu *addLayerMenu = menu.addMenu(i18n("&Add"));
addActionToMenu(addLayerMenu, "add_new_transparency_mask");
addActionToMenu(addLayerMenu, "add_new_filter_mask");
addActionToMenu(addLayerMenu, "add_new_transform_mask");
addActionToMenu(addLayerMenu, "add_new_selection_mask");
QMenu *convertToMenu = menu.addMenu(i18n("&Convert"));
addActionToMenu(convertToMenu, "convert_to_paint_layer");
......@@ -546,22 +547,20 @@ void KisLayerBox::slotContextMenuRequested(const QPoint &pos, const QModelIndex
addActionToMenu(splitAlphaMenu, "split_alpha_into_mask");
addActionToMenu(splitAlphaMenu, "split_alpha_write");
addActionToMenu(splitAlphaMenu, "split_alpha_save_merged");
}
menu.addSeparator();
if (singleLayer) {
addActionToMenu(&menu, "show_in_timeline");
KisNodeSP node = m_filteringModel->nodeFromIndex(index);
if (node && !node->inherits("KisTransformMask")) {
addActionToMenu(&menu, "isolate_layer");
}
}
}
if (singleLayer) {
menu.addSeparator();
addActionToMenu(&menu, "add_new_transparency_mask");
addActionToMenu(&menu, "add_new_filter_mask");
addActionToMenu(&menu, "add_new_transform_mask");
addActionToMenu(&menu, "add_new_selection_mask");
menu.addSeparator();
menu.addAction(m_selectOpaque);
menu.addAction(m_selectOpaque);
}
}
menu.exec(pos);
......
......@@ -14,6 +14,7 @@ add_subdirectory( shearimage )
add_subdirectory( layergroupswitcher )
add_subdirectory( resourcemanager )
add_subdirectory( layersplit )
add_subdirectory( waveletdecompose )
# Allow to skip building GMIC plugin
option(WITH_GMIC "Build the G'Mic plugin" ON)
......
set(kritawaveletdecompose_SOURCES
waveletdecompose.cpp
dlg_waveletdecompose.cpp
kis_wavelet_kernel.cpp
)
ki18n_wrap_ui(kritawaveletdecompose_SOURCES
wdg_waveletdecompose.ui
)
add_library(kritawaveletdecompose MODULE ${kritawaveletdecompose_SOURCES})
target_link_libraries(kritawaveletdecompose kritaui)
install(TARGETS kritawaveletdecompose DESTINATION ${KRITA_PLUGIN_INSTALL_DIR})
install( FILES waveletdecompose.xmlgui DESTINATION ${DATA_INSTALL_DIR}/kritaplugins)
/*
*
* Copyright (c) 2016 Miroslav Talasek <miroslav.talasek@seznam.cz>
*
* 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 "dlg_waveletdecompose.h"
#include <klocalizedstring.h>
#include <kis_debug.h>
DlgWaveletDecompose::DlgWaveletDecompose(QWidget * parent,
const char * name)
: KoDialog(parent)
{
setCaption(i18n("WaveletDecompose"));
setButtons(Ok | Cancel);
setDefaultButton(Ok);
setObjectName(name);
m_page = new WdgWaveletDecompose(this);
Q_CHECK_PTR(m_page);
m_page->layout()->setMargin(0);
m_page->setObjectName("wavelet_decompose");
setMainWidget(m_page);
resize(m_page->sizeHint());
connect(this, SIGNAL(okClicked()),
this, SLOT(okClicked()));
}
DlgWaveletDecompose::~DlgWaveletDecompose()
{
delete m_page;
}
void DlgWaveletDecompose::setScales(quint32 scales)
{
m_page->scales->setValue(scales);
}
qint32 DlgWaveletDecompose::scales()
{
return m_page->scales->value();
}
// SLOTS
void DlgWaveletDecompose::okClicked()
{
accept();
}
/*
*
* Copyright (c) 2016 Miroslav Talasek <miroslav.talasek@seznam.cz>
*
* 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.
*/
#ifndef DLG_WAVELETDECOMPOSE
#define DLG_WAVELETDECOMPOSE
#include <KoDialog.h>
#include "ui_wdg_waveletdecompose.h"
class WdgWaveletDecompose : public QWidget, public Ui::WdgWaveletDecompose
{
Q_OBJECT
public:
WdgWaveletDecompose(QWidget *parent) : QWidget(parent) {
setupUi(this);
}
};
class DlgWaveletDecompose: public KoDialog
{
Q_OBJECT
public:
DlgWaveletDecompose(QWidget * parent = 0,
const char* name = 0);
~DlgWaveletDecompose();
void setScales(quint32 scales);
qint32 scales();
private Q_SLOTS:
void okClicked();
private:
WdgWaveletDecompose * m_page;
};
#endif // DLG_WAVELETDECOMPOSE
/*
* Copyright (c) 2016 Miroslav Talasek <miroslav.talasek@seznam.cz>
*
* 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_wavelet_kernel.h"
#include "kis_convolution_kernel.h"
#include <kis_convolution_painter.h>
#include <QRect>
int KisWaveletKernel::kernelSizeFromRadius(qreal radius)
{
return 2 * ceil(radius) + 1;
}
Matrix<qreal, Dynamic, Dynamic>
KisWaveletKernel::createHorizontalMatrix(qreal radius)
{
int kernelSize = kernelSizeFromRadius(radius);
Matrix<qreal, Dynamic, Dynamic> matrix(1, kernelSize);
/**
* The kernel size should always be odd, then the position of the
* central pixel can be easily calculated
*/
KIS_ASSERT_RECOVER_NOOP(kernelSize & 0x1);
const int center = kernelSize / 2;
for (int x = 0; x < kernelSize; x++) {
if (x == 0 || x == kernelSize - 1)
matrix(0, x) = 0.25;
else if (x == center)
matrix(0, x) = 0.5;
else
matrix(0, x) = 0;