diff --git a/plugins/tools/selectiontools/KisToolSelectGuided.action b/plugins/tools/selectiontools/KisToolSelectGuided.action
new file mode 100644
index 0000000000..6da9d839e1
--- /dev/null
+++ b/plugins/tools/selectiontools/KisToolSelectGuided.action
@@ -0,0 +1,6 @@
+
+
+
+ Guided Selection Tool
+
+
diff --git a/plugins/tools/selectiontools/KisToolSelectGuided.cc b/plugins/tools/selectiontools/KisToolSelectGuided.cc
index ecf7415f1e..7521caf6cf 100644
--- a/plugins/tools/selectiontools/KisToolSelectGuided.cc
+++ b/plugins/tools/selectiontools/KisToolSelectGuided.cc
@@ -1,97 +1,100 @@
#include "KisToolSelectGuided.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "kis_painter.h"
#include
#include "canvas/kis_canvas2.h"
#include "kis_pixel_selection.h"
#include "kis_selection_tool_helper.h"
#include "kis_algebra_2d.h"
#include "KisHandlePainterHelper.h"
#include
#include
#include
#include
#include
#include
#include
#include
KisToolSelectGuided::KisToolSelectGuided(KoCanvasBase *canvas)
: KisToolSelect(canvas),
m_started(false), m_finished(false),m_worker(image()->projection()), m_epsilon(70),m_filterRadius(3.0)
{ }
-void KisToolSelectGuided::GuidedSelectGenerate(KisPaintDeviceSP device, const QRect& applyRect)
+void KisToolSelectGuided::GuidedSelectGenerate()
{
KisCanvas2 *kisCanvas = dynamic_cast(canvas());
KIS_ASSERT_RECOVER_RETURN(kisCanvas);
kisCanvas->updateCanvas();
setMode(KisTool::HOVER_MODE);
if (mode == PIXEL_SELECTION){
- KisPixelSelectionSP tmpSel = new KisPixelSelection();
-
- KisPainter painter(tmpSel);
- painter.setPaintColor(KoColor(Qt::black, tmpSel->colorSpace()));
- painter.setAntiAliasPolygonFill(antiAliasSelection());
- painter.setFillStyle(KisPainter::FillStyleForegroundColor);
- painter.setStrokeStyle(KisPainter::StrokeStyleNone);
-
- QVariant value;
- KisLodTransformScalar t(device);
- const qreal blurAmount = t.scale(config->getProperty(m_filterRadius, value) ? value.toDouble() : 1.0);
- QBitArray channelFlags = config->channelFlags();
-
- const QRect gaussNeedRect = this->neededRect(applyRect, config, device->defaultBounds()->currentLevelOfDetail());
+ KisPaintDeviceSP image = KisPaintDeviceSP(new KisPaintDevice(currentImage()->projection()));
+
+ image.ConvertTo(KoColorSpaceRegistry::instance()->rgb32());
+
+ KisLodTransformScalar t(image);
+ const qreal BoxBlurAmount = t.scale(m_filterRadius ? m_filterRadius.toDouble() : 1.0);
+ QRect applyRect(QPoint(0, 0), image.width(),image.height());
+ const QRect boxNeedRect = this->neededRect(applyRect, config, originalimage->defaultBounds()->currentLevelOfDetail());
+
+ KisSequentialConstIterator it(imageDev, QRect(0, 0, image.width(), image.height()));
+
+ for (int y = 0; y < image.height(); y++) {
+ for (int x = 0; x < image.width(); x++) {
+ it.nextPixel();
+ const quint8* pixel = it.rawDataConst();
+ for (int chan = 0; chan < 4; ++chan) {
+ image &img = image[chan];
+ *(img.scanLine(y) + x) = cs->scaleToU8(pixel, chan);
+ }
+ }
+ }
}
}
-QRect KisToolSelectGuided:::neededRect(const QRect & rect, const KisFilterConfigurationSP config, int lod) const
+QRect KisToolSelectGuided:::neededRect(const QRect & rect, int lod) const
{
KisLodTransformScalar t(lod);
- QVariant value;
-
- const int halfSize = config->getProperty("blurAmount", value) ? KisGaussianKernel::kernelSizeFromRadius(t.scale(value.toFloat())) / 2 : 5;
+ const int halfSize = m_filterRadius ? KisGaussianKernel::kernelSizeFromRadius(t.scale(m_filterRadius.toFloat())) / 2 : 5;
return rect.adjusted( -halfSize * 2, -halfSize * 2, halfSize * 2, halfSize * 2);
}
-QRect KisToolSelectGuided:::changedRect(const QRect & rect, const KisFilterConfigurationSP config, int lod) const
+QRect KisToolSelectGuided:::changedRect(const QRect & rect, int lod) const
{
KisLodTransformScalar t(lod);
- QVariant value;
-
- const int halfSize = config->getProperty("blurAmount", value) ? KisGaussianKernel::kernelSizeFromRadius(t.scale(value.toFloat())) / 2 : 5;
+ const int halfSize = m_filterRadius ? KisGaussianKernel::kernelSizeFromRadius(t.scale(m_filterRadius.toFloat())) / 2 : 5;
return rect.adjusted( -halfSize, -halfSize, halfSize, halfSize);
}
diff --git a/plugins/tools/selectiontools/KisToolSelectGuided.h b/plugins/tools/selectiontools/KisToolSelectGuided.h
index a48f6f3df3..c6e9f5ae9f 100644
--- a/plugins/tools/selectiontools/KisToolSelectGuided.h
+++ b/plugins/tools/selectiontools/KisToolSelectGuided.h
@@ -1,55 +1,49 @@
#ifndef KIS_TOOL_SELECT_GUIDED_H_
#define KIS_TOOL_SELECT_GUIDED_H_
#include
#include "KisSelectionToolFactoryBase.h"
#include
#include
#include
-#include "KisGuidedSelectionFiltering.h"
class QPainterPath;
class KisToolSelectGuided : public KisToolSelect
{
- Q OBJECT
+ Q_OBJECT
public:
public Q_SLOTS:
protected:
using KisToolSelectBase::m_widgetHelper;
private:
};
class KisToolSelectGuidedFactory : public KisSelectionToolFactoryBase
{
public:
KisToolSelectGuidedFactory()
: KisSelectionToolFactoryBase("KisToolSelectGuided")
{
setToolTip(i18n("Guided Selection Tool"));
setSection(TOOL_TYPE_SELECTION);
setIconName(koIconNameCStr("tool_guided_selection"));
setPriority(9);
setActivationShapeId(KRITA_TOOL_ACTIVATION_ID);
}
~KisToolSelectGuidedFactory() override { }
- KoToolBase * createTool(KoCanvasBase *canvas) override
- {
- return new KisToolSelectGuided(canvas);
- }
-
QList createActionsImpl() override
{
KisActionRegistry *actionRegistry = KisActionRegistry::instance();
QList actions = KisSelectionToolFactoryBase::createActionsImpl();
actions << actionRegistry->makeQAction("undo_guided_selection");
return actions;
}
};
#endif // __selecttoolguided_h__
diff --git a/plugins/tools/selectiontools/selection_tools.cc b/plugins/tools/selectiontools/selection_tools.cc
index 2d0c5cd3a4..9b53820013 100644
--- a/plugins/tools/selectiontools/selection_tools.cc
+++ b/plugins/tools/selectiontools/selection_tools.cc
@@ -1,62 +1,63 @@
/*
* selection_tools.cc -- Part of Krita
*
* Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org)
*
* 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 "selection_tools.h"
#include
#include
#include
#include "KoToolRegistry.h"
#include "kis_global.h"
#include "kis_types.h"
#include "kis_tool_select_outline.h"
#include "kis_tool_select_polygonal.h"
#include "kis_tool_select_rectangular.h"
#include "kis_tool_select_contiguous.h"
#include "kis_tool_select_elliptical.h"
#include "kis_tool_select_path.h"
#include "kis_tool_select_similar.h"
#include "KisToolSelectMagnetic.h"
+#include "KisToolSelectGuided.h"
K_PLUGIN_FACTORY_WITH_JSON(SelectionToolsFactory, "kritaselectiontools.json", registerPlugin();)
SelectionTools::SelectionTools(QObject *parent, const QVariantList &)
: QObject(parent)
{
KoToolRegistry::instance()->add(new KisToolSelectOutlineFactory());
KoToolRegistry::instance()->add(new KisToolSelectPolygonalFactory());
KoToolRegistry::instance()->add(new KisToolSelectRectangularFactory());
KoToolRegistry::instance()->add(new KisToolSelectEllipticalFactory());
KoToolRegistry::instance()->add(new KisToolSelectContiguousFactory());
KoToolRegistry::instance()->add(new KisToolSelectPathFactory());
KoToolRegistry::instance()->add(new KisToolSelectSimilarFactory());
KoToolRegistry::instance()->add(new KisToolSelectMagneticFactory());
KoToolRegistry::instance()->add(new KisToolSelectGuidedFactory());
}
SelectionTools::~SelectionTools()
{
}
#include "selection_tools.moc"