diff --git a/plugins/tools/selectiontools/CMakeLists.txt b/plugins/tools/selectiontools/CMakeLists.txt index c81049076c..f29dfb74da 100644 --- a/plugins/tools/selectiontools/CMakeLists.txt +++ b/plugins/tools/selectiontools/CMakeLists.txt @@ -1,30 +1,37 @@ +if (NOT WIN32 AND NOT APPLE) + add_subdirectory(tests) +endif() + set(kritaselectiontools_SOURCES selection_tools.cc kis_tool_select_rectangular.cc kis_tool_select_polygonal.cc kis_tool_select_elliptical.cc kis_tool_select_contiguous.cc kis_tool_select_outline.cc kis_tool_select_path.cc kis_tool_select_similar.cc kis_selection_modifier_mapper.cc + KisMagneticWorker.cc ) qt5_add_resources(kritaselectiontools_SOURCES selectiontools.qrc) add_library(kritaselectiontools MODULE ${kritaselectiontools_SOURCES}) +generate_export_header(kritaselectiontools BASE_NAME kritaselectiontools) + target_link_libraries(kritaselectiontools kritaui kritabasicflakes) install(TARGETS kritaselectiontools DESTINATION ${KRITA_PLUGIN_INSTALL_DIR}) install( FILES KisToolSelectPolygonal.action KisToolSelectElliptical.action KisToolSelectSimilar.action KisToolSelectContiguous.action KisToolSelectRectangular.action KisToolSelectOutline.action KisToolSelectPath.action DESTINATION ${DATA_INSTALL_DIR}/krita/actions ) diff --git a/plugins/tools/selectiontools/KisMagneticWorker.cc b/plugins/tools/selectiontools/KisMagneticWorker.cc new file mode 100644 index 0000000000..9b55a79885 --- /dev/null +++ b/plugins/tools/selectiontools/KisMagneticWorker.cc @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2019 Kuntal Majumder + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; version 2.1 of the License. + * + * This library 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser 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 "KisMagneticWorker.h" + +#include "kis_gaussian_kernel.h" + +#include + +void KisMagneticWorker::run(KisPaintDeviceSP dev, const QRect &rect) +{ + KisGaussianKernel::applyLoG(dev, rect, 2, -1.0, QBitArray(), 0); +} diff --git a/plugins/tools/selectiontools/KisMagneticWorker.h b/plugins/tools/selectiontools/KisMagneticWorker.h new file mode 100644 index 0000000000..9c10a5a668 --- /dev/null +++ b/plugins/tools/selectiontools/KisMagneticWorker.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2019 Kuntal Majumder + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; version 2.1 of the License. + * + * This library 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser 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 KISMAGNETICWORKER_H +#define KISMAGNETICWORKER_H + +#include +#include + +class KRITASELECTIONTOOLS_EXPORT KisMagneticWorker{ + public: + void run(KisPaintDeviceSP dev, const QRect& rect); +}; + +#endif diff --git a/plugins/tools/selectiontools/tests/CMakeLists.txt b/plugins/tools/selectiontools/tests/CMakeLists.txt new file mode 100644 index 0000000000..18ed773851 --- /dev/null +++ b/plugins/tools/selectiontools/tests/CMakeLists.txt @@ -0,0 +1,14 @@ +set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} ) +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/.. + ${CMAKE_CURRENT_BINARY_DIR}/.. + ${CMAKE_SOURCE_DIR}/sdk/tests +) + +macro_add_unittest_definitions() + +########### next target ############### + +ecm_add_test(KisMagneticWorkerTest.cc + NAME_PREFIX plugins-magneticselection- + LINK_LIBRARIES kritaselectiontools kritaimage Qt5::Test) diff --git a/plugins/tools/selectiontools/tests/KisMagneticWorkerTest.cc b/plugins/tools/selectiontools/tests/KisMagneticWorkerTest.cc new file mode 100644 index 0000000000..1e05fa39df --- /dev/null +++ b/plugins/tools/selectiontools/tests/KisMagneticWorkerTest.cc @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2019 Kuntal Majumder + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; version 2.1 of the License. + * + * This library 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser 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 "KisMagneticWorkerTest.h" + +#include +#include +#include +#include +#include + +inline KisPaintDeviceSP loadTestImage(const QString &name, bool convertToAlpha) +{ + QImage image(TestUtil::fetchDataFileLazy(name)); + KisPaintDeviceSP dev = new KisPaintDevice(KoColorSpaceRegistry::instance()->rgb8()); + dev->convertFromQImage(image, 0); + + if (convertToAlpha) { + dev = KisPainter::convertToAlphaAsAlpha(dev); + } + + return dev; +} + +void KisMagneticWorkerTest::testWorker() +{ + KisPaintDeviceSP dev = loadTestImage("test_main.png", false); + const QRect rect = dev->exactBounds(); + KisMagneticWorker worker; + worker.run(dev, rect); + + KIS_DUMP_DEVICE_2(dev, rect, "main", "dd"); +} + +QTEST_MAIN(KisMagneticWorkerTest) diff --git a/plugins/tools/selectiontools/tests/KisMagneticWorkerTest.h b/plugins/tools/selectiontools/tests/KisMagneticWorkerTest.h new file mode 100644 index 0000000000..934b6f8a4f --- /dev/null +++ b/plugins/tools/selectiontools/tests/KisMagneticWorkerTest.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2019 Kuntal Majumder + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; version 2.1 of the License. + * + * This library 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser 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 KISMAGNETICWORKERTEST_H +#define KISMAGNETICWORKERTEST_H + +#include + +class KisMagneticWorkerTest : public QObject +{ + Q_OBJECT +private Q_SLOTS: + void testWorker(); + +}; + +#endif