From 4df65ca8441bb6b62c6689f5a03ae5149845701d Mon Sep 17 00:00:00 2001 From: kunzjacq Date: Fri, 25 Feb 2022 08:26:31 +0100 Subject: [PATCH] Enable compilation with Qt6 and MSVC Add missing headers, account for the different target path, change the Qt binary dir determination method. --- CMakeLists.txt | 7 ++++--- src/app/CMakeLists.txt | 2 +- src/core/BlackOnWhiteEstimator.cpp | 2 ++ src/core/filters/output/OutputGenerator.cpp | 1 + src/core/filters/output/OutputImageBuilder.cpp | 4 +++- src/dewarping/RasterDewarper.cpp | 3 ++- src/imageproc/AdjustBrightness.cpp | 3 ++- src/imageproc/BackgroundColorCalculator.cpp | 3 ++- src/imageproc/Binarize.cpp | 3 ++- src/imageproc/BinaryImage.cpp | 2 +- src/imageproc/BinaryThreshold.cpp | 3 ++- src/imageproc/ColorSegmenter.cpp | 3 ++- src/imageproc/ConnectivityMap.cpp | 3 ++- src/imageproc/DrawOver.cpp | 3 ++- src/imageproc/Grayscale.cpp | 4 +++- src/imageproc/ImageCombination.cpp | 4 +++- src/imageproc/InfluenceMap.cpp | 3 ++- src/imageproc/Morphology.cpp | 3 ++- src/imageproc/OrthogonalRotation.cpp | 4 +++- src/imageproc/PolygonRasterizer.cpp | 1 + src/imageproc/PolynomialSurface.cpp | 2 ++ src/imageproc/Posterizer.cpp | 1 + src/imageproc/RastLineFinder.cpp | 1 + src/imageproc/RastLineFinder.h | 1 + src/imageproc/ReduceThreshold.cpp | 3 ++- src/imageproc/SavGolFilter.cpp | 4 +++- src/imageproc/Scale.cpp | 3 ++- src/imageproc/SeedFill.cpp | 3 ++- src/imageproc/Shear.cpp | 3 ++- src/imageproc/SkewFinder.cpp | 3 ++- src/imageproc/SlicedHistogram.cpp | 4 +++- src/imageproc/SlicedHistogram.h | 1 + src/imageproc/Transform.cpp | 3 ++- src/imageproc/UpscaleIntegerTimes.cpp | 4 +++- src/math/spfit/PolylineModelShape.cpp | 4 +++- 35 files changed, 72 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c7aec8e9..1b537055e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -210,14 +210,15 @@ find_package( Qt6 COMPONENTS Core Gui Widgets Xml Network LinguistTools OpenGL Svg OpenGLWidgets CONFIG) -if (NOT Qt6_FOUND) +if (Qt6_FOUND) + set(QT_BINDIR "${QT6_INSTALL_PREFIX}/bin") +else() find_package(Qt5 ${qt_min_version} COMPONENTS Core Gui Widgets Xml Network LinguistTools OpenGL Svg CONFIG REQUIRED) + set(QT_BINDIR "${QT5_INSTALL_PREFIX}/bin") endif() -get_filename_component(QT_BINDIR ${QT_QMAKE_EXECUTABLE} DIRECTORY) - if(Qt6_FOUND) set(Qt_Core_lib Qt::Core) set(Qt_Gui_lib Qt::Gui) diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 1d5b17094..d4314bd44 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -84,7 +84,7 @@ if (Qt6_FOUND AND WIN32) add_custom_command( TARGET scantailor POST_BUILD - COMMAND ${QT_BINDIR}/windeployqt ${CMAKE_BINARY_DIR} + COMMAND ${QT_BINDIR}/windeployqt $ COMMENT "deploy qt files alongside binary (e.g. plugins)" ) install(CODE "execute_process(COMMAND ${QT_BINDIR}/windeployqt ${CMAKE_INSTALL_PREFIX})") diff --git a/src/core/BlackOnWhiteEstimator.cpp b/src/core/BlackOnWhiteEstimator.cpp index 40d995648..a3cda9b21 100644 --- a/src/core/BlackOnWhiteEstimator.cpp +++ b/src/core/BlackOnWhiteEstimator.cpp @@ -3,6 +3,8 @@ #include "BlackOnWhiteEstimator.h" +#include + #include #include #include diff --git a/src/core/filters/output/OutputGenerator.cpp b/src/core/filters/output/OutputGenerator.cpp index a011b56d7..4fb619484 100644 --- a/src/core/filters/output/OutputGenerator.cpp +++ b/src/core/filters/output/OutputGenerator.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #include "ColorParams.h" #include "DebugImages.h" diff --git a/src/core/filters/output/OutputImageBuilder.cpp b/src/core/filters/output/OutputImageBuilder.cpp index 61b80a91e..828b33b12 100644 --- a/src/core/filters/output/OutputImageBuilder.cpp +++ b/src/core/filters/output/OutputImageBuilder.cpp @@ -3,6 +3,8 @@ #include "OutputImageBuilder.h" +#include + #include #include "ForegroundType.h" @@ -69,4 +71,4 @@ OutputImageBuilder& OutputImageBuilder::setForegroundType(const ForegroundType& m_foregroundType = std::make_unique(foregroundImage); return *this; } -} // namespace output \ No newline at end of file +} // namespace output diff --git a/src/dewarping/RasterDewarper.cpp b/src/dewarping/RasterDewarper.cpp index dde9e2f20..41bb8a2b0 100644 --- a/src/dewarping/RasterDewarper.cpp +++ b/src/dewarping/RasterDewarper.cpp @@ -8,6 +8,7 @@ #include #include +#include #include "CylindricalSurfaceDewarper.h" @@ -527,4 +528,4 @@ QImage RasterDewarper::dewarp(const QImage& src, return dewarpRgb(src.convertToFormat(QImage::Format_RGB32), dstSize, distortionModel, modelDomain, bgColor); } } // RasterDewarper::dewarp -} // namespace dewarping \ No newline at end of file +} // namespace dewarping diff --git a/src/imageproc/AdjustBrightness.cpp b/src/imageproc/AdjustBrightness.cpp index 4398ea4e5..e35e54c8c 100644 --- a/src/imageproc/AdjustBrightness.cpp +++ b/src/imageproc/AdjustBrightness.cpp @@ -4,6 +4,7 @@ #include "AdjustBrightness.h" #include +#include namespace imageproc { void adjustBrightness(QImage& rgbImage, const QImage& brightness, const double wr, const double wb) { @@ -73,4 +74,4 @@ void adjustBrightnessYUV(QImage& rgbImage, const QImage& brightness) { void adjustBrightnessGrayscale(QImage& rgbImage, const QImage& brightness) { adjustBrightness(rgbImage, brightness, 11.0 / 32.0, 5.0 / 32.0); } -} // namespace imageproc \ No newline at end of file +} // namespace imageproc diff --git a/src/imageproc/BackgroundColorCalculator.cpp b/src/imageproc/BackgroundColorCalculator.cpp index cfab54388..780e860c2 100644 --- a/src/imageproc/BackgroundColorCalculator.cpp +++ b/src/imageproc/BackgroundColorCalculator.cpp @@ -4,6 +4,7 @@ #include "BackgroundColorCalculator.h" #include +#include #include "Binarize.h" #include "BinaryImage.h" @@ -197,4 +198,4 @@ QColor BackgroundColorCalculator::calcDominantColor(const QImage& img, const Bin return QColor(dominantRed, dominantGreen, dominantBlue); } } -} // namespace imageproc \ No newline at end of file +} // namespace imageproc diff --git a/src/imageproc/Binarize.cpp b/src/imageproc/Binarize.cpp index 0a10d65c6..4a5ce679b 100644 --- a/src/imageproc/Binarize.cpp +++ b/src/imageproc/Binarize.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "BinaryImage.h" #include "Grayscale.h" @@ -199,4 +200,4 @@ BinaryImage binarizeWolf(const QImage& src, BinaryImage peakThreshold(const QImage& image) { return BinaryImage(image, BinaryThreshold::peakThreshold(image)); } -} // namespace imageproc \ No newline at end of file +} // namespace imageproc diff --git a/src/imageproc/BinaryImage.cpp b/src/imageproc/BinaryImage.cpp index d7533870c..0f676aba1 100644 --- a/src/imageproc/BinaryImage.cpp +++ b/src/imageproc/BinaryImage.cpp @@ -1051,4 +1051,4 @@ void* BinaryImage::SharedData::operator new(size_t, const NumWords numWords) { void BinaryImage::SharedData::operator delete(void* addr, NumWords) { free(addr); } -} // namespace imageproc \ No newline at end of file +} // namespace imageproc diff --git a/src/imageproc/BinaryThreshold.cpp b/src/imageproc/BinaryThreshold.cpp index 70e6e9a67..096386871 100644 --- a/src/imageproc/BinaryThreshold.cpp +++ b/src/imageproc/BinaryThreshold.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "Grayscale.h" #include "Morphology.h" @@ -171,4 +172,4 @@ BinaryThreshold BinaryThreshold::mokjiThreshold(const QImage& image, const double threshold = 0.5 * nominator / denominator; return BinaryThreshold((int) (threshold + 0.5)); } // BinaryThreshold::mokjiThreshold -} // namespace imageproc \ No newline at end of file +} // namespace imageproc diff --git a/src/imageproc/ColorSegmenter.cpp b/src/imageproc/ColorSegmenter.cpp index 82e4274e4..597ee6e02 100644 --- a/src/imageproc/ColorSegmenter.cpp +++ b/src/imageproc/ColorSegmenter.cpp @@ -5,6 +5,7 @@ #include #include +#include #include "BinaryImage.h" #include "BinaryThreshold.h" @@ -404,4 +405,4 @@ GrayImage ColorSegmenter::segment(const BinaryImage& image, const GrayImage& gra ConnectivityMap segmentsMap = buildMapFromGrayscale(image); return buildGrayImage(segmentsMap, grayImage); } -} // namespace imageproc \ No newline at end of file +} // namespace imageproc diff --git a/src/imageproc/ConnectivityMap.cpp b/src/imageproc/ConnectivityMap.cpp index 841003115..fab86d864 100644 --- a/src/imageproc/ConnectivityMap.cpp +++ b/src/imageproc/ConnectivityMap.cpp @@ -5,6 +5,7 @@ #include #include +#include #include "BinaryImage.h" #include "BitOps.h" @@ -571,4 +572,4 @@ void ConnectivityMap::remapIds(const std::vector& map) { } } } -} // namespace imageproc \ No newline at end of file +} // namespace imageproc diff --git a/src/imageproc/DrawOver.cpp b/src/imageproc/DrawOver.cpp index 9309199a0..a44a3a097 100644 --- a/src/imageproc/DrawOver.cpp +++ b/src/imageproc/DrawOver.cpp @@ -5,6 +5,7 @@ #include #include +#include #include "BinaryImage.h" #include "RasterOp.h" @@ -52,4 +53,4 @@ void drawOver(QImage& dst, const QRect& dstRect, const QImage& src, const QRect& srcLine += srcBpl; } } // drawOver -} // namespace imageproc \ No newline at end of file +} // namespace imageproc diff --git a/src/imageproc/Grayscale.cpp b/src/imageproc/Grayscale.cpp index 065c90c70..b3bb3b20d 100644 --- a/src/imageproc/Grayscale.cpp +++ b/src/imageproc/Grayscale.cpp @@ -3,6 +3,8 @@ #include "Grayscale.h" +#include + #include "BinaryImage.h" #include "BitOps.h" @@ -443,4 +445,4 @@ void GrayscaleHistogram::fromAnyImage(const QImage& img, const BinaryImage& mask } } } -} // namespace imageproc \ No newline at end of file +} // namespace imageproc diff --git a/src/imageproc/ImageCombination.cpp b/src/imageproc/ImageCombination.cpp index 226dbb59f..45d101b1d 100644 --- a/src/imageproc/ImageCombination.cpp +++ b/src/imageproc/ImageCombination.cpp @@ -1,11 +1,13 @@ // Copyright (C) 2019 Joseph Artsimovich , 4lex4 <4lex49@zoho.com> // Use of this source code is governed by the GNU GPLv3 license that can be found in the LICENSE file. + #include "ImageCombination.h" #include #include #include +#include #include "BinaryImage.h" @@ -403,4 +405,4 @@ void applyMask(QImage& image, const BinaryImage& bwMask, const BWColor fillingCo impl::applyMask(image, bwMask, fillingColor); } -} // namespace imageproc \ No newline at end of file +} // namespace imageproc diff --git a/src/imageproc/InfluenceMap.cpp b/src/imageproc/InfluenceMap.cpp index faed6a624..15ec20ce3 100644 --- a/src/imageproc/InfluenceMap.cpp +++ b/src/imageproc/InfluenceMap.cpp @@ -4,6 +4,7 @@ #include "InfluenceMap.h" #include +#include #include "BinaryImage.h" #include "BitOps.h" @@ -254,4 +255,4 @@ QImage InfluenceMap::visualized() const { } return dst; } // InfluenceMap::visualized -} // namespace imageproc \ No newline at end of file +} // namespace imageproc diff --git a/src/imageproc/Morphology.cpp b/src/imageproc/Morphology.cpp index e9d64a62e..0cf545ee1 100644 --- a/src/imageproc/Morphology.cpp +++ b/src/imageproc/Morphology.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "BinaryImage.h" #include "GrayImage.h" @@ -1110,4 +1111,4 @@ BinaryImage blackTopHatTransform(const BinaryImage& src, BinaryImage blackTopHatTransform(const BinaryImage& src, const QSize& brick, BWColor srcSurroundings) { return blackTopHatTransform(src, brick, src.rect(), srcSurroundings); } -} // namespace imageproc \ No newline at end of file +} // namespace imageproc diff --git a/src/imageproc/OrthogonalRotation.cpp b/src/imageproc/OrthogonalRotation.cpp index 32e8690ba..d43ac069b 100644 --- a/src/imageproc/OrthogonalRotation.cpp +++ b/src/imageproc/OrthogonalRotation.cpp @@ -3,6 +3,8 @@ #include "OrthogonalRotation.h" +#include + #include "BinaryImage.h" #include "RasterOp.h" @@ -151,4 +153,4 @@ BinaryImage orthogonalRotation(const BinaryImage& src, const QRect& srcRect, con BinaryImage orthogonalRotation(const BinaryImage& src, const int degrees) { return orthogonalRotation(src, src.rect(), degrees); } -} // namespace imageproc \ No newline at end of file +} // namespace imageproc diff --git a/src/imageproc/PolygonRasterizer.cpp b/src/imageproc/PolygonRasterizer.cpp index c4224707d..ea35770c6 100644 --- a/src/imageproc/PolygonRasterizer.cpp +++ b/src/imageproc/PolygonRasterizer.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include "BinaryImage.h" #include "PolygonUtils.h" diff --git a/src/imageproc/PolynomialSurface.cpp b/src/imageproc/PolynomialSurface.cpp index 3df3b77dd..819545347 100644 --- a/src/imageproc/PolynomialSurface.cpp +++ b/src/imageproc/PolynomialSurface.cpp @@ -1,6 +1,8 @@ // Copyright (C) 2019 Joseph Artsimovich , 4lex4 <4lex49@zoho.com> // Use of this source code is governed by the GNU GPLv3 license that can be found in the LICENSE file. +#include + #include "PolynomialSurface.h" #include diff --git a/src/imageproc/Posterizer.cpp b/src/imageproc/Posterizer.cpp index 4de86d051..16c2ec0f4 100644 --- a/src/imageproc/Posterizer.cpp +++ b/src/imageproc/Posterizer.cpp @@ -3,6 +3,7 @@ #include "Posterizer.h" +#include #include #include #include diff --git a/src/imageproc/RastLineFinder.cpp b/src/imageproc/RastLineFinder.cpp index 956376824..e8b9348ae 100644 --- a/src/imageproc/RastLineFinder.cpp +++ b/src/imageproc/RastLineFinder.cpp @@ -3,6 +3,7 @@ #include "RastLineFinder.h" +#include #include #include #include diff --git a/src/imageproc/RastLineFinder.h b/src/imageproc/RastLineFinder.h index 1397f2f23..c204fbfcc 100644 --- a/src/imageproc/RastLineFinder.h +++ b/src/imageproc/RastLineFinder.h @@ -6,6 +6,7 @@ #include #include +#include #include #include #include diff --git a/src/imageproc/ReduceThreshold.cpp b/src/imageproc/ReduceThreshold.cpp index 7eaf5be01..af66c474e 100644 --- a/src/imageproc/ReduceThreshold.cpp +++ b/src/imageproc/ReduceThreshold.cpp @@ -3,6 +3,7 @@ #include "ReduceThreshold.h" +#include #include namespace imageproc { @@ -272,4 +273,4 @@ void ReduceThreshold::reduceVertLine(const int threshold) { m_image = dst; } // ReduceThreshold::reduceVertLine -} // namespace imageproc \ No newline at end of file +} // namespace imageproc diff --git a/src/imageproc/SavGolFilter.cpp b/src/imageproc/SavGolFilter.cpp index 5013b4c22..aad50e932 100644 --- a/src/imageproc/SavGolFilter.cpp +++ b/src/imageproc/SavGolFilter.cpp @@ -3,6 +3,8 @@ #include "SavGolFilter.h" +#include + #include "Grayscale.h" #include "SavGolKernel.h" @@ -274,4 +276,4 @@ QImage savGolFilter(const QImage& src, const QSize& windowSize, const int horDeg } return savGolFilterGrayToGray(toGrayscale(src), windowSize, horDegree, vertDegree); } -} // namespace imageproc \ No newline at end of file +} // namespace imageproc diff --git a/src/imageproc/Scale.cpp b/src/imageproc/Scale.cpp index a97c99c8e..7f5e3c5be 100644 --- a/src/imageproc/Scale.cpp +++ b/src/imageproc/Scale.cpp @@ -3,6 +3,7 @@ #include "Scale.h" +#include #include #include "GrayImage.h" @@ -355,4 +356,4 @@ GrayImage scaleToGray(const GrayImage& src, const QSize& dstSize) { } return scaleGrayToGray(src, dstSize); } -} // namespace imageproc \ No newline at end of file +} // namespace imageproc diff --git a/src/imageproc/SeedFill.cpp b/src/imageproc/SeedFill.cpp index c6ff52f4b..e5a94a65a 100644 --- a/src/imageproc/SeedFill.cpp +++ b/src/imageproc/SeedFill.cpp @@ -4,6 +4,7 @@ #include "SeedFill.h" #include +#include #include "GrayImage.h" #include "SeedFillGeneric.h" @@ -448,4 +449,4 @@ GrayImage seedFillGraySlow(const GrayImage& seed, const GrayImage& mask, const C } return img; } -} // namespace imageproc \ No newline at end of file +} // namespace imageproc diff --git a/src/imageproc/Shear.cpp b/src/imageproc/Shear.cpp index 0b7a33970..e7a5b3a08 100644 --- a/src/imageproc/Shear.cpp +++ b/src/imageproc/Shear.cpp @@ -3,6 +3,7 @@ #include "Shear.h" +#include #include #include @@ -168,4 +169,4 @@ void hShearInPlace(BinaryImage& image, const double shear, const double yOrigin, void vShearInPlace(BinaryImage& image, const double shear, const double xOrigin, const BWColor backgroundColor) { vShearFromTo(image, image, shear, xOrigin, backgroundColor); } -} // namespace imageproc \ No newline at end of file +} // namespace imageproc diff --git a/src/imageproc/SkewFinder.cpp b/src/imageproc/SkewFinder.cpp index dd462a139..fa9d62411 100644 --- a/src/imageproc/SkewFinder.cpp +++ b/src/imageproc/SkewFinder.cpp @@ -5,6 +5,7 @@ #include #include +#include #include "BinaryImage.h" #include "BitOps.h" @@ -207,4 +208,4 @@ double SkewFinder::calcScore(const BinaryImage& image) { } return score; } -} // namespace imageproc \ No newline at end of file +} // namespace imageproc diff --git a/src/imageproc/SlicedHistogram.cpp b/src/imageproc/SlicedHistogram.cpp index a3bc1555d..0d8eae928 100644 --- a/src/imageproc/SlicedHistogram.cpp +++ b/src/imageproc/SlicedHistogram.cpp @@ -3,6 +3,8 @@ #include "SlicedHistogram.h" +#include + #include "BinaryImage.h" #include "BitOps.h" @@ -85,4 +87,4 @@ void SlicedHistogram::processVerticalLines(const BinaryImage& image, const QRect m_data.push_back(count); } } -} // namespace imageproc \ No newline at end of file +} // namespace imageproc diff --git a/src/imageproc/SlicedHistogram.h b/src/imageproc/SlicedHistogram.h index 2f830e594..29f29bd24 100644 --- a/src/imageproc/SlicedHistogram.h +++ b/src/imageproc/SlicedHistogram.h @@ -6,6 +6,7 @@ #include #include +#include class QRect; diff --git a/src/imageproc/Transform.cpp b/src/imageproc/Transform.cpp index a0be0ff90..e8da11ac7 100644 --- a/src/imageproc/Transform.cpp +++ b/src/imageproc/Transform.cpp @@ -5,6 +5,7 @@ #include #include +#include #include "BadAllocIfNull.h" #include "ColorMixer.h" @@ -383,4 +384,4 @@ GrayImage transformToGray(const QImage& src, fixDpiInPlace(dst, src, xform); return dst; } -} // namespace imageproc \ No newline at end of file +} // namespace imageproc diff --git a/src/imageproc/UpscaleIntegerTimes.cpp b/src/imageproc/UpscaleIntegerTimes.cpp index aa977c19a..7df04813d 100644 --- a/src/imageproc/UpscaleIntegerTimes.cpp +++ b/src/imageproc/UpscaleIntegerTimes.cpp @@ -5,6 +5,8 @@ #include "BinaryImage.h" +#include + namespace imageproc { namespace { inline uint32_t multiplyBit(uint32_t bit, int times) { @@ -91,4 +93,4 @@ BinaryImage upscaleIntegerTimes(const BinaryImage& src, const QSize& dstSize, co dst.fillExcept(rect, padding); return dst; } -} // namespace imageproc \ No newline at end of file +} // namespace imageproc diff --git a/src/math/spfit/PolylineModelShape.cpp b/src/math/spfit/PolylineModelShape.cpp index 683f60990..a26546517 100644 --- a/src/math/spfit/PolylineModelShape.cpp +++ b/src/math/spfit/PolylineModelShape.cpp @@ -5,6 +5,8 @@ #include +#include + #include "FrenetFrame.h" #include "ToLineProjector.h" @@ -116,4 +118,4 @@ SqDistApproximant PolylineModelShape::calcApproximant(const QPointF& pt, return SqDistApproximant::curveDistance(pt, frenetFrame, signedCurvature); } } -} // namespace spfit \ No newline at end of file +} // namespace spfit