From d8c1524f61091d721199c8abfc311221ba395e0a Mon Sep 17 00:00:00 2001 From: jkriege2 Date: Mon, 18 Jul 2022 23:33:20 +0200 Subject: [PATCH] partly solve issue #81 by making print-support optional. In addition it can be switched off with the CMake-option JKQtPlotter_BUILD_FORCE_NO_PRINTER_SUPPORT=ON --- cmake/jkqtplotter_cmake_options.cmake | 3 + cmake/jkqtplotter_common_qtsettings.cmake | 28 ++- doc/dox/buildinstructions.dox | 1 + doc/dox/todo.dox | 2 +- doc/dox/whatsnew.dox | 1 + .../datastore_statistics_2d/CMakeLists.txt | 4 +- .../test_user_interaction.cpp | 4 + lib/CMakeLists.txt | 9 +- lib/jkqtcommon/CMakeLists.txt | 66 +++---- lib/jkqtfastplotter/CMakeLists.txt | 77 +++----- lib/jkqtmathtext/CMakeLists.txt | 72 +++----- lib/jkqtplotter/CMakeLists.txt | 84 ++++----- lib/jkqtplotter/LibTarget.cmake.in | 3 +- .../gui/jkqtpenhancedtableview.cpp | 27 ++- lib/jkqtplotter/gui/jkqtpenhancedtableview.h | 25 ++- lib/jkqtplotter/jkqtpbaseplotter.cpp | 170 ++++++++++++------ lib/jkqtplotter/jkqtpbaseplotter.h | 64 +++++-- lib/jkqtplotter/jkqtplotter.cpp | 30 +--- lib/jkqtplotter/jkqtplotter.h | 2 + lib/jkqtplotter/jkqtplotter_configmacros.h | 51 ++++++ lib/jkqtplotter/jkqtptools.cpp | 8 - 21 files changed, 422 insertions(+), 309 deletions(-) create mode 100644 lib/jkqtplotter/jkqtplotter_configmacros.h diff --git a/cmake/jkqtplotter_cmake_options.cmake b/cmake/jkqtplotter_cmake_options.cmake index 1f6bb6ce68..d6748d7288 100644 --- a/cmake/jkqtplotter_cmake_options.cmake +++ b/cmake/jkqtplotter_cmake_options.cmake @@ -13,6 +13,9 @@ endif() if(NOT DEFINED JKQtPlotter_BUILD_EXAMPLES) option(JKQtPlotter_BUILD_EXAMPLES "Build the examples examples" ON) endif() +if(NOT DEFINED JKQtPlotter_BUILD_FORCE_NO_PRINTER_SUPPORT) + option(JKQtPlotter_BUILD_FORCE_NO_PRINTER_SUPPORT "Build the library with printer support switched off, even if it is available" OFF) +endif() if(NOT DEFINED CMAKE_INSTALL_PREFIX) option(CMAKE_INSTALL_PREFIX "Install directory" ${CMAKE_CURRENT_SOURCE_DIR}/install) endif() diff --git a/cmake/jkqtplotter_common_qtsettings.cmake b/cmake/jkqtplotter_common_qtsettings.cmake index 60852916e0..6b247f5367 100644 --- a/cmake/jkqtplotter_common_qtsettings.cmake +++ b/cmake/jkqtplotter_common_qtsettings.cmake @@ -4,17 +4,27 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) -find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED) -find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED) +find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets Svg Xml OpenGL REQUIRED) if(${QT_VERSION_MAJOR} VERSION_GREATER_EQUAL "6") find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS OpenGLWidgets) endif() - -# configure compiler -if(${QT_VERSION_MAJOR} VERSION_LESS "6" ) - set(CMAKE_CXX_STANDARD 11) - set(CMAKE_CXX_STANDARD_REQUIRED on) +if(NOT ${JKQtPlotter_BUILD_FORCE_NO_PRINTER_SUPPORT}) + find_package(Qt${QT_VERSION_MAJOR} OPTIONAL_COMPONENTS PrintSupport) else() - set(CMAKE_CXX_STANDARD 17) - set(CMAKE_CXX_STANDARD_REQUIRED on) + message(STATUS "WARNING: not searching for Qt${QT_VERSION_MAJOR}::PrintSupport, because JKQtPlotter_BUILD_FORCE_NO_PRINTER_SUPPORT=${JKQtPlotter_BUILD_FORCE_NO_PRINTER_SUPPORT}") +endif() + + +set(JKQtPlotter_HAS_NO_PRINTER_SUPPORT FALSE) +if(JKQtPlotter_BUILD_FORCE_NO_PRINTER_SUPPORT) + set(JKQtPlotter_HAS_NO_PRINTER_SUPPORT TRUE) +else() + if(TARGET Qt${QT_VERSION_MAJOR}::PrintSupport) + else() + set(JKQtPlotter_HAS_NO_PRINTER_SUPPORT TRUE) + endif() + if(${QT_VERSION_MAJOR} VERSION_LESS "5" ) + set(JKQtPlotter_HAS_NO_PRINTER_SUPPORT FALSE) + endif() endif() diff --git a/doc/dox/buildinstructions.dox b/doc/dox/buildinstructions.dox index d70806d6ce..3b330edb2c 100644 --- a/doc/dox/buildinstructions.dox +++ b/doc/dox/buildinstructions.dox @@ -51,6 +51,7 @@ The CMake build system offers several configuration variables that you may set/c - \c JKQtPlotter_BUILD_SHARED_LIBS : Build as shared library (default: \c ON ) - \c JKQtPlotter_BUILD_STATIC_LIBS : Build as static library (default: \c ON ) - \c JKQtPlotter_BUILD_INCLUDE_XITS_FONTS : Include XITS fonts as resources in library (default: \c ON ) + - \c JKQtPlotter_BUILD_FORCE_NO_PRINTER_SUPPORT : switches off print-support (when set to \c ON ), even if the current platform supports it (default: \c OFF ) - \c JKQtPlotter_BUILD_DECORATE_LIBNAMES_WITH_BUILDTYPE : If set, the build-type is appended to the library name (default: \c ON ) - \c JKQtPlotter_BUILD_EXAMPLES : Build examples (default: \c ON ) - \c CMAKE_INSTALL_PREFIX : Install directory for the library diff --git a/doc/dox/todo.dox b/doc/dox/todo.dox index ae1f49644a..978db34b4f 100644 --- a/doc/dox/todo.dox +++ b/doc/dox/todo.dox @@ -33,7 +33,7 @@ This page lists several todos and wishes for future version of JKQTPlotter
  • graphs: add candlestick charts (financial, see https://en.m.wikipedia.org/wiki/Candlestick_chart)
  • graphs: add OHLC charts (financial, see https://en.m.wikipedia.org/wiki/Open-high-low-close_chart)
  • graphs: explore/demonstrate/improve plotting speed for large dataset (e.g. only draw visible elements, use algorithm to draw fewer lines if they overlay ...)
  • -
  • +
  • plot: refactor print preview/export preview code
  • diff --git a/doc/dox/whatsnew.dox b/doc/dox/whatsnew.dox index 6c00571ca0..7110188697 100644 --- a/doc/dox/whatsnew.dox +++ b/doc/dox/whatsnew.dox @@ -27,6 +27,7 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
  • NEW: new "seaborn" style for plots
  • NEW/BREAKING CHANGE: changed JKQTPColorDerivationMode into a struct, which extends its capabilities above the previously available few enum-items
  • NEW: added debug-feature to show boxes around text in the plot
  • +
  • BREAKING: Print-Support can now be switched off with a CMAKE-option JKQtPlotter_BUILD_FORCE_NO_PRINTER_SUPPORT=ON. This also switches off PDF and SVG export, partly solves issue #81, many thanks to user:sufuk for contributing part of the code and supplying the idea!
  • JKQTMathText: