Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port the plugins to Qt6 #40

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions AffineTransformations/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ ADD_DEFINITIONS(-DQT_SHARED)
ADD_DEFINITIONS(-DQT_DLL)

# QT5_WRAP_CPP(PLUGIN_MOC_SRC ${PLUGIN_MOCS})
QT5_ADD_RESOURCES(PLUGIN_RCC ${PLUGIN_RESOURCES})
qt_add_resources(PLUGIN_RCC ${PLUGIN_RESOURCES})

link_directories(${OpenCV_LIBRARY_DIRS} ${NOMACS_BUILD_DIRECTORY}/libs ${NOMACS_BUILD_DIRECTORY})
ADD_LIBRARY(${PROJECT_NAME} SHARED ${PLUGIN_SOURCES} ${PLUGIN_MOC_SRC} ${PLUGIN_RCC} ${PLUGIN_HEADERS})
target_link_libraries(${PROJECT_NAME} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${QT_QTMAIN_LIBRARY} ${OpenCV_LIBS} ${NOMACS_LIBS})
target_link_libraries(${PROJECT_NAME} Qt5::Widgets Qt5::Gui)
target_link_libraries(${PROJECT_NAME} Qt::Widgets Qt::Gui)

NMC_CREATE_TARGETS()
NMC_GENERATE_USER_FILE()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"AuthorName" : "Tim Jerman",
"Company" : "",
"DateCreated" : "2014-06-01",
"DateModified" : "2020-08-19",
"DateModified" : "2023-04-23",
"Description" : "Apply affine transformations to the selected image. The available transformations are: scale, rotation (with automatic skewness detection), and shear.",
"Tagline" : "Transform and rotate images",
"PluginId" : "7a4a50a45ddb408ba46a16a40e6518fd",
Expand Down
1 change: 1 addition & 0 deletions AffineTransformations/src/DkImgTransformationsPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "DkUtils.h"
#include "DkToolbars.h"

#include <QActionGroup>
#include <QMouseEvent>

#define PI 3.14159265
Expand Down
4 changes: 2 additions & 2 deletions AffineTransformations/src/DkImgTransformationsPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ class DkInteractionRects : public QWidget {

public:

DkInteractionRects(QRect imgRect, QWidget* parent = 0, Qt::WindowFlags f = 0);
DkInteractionRects(QWidget* parent = 0, Qt::WindowFlags f = 0);
DkInteractionRects(QRect imgRect, QWidget* parent = 0, Qt::WindowFlags f = Qt::Widget);
DkInteractionRects(QWidget* parent = 0, Qt::WindowFlags f = Qt::Widget);
~DkInteractionRects();

void draw(QPainter* painter);
Expand Down
3 changes: 2 additions & 1 deletion AffineTransformations/src/DkSkewEstimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "DkImageStorage.h"

#include <QDebug>
#include <QRandomGenerator>

namespace nmp {

Expand Down Expand Up @@ -301,7 +302,7 @@ cv::Mat DkSkewEstimator::computeEdgeMap(cv::Mat separability, double thr, int di

int DkSkewEstimator::randInt(int low, int high) {

return qrand() % ((high + 1) - low) + low;
return QRandomGenerator::global()->bounded(low, high);
}

QVector<QVector3D> DkSkewEstimator::computeWeights(cv::Mat edgeMap, int direction) {
Expand Down
4 changes: 2 additions & 2 deletions CompositePlugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ ADD_DEFINITIONS(-DQT_PLUGIN)
ADD_DEFINITIONS(-DQT_SHARED)
ADD_DEFINITIONS(-DQT_DLL)

QT5_ADD_RESOURCES(PLUGIN_RCC ${PLUGIN_RESOURCES})
qt_add_resources(PLUGIN_RCC ${PLUGIN_RESOURCES})

link_directories(${OpenCV_LIBRARY_DIRS} ${NOMACS_BUILD_DIRECTORY}/libs ${NOMACS_BUILD_DIRECTORY})
ADD_LIBRARY(${PROJECT_NAME} SHARED ${PLUGIN_SOURCES} ${PLUGIN_MOC_SRC} ${PLUGIN_RCC} ${PLUGIN_HEADERS})
target_link_libraries(${PROJECT_NAME} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${QT_QTMAIN_LIBRARY} ${OpenCV_LIBS} ${NOMACS_LIBS})
target_link_libraries(${PROJECT_NAME} Qt5::Widgets Qt5::Gui Qt5::Network)
target_link_libraries(${PROJECT_NAME} Qt::Widgets Qt::Gui Qt::Network)

NMC_CREATE_TARGETS()
NMC_GENERATE_USER_FILE()
Expand Down
6 changes: 5 additions & 1 deletion CompositePlugin/src/SbChannelWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ namespace nmc {
if (couldLoad) {
QImage qImg = bl.image();
if (qImg.hasAlphaChannel()) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
emit newAlpha(qImg.alphaChannel()); //aparently alphaChannel() is obsolete, however I don't know what else to use
#endif
//emit newAlpha(qImg.convertToFormat(QImage::Format_Alpha8)); //because that doesn't seem to work as expected..
}
else {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
emit newAlpha(QImage());
#endif
}

//this is optional; markus says it makes the grayscale image nicer
Expand Down Expand Up @@ -170,4 +174,4 @@ namespace nmc {
emit imageChanged(c);
}
}
};
};
4 changes: 3 additions & 1 deletion CompositePlugin/src/SbChannelWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ namespace nmc {

signals:
void imageChanged(int channel); // whenever there is an update (actual image change, inversion, intensity)
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void newAlpha(QImage alpha); // is emitted upon image loading
#endif
};


};
};
2 changes: 1 addition & 1 deletion CompositePlugin/src/SbCompositePlugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"AuthorName" : "Simon Brenner",
"Company" : "TU Wien, Computer Vision Lab",
"DateCreated" : "2020-06-10",
"DateModified" : "2020-08-19",
"DateModified" : "2023-04-23",
"PluginId" : "5414075eeff248e4be909635701494bf",
"Version" : "0.1.0"
}
4 changes: 2 additions & 2 deletions FakeMiniaturesPlugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ ADD_DEFINITIONS(-DQT_PLUGIN)
ADD_DEFINITIONS(-DQT_SHARED)
ADD_DEFINITIONS(-DQT_DLL)

QT5_ADD_RESOURCES(PLUGIN_RCC ${PLUGIN_RESOURCES})
qt_add_resources(PLUGIN_RCC ${PLUGIN_RESOURCES})

link_directories(${OpenCV_LIBRARY_DIRS} ${NOMACS_BUILD_DIRECTORY}/libs ${NOMACS_BUILD_DIRECTORY})
ADD_LIBRARY(${PROJECT_NAME} SHARED ${PLUGIN_SOURCES} ${PLUGIN_MOC_SRC} ${PLUGIN_RCC} ${PLUGIN_HEADERS})
target_link_libraries(${PROJECT_NAME} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${QT_QTMAIN_LIBRARY} ${OpenCV_LIBS} ${NOMACS_LIBS})
target_link_libraries(${PROJECT_NAME} Qt5::Widgets Qt5::Gui)
target_link_libraries(${PROJECT_NAME} Qt::Widgets Qt::Gui)

NMC_CREATE_TARGETS()
NMC_GENERATE_USER_FILE()
Expand Down
2 changes: 1 addition & 1 deletion FakeMiniaturesPlugin/src/DkFakeMiniaturesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ void DkPreviewLabel::mouseReleaseEvent(QMouseEvent *e) {
QLabel::mouseReleaseEvent(e);
};

void DkPreviewLabel::enterEvent(QEvent * e){
void DkPreviewLabel::enterEvent(QEnterEvent * e){
showROI = true;
repaint();
QLabel::enterEvent(e);
Expand Down
4 changes: 2 additions & 2 deletions FakeMiniaturesPlugin/src/DkFakeMiniaturesDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class DkPreviewLabel : public QLabel
void mousePressEvent(QMouseEvent *e);
void mouseMoveEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
void enterEvent(QEvent * e);
void enterEvent(QEnterEvent * e);
void leaveEvent(QEvent * e);

private:
Expand Down Expand Up @@ -266,4 +266,4 @@ class DkSaturation : public DkFakeMiniaturesToolWidget {
~DkSaturation();
};

};
};
2 changes: 1 addition & 1 deletion FakeMiniaturesPlugin/src/DkFakeMiniaturesPlugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"AuthorName" : "Tim Jerman",
"Company" : "",
"DateCreated" : "2014-06-01",
"DateModified" : "2020-08-19",
"DateModified" : "2023-04-23",
"Description" : "On the preview image select (by mouse click move and release) the region without blurring. A blur is applyied depending on the distance from this region. The amount of blur and saturation can be changed with the sliders on the right of the dialog.",
"Tagline" : "Apply a fake miniature filter (tilt shift effect) to the image.",
"PluginId" : "a2ac7b68866b4ab29fb1df3e170b8f0d",
Expand Down
4 changes: 2 additions & 2 deletions PageExtractionPlugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ ADD_DEFINITIONS(-DQT_PLUGIN)
ADD_DEFINITIONS(-DQT_SHARED)
ADD_DEFINITIONS(-DQT_DLL)

