Merge pull request #66 from jkriege2/add_qt6_compatibility

Add qt6 compatibility
This commit is contained in:
Jan W. Krieger 2022-04-22 20:28:49 +02:00 committed by GitHub
commit 014f4e597f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
87 changed files with 665 additions and 261 deletions

View File

@ -51,7 +51,11 @@ jobs:
# queries: ./path/to/local/query, your-org/your-repo/queries@main
- name: Install dependencies
run: sudo apt -y install build-essential cmake mesa-common-dev libglu1-mesa-dev libfontconfig1 qt5-qmake qtbase5-dev-tools qt5-default libqt5opengl5-dev qtdeclarative5-dev libqt5svg5-dev libqt5x11extras5-dev
run: |
sudo apt-get update
sudo apt-get update --fix-missing
sudo apt-get install -f
sudo apt -y install build-essential cmake mesa-common-dev libglu1-mesa-dev libfontconfig1 qt5-qmake qtbase5-dev-tools qt5-default libqt5opengl5-dev qtdeclarative5-dev libqt5svg5-dev libqt5x11extras5-dev
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
@ -60,7 +64,7 @@ jobs:
mkdir build
cd build
cmake --version
cmake -G "Unix Makefiles" "-DCMAKE_BUILD_TYPE=Release" ..
cmake -G "Unix Makefiles" "-DCMAKE_BUILD_TYPE=Release" "-DJKQtPlotter_BUILD_EXAMPLES:BOOL=OFF" ..
cmake --build . --config "Release"
cd ..

View File

@ -8,6 +8,8 @@ This software is licensed under the term of the [GNU Lesser General Public Licen
![Language](https://img.shields.io/github/languages/top/jkriege2/JKQtPlotter)
[![Qt5](https://img.shields.io/badge/Qt-5-brightgreen)](https://doc.qt.io/qt-5/)
[![Qt6](https://img.shields.io/badge/Qt-6-brightgreen)](https://doc.qt.io/qt-6/)
[![Documentation](https://img.shields.io/badge/documentation-online-blue)](http://jkriege2.github.io/JKQtPlotter/index.html)
[![Build status](https://ci.appveyor.com/api/projects/status/vq2o9pfi97isxm2a?svg=true)](https://ci.appveyor.com/project/jkriege2/jkqtplotter)
@ -29,7 +31,7 @@ This software is licensed under the term of the [GNU Lesser General Public Licen
## Main Features
- 2D Plotter widget class (JKQTPlotter)
- high-quality plotting
- no other dependencies than Qt >= 5.0
- no other dependencies than Qt >= 5.0 ([CImg](https://cimg.eu/) and [OpenCV](https://opencv.org/) are optional dependencies)
- highly customizable axes/grids (linear/log, date/time, custom ticks ...)
- integrated LaTeX parser (pure C++, no dependencies) to render mathematical equations in axis labels, ticks, ...
- extensive user-interactions pre-programmed (several zooming modes, selecting regions, custom context menus, switch graph visibility, ...)

View File

@ -37,6 +37,12 @@ environment:
CMAKE_GENERATOR: "Visual Studio 16 2019"
CMAKE_BUILDFLAGS: /verbosity:minimal /maxcpucount
- QTABI: msvc2019_64
COMPILER: MSVC
QTVER: 6.3.0
CMAKE_GENERATOR: "Visual Studio 16 2019"
CMAKE_BUILDFLAGS: /verbosity:minimal /maxcpucount
# - QTABI: mingw81_64
# COMPILER: MinGW
# MINGWDIR: C:\Qt\Tools\mingw810_64
@ -47,6 +53,11 @@ environment:
COMPILER: GCC
QTVER: 5.15
CMAKE_GENERATOR: "Unix Makefiles"
- QTABI: gcc_64
COMPILER: GCC
QTVER: 6.2
CMAKE_GENERATOR: "Unix Makefiles"
image:
# AppVeyor builds are ordered by the image list:

View File

@ -1,8 +1,5 @@
cmake_minimum_required(VERSION 3.1)
# configure compiler
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED on)
if(NOT APPLE)
set(CMAKE_INSTALL_RPATH $ORIGIN)

View File

@ -6,3 +6,15 @@ 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)
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)
else()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED on)
endif()

View File

@ -3,12 +3,14 @@ function(jkqtplotter_deployqt TARGET_NAME)
if (WIN32)
get_target_property(_qmake_executable Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION)
get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY)
find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${_qt_bin_dir}")
set(WINDEPLOYQTOPTION "--release")
find_program(WINDEPLOYQT_ENV_SETUP qtenv2.bat HINTS "${_qt_bin_dir}")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(WINDEPLOYQTOPTION "--debug")
endif()
find_program(WINDEPLOYQT_EXECUTABLE NAMES windeployqt.debug.bat HINTS "${_qt_bin_dir}")
else()
find_program(WINDEPLOYQT_EXECUTABLE NAMES windeployqt HINTS "${_qt_bin_dir}")
endif()
# install system runtime lib
include( InstallRequiredSystemLibraries )
@ -18,13 +20,7 @@ function(jkqtplotter_deployqt TARGET_NAME)
get_filename_component(CMAKE_CXX_COMPILER_BINPATH ${CMAKE_CXX_COMPILER} DIRECTORY )
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E
env PATH="${CMAKE_CXX_COMPILER_BINPATH}\;${_qt_bin_dir}" "${WINDEPLOYQT_EXECUTABLE}"
--compiler-runtime
-xml
-printsupport
${WINDEPLOYQTOPTION}
\"$<TARGET_FILE:${TARGET_NAME}>\"
COMMAND "${WINDEPLOYQT_ENV_SETUP}" && "${WINDEPLOYQT_EXECUTABLE}" \"$<TARGET_FILE:${TARGET_NAME}>\"
COMMENT "Running windeployqt ... "
)
endif(WIN32)

View File

@ -44,7 +44,7 @@ PROJECT_NUMBER =
# for a project that appears at the top of each page and should give viewer a
# quick idea about the purpose of the project. Keep the description short.
PROJECT_BRIEF = "an extensive Qt5 Plotter framework (including a feature-richt plotter widget, a speed-optimized, but limited variant and a LaTeX equation renderer!), written fully in C/C++ and without external dependencies"
PROJECT_BRIEF = "an extensive Qt5+Qt6 Plotter framework (including a feature-richt plotter widget, a speed-optimized, but limited variant and a LaTeX equation renderer!), written fully in C/C++ and without external dependencies"
# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
# in the documentation. The maximum height of the logo should not exceed 55

View File

@ -89,6 +89,8 @@ Here is the \c CMakeLists.txt from that directory:
# Configure project for usage of Qt5
find_package(Qt5 COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGl REQUIRED)
# Configure project for usage of Qt6
#find_package(Qt6 COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGl OpenGLWidgets REQUIRED)
# include JKQTPlotter
find_package(JKQTCommonLib REQUIRED)

View File

@ -2,7 +2,7 @@
\mainpage JKQTPlotter - A Qt Plotting Library
- This is an extensive library of function/data plotter classes for Qt (>= 5.0, tested with Qt up to 5.12).
- This is an extensive library of function/data plotter classes for Qt5 (tested with Qt up to 5.15) and Qt6 (tested with Qt up to 6.3).
- This software is licensed under the term of the GNU Lesser General Public License 2.1
(LGPL 2.1) or above. See \ref licensesec for details.
- <a href="http://jkriege2.github.io/JKQtPlotter/index.html">Online-Documentation (http://jkriege2.github.io/JKQtPlotter/index.html)</a>
@ -14,7 +14,7 @@
\section jkqtp_main_features Main Features
- <b>Extensive Scientific 2D Plotting framework (JKQTPlotter / JKQTBasePlotter)</b>
- high-quality plotting
- no other dependencies than Qt >= 5.0
- no other required dependencies than Qt5 or Qt6
- highly customizable axes/grids (linear/log, date/time, custom ticks ...)
- integrated LaTeX parser/renderer JKQTMathText for axis labels, ticks, notes ...
- \ref JKQTPLOTTER_USERINTERACTION "extensive user-interactions pre-programmed (several zooming modes, selecting regions, custom context menus, switch graph visibility, ...)"

View File

@ -41,6 +41,7 @@ Changes, compared to \ref page_whatsnew_V2019_11 "v2019.11" include:
<li>improved/breaking change: made more functions and function parameters const</li>
<li>improved/breaking change: image plots now manage CONST-data, not plain pointer arrays... This is OK, since the raw data is never owned nor modified by the plot, only referenced!.</li>
<li>bugfixed/improved: aspect ratio handling in JKQTPlotter.</li>
<li>new: Compatibility with Qt 5.15 and Qt6</li>
<li>new: added geometric plot objects JKQTPGeoArrow to draw arrows (aka lines with added line-end decorators, also extended JKQTPGeoLine, JKQTPGeoInfiniteLine, JKQTPGeoPolyLines to draw line-end decorator (aka arrows)</li>
<li>new: all geometric objects can either be drawn as graphic element (i.e. lines are straight line, even on non-linear axes), or as mathematical curve (i.e. on non-linear axes, lines become the appropriate curve representing the linear function, connecting the given start/end-points). The only exceptions are ellipses (and the derived arcs,pies,chords), which are always drawn as mathematical curves</li>
<li>new: a new graph class JKQTPXYFunctionLineGraph draws parametric 2D curves ( \f$ [x,y] = f(t) \f$ ), see \ref JKQTPlotterEvalCurves for an example</li>

View File

@ -14,7 +14,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -103,7 +103,8 @@ void doExample()
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -12,7 +12,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -1,5 +1,5 @@
# set minimum required CMake-Version
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.20)
# set Project name
set(EXAMPLE_NAME simpletest)
@ -12,7 +12,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 11)
#set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
# Configure project for usage of Qt5
# Configure project for usage of Qt5/Qt6
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)

View File

@ -5,7 +5,7 @@ This project (see [`cmake_link_example`](https://github.com/jkriege2/JKQtPlotter
This example uses very simple code, which simply displays a plotter and shows some data. The important part of this example is the ´CMakeLists.txt`-file:
```
# set minimum required CMake-Version
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.20)
# set Project name
set(EXAMPLE_NAME simpletest)
@ -15,11 +15,13 @@ This example uses very simple code, which simply displays a plotter and shows so
# some basic configurations
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 11) # for Qt5
#set(CMAKE_CXX_STANDARD 17) # for QT6
#set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
# Configure project for usage of Qt5
find_package(Qt5 COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGl REQUIRED)
# Configure project for usage of Qt5/Qt6
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)
# include JKQTPlotter
find_package(JKQTCommonLib REQUIRED)

View File

@ -20,7 +20,7 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -13,7 +13,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -19,7 +19,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -13,7 +13,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -19,7 +19,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -19,7 +19,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -19,7 +19,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -169,7 +169,8 @@ void drawWithTimeAxis(JKQTPlotter& plot) {
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -18,7 +18,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -13,7 +13,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -14,7 +14,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -11,7 +11,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -135,7 +135,8 @@ void drawExample(QApplication& app, const QString& name) {
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -13,7 +13,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -85,7 +85,8 @@ void drawEllExample(JKQTPlotter* plot, double x0, double y0, double wid, double
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -13,7 +13,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -13,7 +13,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -12,7 +12,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -12,7 +12,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -18,7 +18,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -14,7 +14,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -12,7 +12,7 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -4,7 +4,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -400,7 +400,9 @@ void TestForm::updateMath()
painter.begin(&pix);
if (ui->chkAntiAlias->isChecked()) painter.setRenderHint(QPainter::Antialiasing);
#if (QT_VERSION<QT_VERSION_CHECK(6, 0, 0))
if (ui->chkAntiAliasHQ->isChecked()) painter.setRenderHint(QPainter::HighQualityAntialiasing);
#endif
if (ui->chkAntiAliasText->isChecked()) painter.setRenderHint(QPainter::TextAntialiasing);
if (ui->chkSmoothTransform->isChecked()) painter.setRenderHint(QPainter::QPainter::SmoothPixmapTransform);
ht.start();

View File

@ -6,7 +6,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -15,7 +15,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -13,7 +13,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -16,7 +16,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -12,7 +12,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -12,7 +12,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -13,7 +13,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -18,7 +18,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -14,7 +14,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -15,7 +15,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -12,13 +12,15 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -8,7 +8,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -103,7 +103,8 @@ void addGraph(JKQTPlotter& plot, bool swapXY) {
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -13,7 +13,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -12,7 +12,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -6,7 +6,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -14,7 +14,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -13,7 +13,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -5,7 +5,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -5,7 +5,8 @@
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -164,7 +164,8 @@ JKQTPlotter* showPlot() {
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif

View File

@ -10,7 +10,10 @@ message( STATUS "Version: ${PROJECT_VERSION}")
if (CMAKE_BUILD_TYPE)
message( STATUS "Build type: ${CMAKE_BUILD_TYPE}")
endif(CMAKE_BUILD_TYPE)
message( STATUS "Using compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}" )
message( STATUS "Using CMake: ${CMAKE_VERSION}")
message( STATUS " Generator: ${CMAKE_GENERATOR}")
message( STATUS "Using compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}, platform: ${CMAKE_CXX_PLATFORM_ID}" )
message( STATUS "C++ Standard: C++${CMAKE_CXX_STANDARD}, required: ${CMAKE_CXX_STANDARD_REQUIRED}" )
message( STATUS "Architecture: ${CMAKE_CXX_LIBRARY_ARCHITECTURE} / ${CMAKE_LIBRARY_ARCHITECTURE}" )
message( STATUS "System Name: ${CMAKE_SYSTEM_NAME}" )
message( STATUS "Processor Name: ${CMAKE_SYSTEM_PROCESSOR}" )

View File

@ -100,9 +100,15 @@ if(JKQtPlotter_BUILD_SHARED_LIBS)
target_link_libraries(${libsh_name} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Xml Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::PrintSupport)
target_compile_definitions(${libsh_name} PUBLIC JKQTCOMMON_LIB_IN_DLL)
target_compile_definitions(${libsh_name} PRIVATE JKQTCOMMON_LIB_EXPORT_LIBRARY)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${libsh_name} PUBLIC cxx_std_11)
if(${QT_VERSION_MAJOR} VERSION_LESS "6")
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${libsh_name} PUBLIC cxx_std_11)
else()
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 17)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${libsh_name} PUBLIC cxx_std_17)
endif()
if(MINGW)
# COMPILER-SETTINGS FOR MINGW
target_compile_options(${libsh_name} PUBLIC -fexceptions)
@ -125,9 +131,15 @@ if(JKQtPlotter_BUILD_STATIC_LIBS)
add_library(${lib_name} STATIC ${SOURCES} ${HEADERS})
set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}")
set_property(TARGET ${lib_name} PROPERTY OUTPUT_NAME "${lib_name_decorated}")
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${lib_name} PUBLIC cxx_std_11)
if(${QT_VERSION_MAJOR} VERSION_LESS "6")
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${lib_name} PUBLIC cxx_std_11)
else()
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 17)
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${lib_name} PUBLIC cxx_std_17)
endif()
if(MINGW)
# COMPILER-SETTINGS FOR MINGW
target_compile_options(${lib_name} PUBLIC -fexceptions)

View File

@ -7,8 +7,7 @@
# package requires Qt 5/6
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@QT_VERSION_MAJOR@ COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED)
# include auto-generated targets.cmake file
include("${CMAKE_CURRENT_LIST_DIR}/@JKQTP_CURRENT_TARGET_FILENAME@")

