diff --git a/plugins/tools/selectiontools/guided_selection/KisToolSelectGuided.action b/plugins/tools/selectiontools/guided_selection/KisToolSelectGuided.action
new file mode 100644
index 0000000000..6da9d839e1
--- /dev/null
+++ b/plugins/tools/selectiontools/guided_selection/KisToolSelectGuided.action
@@ -0,0 +1,6 @@
+
+
+
+ Guided Selection Tool
+
+
diff --git a/plugins/tools/selectiontools/guided_selection/kis_tool_select_guided.cpp b/plugins/tools/selectiontools/guided_selection/kis_tool_select_guided.cpp
index 0fbd8580b3..36363c08f6 100644
--- a/plugins/tools/selectiontools/guided_selection/kis_tool_select_guided.cpp
+++ b/plugins/tools/selectiontools/guided_selection/kis_tool_select_guided.cpp
@@ -1,165 +1,148 @@
-/*
- * Copyright (c) 2017 Eugene Ingerman
- *
- * 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_tool_select_guided.h"
#include "QApplication"
#include "QPainterPath"
#include
#include
#include
#include "kis_canvas2.h"
#include "kis_cursor.h"
#include "kis_painter.h"
#include "kis_paintop_preset.h"
#include "kundo2magicstring.h"
#include "kundo2stack.h"
#include "commands_new/kis_transaction_based_command.h"
#include "kis_transaction.h"
#include "kis_processing_applicator.h"
#include "kis_datamanager.h"
#include "KoColorSpaceRegistry.h"
#include "kis_tool_select_guided_options_widget.h"
#include "libs/image/kis_paint_device_debug_utils.h"
#include "kis_paint_layer.h"
#include "kis_algebra_2d.h"
-
-#include "KisToolSelectGuided.h"
-
#include
#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_tool_select_guided_options_widget.h"
#include "kis_algebra_2d.h"
#include "KisHandlePainterHelper.h"
#include
#include
#include
#include
#include
#include
#include
#include
+#include
+
KisToolSelectGuided::KisToolSelectGuided(KoCanvasBase *canvas)
: KisToolSelect(canvas,
+ KisCursor::load("tool_magnetic_selection_cursor.png", 5, 5),
i18n("Guided Selection")),
- m_finished(false), m_epsilon(70),m_filterRadius(3)
-
+ m_finished(false), m_filterRadius(3), m_epsilon(70)
{ }
/*void KisToolSelectGuided::GuidedSelectGenerate()
{
KisCanvas2 *kisCanvas = dynamic_cast(canvas());
KIS_ASSERT_RECOVER_RETURN(kisCanvas);
kisCanvas->updateCanvas();
setMode(KisTool::HOVER_MODE);
if (mode == PIXEL_SELECTION){
KisPaintDeviceSP image = KisPaintDeviceSP(new KisPaintDevice(currentImage()->projection()));
image.ConvertTo(KoColorSpaceRegistry::instance()->rgb32());
KisLodTransformScalar t(image);
const qreal BoxBlurAmount = t.scale(m_filterEpsilon ? m_filterEpsilon.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, int lod) const
{
KisLodTransformScalar t(lod);
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, int lod) const
{
KisLodTransformScalar t(lod);
const int halfSize = m_filterRadius ? KisGaussianKernel::kernelSizeFromRadius(t.scale(m_filterRadius.toFloat())) / 2 : 5;
return rect.adjusted( -halfSize, -halfSize, halfSize, halfSize);
}*/
void KisToolSelectGuided::paint(QPainter& gc, const KoViewConverter &converter)
{
}
QWidget * KisToolSelectGuided::createOptionWidget()
{
KisCanvas2 * kiscanvas = dynamic_cast(canvas());
m_d->optionsWidget = new KisToolSelectGuidedOptionsWidget(kiscanvas->viewManager()->canvasResourceProvider(), 0);
m_d->optionsWidget->setObjectName(toolId() + "option widget");
return m_d->optionsWidget;
}
diff --git a/plugins/tools/selectiontools/guided_selection/kis_tool_select_guided.h b/plugins/tools/selectiontools/guided_selection/kis_tool_select_guided.h
index 1fb93418b9..736c6a1d32 100644
--- a/plugins/tools/selectiontools/guided_selection/kis_tool_select_guided.h
+++ b/plugins/tools/selectiontools/guided_selection/kis_tool_select_guided.h
@@ -1,68 +1,72 @@
#ifndef KIS_TOOL_SELECT_GUIDED_H_
#define KIS_TOOL_SELECT_GUIDED_H_
#include
+#include
+#include "kis_tool_paint.h"
#include "KisSelectionToolFactoryBase.h"
-#include
#include
+#include
#include
+#include
+#include
+#include
+#include
+#include
+#include "plugins/tools/selectiontools/selection_tools.h"
+#include "tool_selectguided.h"
+#include "kis_selection_tool_config_widget_helper.h"
+#include
class QPainterPath;
class KisToolSelectGuided : public KisToolSelect
{
Q_OBJECT
public:
- KisToolSelectGuided(KoCanvasBase *canvas);
+ KisToolSelectGuided(KoCanvasBase * canvas);
~KisToolSelectGuided() override = default;
- QWidget * createOptionWidget() override;
+
void paint(QPainter& gc, const KoViewConverter &converter) override;
+ QWidget * createOptionWidget() override;
public Q_SLOTS:
protected:
private:
//const QRect& applyRect;
//const QRect& neededRect;
+ struct Private;
+ const QScopedPointer m_d;
bool m_finished;
int m_filterRadius;
qreal m_epsilon;
QPainterPath m_paintPath;
};
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_polygon_selection");
-
- return actions;
- }
};
-#endif // __selecttoolguided_h__
+#endif // KIS_TOOL_SELECT_GUIDED_H
diff --git a/plugins/tools/selectiontools/guided_selection/kis_tool_select_guided_options_widget.ui b/plugins/tools/selectiontools/guided_selection/kis_tool_select_guided_options_widget.ui
index 8d6e515a69..598ed64289 100644
--- a/plugins/tools/selectiontools/guided_selection/kis_tool_select_guided_options_widget.ui
+++ b/plugins/tools/selectiontools/guided_selection/kis_tool_select_guided_options_widget.ui
@@ -1,128 +1,128 @@
- KisToolSmartPatchOptionsWidget
-
+ KisToolSelectGuidedOptionsWidget
+
0
0
338
245
-
Selection technique utilizing guided filter provided by Kaiming He.
true
-
Qt::Horizontal
-
0
0
Kernel Radius
patchRadiusLabel
-
0
0
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
1
100
-
0
0
Epsilon
patchRadiusLabel
-
0
0
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
1.000000000000000
10.000000000000000
1.000000000000000
-
Activate Selection Painting?
-
Qt::Vertical
0
0
diff --git a/plugins/tools/selectiontools/guided_selection/tool_selectguided.cpp b/plugins/tools/selectiontools/guided_selection/tool_selectguided.cpp
index c0d747c92c..50492212e3 100644
--- a/plugins/tools/selectiontools/guided_selection/tool_selectguided.cpp
+++ b/plugins/tools/selectiontools/guided_selection/tool_selectguided.cpp
@@ -1,45 +1,27 @@
-/*
- * Copyright (c) 2017 Eugene Ingerman
- *
- * 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 "tool_selectguided.h"
#include
#include
#include
#include
#include
#include "kis_paint_device.h"
#include "kis_tool_select_guided.h"
K_PLUGIN_FACTORY_WITH_JSON(DefaultToolsFactory, "kritatoolselectguided.json", registerPlugin();)
ToolSelectGuided::ToolSelectGuided(QObject *parent, const QVariantList &)
: QObject(parent)
{
KoToolRegistry::instance()->add(new KisToolSelectGuidedFactory());
}
ToolSelectGuided::~ToolSelectGuided()
{
}
#include "tool_selectguided.moc"
diff --git a/plugins/tools/selectiontools/guided_selection/tool_selectguided.h b/plugins/tools/selectiontools/guided_selection/tool_selectguided.h
index c4b8cc9a74..dd598f285e 100644
--- a/plugins/tools/selectiontools/guided_selection/tool_selectguided.h
+++ b/plugins/tools/selectiontools/guided_selection/tool_selectguided.h
@@ -1,34 +1,16 @@
-/*
- * Copyright (c) 2017 Eugene Ingerman
- *
- * 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 TOOL_SELECTGUIDED_H_
#define TOOL_SELECTGUIDED_H_
#include
#include
class ToolSelectGuided : public QObject
{
Q_OBJECT
public:
ToolSelectGuided(QObject *parent, const QVariantList &);
~ToolSelectGuided() override;
};
#endif // TOOL_SELECTGUIDED_H_
diff --git a/plugins/tools/selectiontools/selection_tools.cc b/plugins/tools/selectiontools/selection_tools.cc
index fb0af54745..3d9b28981c 100644
--- a/plugins/tools/selectiontools/selection_tools.cc
+++ b/plugins/tools/selectiontools/selection_tools.cc
@@ -1,61 +1,64 @@
/*
* 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 "guided_selection/kis_tool_select_guided.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"