QT5_ADD_RESOURCES(PLUGIN_RCC ${PLUGIN_RESOURCES})
qt_add_resources(PLUGIN_RCC ${PLUGIN_RESOURCES})

link_directories(${OpenCV_LIBRARY_DIRS} ${NOMACS_BUILD_DIRECTORY}/libs ${NOMACS_BUILD_DIRECTORY})
ADD_LIBRARY(${PROJECT_NAME} SHARED ${PLUGIN_SOURCES} ${PLUGIN_MOC_SRC} ${PLUGIN_RCC} ${PLUGIN_HEADERS})
target_link_libraries(${PROJECT_NAME} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${QT_QTMAIN_LIBRARY} ${OpenCV_LIBS} ${NOMACS_LIBS})
target_link_libraries(${PROJECT_NAME} Qt5::Widgets Qt5::Gui)
target_link_libraries(${PROJECT_NAME} Qt::Widgets Qt::Gui)

NMC_CREATE_TARGETS()
NMC_GENERATE_USER_FILE()
Expand Down
2 changes: 1 addition & 1 deletion PageExtractionPlugin/src/DkPageExtractionPlugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"AuthorName" : "Markus Diem, Thomas Lang",
"Company" : "Computer Vision Lab",
"DateCreated" : "2015-08-27",
"DateModified" : "2020-08-19",
"DateModified" : "2023-04-23",
"Description" : "This plugin detects document pages and either crops the image accordingly or annotates the region.",
"Tagline" : "Detect document pages in images",
"PluginId" : "4acb88c461024cb080ae5cd15d0ef0ec",
Expand Down
4 changes: 2 additions & 2 deletions PaintPlugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ ADD_DEFINITIONS(-DQT_PLUGIN)
ADD_DEFINITIONS(-DQT_SHARED)
ADD_DEFINITIONS(-DQT_DLL)

QT5_ADD_RESOURCES(PLUGIN_RCC ${PLUGIN_RESOURCES})
qt_add_resources(PLUGIN_RCC ${PLUGIN_RESOURCES})

link_directories(${OpenCV_LIBRARY_DIRS} ${NOMACS_BUILD_DIRECTORY}/libs ${NOMACS_BUILD_DIRECTORY})
ADD_LIBRARY(${PROJECT_NAME} SHARED ${PLUGIN_SOURCES} ${PLUGIN_MOC_SRC} ${PLUGIN_RCC} ${PLUGIN_HEADERS})
target_link_libraries(${PROJECT_NAME} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${QT_QTMAIN_LIBRARY} ${OpenCV_LIBS} ${NOMACS_LIBS})
target_link_libraries(${PROJECT_NAME} Qt5::Widgets Qt5::Gui)
target_link_libraries(${PROJECT_NAME} Qt::Widgets Qt::Gui)

NMC_CREATE_TARGETS()
NMC_GENERATE_USER_FILE()
Expand Down
2 changes: 1 addition & 1 deletion PaintPlugin/src/DkPaintPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "DkPaintPlugin.h"
#include "DkToolbars.h"

#include <QActionGroup>
#include <QDebug>
#include <QMouseEvent>

Expand Down Expand Up @@ -480,7 +481,6 @@ QImage DkPaintViewPort::getPaintedImage() {
//if (worldMatrix)
// painter.setWorldTransform(*worldMatrix);

painter.setRenderHint(QPainter::HighQualityAntialiasing);
painter.setRenderHint(QPainter::Antialiasing);

for (int idx = 0; idx < paths.size(); idx++) {
Expand Down
2 changes: 1 addition & 1 deletion PaintPlugin/src/DkPaintPlugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"AuthorName" : "Tim Jerman",
"Company" : "",
"DateCreated" : "2014-05-01",
"DateModified" : "2020-08-19",
"DateModified" : "2023-04-23",
"Description" : "Paint on an image. The color, size and opacity of the brush can be changed.",
"Tagline" : "Draw with adjustable brushes to an image.",
"PluginId" : "ad970ef36cc24737afd2b53ad015ff0d",
Expand Down
2 changes: 1 addition & 1 deletion SIMPLE_PLUGIN/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ QT5_ADD_RESOURCES(PLUGIN_RCC ${PLUGIN_RESOURCES})
link_directories(${OpenCV_LIBRARY_DIRS} ${NOMACS_BUILD_DIRECTORY}/libs ${NOMACS_BUILD_DIRECTORY})
ADD_LIBRARY(${PROJECT_NAME} SHARED ${PLUGIN_SOURCES} ${PLUGIN_MOC_SRC} ${PLUGIN_RCC} ${PLUGIN_HEADERS})
target_link_libraries(${PROJECT_NAME} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${QT_QTMAIN_LIBRARY} ${OpenCV_LIBS} ${NOMACS_LIBS})
target_link_libraries(${PROJECT_NAME} Qt5::Widgets Qt5::Gui)
target_link_libraries(${PROJECT_NAME} Qt::Widgets Qt::Gui)

NMC_CREATE_TARGETS()
NMC_GENERATE_USER_FILE()
Expand Down
55 changes: 35 additions & 20 deletions cmake/Utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,41 @@ endmacro(NMC_POLICY)
macro(NMC_FINDQT)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC OFF)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

if(NOT QT_QMAKE_EXECUTABLE)
find_program(QT_QMAKE_EXECUTABLE NAMES "qmake" "qmake-qt5" "qmake.exe")
endif()
if(NOT QT_QMAKE_EXECUTABLE)
message(FATAL_ERROR "you have to set the path to the Qt5 qmake executable")
endif()
message(STATUS "QMake found: ${QT_QMAKE_EXECUTABLE}")

GET_FILENAME_COMPONENT(QT_QMAKE_PATH ${QT_QMAKE_EXECUTABLE} PATH)
set(QT_ROOT ${QT_QMAKE_PATH}/)
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${QT_QMAKE_PATH}\\..\\lib\\cmake\\Qt5)
find_package(Qt5 REQUIRED Widgets Network LinguistTools PrintSupport Concurrent Gui Svg)
if (NOT Qt5_FOUND)
message(FATAL_ERROR "Qt5Widgets not found. Check your QT_QMAKE_EXECUTABLE path and set it to the correct location")
endif()
add_definitions(-DQT5)


if(CMAKE_VERSION VERSION_LESS "3.7.0")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
endif()

if (MSVC)
if(NOT QT_QMAKE_EXECUTABLE)
find_program(QT_QMAKE_EXECUTABLE NAMES "qmake" "qmake-qt5" "qmake.exe")
endif()
if(NOT QT_QMAKE_EXECUTABLE)
message(FATAL_ERROR "you have to set the path to the Qt5 qmake executable")
endif()

message(STATUS "QMake found: ${QT_QMAKE_EXECUTABLE}")
get_filename_component(QT_QMAKE_PATH ${QT_QMAKE_EXECUTABLE} PATH)
endif()

if (NOT DEFINED QT_VERSION_MAJOR)
find_package(QT NAMES Qt6 Qt5 REQAUIRED COMPONENTS Core)
endif()

find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Network LinguistTools PrintSupport Concurrent Gui Svg)

if (${QT_VERSION_MAJOR} VERSION_GREATER_EQUAL "6")
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core5Compat)
endif()

if (NOT Qt${QT_VERSION_MAJOR}_FOUND)
message(FATAL_ERROR "Qt Libraries not found!")
endif()

if (MSVC)
find_package(Qt5 ${QT5_MIN_VERSION} REQUIRED WinExtras)
endif()

endmacro(NMC_FINDQT)

macro(NMC_FIND_OPENCV)
Expand Down