View File

@ -25,6 +25,12 @@
#ifdef QT_XML_LIB
# include <QtXml/QtXml>
#endif
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
#include<QRegularExpression>
#include<QRegularExpressionMatch>
#else
#include<QRegExp>
#endif
const int JKQTPImageTools::PALETTE_ICON_WIDTH = 64;
const int JKQTPImageTools::PALETTE_IMAGEICON_HEIGHT = 64;
@ -2609,7 +2615,7 @@ JKQTPImageTools::LUTType JKQTPBuildColorPaletteLUTLinInterpolate(const QMap<doub
{
QList<QPair<double, QRgb> > itemsi;
for (auto it=items.begin(); it!=items.end(); ++it) {
itemsi.append(qMakePair<double, QRgb>(it.key(), it.value()));
itemsi.append(QPair<double, QRgb>(it.key(), it.value()));
}
return JKQTPBuildColorPaletteLUTLinInterpolateSorted(itemsi, lut_size);
}
@ -2618,7 +2624,7 @@ JKQTPImageTools::LUTType JKQTPBuildColorPaletteLUT(const QMap<double, QRgb> &ite
{
QList<QPair<double, QRgb> > itemsi;
for (auto it=items.begin(); it!=items.end(); ++it) {
itemsi.append(qMakePair<double, QRgb>(it.key(), it.value()));
itemsi.append(QPair<double, QRgb>(it.key(), it.value()));
}
return JKQTPBuildColorPaletteLUTSorted(itemsi, lut_size);
}
@ -2820,26 +2826,48 @@ QVector<int> JKQTPImageTools::registerPalettesFromFile(const QString &filename,
bool has4=false;
bool rgb255=false;
QList<QPair<double, QRgb> > pal;
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
QRegularExpression rx3("\\s*([0-9eE.+-]+)\\s*([,\\t ])\\s*([0-9eE.+-]+)\\s*\\2\\s*([0-9eE.+-]+)\\s*", QRegularExpression::CaseInsensitiveOption|QRegularExpression::InvertedGreedinessOption);
QRegularExpression rx4("\\s*([0-9eE.+-]+)\\s*([,\\t ])\\s*([0-9eE.+-]+)\\s*\\2\\s*([0-9eE.+-]+)\\s*\\2\\s*([0-9eE.+-]+)\\s*", QRegularExpression::CaseInsensitiveOption|QRegularExpression::InvertedGreedinessOption);
#else
QRegExp rx3("\\s*([0-9eE.+-]+)\\s*([,\\t ])\\s*([0-9eE.+-]+)\\s*\\2\\s*([0-9eE.+-]+)\\s*", Qt::CaseInsensitive);
rx3.setMinimal(false);
QRegExp rx4("\\s*([0-9eE.+-]+)\\s*([,\\t ])\\s*([0-9eE.+-]+)\\s*\\2\\s*([0-9eE.+-]+)\\s*\\2\\s*([0-9eE.+-]+)\\s*", Qt::CaseInsensitive);
rx4.setMinimal(false);
#endif
// determine format
for (int i=slt.size()-1; i>=0; i--) {
slt[i]=slt[i].trimmed();
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
const auto m4=rx4.match(slt[i]);
const auto m3=rx3.match(slt[i]);
if (m4.hasMatch()) {
const double r=JKQTPImagePlot_QStringToDouble(m4.captured(3));
const double g=JKQTPImagePlot_QStringToDouble(m4.captured(4));
const double b=JKQTPImagePlot_QStringToDouble(m4.captured(5));
#else
if (rx4.indexIn(slt[i])>=0) {
const double r=JKQTPImagePlot_QStringToDouble(rx4.cap(3));
const double g=JKQTPImagePlot_QStringToDouble(rx4.cap(4));
const double b=JKQTPImagePlot_QStringToDouble(rx4.cap(5));
#endif
has4=true;
double r=JKQTPImagePlot_QStringToDouble(rx4.cap(3));
double g=JKQTPImagePlot_QStringToDouble(rx4.cap(4));
double b=JKQTPImagePlot_QStringToDouble(rx4.cap(5));
if (r>1.0 || g>1.0 || b>1.0) {
rgb255=true;
}
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
} else if (m3.hasMatch()) {
const double r=JKQTPImagePlot_QStringToDouble(m3.captured(1));
const double g=JKQTPImagePlot_QStringToDouble(m3.captured(3));
const double b=JKQTPImagePlot_QStringToDouble(m3.captured(4));
#else
} else if (rx3.indexIn(slt[i])>=0) {
has4=false;
double r=JKQTPImagePlot_QStringToDouble(rx3.cap(1));
double g=JKQTPImagePlot_QStringToDouble(rx3.cap(3));
double b=JKQTPImagePlot_QStringToDouble(rx3.cap(4));
#endif
has4=false;
if (r>1.0 || g>1.0 || b>1.0) {
rgb255=true;
}
@ -2852,6 +2880,20 @@ QVector<int> JKQTPImageTools::registerPalettesFromFile(const QString &filename,
for (int i=0; i<slt.size(); i++) {
double x=0;
double r=0, g=0, b=0;
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
const auto m4=rx4.match(slt[i]);
const auto m3=rx3.match(slt[i]);
if (has4 && m4.hasMatch()) {
x=JKQTPImagePlot_QStringToDouble(m4.captured(1));
r=JKQTPImagePlot_QStringToDouble(m4.captured(3));
g=JKQTPImagePlot_QStringToDouble(m4.captured(4));
b=JKQTPImagePlot_QStringToDouble(m4.captured(5));
} else if (!has4 && m3.hasMatch()) {
x=i;
r=JKQTPImagePlot_QStringToDouble(m3.captured(1));
g=JKQTPImagePlot_QStringToDouble(m3.captured(3));
b=JKQTPImagePlot_QStringToDouble(m3.captured(4));
#else
if (has4 && rx4.indexIn(slt[i])>=0) {
x=JKQTPImagePlot_QStringToDouble(rx4.cap(1));
r=JKQTPImagePlot_QStringToDouble(rx4.cap(3));
@ -2863,15 +2905,16 @@ QVector<int> JKQTPImageTools::registerPalettesFromFile(const QString &filename,
g=JKQTPImagePlot_QStringToDouble(rx3.cap(3));
b=JKQTPImagePlot_QStringToDouble(rx3.cap(4));
//qDebug()<<r<<g<<b;
#endif
} else {
ok=false;
break;
}
if (ok) {
if (!rgb255) {
pal<<qMakePair(x, qRgb(qBound(0,static_cast<int>(round(255*r)), 255), qBound(0,static_cast<int>(round(255*g)), 255), qBound(0,static_cast<int>(round(255*b)), 255)));
pal<<QPair<double,QRgb>(x, qRgb(qBound(0,static_cast<int>(round(255*r)), 255), qBound(0,static_cast<int>(round(255*g)), 255), qBound(0,static_cast<int>(round(255*b)), 255)));
} else {
pal<<qMakePair(x, qRgb(qBound(0,static_cast<int>(round(r)), 255), qBound(0,static_cast<int>(round(g)), 255), qBound(0,static_cast<int>(round(b)), 255)));
pal<<QPair<double,QRgb>(x, qRgb(qBound(0,static_cast<int>(round(r)), 255), qBound(0,static_cast<int>(round(g)), 255), qBound(0,static_cast<int>(round(b)), 255)));
}
}
}

View File

@ -45,7 +45,12 @@ Copyright (c) 2008-2020 Jan W. Krieger (<jan@jkrieger.de>)
#include <ctype.h>
#include <sstream>
#include <locale>
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
#include<QRegularExpression>
#include<QRegularExpressionMatch>
#else
#include<QRegExp>
#endif
std::string jkqtp_tolower(const std::string& s){
std::string d;
@ -527,6 +532,24 @@ QString jkqtp_QColor2String(QColor color, bool useSpecialTransparencySyntax) {
QColor jkqtp_String2QColor(const QString &color)
{
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
QRegularExpression rxP("(.+)\\s*,\\s*(\\d+\\.?\\d+)\\%");
QRegularExpression rxNP("(.+)\\s*,\\s*([\\d]+)");
const auto mP=rxP.match(color);
if (mP.hasMatch()) {
QColor col(mP.captured(1));
double a=QLocale::c().toDouble(mP.captured(2));
col.setAlphaF(a/100.0);
return col;
}
const auto mNP=rxNP.match(color);
if (mNP.hasMatch()) {
QColor col(mNP.captured(1));
double a=QLocale::c().toInt(mNP.captured(2));
col.setAlphaF(a/255.0);
return col;
}
#else
QRegExp rxP("(.+)\\s*,\\s*(\\d+\\.?\\d+)\\%");
QRegExp rxNP("(.+)\\s*,\\s*([\\d]+)");
if (rxP.exactMatch(color)) {
@ -541,6 +564,7 @@ QColor jkqtp_String2QColor(const QString &color)
col.setAlphaF(a/255.0);
return col;
}
#endif
return QColor(color);
}

View File

@ -23,9 +23,17 @@
#include <QList>
#include <QApplication>
#include <QDesktopWidget>
#include <QLocale>
#include <QtCore>
#if (QT_VERSION>QT_VERSION_CHECK(5, 3, 0))
# include <QScreen>
# include <QGuiApplication>
#else
# include <QDesktopWidget>
#endif
#if QT_VERSION>=QT_VERSION_CHECK(6,0,0)
# include <QByteArrayView>
#endif
void jksaveWidgetGeometry(QSettings& settings, QWidget* widget, const QString& prefix) {
settings.setValue(prefix+"pos", widget->pos());
@ -34,11 +42,15 @@ void jksaveWidgetGeometry(QSettings& settings, QWidget* widget, const QString& p
void jkloadWidgetGeometry(QSettings& settings, QWidget* widget, QPoint defaultPosition, QSize defaultSize, const QString& prefix) {
QPoint pos = settings.value(prefix+"pos", defaultPosition).toPoint();
QSize size = settings.value(prefix+"size", defaultSize).toSize();
widget->resize(size.boundedTo(QApplication::desktop()->screenGeometry(widget).size()));
if (pos.x()<0 || pos.x()>QApplication::desktop()->screenGeometry(widget).width()) pos.setX(0);
if (pos.y()<0 || pos.y()>QApplication::desktop()->screenGeometry(widget).height()) pos.setY(0);
const QSize size = settings.value(prefix+"size", defaultSize).toSize();
#if (QT_VERSION>=QT_VERSION_CHECK(5, 3, 0))
const auto widgeo = widget->screen()->geometry();
#else
const auto widgeo = QApplication::desktop()->screenGeometry(widget);
#endif
widget->resize(size.boundedTo(widgeo.size()));
if (pos.x()<0 || pos.x()>widgeo.width()) pos.setX(0);
if (pos.y()<0 || pos.y()>widgeo.height()) pos.setY(0);
widget->move(pos);
}
@ -78,7 +90,23 @@ QString jkVariantListToString(const QList<QVariant>& data, const QString& separa
for (int i=0; i<data.size(); i++) {
if (i>0) r=r+separator;
QVariant v=data[i];
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
if (v.typeId()==QMetaType::Bool) r=r+loc.toString(v.toBool());
else if (v.typeId()==QMetaType::Char) r=r+loc.toString(v.toInt());
else if (v.typeId()==QMetaType::QDate) r=r+loc.toString(v.toDate());
else if (v.typeId()==QMetaType::QDateTime) r=r+loc.toString(v.toDateTime());
else if (v.typeId()==QMetaType::Double) r=r+loc.toString(v.toDouble());
else if (v.typeId()==QMetaType::Int) r=r+loc.toString(v.toInt());
else if (v.typeId()==QMetaType::LongLong) r=r+loc.toString(v.toLongLong());
else if (v.typeId()==QMetaType::QString) r=r+QString("\"%1\"").arg(v.toString().replace("\"", "_").replace("\t", " ").replace("\r", "").replace("\n", " ").replace(",", " ").replace(";", " "));
else if (v.typeId()==QMetaType::QTime) r=r+loc.toString(v.toTime());
else if (v.typeId()==QMetaType::UInt) r=r+loc.toString(v.toUInt());
else if (v.typeId()==QMetaType::ULongLong) r=r+loc.toString(v.toULongLong());
else r=r+v.toString();
#else
switch (v.type()) {
case QVariant::Bool: r=r+loc.toString(v.toBool()); break;
case QVariant::Char: r=r+loc.toString(v.toInt()); break;
case QVariant::Date: r=r+loc.toString(v.toDate()); break;
@ -93,6 +121,7 @@ QString jkVariantListToString(const QList<QVariant>& data, const QString& separa
//case : r=r+loc.toString(v.); break;
default: r=r+v.toString(); break;
}
#endif
}
return r;
}
@ -101,7 +130,11 @@ JKQTCOMMON_LIB_EXPORT QString jkqtp_filenameize(const QString& data) {
QString r;
QString data1=data.simplified();
for (int i=0; i<data1.size(); i++) {
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
const auto c=data1[i];
#else
QCharRef c=data1[i];
#endif
if (c.isLetterOrNumber() || (c=='-') || (c=='_') || (c=='.')) {
r+=c;
} else {
@ -167,7 +200,11 @@ QString jkqtp_MouseButton2String(Qt::MouseButton button, bool useNONE)
}
if (button==Qt::LeftButton) return "LEFT";
if (button==Qt::RightButton) return "RIGHT";
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
if (button==Qt::MiddleButton) return "MIDDLE";
#else
if (button==Qt::MidButton) return "MIDDLE";
#endif
if (button==Qt::BackButton) return "BACK";
if (button==Qt::ForwardButton) return "FORWARD";
if (button==Qt::TaskButton) return "TASK";
@ -200,7 +237,11 @@ Qt::MouseButton jkqtp_String2MouseButton(const QString &button)
auto but=button.toUpper().trimmed();
if (but=="LEFT") return Qt::LeftButton;
if (but=="RIGHT") return Qt::RightButton;
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
if (but=="MIDDLE") return Qt::MiddleButton;
#else
if (but=="MIDDLE") return Qt::MidButton;
#endif
if (but=="BACK") return Qt::BackButton;
if (but=="FORWARD") return Qt::ForwardButton;
if (but=="TASK") return Qt::TaskButton;
@ -227,3 +268,12 @@ Qt::MouseButton jkqtp_String2MouseButton(const QString &button)
if (but=="EXTRA24") return Qt::ExtraButton24;
return Qt::NoButton;
}
quint16 jkqtp_checksum(const void *data, size_t len)
{
#if QT_VERSION>=QT_VERSION_CHECK(6,0,0)
return qChecksum(QByteArrayView(static_cast<const uint8_t*>(data), len));
#else
return qChecksum(static_cast<const char*>(data), len);
#endif
}

View File

@ -134,6 +134,12 @@ JKQTCOMMON_LIB_EXPORT QString jkqtp_MouseButton2String(Qt::MouseButton button, b
* \see jkqtp_MouseButton2String()
*/
JKQTCOMMON_LIB_EXPORT Qt::MouseButton jkqtp_String2MouseButton(const QString &button);
/** \brief convert a <a href="http://doc.qt.io/qt-5/qstring.html">QString</a> (created by jkqtp_MouseButton2String() ) to <a href="http://doc.qt.io/qt-5/qt.html#MouseButton-enum">Qt::MouseButton</a>
* \ingroup tools
*
* \see jkqtp_MouseButton2String()
*/
JKQTCOMMON_LIB_EXPORT quint16 jkqtp_checksum(const void* data, size_t len);
#endif // JKQTTOOLS_H

View File

@ -21,7 +21,7 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
# Set up source files
set(SOURCES
jkqtfastplotter.cpp
${CMAKE_CURRENT_LIST_DIR}/jkqtfastplotter.cpp
)
set(HEADERS
@ -40,10 +40,17 @@ if(JKQtPlotter_BUILD_SHARED_LIBS)
set_property(TARGET ${libsh_name} PROPERTY VERSION "${PROJECT_VERSION}")
set_property(TARGET ${libsh_name} PROPERTY OUTPUT_NAME "${libsh_name_decorated}")
target_link_libraries(${libsh_name} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::PrintSupport Qt${QT_VERSION_MAJOR}::OpenGL JKQTCommonSharedLib)
if(${QT_VERSION_MAJOR} VERSION_LESS "6")
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${libsh_name} PUBLIC cxx_std_11)
else()
target_link_libraries(${libsh_name} PUBLIC Qt${QT_VERSION_MAJOR}::OpenGLWidgets)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 17)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${libsh_name} PUBLIC cxx_std_17)
endif()
target_compile_definitions(${libsh_name} PUBLIC JKQTFASTPLOTTER_LIB_IN_DLL)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${libsh_name} PUBLIC cxx_std_11)
if(MINGW)
# COMPILER-SETTINGS FOR MINGW
target_compile_options(${libsh_name} PUBLIC -fexceptions)
@ -67,8 +74,6 @@ if(JKQtPlotter_BUILD_STATIC_LIBS)
add_library(${lib_name} STATIC ${SOURCES} ${RESOURCES} ${HEADERS})
set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}")
set_property(TARGET ${lib_name} PROPERTY OUTPUT_NAME "${lib_name_decorated}")
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
if(MINGW)
# COMPILER-SETTINGS FOR MINGW
target_compile_options(${lib_name} PUBLIC -fexceptions)
@ -77,9 +82,18 @@ if(JKQtPlotter_BUILD_STATIC_LIBS)
target_compile_options(${lib_name} PUBLIC /EHsc)
target_compile_definitions(${lib_name} PUBLIC NOMINMAX)
endif()
target_compile_features(${lib_name} PUBLIC cxx_std_11)
target_link_libraries(${lib_name} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::PrintSupport Qt${QT_VERSION_MAJOR}::OpenGL JKQTCommonLib)
target_include_directories(${lib_name} PUBLIC
if(${QT_VERSION_MAJOR} VERSION_LESS "6")
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${lib_name} PUBLIC cxx_std_11)
else()
target_link_libraries(${lib_name} PUBLIC Qt${QT_VERSION_MAJOR}::OpenGLWidgets)
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 17)
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${lib_name} PUBLIC cxx_std_17)
endif()
target_include_directories(${lib_name} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/../>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

View File

@ -7,8 +7,10 @@
# package requires Qt 5/6
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@QT_VERSION_MAJOR@ COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED)
if(${QT_VERSION_MAJOR} VERSION_GREATER_EQUAL "6")
find_package(Qt@QT_VERSION_MAJOR@ REQUIRED COMPONENTS OpenGLWidgets)
endif()
find_package(JKQTCommon@JKQTP_CURRENT_TARGET_SHAREDPART@Lib REQUIRED PATHS ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_MODULE_PATH})
# include auto-generated targets.cmake file

View File

@ -69,7 +69,11 @@ void JKQTFPPlot::paint(QPainter& painter) {
}
JKQTFastPlotter::JKQTFastPlotter(QWidget *parent) :
QGLWidget(QGLFormat(QGL::StencilBuffer | QGL::AlphaChannel | QGL::Rgba), parent)//, mutexRepaint(QMutex::Recursive), mutexRepaintData(QMutex::Recursive), mutexRepaintSystem(QMutex::Recursive)
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
JKQTFASTPLOTTER_BASE(parent)
#else
JKQTFASTPLOTTER_BASE(QGLFormat(QGL::StencilBuffer | QGL::AlphaChannel | QGL::Rgba), parent)//, mutexRepaint(QMutex::Recursive), mutexRepaintData(QMutex::Recursive), mutexRepaintSystem(QMutex::Recursive)
#endif
{
mouseDragStart=QPoint(0,0);
mouseDragEnd=QPoint(0,0);
@ -263,7 +267,7 @@ void JKQTFastPlotter::mouseReleaseEvent(QMouseEvent *event)
}
void JKQTFastPlotter::resizeEvent(QResizeEvent *event) {
QGLWidget::resizeEvent(event);
JKQTFASTPLOTTER_BASE::resizeEvent(event);
if (width() > image.width() || height() > image.height()) {
QImage newImage(QSize(width(), height()), QImage::Format_ARGB32);
image=newImage;
@ -350,7 +354,7 @@ void JKQTFastPlotter::plotSystem(QPainter& painter) {
systemPath.moveTo(x2p(x), internalPlotBorderTop+plotHeight+tickLength);
systemPath.lineTo(x2p(x), internalPlotBorderTop+plotHeight-tickLength);
QString text=QLocale::system().toString(x);
painter.drawText(QPointF(x2p(x)-fmTicks.width(text)/2.0, internalPlotBorderTop+plotHeight+fmTicks.ascent()+fmTicks.width("x")/2.0+tickLength), text);
painter.drawText(QPointF(x2p(x)-fmTicks.boundingRect(text).width()/2.0, internalPlotBorderTop+plotHeight+fmTicks.ascent()+fmTicks.boundingRect("x").width()/2.0+tickLength), text);
}
if (xAxisLog) {
x=x*10.0;
@ -368,7 +372,7 @@ void JKQTFastPlotter::plotSystem(QPainter& painter) {
systemPath.moveTo(x2p(x), internalPlotBorderTop+plotHeight+tickLength);
systemPath.lineTo(x2p(x), internalPlotBorderTop+plotHeight-tickLength);
QString text=QLocale::system().toString(x);
painter.drawText(QPointF(x2p(x)-fmTicks.width(text)/2.0, internalPlotBorderTop+plotHeight+fmTicks.ascent()+fmTicks.width("x")/2.0+tickLength), text);
painter.drawText(QPointF(x2p(x)-fmTicks.boundingRect(text).width()/2.0, internalPlotBorderTop+plotHeight+fmTicks.ascent()+fmTicks.boundingRect("x").width()/2.0+tickLength), text);
}
if (xAxisLog) {
x=x/10.0;
@ -387,7 +391,7 @@ void JKQTFastPlotter::plotSystem(QPainter& painter) {
systemPath.moveTo(internalPlotBorderLeft-tickLength, y2p(y));
systemPath.lineTo(internalPlotBorderLeft+tickLength, y2p(y));
QString text=QLocale::system().toString(y);
painter.drawText(QPointF(internalPlotBorderLeft-fmTicks.width("x")/2.0-fmTicks.width(text)-tickLength, y2p(y)+fmTicks.ascent()/2.0), text);
painter.drawText(QPointF(internalPlotBorderLeft-fmTicks.boundingRect("x").width()/2.0-fmTicks.boundingRect(text).width()-tickLength, y2p(y)+fmTicks.ascent()/2.0), text);
}
if (yAxisLog) {
y=y*10.0;
@ -405,7 +409,7 @@ void JKQTFastPlotter::plotSystem(QPainter& painter) {
systemPath.moveTo(internalPlotBorderLeft-tickLength, y2p(y));
systemPath.lineTo(internalPlotBorderLeft+tickLength, y2p(y));
QString text=QLocale::system().toString(y);
painter.drawText(QPointF(internalPlotBorderLeft-fmTicks.width("x")/2.0-fmTicks.width(text)-tickLength, y2p(y)+fmTicks.ascent()/2.0), text);
painter.drawText(QPointF(internalPlotBorderLeft-fmTicks.boundingRect("x").width()/2.0-fmTicks.boundingRect(text).width()-tickLength, y2p(y)+fmTicks.ascent()/2.0), text);
}
if (yAxisLog) {
y=y/10.0;
@ -453,11 +457,11 @@ void JKQTFastPlotter::plotSystem(QPainter& painter) {
if (xAxisLabelVisible) {
painter.setPen(pSystem);
painter.setFont(fLabels);
painter.drawText(QPointF(internalPlotBorderLeft+plotWidth-fmLabels.width(xAxisLabel), internalPlotBorderTop+plotHeight+fmTicks.height()+fmTicks.width("x")/2.0+fmLabels.ascent()+tickLength), xAxisLabel);
painter.drawText(QPointF(internalPlotBorderLeft+plotWidth-fmLabels.boundingRect(xAxisLabel).width(), internalPlotBorderTop+plotHeight+fmTicks.height()+fmTicks.boundingRect("x").width()/2.0+fmLabels.ascent()+tickLength), xAxisLabel);
}
if (yAxisLabelVisible) {
painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();});
painter.translate(fmLabels.ascent(), internalPlotBorderTop+fmLabels.width(yAxisLabel));
painter.translate(fmLabels.ascent(), internalPlotBorderTop+fmLabels.boundingRect(yAxisLabel).width());
painter.rotate(-90);
painter.drawText(QPointF(0, 0), yAxisLabel);

View File

@ -34,7 +34,13 @@
#include <cmath>
#include <iostream>
#include <QMutex>
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
#include <QtOpenGLWidgets/QOpenGLWidget>
#define JKQTFASTPLOTTER_BASE QOpenGLWidget
#else
#include <QGLWidget>
#define JKQTFASTPLOTTER_BASE QGLWidget
#endif
#include "jkqtcommon/jkqtpmathtools.h"
#ifdef DEBUG_TIMING
# include "jkqtcommon/jkqtphighrestimer.h"
@ -83,7 +89,13 @@ class JKQTFPPlot;
.
*/
class JKQTFASTPLOTTER_LIB_EXPORT JKQTFastPlotter : public QGLWidget {
class JKQTFASTPLOTTER_LIB_EXPORT JKQTFastPlotter :
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
public QOpenGLWidget
#else
public QGLWidget
#endif
{
Q_OBJECT
public:

View File

@ -47,9 +47,15 @@ if(JKQtPlotter_BUILD_SHARED_LIBS)
target_link_libraries(${libsh_name} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::PrintSupport JKQTCommonSharedLib)
target_compile_definitions(${libsh_name} PUBLIC JKQTMATHTEXT_LIB_IN_DLL)
target_compile_definitions(${libsh_name} PRIVATE JKQTMATHTEXT_LIB_EXPORT_LIBRARY)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${libsh_name} PUBLIC cxx_std_11)
if(${QT_VERSION_MAJOR} VERSION_LESS "6")
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${libsh_name} PUBLIC cxx_std_11)
else()
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 17)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${libsh_name} PUBLIC cxx_std_17)
endif()
if(MINGW)
# COMPILER-SETTINGS FOR MINGW
target_compile_options(${libsh_name} PUBLIC -fexceptions)
@ -75,9 +81,15 @@ if(JKQtPlotter_BUILD_STATIC_LIBS)
add_library(${lib_name} STATIC ${SOURCES} ${RESOURCES} ${HEADERS})
set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}")
set_property(TARGET ${lib_name} PROPERTY OUTPUT_NAME "${lib_name_decorated}")
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${lib_name} PUBLIC cxx_std_11)
if(${QT_VERSION_MAJOR} VERSION_LESS "6")
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${lib_name} PUBLIC cxx_std_11)
else()
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 17)
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${lib_name} PUBLIC cxx_std_17)
endif()
if(MINGW)
# COMPILER-SETTINGS FOR MINGW
target_compile_options(${lib_name} PUBLIC -fexceptions)

View File

@ -7,8 +7,7 @@
# package requires Qt 5/6
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@QT_VERSION_MAJOR@ COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED)
find_package(JKQTCommon@JKQTP_CURRENT_TARGET_SHAREDPART@Lib REQUIRED PATHS ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_MODULE_PATH})

View File

@ -30,6 +30,7 @@
#include <QApplication>
#include <QPainterPath>
const double JKQTMathText::ABS_MIN_LINEWIDTH=0.02;
QPainterPath makeHBracePath(double x, double ybrace, double width, double bw, double cubicshrink=0.5, double cubiccontrolfac=0.3) {
@ -277,14 +278,14 @@ void JKQTMathText::MTtextNode::getSizeInternal(QPainter& painter, JKQTMathText::
QRectF tbr=parent->getTightBoundingRect(f, txt, painter.device()); //fm.tightBoundingRect(txt);
if (txt=="|") {
br=fm.boundingRect("X");
tbr=QRectF(0,0,fm.width("X"), fm.ascent());//fm.boundingRect("X");
tbr=QRectF(0,0,fm.boundingRect("X").width(), fm.ascent());//fm.boundingRect("X");
br.setWidth(0.7*br.width());
}
width=br.width();//width(text);
if (txt.size()>0) {
if (txt[0].isSpace() /*&& br.width()<=0*/) width=width+fm.boundingRect("I").width();
if (txt.size()>1 && txt[txt.size()-1].isSpace() /*&& (fm.boundingRect("a ").width()==fm.boundingRect("a").width())*/) width=width+fm.width("I");
if (txt.size()>1 && txt[txt.size()-1].isSpace() /*&& (fm.boundingRect("a ").width()==fm.boundingRect("a").width())*/) width=width+fm.boundingRect("I").width();
}
//qDebug()<<"text: "<<text<<" "<<tbr.height()<<tbr.top()<<tbr.bottom();
@ -340,7 +341,7 @@ double JKQTMathText::MTtextNode::draw(QPainter& painter, double x, double y, JKQ
QFontMetricsF fm(f, painter.device());
/*if (txt.size()>1 && txt[txt.size()-1].isSpace()) {
QFontMetricsF fm(f, painter.device());
//if ((fm.width("a ")==fm.width("a"))) dx=fm.boundingRect("I").width();
//if ((fm.QFMF_WIDTH("a ")==fm.QFMF_WIDTH("a"))) dx=fm.boundingRect("I").QFMF_WIDTH();
}*/
if (!hasDigits || !f.italic()) {
@ -367,7 +368,7 @@ double JKQTMathText::MTtextNode::draw(QPainter& painter, double x, double y, JKQ
painter.setFont(ff);
painter.drawText(QPointF(xx, y), QString(txt[i]));
}
xx=xx+fmff.width(txt[i]);
xx=xx+fmff.boundingRect(txt[i]).width();
} else {
if (currentEv.font==MTEblackboard && parent->blackboardSimulated) {
QPainterPath path;
@ -377,7 +378,7 @@ double JKQTMathText::MTtextNode::draw(QPainter& painter, double x, double y, JKQ
painter.setFont(f);
painter.drawText(QPointF(xx, y), QString(txt[i]));
}
xx=xx+fm.width(txt[i]);
xx=xx+fm.boundingRect(txt[i]).width();
}
i++;
}
@ -465,7 +466,7 @@ void JKQTMathText::MTinstruction1Node::getSizeInternal(QPainter& painter, JKQTMa
child->getSize(painter, ev, width, baselineHeight, overallHeight, strikeoutPos);
if (name=="colorbox" || name=="fbox" || name=="boxed") {
QFontMetricsF fm(ev.getFont(parent));
double xw=fm.width("x");
double xw=fm.boundingRect("x").width();
width+=xw;
overallHeight+=xw;
baselineHeight+=xw/2.0;
@ -488,7 +489,7 @@ double JKQTMathText::MTinstruction1Node::draw(QPainter& painter, double x, doubl
child->getSize(painter, currentEv, width, baselineHeight, overallHeight, strikeoutPos);
QPen p=painter.pen();
QFontMetricsF fm(currentEv.getFont(parent));
double xw=fm.width("x");
double xw=fm.boundingRect("x").width();
p.setColor(fcol);
painter.setPen(p);
painter.drawRect(QRectF(x,y-baselineHeight-xw/2,width+xw,overallHeight+xw));
@ -2860,11 +2861,11 @@ void JKQTMathText::MTsymbolNode::getSizeInternal(QPainter& painter, JKQTMathText
if (currentEv.insideMath) width=qMax(parent->getTightBoundingRect(f, symb, painter.device()).width(),parent->getTightBoundingRect(f, "i", painter.device()).width());//fm.width(symbol);
else width=fm.boundingRect(symb).width();//fm.width(symbol);
width=qMax(fm.width("j"), width);
width=qMax(fm.boundingRect("j").width(), width);
if (symb.isEmpty()) {
width=fm.width("a");
if (symbolName=="|") width=fm.width("1")*0.8;
else if (symbolName=="infty") width=fm.width("M");
width=fm.boundingRect("a").width();
if (symbolName=="|") width=fm.boundingRect("1").width()*0.8;
else if (symbolName=="infty") width=fm.boundingRect("M").width();
else if (symbolName=="quad" || symbolName=="qquad") width=parent->getTightBoundingRect(f, "M", painter.device()).width();
else if (symbolName==" " || symbolName=="space") width=parent->getTightBoundingRect(f, "x", painter.device()).width();
else if (symbolName==";") width=parent->getTightBoundingRect(f, "x", painter.device()).width()*0.75;
@ -2933,7 +2934,7 @@ double JKQTMathText::MTsymbolNode::draw(QPainter& painter, double x, double y, J
p.setWidthF(fm.lineWidth());
p.setStyle(Qt::SolidLine);
painter.setPen(p);
double xwi=fm.width("x");
double xwi=fm.boundingRect("x").width();
if (!props.symbol.isEmpty()) {
// if the symbol has been recognized in the constructor: draw the symbol
painter.drawText(QPointF(x+shift, y+props.yfactor*overallHeight), props.symbol);
@ -2949,7 +2950,7 @@ double JKQTMathText::MTsymbolNode::draw(QPainter& painter, double x, double y, J
f1.setItalic(false);
painter.setFont(f1);
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
painter.translate(x+shift+fm1.width("8")/3.0, y-fm1.xHeight());
painter.translate(x+shift+fm1.boundingRect("8").width()/3.0, y-fm1.xHeight());
painter.rotate(90);
painter.drawText(QPointF(0,0), "8");
@ -2961,7 +2962,7 @@ double JKQTMathText::MTsymbolNode::draw(QPainter& painter, double x, double y, J
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
painter.translate(x+shift, y);
painter.drawText(QPointF(0,0), "|");
painter.translate(fm1.width("8")/3.0, 0);
painter.translate(fm1.boundingRect("8").width()/3.0, 0);
painter.drawText(QPointF(0,0), "|");
@ -4876,7 +4877,9 @@ void JKQTMathTextLabel::internalPaint()
//qDebug()<<"internalPaint(): "<<p.begin(&buffer);
p.begin(&buffer);
p.setRenderHint(QPainter::Antialiasing);
#if (QT_VERSION<QT_VERSION_CHECK(6, 0, 0))
p.setRenderHint(QPainter::HighQualityAntialiasing);
#endif
p.setRenderHint(QPainter::TextAntialiasing);
size=m_mathText->getSize(p);
p.end();
@ -4889,7 +4892,9 @@ void JKQTMathTextLabel::internalPaint()
//qDebug()<<"internalPaint(): "<<p.begin(&buffer);
p.begin(&buffer);
p.setRenderHint(QPainter::Antialiasing);
#if (QT_VERSION<QT_VERSION_CHECK(6, 0, 0))
p.setRenderHint(QPainter::HighQualityAntialiasing);
#endif
p.setRenderHint(QPainter::TextAntialiasing);
m_mathText->draw(p,alignment(), QRectF(QPointF(0,0), size));
p.end();

View File

@ -1194,14 +1194,16 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject {
};
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
inline size_t qHash(const JKQTMathText::tbrDataH& data, size_t /*seed=0*/) {
#else
inline uint qHash(const JKQTMathText::tbrDataH& data) {
return qHash(data.f.family())+qHash(data.text);
#endif
return qHash(data.f.family())+qHash(data.text);
}
/*! \brief A QLabel-derived class that draws an equation with LaTeX markup using JKQTMathText
\ingroup jkqtmathtext

View File

@ -202,9 +202,15 @@ if(JKQtPlotter_BUILD_SHARED_LIBS)
set_property(TARGET ${libsh_name} PROPERTY VERSION "${PROJECT_VERSION}")
set_property(TARGET ${libsh_name} PROPERTY OUTPUT_NAME "${libsh_name_decorated}")
target_link_libraries(${libsh_name} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::PrintSupport Qt${QT_VERSION_MAJOR}::Svg Qt${QT_VERSION_MAJOR}::Xml JKQTCommonSharedLib JKQTMathTextSharedLib)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${libsh_name} PUBLIC cxx_std_11)
if(${QT_VERSION_MAJOR} VERSION_LESS "6")
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${libsh_name} PUBLIC cxx_std_11)
else()
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 17)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${libsh_name} PUBLIC cxx_std_17)
endif()
target_compile_definitions(${libsh_name} PUBLIC JKQTPLOTTER_LIB_IN_DLL)
target_compile_definitions(${libsh_name} PRIVATE JKQTPLOTTER_LIB_EXPORT_LIBRARY)
if(MINGW)
@ -229,8 +235,15 @@ if(JKQtPlotter_BUILD_STATIC_LIBS)
add_library(${lib_name} STATIC ${SOURCES_BASE} ${SOURCES_GRAPHS} ${SOURCES_GUI} ${RESOURCES} ${HEADERS_BASE} ${HEADERS_GRAPHS} ${HEADERS_GUI})
set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}")
set_property(TARGET ${lib_name} PROPERTY OUTPUT_NAME "${lib_name_decorated}")
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
if(${QT_VERSION_MAJOR} VERSION_LESS "6")
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${lib_name} PUBLIC cxx_std_11)
else()
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 17)
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${lib_name} PUBLIC cxx_std_17)
endif()
if(MINGW)
# COMPILER-SETTINGS FOR MINGW
target_compile_options(${lib_name} PUBLIC -fexceptions)
@ -239,7 +252,6 @@ if(JKQtPlotter_BUILD_STATIC_LIBS)
target_compile_options(${lib_name} PUBLIC /EHsc)
target_compile_definitions(${lib_name} PUBLIC NOMINMAX)
endif()
target_compile_features(${lib_name} PUBLIC cxx_std_11)
target_include_directories(${lib_name} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/../>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>

View File

@ -6,8 +6,7 @@
#
# package requires Qt 5/6
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@QT_VERSION_MAJOR@ COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED)
find_package(JKQTCommon@JKQTP_CURRENT_TARGET_SHAREDPART@Lib REQUIRED PATHS ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_MODULE_PATH})
find_package(JKQTMathText@JKQTP_CURRENT_TARGET_SHAREDPART@Lib REQUIRED PATHS ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_MODULE_PATH})

View File

@ -25,6 +25,7 @@
#include "jkqtcommon/jkqtpenhancedpainter.h"
#include "jkqtplotter/jkqtplotter.h"
#include "jkqtcommon/jkqtpgeometrytools.h"
#include "jkqtcommon/jkqttools.h"
#include <QDebug>
#include <QImageWriter>
#include <QFileDialog>
@ -63,7 +64,7 @@ void JKQTPContourPlot::draw(JKQTPEnhancedPainter &painter)
int64_t colChecksum=-1;
if (data && Nx*Ny>0) {
colChecksum=static_cast<int64_t>(qChecksum(reinterpret_cast<const char*>(data), static_cast<int64_t>(Nx)*static_cast<int64_t>(Ny)* static_cast<int64_t>(getSampleSize()/sizeof(char))));
colChecksum=static_cast<int64_t>(jkqtp_checksum(reinterpret_cast<const char*>(data), static_cast<int64_t>(Nx)*static_cast<int64_t>(Ny)* static_cast<int64_t>(getSampleSize()/sizeof(char))));
}
/*if (parent && parent->getDatastore() && imageColumn>=0) {
colChecksum=static_cast<int64_t>(parent->getDatastore()->getColumnChecksum(imageColumn));

View File

@ -129,6 +129,26 @@ void JKQTPEnhancedTableView::copySelectionToExcel(int copyrole, bool storeHead)
if (sel.size()==1) {
QVariant vdata=sel[0].data(copyrole);
QString txt="";
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
switch (vdata.typeId()) {
case QMetaType::Int:
case QMetaType::LongLong:
case QMetaType::UInt:
case QMetaType::ULongLong:
case QMetaType::Bool:
txt=vdata.toString();
break;
case QMetaType::Double:
txt=loc.toString(vdata.toDouble());
break;
case QMetaType::QPointF:
txt=loc.toString(vdata.toPointF().x());
break;
default:
txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " "));
break;
}
#else
switch (vdata.type()) {
case QVariant::Int:
case QVariant::LongLong:
@ -147,6 +167,7 @@ void JKQTPEnhancedTableView::copySelectionToExcel(int copyrole, bool storeHead)
txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " "));
break;
}
#endif
QApplication::clipboard()->setText(txt);
} else {
QSet<int> rows, cols;
@ -210,6 +231,26 @@ void JKQTPEnhancedTableView::copySelectionToExcel(int copyrole, bool storeHead)
int c=collist.indexOf(sel[i].column());
QVariant vdata=sel[i].data(copyrole);
QString txt="";
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
switch (vdata.typeId()) {
case QMetaType::Int:
case QMetaType::LongLong:
case QMetaType::UInt:
case QMetaType::ULongLong:
case QMetaType::Bool:
txt=vdata.toString();
break;
case QMetaType::Double:
txt=loc.toString(vdata.toDouble());
break;
case QMetaType::QPointF:
txt=loc.toString(vdata.toPointF().x());
break;
default:
txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " "));
break;
}
#else
switch (vdata.type()) {
case QVariant::Int:
case QVariant::LongLong:
@ -228,6 +269,7 @@ void JKQTPEnhancedTableView::copySelectionToExcel(int copyrole, bool storeHead)
txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " "));
break;
}
#endif
int shift=0;
if (storeHead) shift=1;
if ((r>=0) && (c>=0) && (r<=data.size()) && (c<=colcnt))data[r+shift][c+shift]=txt;
@ -256,6 +298,26 @@ void JKQTPEnhancedTableView::copySelectionToCSV(int copyrole, bool storeHead, co
if (sel.size()==1) {
QVariant vdata=sel[0].data(copyrole);
QString txt="";
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
switch (vdata.typeId()) {
case QMetaType::Int:
case QMetaType::LongLong:
case QMetaType::UInt:
case QMetaType::ULongLong:
case QMetaType::Bool:
txt=vdata.toString();
break;
case QMetaType::Double:
txt=JKQTPDoubleToQString(vdata.toDouble(), 15, 'g', decimalpoint);
break;
case QMetaType::QPointF:
txt=JKQTPDoubleToQString(vdata.toPointF().x(), 15, 'g', decimalpoint);
break;
default:
txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " "));
break;
}
#else
switch (vdata.type()) {
case QVariant::Int:
case QVariant::LongLong:
@ -274,6 +336,7 @@ void JKQTPEnhancedTableView::copySelectionToCSV(int copyrole, bool storeHead, co
txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " "));
break;
}
#endif
QApplication::clipboard()->setText(txt);
} else {
QSet<int> rows, cols;
@ -337,6 +400,26 @@ void JKQTPEnhancedTableView::copySelectionToCSV(int copyrole, bool storeHead, co
int c=collist.indexOf(sel[i].column());
QVariant vdata=sel[i].data(copyrole);
QString txt="";
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
switch (vdata.typeId()) {
case QMetaType::Int:
case QMetaType::LongLong:
case QMetaType::UInt:
case QMetaType::ULongLong:
case QMetaType::Bool:
txt=vdata.toString();
break;
case QMetaType::Double:
txt=JKQTPDoubleToQString(vdata.toDouble(), 15, 'g', decimalpoint);
break;
case QMetaType::QPointF:
txt=JKQTPDoubleToQString(vdata.toPointF().x(), 15, 'g', decimalpoint);
break;
default:
txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " "));
break;
}
#else
switch (vdata.type()) {
case QVariant::Int:
case QVariant::LongLong:
@ -355,6 +438,7 @@ void JKQTPEnhancedTableView::copySelectionToCSV(int copyrole, bool storeHead, co
txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " "));
break;
}
#endif
int shift=0;
if (storeHead) shift=1;
if ((r>=0) && (c>=0) && (r<=data.size()) && (c<=colcnt))data[r+shift][c+shift]=txt;
@ -568,7 +652,12 @@ QSizeF JKQTPEnhancedTableView::getTotalSize() const
void JKQTPEnhancedTableView::paint(QPainter &painter, double scale, int page, double hhh, double vhw, const QList<int>& pageCols, const QList<int>& pageRows, QPrinter* p)
{
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
QStyleOptionViewItem option = viewOptions();
QStyleOptionViewItem option;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
initViewItemOption(&option);
#else
option = viewOptions();
#endif
painter.scale(scale, scale);
QPen headerPen("black");
headerPen.setWidth(2);

View File

@ -778,29 +778,30 @@ void JKQTBasePlotter::calcPlotScaling(JKQTPEnhancedPainter& painter){
internalPlotKeyBorderBottom=0;
internalPlotKeyBorderLeft=0;
internalPlotKeyBorderRight=0;
const qreal Xwid=kfm.boundingRect('X').width();
if (plotterStyle.keyStyle.position==JKQTPKeyOutsideTopRight) {
internalPlotKeyBorderTop=keyHeight+2*plotterStyle.keyStyle.yMargin*kfm.width('X')+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.yOffset*kfm.width('X')+2;
internalPlotKeyBorderTop=keyHeight+2*plotterStyle.keyStyle.yMargin*Xwid+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.yOffset*Xwid+2;
internalPlotBorderTop = internalPlotBorderTop + internalPlotKeyBorderTop;
} else if (plotterStyle.keyStyle.position==JKQTPKeyOutsideTopLeft) {
internalPlotKeyBorderTop=keyHeight+2*plotterStyle.keyStyle.yMargin*kfm.width('X')+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.yOffset*kfm.width('X')+2;
internalPlotKeyBorderTop=keyHeight+2*plotterStyle.keyStyle.yMargin*Xwid+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.yOffset*Xwid+2;
internalPlotBorderTop = internalPlotBorderTop + internalPlotKeyBorderTop;
} else if (plotterStyle.keyStyle.position==JKQTPKeyOutsideLeftTop) {
internalPlotKeyBorderLeft=keyWidth+2*plotterStyle.keyStyle.xMargin*kfm.width('X')+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.xOffset*kfm.width('X')+2;
internalPlotKeyBorderLeft=keyWidth+2*plotterStyle.keyStyle.xMargin*Xwid+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.xOffset*Xwid+2;
internalPlotBorderLeft = internalPlotBorderLeft + internalPlotKeyBorderLeft;
} else if (plotterStyle.keyStyle.position==JKQTPKeyOutsideLeftBottom) {
internalPlotKeyBorderLeft=keyWidth+2*plotterStyle.keyStyle.xMargin*kfm.width('X')+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.xOffset*kfm.width('X')+2;
internalPlotKeyBorderLeft=keyWidth+2*plotterStyle.keyStyle.xMargin*Xwid+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.xOffset*Xwid+2;
internalPlotBorderLeft = internalPlotBorderLeft + internalPlotKeyBorderLeft;
} else if (plotterStyle.keyStyle.position==JKQTPKeyOutsideBottomRight) {
internalPlotKeyBorderBottom=keyHeight+2*plotterStyle.keyStyle.yMargin*kfm.width('X')+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.yOffset*kfm.width('X')+2;
internalPlotKeyBorderBottom=keyHeight+2*plotterStyle.keyStyle.yMargin*Xwid+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.yOffset*Xwid+2;
internalPlotBorderBottom = internalPlotBorderBottom + internalPlotKeyBorderBottom;
} else if (plotterStyle.keyStyle.position==JKQTPKeyOutsideBottomLeft) {
internalPlotKeyBorderBottom=keyHeight+2*plotterStyle.keyStyle.yMargin*kfm.width('X')+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.yOffset*kfm.width('X')+2;
internalPlotKeyBorderBottom=keyHeight+2*plotterStyle.keyStyle.yMargin*Xwid+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.yOffset*Xwid+2;
internalPlotBorderBottom = internalPlotBorderBottom + internalPlotKeyBorderBottom;
} else if (plotterStyle.keyStyle.position==JKQTPKeyOutsideRightTop) {
internalPlotKeyBorderRight = keyWidth+2*plotterStyle.keyStyle.xMargin*kfm.width('X')+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.xOffset*kfm.width('X')+2;
internalPlotKeyBorderRight = keyWidth+2*plotterStyle.keyStyle.xMargin*Xwid+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.xOffset*Xwid+2;
internalPlotBorderRight = internalPlotBorderRight + internalPlotKeyBorderRight;
} else if (plotterStyle.keyStyle.position==JKQTPKeyOutsideRightBottom) {
internalPlotKeyBorderRight = keyWidth+2*plotterStyle.keyStyle.xMargin*kfm.width('X')+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.xOffset*kfm.width('X')+2;
internalPlotKeyBorderRight = keyWidth+2*plotterStyle.keyStyle.xMargin*Xwid+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.xOffset*Xwid+2;
internalPlotBorderRight = internalPlotBorderRight + internalPlotKeyBorderRight;
}
@ -1052,13 +1053,14 @@ void JKQTBasePlotter::drawKey(JKQTPEnhancedPainter& painter) {
QFont kf(plotterStyle.defaultFontName, 10);
kf.setPointSizeF(plotterStyle.keyStyle.fontSize*fontSizeMultiplier);
QFontMetricsF kfm(kf);
const qreal Xwid=kfm.boundingRect('X').width();
// get the size of the key and if keyWidth>0 && keyHeight>0 draw the frame and the contents
double keyWidth=0;
double keyHeight=0;
getKeyExtent(painter, &keyWidth, &keyHeight);
double keyRectangleWidth=keyWidth+2.0*plotterStyle.keyStyle.xMargin*kfm.width('X')+2.0*plotterStyle.keyStyle.frameWidth*lineWidthPrintMultiplier;
double keyRectangleHeight=keyHeight+2.0*plotterStyle.keyStyle.yMargin*kfm.width('X')+2.0*plotterStyle.keyStyle.frameWidth*lineWidthPrintMultiplier;
double keyRectangleWidth=keyWidth+2.0*plotterStyle.keyStyle.xMargin*Xwid+2.0*plotterStyle.keyStyle.frameWidth*lineWidthPrintMultiplier;
double keyRectangleHeight=keyHeight+2.0*plotterStyle.keyStyle.yMargin*Xwid+2.0*plotterStyle.keyStyle.frameWidth*lineWidthPrintMultiplier;
if ((keyWidth>0) && (keyHeight>0)) {
// key position
@ -1067,64 +1069,64 @@ void JKQTBasePlotter::drawKey(JKQTPEnhancedPainter& painter) {
// default: inside top-right
double x0=internalPlotBorderLeft+internalPlotWidth-keyRectangleWidth;
double x=x0-plotterStyle.keyStyle.xOffset*kfm.width('X');
double x=x0-plotterStyle.keyStyle.xOffset*Xwid;
double y0=internalPlotBorderTop;
double y=y0+plotterStyle.keyStyle.yOffset*kfm.width('X');
double y=y0+plotterStyle.keyStyle.yOffset*Xwid;
switch(plotterStyle.keyStyle.position) {
case JKQTPKeyOutsideTopRight:
x0=internalPlotBorderLeft+internalPlotWidth+internalPlotBorderRight-keyRectangleWidth;
x=x0-plotterStyle.keyStyle.xOffset*kfm.width('X');
x=x0-plotterStyle.keyStyle.xOffset*Xwid;
y0=internalTitleHeight;
y=y0+plotterStyle.keyStyle.yOffset*kfm.width('X');
y=y0+plotterStyle.keyStyle.yOffset*Xwid;
break;
case JKQTPKeyOutsideTopLeft:
x0=internalPlotBorderLeft;
x=x0+plotterStyle.keyStyle.xOffset*kfm.width('X');
x=x0+plotterStyle.keyStyle.xOffset*Xwid;
y0=internalTitleHeight;
y=y0+plotterStyle.keyStyle.yOffset*kfm.width('X');
y=y0+plotterStyle.keyStyle.yOffset*Xwid;
break;
case JKQTPKeyOutsideBottomRight:
x0=internalPlotBorderLeft+internalPlotWidth-keyRectangleWidth;
x=x0-plotterStyle.keyStyle.xOffset*kfm.width('X');
x=x0-plotterStyle.keyStyle.xOffset*Xwid;
y0=internalPlotBorderTop+internalPlotHeight+internalPlotBorderBottom-keyRectangleHeight;
y=y0-plotterStyle.keyStyle.yOffset*kfm.width('X');
y=y0-plotterStyle.keyStyle.yOffset*Xwid;
break;
case JKQTPKeyOutsideBottomLeft:
x0=internalPlotBorderLeft;
x=x0+plotterStyle.keyStyle.xOffset*kfm.width('X');
x=x0+plotterStyle.keyStyle.xOffset*Xwid;
y0=internalPlotBorderTop+internalPlotHeight+internalPlotBorderBottom-keyRectangleHeight;
y=y0-plotterStyle.keyStyle.yOffset*kfm.width('X');
y=y0-plotterStyle.keyStyle.yOffset*Xwid;
break;
case JKQTPKeyOutsideRightTop:
x0=internalPlotBorderLeft+internalPlotWidth+internalPlotBorderRight-keyRectangleWidth;
x=x0-plotterStyle.keyStyle.xOffset*kfm.width('X');
x=x0-plotterStyle.keyStyle.xOffset*Xwid;
y0=internalPlotBorderTop;
y=y0+plotterStyle.keyStyle.yOffset*kfm.width('X');
y=y0+plotterStyle.keyStyle.yOffset*Xwid;
break;
case JKQTPKeyOutsideRightBottom:
x0=internalPlotBorderLeft+internalPlotWidth+internalPlotBorderRight-keyRectangleWidth;
x=x0-plotterStyle.keyStyle.xOffset*kfm.width('X');
x=x0-plotterStyle.keyStyle.xOffset*Xwid;
y0=internalPlotBorderTop+internalPlotHeight-keyRectangleHeight;
y=y0-plotterStyle.keyStyle.yOffset*kfm.width('X');
y=y0-plotterStyle.keyStyle.yOffset*Xwid;
break;
case JKQTPKeyOutsideLeftTop:
x0=0;
x=x0+plotterStyle.keyStyle.xOffset*kfm.width('X');
x=x0+plotterStyle.keyStyle.xOffset*Xwid;
y0=internalPlotBorderTop;
y=y0+plotterStyle.keyStyle.yOffset*kfm.width('X');
y=y0+plotterStyle.keyStyle.yOffset*Xwid;
break;
case JKQTPKeyOutsideLeftBottom:
x0=0;
x=x0+plotterStyle.keyStyle.xOffset*kfm.width('X');
x=x0+plotterStyle.keyStyle.xOffset*Xwid;
y0=internalPlotBorderTop+internalPlotHeight-keyRectangleHeight;
y=y0-plotterStyle.keyStyle.yOffset*kfm.width('X');
y=y0-plotterStyle.keyStyle.yOffset*Xwid;
break;
@ -1132,27 +1134,27 @@ void JKQTBasePlotter::drawKey(JKQTPEnhancedPainter& painter) {
case JKQTPKeyInsideBottomRight:
x0=internalPlotBorderLeft+internalPlotWidth-keyRectangleWidth;
x=x0-plotterStyle.keyStyle.xOffset*kfm.width('X');
x=x0-plotterStyle.keyStyle.xOffset*Xwid;
y0=internalPlotBorderTop+internalPlotHeight-keyRectangleHeight;
y=y0-plotterStyle.keyStyle.yOffset*kfm.width('X');
y=y0-plotterStyle.keyStyle.yOffset*Xwid;
break;
case JKQTPKeyInsideBottomLeft:
x0=internalPlotBorderLeft;
x=x0+plotterStyle.keyStyle.xOffset*kfm.width('X');
x=x0+plotterStyle.keyStyle.xOffset*Xwid;
y0=internalPlotBorderTop+internalPlotHeight-keyRectangleHeight;
y=y0-plotterStyle.keyStyle.yOffset*kfm.width('X');
y=y0-plotterStyle.keyStyle.yOffset*Xwid;
break;
case JKQTPKeyInsideTopLeft:
x0=internalPlotBorderLeft;
x=x0+plotterStyle.keyStyle.xOffset*kfm.width('X');
x=x0+plotterStyle.keyStyle.xOffset*Xwid;
y0=internalPlotBorderTop;
y=y0+plotterStyle.keyStyle.yOffset*kfm.width('X');
y=y0+plotterStyle.keyStyle.yOffset*Xwid;
break;
case JKQTPKeyInsideTopRight:
x0=internalPlotBorderLeft+internalPlotWidth-keyRectangleWidth;
x=x0-plotterStyle.keyStyle.xOffset*kfm.width('X');
x=x0-plotterStyle.keyStyle.xOffset*Xwid;
y0=internalPlotBorderTop;
y=y0+plotterStyle.keyStyle.yOffset*kfm.width('X');
y=y0+plotterStyle.keyStyle.yOffset*Xwid;
break;
}
QRectF rectKey;
@ -1177,8 +1179,8 @@ void JKQTBasePlotter::drawKey(JKQTPEnhancedPainter& painter) {
} else {
painter.drawRoundedRect(rectKey, pt2px(painter, plotterStyle.keyStyle.frameRounding), pt2px(painter, plotterStyle.keyStyle.frameRounding));
}
y=y+plotterStyle.keyStyle.yMargin*kfm.width('X')+plotterStyle.keyStyle.frameWidth*lineWidthMultiplier/2.0;
x=x+plotterStyle.keyStyle.xMargin*kfm.width('X')+plotterStyle.keyStyle.frameWidth*lineWidthMultiplier/2.0;
y=y+plotterStyle.keyStyle.yMargin*Xwid+plotterStyle.keyStyle.frameWidth*lineWidthMultiplier/2.0;
x=x+plotterStyle.keyStyle.xMargin*Xwid+plotterStyle.keyStyle.frameWidth*lineWidthMultiplier/2.0;
painter.setPen(pf);
@ -1229,7 +1231,9 @@ void JKQTBasePlotter::drawPlot(JKQTPEnhancedPainter& painter) {
if (plotterStyle.widgetBackgroundBrush!=QBrush(Qt::transparent)) painter.fillRect(QRectF(0,0,widgetWidth/paintMagnification, widgetHeight/paintMagnification), plotterStyle.widgetBackgroundBrush);
}
QRectF rPlotBack(internalPlotBorderLeft, internalPlotBorderTop, internalPlotWidth, internalPlotHeight);
#if QT_VERSION<QT_VERSION_CHECK(6,0,0)
painter.setRenderHint(JKQTPEnhancedPainter::NonCosmeticDefaultPen, true);
#endif
painter.setRenderHint(JKQTPEnhancedPainter::Antialiasing, plotterStyle.useAntiAliasingForSystem);
painter.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing, plotterStyle.useAntiAliasingForText);
if (plotterStyle.plotFrameVisible) {
@ -1742,7 +1746,7 @@ bool JKQTBasePlotter::exportpreview(QSizeF pageSize, bool unitIsMM) {
{
QPalette p(scroll->palette());
// Set background colour to black
p.setColor(QPalette::Background, Qt::darkGray);
p.setColor(QPalette::Window, Qt::darkGray);
scroll->setPalette(p);
}
exportPreviewLabel=new QLabel(scroll);
@ -1751,7 +1755,7 @@ bool JKQTBasePlotter::exportpreview(QSizeF pageSize, bool unitIsMM) {
{
QPalette p(exportPreviewLabel->palette());
// Set background colour to black
p.setColor(QPalette::Background, Qt::darkGray);
p.setColor(QPalette::Window, Qt::darkGray);
exportPreviewLabel->setPalette(p);
}
@ -3306,8 +3310,8 @@ void JKQTBasePlotter::copyData() {
QTextStream txt(&result);
QLocale loc=QLocale::system();
loc.setNumberOptions(QLocale::OmitGroupSeparator);
QChar dp=loc.decimalPoint();
QString sep="\t";
const auto dp=loc.decimalPoint();
const QString sep="\t";
datastore->saveCSV(txt, cols, sep, QString(dp), " ", "\"");
txt.flush();
}
@ -3753,11 +3757,13 @@ void JKQTBasePlotter::saveAsPixelImage(const QString& filename, bool displayPrev
png.fill(Qt::transparent);
JKQTPEnhancedPainter painter;
painter.begin(&png);
painter.setRenderHint(JKQTPEnhancedPainter::NonCosmeticDefaultPen, true);
painter.setRenderHint(JKQTPEnhancedPainter::Antialiasing);
painter.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing);
painter.setRenderHint(JKQTPEnhancedPainter::SmoothPixmapTransform);
#if (QT_VERSION<QT_VERSION_CHECK(6, 0, 0))
painter.setRenderHint(JKQTPEnhancedPainter::NonCosmeticDefaultPen, true);
painter.setRenderHint(JKQTPEnhancedPainter::HighQualityAntialiasing);
#endif
/*calcPlotScaling(painter);
gridPaint(painter, png.rect().size());*/\
@ -3809,11 +3815,13 @@ void JKQTBasePlotter::copyPixelImage() {
png.fill(Qt::transparent);
JKQTPEnhancedPainter painter;
painter.begin(&png);
painter.setRenderHint(JKQTPEnhancedPainter::NonCosmeticDefaultPen, true);
painter.setRenderHint(JKQTPEnhancedPainter::Antialiasing);
painter.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing);
painter.setRenderHint(JKQTPEnhancedPainter::SmoothPixmapTransform);
#if (QT_VERSION<QT_VERSION_CHECK(6, 0, 0))
painter.setRenderHint(JKQTPEnhancedPainter::NonCosmeticDefaultPen, true);
painter.setRenderHint(JKQTPEnhancedPainter::HighQualityAntialiasing);
#endif
/*calcPlotScaling(painter);
gridPaint(painter, png.rect().size());*/
@ -4136,21 +4144,22 @@ void JKQTBasePlotter::drawKeyContents(JKQTPEnhancedPainter& painter, double x, d
#ifdef JKQTBP_AUTOTIMER
jkaaot.write(QString("one-col: graph %1: %2").arg(i).arg(g->getTitle()));
#endif
const auto Xwid=kfm.boundingRect('X').width();
if (!g->getTitle().isEmpty() && g->isVisible()) {
QSizeF fs=getTextSizeSize(plotterStyle.defaultFontName,plotterStyle.keyStyle.fontSize*fontSizeMultiplier,g->getTitle(),painter);// mt.getSize(painter);
double itheight=qMax(plotterStyle.keyStyle.itemHeight*kfm.width('X'), fs.height());
QRectF markerRect(x, y+1.5*lineWidthMultiplier, plotterStyle.keyStyle.sampleLineLength*kfm.width('X'), itheight-3.0*lineWidthMultiplier);
double itheight=qMax(plotterStyle.keyStyle.itemHeight*Xwid, fs.height());
QRectF markerRect(x, y+1.5*lineWidthMultiplier, plotterStyle.keyStyle.sampleLineLength*Xwid, itheight-3.0*lineWidthMultiplier);
g->drawKeyMarker(painter, markerRect);
mathText.setFontColor(plotterStyle.keyStyle.textColor);
mathText.setFontSize(plotterStyle.keyStyle.fontSize*fontSizeMultiplier);
mathText.setFontRomanOrSpecial(plotterStyle.defaultFontName);
mathText.parse(g->getTitle());
QRectF txtRect(x+(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation)*kfm.width('X'),y, key_text_width, itheight);
QRectF txtRect(x+(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation)*Xwid,y, key_text_width, itheight);
mathText.draw(painter, Qt::AlignLeft|Qt::AlignVCenter, txtRect);
//if (itheight<key_item_height*kfm.height()) itheight=key_item_height*kfm.height();
//y=y+itheight+(plotterStyle.keyStyle.ySeparation)*kfm.height();
y=y+key_text_height+(plotterStyle.keyStyle.ySeparation)*kfm.width('X');
y=y+key_text_height+(plotterStyle.keyStyle.ySeparation)*Xwid;
if (plotterStyle.debugShowRegionBoxes) {
painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();});
QPen p("orange");
@ -4174,16 +4183,17 @@ void JKQTBasePlotter::drawKeyContents(JKQTPEnhancedPainter& painter, double x, d
jkaaot.write(QString("one-row: graph %1: %2").arg(i).arg(g->getTitle()));
#endif
if (!g->getTitle().isEmpty() && g->isVisible()) {
const auto Xwid=kfm.boundingRect('X').width();
QSizeF fs=getTextSizeSize(plotterStyle.defaultFontName,plotterStyle.keyStyle.fontSize*fontSizeMultiplier,g->getTitle(),painter);// mt.getSize(painter);
double itheight=qMax(plotterStyle.keyStyle.itemHeight*kfm.width('X'), fs.height());
QRectF markerRect(x, y+1.5*lineWidthMultiplier, plotterStyle.keyStyle.sampleLineLength*kfm.width('X'), itheight-3.0*lineWidthMultiplier);
double itheight=qMax(plotterStyle.keyStyle.itemHeight*Xwid, fs.height());
QRectF markerRect(x, y+1.5*lineWidthMultiplier, plotterStyle.keyStyle.sampleLineLength*Xwid, itheight-3.0*lineWidthMultiplier);
g->drawKeyMarker(painter, markerRect);
mathText.setFontColor(plotterStyle.keyStyle.textColor);
mathText.setFontSize(plotterStyle.keyStyle.fontSize*fontSizeMultiplier);
mathText.setFontRomanOrSpecial(plotterStyle.defaultFontName);
mathText.parse(g->getTitle());
QRectF txtRect(x+(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation)*kfm.width('X'),y, fs.width(), itheight);
QRectF txtRect(x+(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation)*Xwid,y, fs.width(), itheight);
mathText.draw(painter, Qt::AlignLeft|Qt::AlignVCenter, txtRect);
if (plotterStyle.debugShowRegionBoxes) {
painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();});
@ -4199,11 +4209,11 @@ void JKQTBasePlotter::drawKeyContents(JKQTPEnhancedPainter& painter, double x, d
}
//if (itheight<key_item_height*kfm.height()) itheight=key_item_height*kfm.height();
//y=y+itheight+(plotterStyle.keyStyle.ySeparation)*kfm.height();
x=x+fs.width()+(2.0*plotterStyle.keyStyle.xSeparation+plotterStyle.keyStyle.sampleLineLength)*kfm.width('X');
x=x+fs.width()+(2.0*plotterStyle.keyStyle.xSeparation+plotterStyle.keyStyle.sampleLineLength)*Xwid;
}
}
} else if (plotterStyle.keyStyle.layout==JKQTPKeyLayoutMultiColumn) {
//int columns=floor(static_cast<double>(plotWidth)/static_cast<double>(key_item_width*kfm.width('X')));
//int columns=floor(static_cast<double>(plotWidth)/static_cast<double>(key_item_width*Xwid));
bool colfirst=true;
if (plotterStyle.keyStyle.position==JKQTPKeyInsideTopLeft || plotterStyle.keyStyle.position==JKQTPKeyInsideTopRight
@ -4215,6 +4225,7 @@ void JKQTBasePlotter::drawKeyContents(JKQTPEnhancedPainter& painter, double x, d
int c=1;
double xx=x;
double yy=y;
const auto Xwid=kfm.boundingRect('X').width();
for (int i=0; i<graphs.size(); i++) {
JKQTPPlotElement* g=graphs[i];
#ifdef JKQTBP_AUTOTIMER
@ -4222,15 +4233,15 @@ void JKQTBasePlotter::drawKeyContents(JKQTPEnhancedPainter& painter, double x, d
#endif
if (!g->getTitle().isEmpty() && g->isVisible()) {
//QSizeF fs=getTextSizeSize(plotterStyle.defaultFontName,plotterStyle.keyStyle.fontSize*fontSizeMultiplier,g->getTitle(),painter);// mt.getSize(painter);
double itheight=qMax(plotterStyle.keyStyle.itemHeight*kfm.width('X'), key_text_height);
QRectF markerRect(xx, yy+1.5*lineWidthMultiplier, plotterStyle.keyStyle.sampleLineLength*kfm.width('X'), itheight-3.0*lineWidthMultiplier);
double itheight=qMax(plotterStyle.keyStyle.itemHeight*Xwid, key_text_height);
QRectF markerRect(xx, yy+1.5*lineWidthMultiplier, plotterStyle.keyStyle.sampleLineLength*Xwid, itheight-3.0*lineWidthMultiplier);
g->drawKeyMarker(painter, markerRect);
mathText.setFontColor(plotterStyle.keyStyle.textColor);
mathText.setFontSize(plotterStyle.keyStyle.fontSize*fontSizeMultiplier);
mathText.setFontRomanOrSpecial(plotterStyle.defaultFontName);
mathText.parse(g->getTitle());
//QSizeF fs=mt.getSize(painter);
QRectF txtRect(xx+(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation)*kfm.width('X'),yy, key_text_width, key_text_height);
QRectF txtRect(xx+(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation)*Xwid,yy, key_text_width, key_text_height);
mathText.draw(painter, Qt::AlignLeft|Qt::AlignVCenter, txtRect);
if (plotterStyle.debugShowRegionBoxes) {
@ -4247,26 +4258,26 @@ void JKQTBasePlotter::drawKeyContents(JKQTPEnhancedPainter& painter, double x, d
}
if (colfirst) {
yy=yy+key_text_height+(plotterStyle.keyStyle.ySeparation)*kfm.width('X');
yy=yy+key_text_height+(plotterStyle.keyStyle.ySeparation)*Xwid;
l++;
if (l>lines) {
l=1;
c++;
xx=xx+key_text_width+(plotterStyle.keyStyle.sampleLineLength+2.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X');
/*if (plotterStyle.keyStyle.autosize) xx=xx+key_text_width+(key_line_length+3.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X');
else xx=xx+(key_item_width+2.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X');*/
xx=xx+key_text_width+(plotterStyle.keyStyle.sampleLineLength+2.0*plotterStyle.keyStyle.xSeparation)*Xwid;
/*if (plotterStyle.keyStyle.autosize) xx=xx+key_text_width+(key_line_length+3.0*plotterStyle.keyStyle.xSeparation)*Xwid;
else xx=xx+(key_item_width+2.0*plotterStyle.keyStyle.xSeparation)*Xwid;*/
yy=y;
}
} else {
/*if (plotterStyle.keyStyle.autosize) xx=xx+key_text_width+(key_line_length+3.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X');
else xx=xx+(key_item_width+2.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X');*/
xx=xx+key_text_width+(plotterStyle.keyStyle.sampleLineLength+2.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X');
/*if (plotterStyle.keyStyle.autosize) xx=xx+key_text_width+(key_line_length+3.0*plotterStyle.keyStyle.xSeparation)*Xwid;
else xx=xx+(key_item_width+2.0*plotterStyle.keyStyle.xSeparation)*Xwid;*/
xx=xx+key_text_width+(plotterStyle.keyStyle.sampleLineLength+2.0*plotterStyle.keyStyle.xSeparation)*Xwid;
c++;
if (c>columns) {
c=1;
l++;
//yy=yy+(key_item_height+plotterStyle.keyStyle.ySeparation)*kfm.height();
yy=yy+itheight+(plotterStyle.keyStyle.ySeparation)*kfm.width('X');
yy=yy+itheight+(plotterStyle.keyStyle.ySeparation)*Xwid;
xx=x;
}
}
@ -4288,7 +4299,8 @@ void JKQTBasePlotter::getKeyExtent(JKQTPEnhancedPainter& painter, double* width,
f.setFamily(plotterStyle.defaultFontName);
f.setPointSizeF(plotterStyle.keyStyle.fontSize*fontSizeMultiplier);
QFontMetricsF kfm(f);
if (text_height!=nullptr) *text_height=plotterStyle.keyStyle.itemHeight*kfm.width('X');
const qreal Xwid=kfm.boundingRect('X').width();
if (text_height!=nullptr) *text_height=plotterStyle.keyStyle.itemHeight*Xwid;
if (plotterStyle.keyStyle.layout==JKQTPKeyLayoutOneColumn) {
int keyHeight=graphs.size();
double w=0;
@ -4306,18 +4318,18 @@ void JKQTBasePlotter::getKeyExtent(JKQTPEnhancedPainter& painter, double* width,
QSizeF fs=getTextSizeSize(plotterStyle.defaultFontName, plotterStyle.keyStyle.fontSize*fontSizeMultiplier, graphs[i]->getTitle(), painter);
if (fs.width()>w) w=fs.width();
if (text_height && fs.height()>*text_height) *text_height=fs.height();
h=h+qMax(plotterStyle.keyStyle.itemHeight*kfm.width('X'), fs.height())+plotterStyle.keyStyle.ySeparation*kfm.width('X');
h=h+qMax(plotterStyle.keyStyle.itemHeight*Xwid, fs.height())+plotterStyle.keyStyle.ySeparation*Xwid;
}
}
if (plotterStyle.keyStyle.autosize) {
if (width) *width=w+(plotterStyle.keyStyle.sampleLineLength+2.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X');
if (text_width!=nullptr) *text_width=w+2.0*kfm.width('X');
if (width) *width=w+(plotterStyle.keyStyle.sampleLineLength+2.0*plotterStyle.keyStyle.xSeparation)*Xwid;
if (text_width!=nullptr) *text_width=w+2.0*Xwid;
} else {
if (width) *width=plotterStyle.keyStyle.itemWidth*kfm.width('X');
if (text_width!=nullptr) *text_width=(plotterStyle.keyStyle.itemWidth-(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation))*kfm.width('X');
if (width) *width=plotterStyle.keyStyle.itemWidth*Xwid;
if (text_width!=nullptr) *text_width=(plotterStyle.keyStyle.itemWidth-(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation))*Xwid;
}
if (h>plotterStyle.keyStyle.ySeparation*kfm.width('X')) h=h-plotterStyle.keyStyle.ySeparation*kfm.width('X');
if (height) *height=h;//keyHeight*key_item_height*kfm.width('X');
if (h>plotterStyle.keyStyle.ySeparation*Xwid) h=h-plotterStyle.keyStyle.ySeparation*Xwid;
if (height) *height=h;//keyHeight*key_item_height*Xwid;
if (columns_count) *columns_count=1;
if (lines_count) *lines_count=keyHeight;
} else if (plotterStyle.keyStyle.layout==JKQTPKeyLayoutOneRow) {
@ -4337,19 +4349,19 @@ void JKQTBasePlotter::getKeyExtent(JKQTPEnhancedPainter& painter, double* width,
QSizeF fs=getTextSizeSize(plotterStyle.defaultFontName, plotterStyle.keyStyle.fontSize*fontSizeMultiplier, graphs[i]->getTitle(), painter);
if (fs.height()>h) h=fs.height();
if (text_width && fs.width()>*text_width) *text_width=fs.width();
w=w+fs.width()+(plotterStyle.keyStyle.sampleLineLength+2.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X');
w=w+fs.width()+(plotterStyle.keyStyle.sampleLineLength+2.0*plotterStyle.keyStyle.xSeparation)*Xwid;
}
}
if (h<plotterStyle.keyStyle.itemHeight*kfm.width('X')) h=plotterStyle.keyStyle.itemHeight*kfm.width('X');
if (h<plotterStyle.keyStyle.itemHeight*Xwid) h=plotterStyle.keyStyle.itemHeight*Xwid;
if (plotterStyle.keyStyle.autosize) {
if (height) *height=h;
if (text_height!=nullptr) *text_height=h;
} else {
if (height) *height=h;
if (text_height!=nullptr) *text_height=(plotterStyle.keyStyle.itemHeight-(plotterStyle.keyStyle.ySeparation))*kfm.width('X');
if (text_height!=nullptr) *text_height=(plotterStyle.keyStyle.itemHeight-(plotterStyle.keyStyle.ySeparation))*Xwid;
}
if (w>(plotterStyle.keyStyle.xSeparation)*kfm.width('X')) w=w-(plotterStyle.keyStyle.xSeparation)*kfm.width('X');
if (width) *width=w;//keyHeight*key_item_height*kfm.width('X');
if (w>(plotterStyle.keyStyle.xSeparation)*Xwid) w=w-(plotterStyle.keyStyle.xSeparation)*Xwid;
if (width) *width=w;//keyHeight*key_item_height*Xwid;
if (columns_count) *columns_count=keyWidth;
if (lines_count) *lines_count=1;
} else if (plotterStyle.keyStyle.layout==JKQTPKeyLayoutMultiColumn) {
@ -4378,12 +4390,12 @@ void JKQTBasePlotter::getKeyExtent(JKQTPEnhancedPainter& painter, double* width,
if (text_height) {
if (plotterStyle.keyStyle.autosize) *text_height=txtH;
else *text_height=plotterStyle.keyStyle.itemHeight*kfm.width('X');
else *text_height=plotterStyle.keyStyle.itemHeight*Xwid;
}
double columns=floor(double(internalPlotWidth)/(w+(2.0*plotterStyle.keyStyle.xSeparation+plotterStyle.keyStyle.sampleLineLength)*kfm.width('X')));
if (!plotterStyle.keyStyle.autosize) columns=floor(double(internalPlotWidth)/((plotterStyle.keyStyle.itemWidth+2.0*plotterStyle.keyStyle.xSeparation+plotterStyle.keyStyle.sampleLineLength)*kfm.width('X')));
double columns=floor(double(internalPlotWidth)/(w+(2.0*plotterStyle.keyStyle.xSeparation+plotterStyle.keyStyle.sampleLineLength)*Xwid));
if (!plotterStyle.keyStyle.autosize) columns=floor(double(internalPlotWidth)/((plotterStyle.keyStyle.itemWidth+2.0*plotterStyle.keyStyle.xSeparation+plotterStyle.keyStyle.sampleLineLength)*Xwid));
columns=qMin(columns, keyHeight);
int lines=static_cast<int>(ceil(static_cast<double>(keyHeight)/static_cast<double>(columns)));
lines=jkqtp_roundTo<int>(qMin(static_cast<double>(lines), keyHeight));
@ -4391,9 +4403,9 @@ void JKQTBasePlotter::getKeyExtent(JKQTPEnhancedPainter& painter, double* width,
if (plotterStyle.keyStyle.position==JKQTPKeyInsideTopLeft || plotterStyle.keyStyle.position==JKQTPKeyInsideTopRight
|| plotterStyle.keyStyle.position==JKQTPKeyOutsideTopLeft || plotterStyle.keyStyle.position==JKQTPKeyOutsideTopRight) {
if (plotterStyle.keyStyle.autosize) {
lines=static_cast<int>(floor(static_cast<double>(internalPlotHeight)/static_cast<double>(txtH+(plotterStyle.keyStyle.ySeparation)*kfm.width('X'))));
lines=static_cast<int>(floor(static_cast<double>(internalPlotHeight)/static_cast<double>(txtH+(plotterStyle.keyStyle.ySeparation)*Xwid)));
} else {
lines=static_cast<int>(floor(static_cast<double>(internalPlotHeight)/static_cast<double>((plotterStyle.keyStyle.itemHeight+plotterStyle.keyStyle.ySeparation)*kfm.width('X'))));
lines=static_cast<int>(floor(static_cast<double>(internalPlotHeight)/static_cast<double>((plotterStyle.keyStyle.itemHeight+plotterStyle.keyStyle.ySeparation)*Xwid)));
}
columns=static_cast<int>(ceil(static_cast<double>(keyHeight)/static_cast<double>(lines)));
lines=jkqtp_roundTo<int>(qMin(static_cast<double>(lines), keyHeight));
@ -4404,15 +4416,15 @@ void JKQTBasePlotter::getKeyExtent(JKQTPEnhancedPainter& painter, double* width,
if (lines_count) *lines_count=lines;
if (plotterStyle.keyStyle.autosize) {
if (width) *width=(w+(plotterStyle.keyStyle.sampleLineLength+3.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X'))*columns;
if (height) *height=lines*(txtH+plotterStyle.keyStyle.ySeparation*kfm.width('X'));
if (lines>0) *height=*height-plotterStyle.keyStyle.ySeparation*kfm.width('X');
if (width) *width=(w+(plotterStyle.keyStyle.sampleLineLength+3.0*plotterStyle.keyStyle.xSeparation)*Xwid)*columns;
if (height) *height=lines*(txtH+plotterStyle.keyStyle.ySeparation*Xwid);
if (lines>0) *height=*height-plotterStyle.keyStyle.ySeparation*Xwid;
if (text_width!=nullptr) *text_width=w;
} else {
if (width) *width=(plotterStyle.keyStyle.itemWidth+2.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X')*columns;
if (height) *height=lines*(plotterStyle.keyStyle.itemHeight+plotterStyle.keyStyle.ySeparation)*kfm.width('X');
if (lines>0) *height=*height-plotterStyle.keyStyle.ySeparation*kfm.width('X');
if (text_width!=nullptr) *text_width=(plotterStyle.keyStyle.itemWidth-(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation))*kfm.width('X');
if (width) *width=(plotterStyle.keyStyle.itemWidth+2.0*plotterStyle.keyStyle.xSeparation)*Xwid*columns;
if (height) *height=lines*(plotterStyle.keyStyle.itemHeight+plotterStyle.keyStyle.ySeparation)*Xwid;
if (lines>0) *height=*height-plotterStyle.keyStyle.ySeparation*Xwid;
if (text_width!=nullptr) *text_width=(plotterStyle.keyStyle.itemWidth-(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation))*Xwid;
}
#ifdef SHOW_JKQTPLOTTER_DEBUG
qDebug()<<"getKeyExtent(): mult-column: columns="<<columns<<" lines="<<lines;
@ -5019,7 +5031,14 @@ bool JKQTPPaintDeviceAdapter::useLatexParser() const
QPaintDevice *JKQTPPaintDeviceAdapter::createPaintdeviceMM(const QString &filename, double widthMM, double heightMM) const
{
return createPaintdevice(filename, jkqtp_roundTo<int>(widthMM/25.4*QApplication::desktop()->logicalDpiX()), jkqtp_roundTo<int>(heightMM/25.4*QApplication::desktop()->logicalDpiY()));
#if QT_VERSION>=QT_VERSION_CHECK(6,0,0)
const qreal dpix=qGuiApp->primaryScreen()->logicalDotsPerInchX();
const qreal dpiy=qGuiApp->primaryScreen()->logicalDotsPerInchY();
#else
const qreal dpix=QApplication::desktop()->logicalDpiX();
const qreal dpiy=QApplication::desktop()->logicalDpiY();
#endif
return createPaintdevice(filename, jkqtp_roundTo<int>(widthMM/25.4*dpix), jkqtp_roundTo<int>(heightMM/25.4*dpiy));
}
JKQTPSaveDataAdapter::~JKQTPSaveDataAdapter() = default;

View File

@ -2130,7 +2130,11 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject {
/** \brief qHash()-specialization
* \ingroup jkqtpplottersupprt
*/
inline uint qHash(const JKQTBasePlotter::textSizeKey& data) {
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
inline size_t qHash(const JKQTBasePlotter::textSizeKey& data, size_t /*seed=0*/) {
#else
inline uint qHash(const JKQTBasePlotter::textSizeKey& data, uint /*seed=0*/) {
#endif
return qHash(data.f.family())+qHash(data.text);
}

View File

@ -1056,7 +1056,7 @@ void JKQTPDatastore::saveCSV(QTextStream& txt, const QSet<int>& userColumns, con
// find out the decimal and the thousand separator
QLocale loc=QLocale::c();
loc.setNumberOptions(QLocale::OmitGroupSeparator);
QChar dsep=loc.decimalPoint();
const auto dsep=loc.decimalPoint();
txt.setLocale(loc);

View File

@ -22,6 +22,7 @@
#include "jkqtplotter/jkqtplotter_imexport.h"
#include "jkqtplotter/jkqtptools.h"
#include "jkqtcommon/jkqtpdebuggingtools.h"
#include "jkqtcommon/jkqttools.h"
#include <vector>
#include <cmath>
#include <iostream>
@ -2518,7 +2519,7 @@ quint16 JKQTPColumn::calculateChecksum() const
{
if (!datastore) return 0;
if (!datastore->getItem(datastoreItem)) return 0;
return qChecksum(reinterpret_cast<const char*>(getPointer(0)), static_cast<uint>(getRows()*sizeof(double)));
return jkqtp_checksum(reinterpret_cast<const char*>(getPointer(0)), static_cast<uint>(getRows()*sizeof(double)));
}
////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -59,7 +59,9 @@ QImage JKQTPPlotElement::generateKeyMarker(QSize size)
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setRenderHint(QPainter::TextAntialiasing, true);
painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
#if (QT_VERSION<QT_VERSION_CHECK(6, 0, 0))
painter.setRenderHint(QPainter::HighQualityAntialiasing, true);
#endif
QRectF rect(0,0,size.width(),size.height());
drawKeyMarker(painter, rect);
}
@ -414,6 +416,7 @@ void JKQTPXYGraph::setXYColumns(int xCol, int yCol)
setYColumn(yCol);
}
#if QT_VERSION<QT_VERSION_CHECK(6,0,0)
void JKQTPXYGraph::setXYColumns(std::pair<int, int> xyColPair)
{
setXColumn(xyColPair.first);
@ -425,6 +428,7 @@ void JKQTPXYGraph::setXYColumns(std::pair<size_t, size_t> xyColPair)
setXColumn(xyColPair.first);
setYColumn(xyColPair.second);
}
#endif
void JKQTPXYGraph::setXYColumns(QPair<int, int> xyColPair)
{

View File

@ -605,10 +605,12 @@ public slots:
void setXYColumns(size_t xCol, size_t yCol);
/** \brief sets xColumn and yColumn at the same time */
void setXYColumns(int xCol, int yCol);
#if QT_VERSION<QT_VERSION_CHECK(6,0,0)
/** \brief sets xColumn and yColumn at the same time */
void setXYColumns(std::pair<int,int> xyColPair);
/** \brief sets xColumn and yColumn at the same time */
void setXYColumns(std::pair<size_t,size_t> xyColPair);
#endif
/** \brief sets xColumn and yColumn at the same time */
void setXYColumns(QPair<int,int> xyColPair);
/** \brief sets xColumn and yColumn at the same time */

View File

@ -479,7 +479,9 @@ void JKQTPlotter::paintUserAction() {
image=oldImage;
if (image.width()>0 && image.height()>0 && !image.isNull()) {
JKQTPEnhancedPainter painter(&image);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
painter.setRenderHint(JKQTPEnhancedPainter::NonCosmeticDefaultPen, true);
#endif
painter.setRenderHint(JKQTPEnhancedPainter::Antialiasing, true);
painter.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing, true);
painter.setPen(plotterStyle.userActionOverlayPen);
@ -1437,12 +1439,12 @@ QAction* JKQTPlotter::getActMouseLeftAsToolTip() const {
void JKQTPlotter::setOverrideMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier, JKQTPMouseDragActions action)
{
registeredOverrideMouseDragActionModes.insert(qMakePair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifier), action);
registeredOverrideMouseDragActionModes.insert(QPair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifier), action);
}
void JKQTPlotter::resetOverrideMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier)
{
registeredOverrideMouseDragActionModes.remove(qMakePair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifier));
registeredOverrideMouseDragActionModes.remove(QPair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifier));
}
void JKQTPlotter::setContextMenuMode(JKQTPContextMenuModes mode) {
@ -1686,7 +1688,7 @@ JKQTPMouseDragActionsHashMapIterator JKQTPlotter::findMatchingMouseDragAction(Qt
if (found) *found=false;
JKQTPMouseDragActionsHashMapIterator it=registeredOverrideMouseDragActionModes.cbegin();
while (it!=registeredOverrideMouseDragActionModes.cend() ) {
if (it.key()==qMakePair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifiers)) {
if (it.key()==QPair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifiers)) {
if (found) *found=true;
return it;
}
@ -1694,7 +1696,7 @@ JKQTPMouseDragActionsHashMapIterator JKQTPlotter::findMatchingMouseDragAction(Qt
}
it=plotterStyle.registeredMouseDragActionModes.cbegin();
while (it!=plotterStyle.registeredMouseDragActionModes.cend() ) {
if (it.key()==qMakePair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifiers)) {
if (it.key()==QPair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifiers)) {
if (found) *found=true;
return it;
}
@ -1707,7 +1709,7 @@ JKQTPMouseDoubleClickActionsHashMapIterator JKQTPlotter::findMatchingMouseDouble
{
if (found) *found=false;
for (JKQTPMouseDoubleClickActionsHashMapIterator it=plotterStyle.registeredMouseDoubleClickActions.cbegin(); it!=plotterStyle.registeredMouseDoubleClickActions.cend(); ++it) {
if (it.key()==qMakePair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifiers)) {
if (it.key()==QPair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifiers)) {
if (found) *found=true;
return it;
}
@ -1738,7 +1740,7 @@ void JKQTPlotter::setPlotUpdateEnabled(bool enable)
void JKQTPlotter::registerMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier, JKQTPMouseDragActions action)
{
plotterStyle.registeredMouseDragActionModes[qMakePair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifier)]=action;
plotterStyle.registeredMouseDragActionModes[QPair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifier)]=action;
if (button==Qt::LeftButton && modifier==Qt::NoModifier) {
actMouseLeftAsDefault->setChecked(true);
resetMouseLeftAction();
@ -1747,7 +1749,7 @@ void JKQTPlotter::registerMouseDragAction(Qt::MouseButton button, Qt::KeyboardMo
void JKQTPlotter::deregisterMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier)
{
plotterStyle.registeredMouseDragActionModes.remove(qMakePair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifier));
plotterStyle.registeredMouseDragActionModes.remove(QPair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifier));
}
void JKQTPlotter::clearAllRegisteredMouseDragActions()
@ -1757,12 +1759,12 @@ void JKQTPlotter::clearAllRegisteredMouseDragActions()
void JKQTPlotter::registerMouseDoubleClickAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier, JKQTPMouseDoubleClickActions action)
{
plotterStyle.registeredMouseDoubleClickActions[qMakePair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifier)]=action;
plotterStyle.registeredMouseDoubleClickActions[QPair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifier)]=action;
}
void JKQTPlotter::deregisterMouseDoubleClickAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier)
{
plotterStyle.registeredMouseDoubleClickActions.remove(qMakePair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifier));
plotterStyle.registeredMouseDoubleClickActions.remove(QPair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifier));
}
void JKQTPlotter::clearAllRegisteredMouseDoubleClickActions()

View File

@ -1727,8 +1727,11 @@ QT_BEGIN_NAMESPACE
* \internal
* \ingroup jkqtpplottersupprt
*/
template<>
inline uint qHash(const QPair<Qt::MouseButton,Qt::KeyboardModifiers> &key, uint seed ) noexcept(noexcept(qHash(key.first, seed)) && noexcept(qHash(key.second, seed))) {
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
inline size_t qHash(const QPair<Qt::MouseButton,Qt::KeyboardModifiers> &key, size_t seed=0) {
#else
inline uint qHash(const QPair<Qt::MouseButton,Qt::KeyboardModifiers> &key, uint seed=0) {
#endif
return static_cast<uint>(key.first)+static_cast<uint>(key.second);
}
@ -1736,8 +1739,11 @@ inline uint qHash(const QPair<Qt::MouseButton,Qt::KeyboardModifiers> &key, uint
* \internal
* \ingroup jkqtpplottersupprt
*/
template<>
inline uint qHash(const Qt::MouseButton &key, uint /*seed*/ ) noexcept(noexcept(qHash(key))) {
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
inline size_t qHash(const Qt::MouseButton &key, size_t /*seed=0*/) {
#else
inline uint qHash(const Qt::MouseButton &key, uint /*seed=0*/) {
#endif
return static_cast<uint>(key);
}
@ -1745,8 +1751,11 @@ inline uint qHash(const Qt::MouseButton &key, uint /*seed*/ ) noexcept(noexcept(
* \internal
* \ingroup jkqtpplottersupprt
*/
template<>
inline uint qHash(const Qt::KeyboardModifiers &key, uint /*seed*/ ) noexcept(noexcept(qHash(key))) {
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
inline size_t qHash(const Qt::KeyboardModifiers &key, size_t /*seed=0*/) {
#else
inline uint qHash(const Qt::KeyboardModifiers &key, uint /*seed=0*/) {
#endif
return static_cast<uint>(key);
}