partly solve issue #81 by making print-support optional. In addition it can be switched off with the CMake-option JKQtPlotter_BUILD_FORCE_NO_PRINTER_SUPPORT=ON

This commit is contained in:
jkriege2 2022-07-18 23:33:20 +02:00
parent d132009679
commit d8c1524f61
21 changed files with 422 additions and 309 deletions

View File

@ -13,6 +13,9 @@ endif()
if(NOT DEFINED JKQtPlotter_BUILD_EXAMPLES)
option(JKQtPlotter_BUILD_EXAMPLES "Build the examples examples" ON)
endif()
if(NOT DEFINED JKQtPlotter_BUILD_FORCE_NO_PRINTER_SUPPORT)
option(JKQtPlotter_BUILD_FORCE_NO_PRINTER_SUPPORT "Build the library with printer support switched off, even if it is available" OFF)
endif()
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
option(CMAKE_INSTALL_PREFIX "Install directory" ${CMAKE_CURRENT_SOURCE_DIR}/install)
endif()

View File

@ -4,17 +4,27 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets Svg Xml OpenGL REQUIRED)
if(${QT_VERSION_MAJOR} VERSION_GREATER_EQUAL "6")
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS OpenGLWidgets)
endif()
# configure compiler
if(${QT_VERSION_MAJOR} VERSION_LESS "6" )
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED on)
if(NOT ${JKQtPlotter_BUILD_FORCE_NO_PRINTER_SUPPORT})
find_package(Qt${QT_VERSION_MAJOR} OPTIONAL_COMPONENTS PrintSupport)
else()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED on)
message(STATUS "WARNING: not searching for Qt${QT_VERSION_MAJOR}::PrintSupport, because JKQtPlotter_BUILD_FORCE_NO_PRINTER_SUPPORT=${JKQtPlotter_BUILD_FORCE_NO_PRINTER_SUPPORT}")
endif()
set(JKQtPlotter_HAS_NO_PRINTER_SUPPORT FALSE)
if(JKQtPlotter_BUILD_FORCE_NO_PRINTER_SUPPORT)
set(JKQtPlotter_HAS_NO_PRINTER_SUPPORT TRUE)
else()
if(TARGET Qt${QT_VERSION_MAJOR}::PrintSupport)
else()
set(JKQtPlotter_HAS_NO_PRINTER_SUPPORT TRUE)
endif()
if(${QT_VERSION_MAJOR} VERSION_LESS "5" )
set(JKQtPlotter_HAS_NO_PRINTER_SUPPORT FALSE)
endif()
endif()

View File

@ -51,6 +51,7 @@ The CMake build system offers several configuration variables that you may set/c
- \c JKQtPlotter_BUILD_SHARED_LIBS : Build as shared library (default: \c ON )
- \c JKQtPlotter_BUILD_STATIC_LIBS : Build as static library (default: \c ON )
- \c JKQtPlotter_BUILD_INCLUDE_XITS_FONTS : Include XITS fonts as resources in library (default: \c ON )
- \c JKQtPlotter_BUILD_FORCE_NO_PRINTER_SUPPORT : switches off print-support (when set to \c ON ), even if the current platform supports it (default: \c OFF )
- \c JKQtPlotter_BUILD_DECORATE_LIBNAMES_WITH_BUILDTYPE : If set, the build-type is appended to the library name (default: \c ON )
- \c JKQtPlotter_BUILD_EXAMPLES : Build examples (default: \c ON )
- \c CMAKE_INSTALL_PREFIX : Install directory for the library

View File

@ -33,7 +33,7 @@ This page lists several todos and wishes for future version of JKQTPlotter
<li>graphs: add candlestick charts (financial, see https://en.m.wikipedia.org/wiki/Candlestick_chart)</li>
<li>graphs: add OHLC charts (financial, see https://en.m.wikipedia.org/wiki/Open-high-low-close_chart)</li>
<li>graphs: explore/demonstrate/improve plotting speed for large dataset (e.g. only draw visible elements, use algorithm to draw fewer lines if they overlay ...)</li>
<li></li>
<li>plot: refactor print preview/export preview code </li>
<li></li>
<li></li>
</ul></li>

View File

@ -27,6 +27,7 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
<li>NEW: new "seaborn" style for plots</li>
<li>NEW/BREAKING CHANGE: changed JKQTPColorDerivationMode into a struct, which extends its capabilities above the previously available few enum-items</li>
<li>NEW: added debug-feature to show boxes around text in the plot</li>
<li>BREAKING: Print-Support can now be switched off with a CMAKE-option JKQtPlotter_BUILD_FORCE_NO_PRINTER_SUPPORT=ON. This also switches off PDF and SVG export, partly solves issue <a href="https://github.com/jkriege2/JKQtPlotter/issues/81">#81</a>, many thanks to <a href="https://github.com/sufuk">user:sufuk</a> for contributing part of the code and supplying the idea! </li>
</ul>
<li>JKQTMathText:<ul>

View File

@ -15,9 +15,9 @@ set(UIS )
add_executable(${EXENAME} WIN32 ${SOURCES} ${HEADERS} ${RESOURCES} ${UIS})
target_include_directories(${EXENAME} PRIVATE ../../lib)
if(JKQtPlotter_BUILD_STATIC_LIBS)
target_link_libraries(${EXENAME} JKQTPlotterLib Qt${QT_VERSION_MAJOR}::PrintSupport Qt${QT_VERSION_MAJOR}::Xml)
target_link_libraries(${EXENAME} JKQTPlotterLib)
elseif(JKQtPlotter_BUILD_SHARED_LIBS)
target_link_libraries(${EXENAME} JKQTPlotterSharedLib Qt${QT_VERSION_MAJOR}::PrintSupport Qt${QT_VERSION_MAJOR}::Xml)
target_link_libraries(${EXENAME} JKQTPlotterSharedLib)
endif()

View File

@ -38,10 +38,14 @@ TestUserInteraction::TestUserInteraction(QWidget *parent) :
// Some of the are also available in the context menu and toolbar of the JKQTPlotter
// others are not
QMenu* menuPlot=menuBar()->addMenu("Plot-Menu");
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
menuPlot->addAction(plot->getPlotter()->getActionPrint());
#endif
QMenu* menuPlotS=menuPlot->addMenu("Save ...");
menuPlotS->addAction(plot->getPlotter()->getActionSaveData());
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
menuPlotS->addAction(plot->getPlotter()->getActionSavePDF()); // not available from JKQTPlotter by default
#endif
menuPlotS->addAction(plot->getPlotter()->getActionSavePlot());
QMenu* menuPlotZ=menuPlot->addMenu("Zoom ...");
menuPlotZ->addAction(plot->getPlotter()->getActionZoomAll());

View File

@ -20,8 +20,15 @@ message( STATUS "Processor Name: ${CMAKE_SYSTEM_PROCESSOR}" )
message( STATUS "Using Qt: ${QT_VERSION}" )
message( STATUS " [at ${QT_DIR}]" )
if(JKQtPlotter_BUILD_INCLUDE_XITS_FONTS)
message( STATUS "Using XITS fonts" )
message( STATUS "XITS fonts: LINKED IN" )
else()
message( STATUS "XITS fonts: NOT AVAILABLE IN LIB" )
endif(JKQtPlotter_BUILD_INCLUDE_XITS_FONTS)
if(${JKQtPlotter_HAS_NO_PRINTER_SUPPORT})
message( STATUS "Print support: OFF" )
else()
message( STATUS "Print support: ON" )
endif()
message( STATUS "Installing to: ${CMAKE_INSTALL_PREFIX}" )
message( STATUS "=============================================================================" )
message( STATUS )

View File

@ -95,35 +95,39 @@ set(HEADERS
include(CMakePackageConfigHelpers)
if(JKQtPlotter_BUILD_SHARED_LIBS)
add_library(${libsh_name} SHARED ${SOURCES} ${HEADERS} )
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}::Xml Qt${QT_VERSION_MAJOR}::Widgets)
target_compile_definitions(${libsh_name} PUBLIC JKQTCOMMON_LIB_IN_DLL)
target_compile_definitions(${libsh_name} PRIVATE JKQTCOMMON_LIB_EXPORT_LIBRARY)
function(JKQtCommon_setDefaultLibOptions TARGETNAME)
set_property(TARGET ${TARGETNAME} PROPERTY VERSION "${PROJECT_VERSION}")
target_link_libraries(${TARGETNAME} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Xml Qt${QT_VERSION_MAJOR}::Widgets)
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)
set_property(TARGET ${TARGETNAME} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${TARGETNAME} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${TARGETNAME} 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)
set_property(TARGET ${TARGETNAME} PROPERTY CXX_STANDARD 17)
set_property(TARGET ${TARGETNAME} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${TARGETNAME} PUBLIC cxx_std_17)
endif()
if(MINGW)
# COMPILER-SETTINGS FOR MINGW
target_compile_options(${libsh_name} PUBLIC -fexceptions)
target_compile_options(${TARGETNAME} PUBLIC -fexceptions)
elseif(MSVC)
# COMPILER-SETTINGS FOR MS VISUAL C++
target_compile_options(${libsh_name} PUBLIC /EHsc)
target_compile_definitions(${libsh_name} PUBLIC NOMINMAX)
target_compile_options(${TARGETNAME} PUBLIC /EHsc)
target_compile_definitions(${TARGETNAME} PUBLIC NOMINMAX)
endif()
target_include_directories(${libsh_name} PUBLIC
target_include_directories(${TARGETNAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/../>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
endfunction()
if(JKQtPlotter_BUILD_SHARED_LIBS)
add_library(${libsh_name} SHARED ${SOURCES} ${HEADERS} )
JKQtCommon_setDefaultLibOptions(${libsh_name})
set_property(TARGET ${libsh_name} PROPERTY OUTPUT_NAME "${libsh_name_decorated}")
target_compile_definitions(${libsh_name} PUBLIC JKQTCOMMON_LIB_IN_DLL)
target_compile_definitions(${libsh_name} PRIVATE JKQTCOMMON_LIB_EXPORT_LIBRARY)
set_target_properties(${libsh_name} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS "ON")
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${libsh_name}Version.cmake
VERSION ${PROJECT_VERSION}
@ -132,30 +136,8 @@ endif()
if(JKQtPlotter_BUILD_STATIC_LIBS)
add_library(${lib_name} STATIC ${SOURCES} ${HEADERS})
set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}")
JKQtCommon_setDefaultLibOptions(${lib_name})
set_property(TARGET ${lib_name} PROPERTY OUTPUT_NAME "${lib_name_decorated}")
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)
elseif(MSVC)
# COMPILER-SETTINGS FOR MS VISUAL C++
target_compile_options(${lib_name} PUBLIC /EHsc)
target_compile_definitions(${lib_name} PUBLIC NOMINMAX)
endif()
target_include_directories(${lib_name} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/../>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_link_libraries(${lib_name} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Xml Qt${QT_VERSION_MAJOR}::Widgets)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${lib_name}Version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion )

View File

@ -34,36 +34,39 @@ set(HEADERS
include(CMakePackageConfigHelpers)
if(JKQtPlotter_BUILD_SHARED_LIBS)
add_library(${libsh_name} SHARED ${SOURCES} ${RESOURCES} ${HEADERS})
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}::OpenGL JKQTCommonSharedLib)
function(JKQtFastPlotter_setDefaultLibOptions TARGETNAME)
set_property(TARGET ${TARGETNAME} PROPERTY VERSION "${PROJECT_VERSION}")
target_link_libraries(${TARGETNAME} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::OpenGL Qt${QT_VERSION_MAJOR}::Widgets)
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)
set_property(TARGET ${TARGETNAME} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${TARGETNAME} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${TARGETNAME} 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)
set_property(TARGET ${TARGETNAME} PROPERTY CXX_STANDARD 17)
set_property(TARGET ${TARGETNAME} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${TARGETNAME} PUBLIC cxx_std_17)
endif()
target_compile_definitions(${libsh_name} PUBLIC JKQTFASTPLOTTER_LIB_IN_DLL)
if(MINGW)
# COMPILER-SETTINGS FOR MINGW
target_compile_options(${libsh_name} PUBLIC -fexceptions)
target_compile_options(${TARGETNAME} PUBLIC -fexceptions)
elseif(MSVC)
# COMPILER-SETTINGS FOR MS VISUAL C++
target_compile_options(${libsh_name} PUBLIC /EHsc)
target_compile_definitions(${libsh_name} PUBLIC NOMINMAX)
target_compile_options(${TARGETNAME} PUBLIC /EHsc)
target_compile_definitions(${TARGETNAME} PUBLIC NOMINMAX)
endif()
target_compile_definitions(${libsh_name} PRIVATE JKQTFASTPLOTTER_LIB_EXPORT_LIBRARY)
target_include_directories(${libsh_name} PUBLIC
target_include_directories(${TARGETNAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/../>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
endfunction()
if(JKQtPlotter_BUILD_SHARED_LIBS)
add_library(${libsh_name} SHARED ${SOURCES} ${RESOURCES} ${HEADERS})
JKQtFastPlotter_setDefaultLibOptions(${libsh_name})
set_property(TARGET ${libsh_name} PROPERTY OUTPUT_NAME "${libsh_name_decorated}")
target_link_libraries(${libsh_name} PUBLIC JKQTCommonSharedLib)
target_compile_definitions(${libsh_name} PUBLIC JKQTFASTPLOTTER_LIB_IN_DLL)
target_compile_definitions(${libsh_name} PRIVATE JKQTFASTPLOTTER_LIB_EXPORT_LIBRARY)
set_target_properties(${libsh_name} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS "ON")
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${libsh_name}Version.cmake
VERSION ${PROJECT_VERSION}
@ -72,31 +75,9 @@ endif()
if(JKQtPlotter_BUILD_STATIC_LIBS)
add_library(${lib_name} STATIC ${SOURCES} ${RESOURCES} ${HEADERS})
set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}")
JKQtFastPlotter_setDefaultLibOptions(${lib_name})
set_property(TARGET ${lib_name} PROPERTY OUTPUT_NAME "${lib_name_decorated}")
if(MINGW)
# COMPILER-SETTINGS FOR MINGW
target_compile_options(${lib_name} PUBLIC -fexceptions)
elseif(MSVC)
# COMPILER-SETTINGS FOR MS VISUAL C++
target_compile_options(${lib_name} PUBLIC /EHsc)
target_compile_definitions(${lib_name} PUBLIC NOMINMAX)
endif()
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}::OpenGL JKQTCommonLib)
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}>
)
target_link_libraries(${lib_name} PUBLIC JKQTCommonLib)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${lib_name}Version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion )

View File

@ -85,37 +85,42 @@ endif(JKQtPlotter_BUILD_INCLUDE_XITS_FONTS)
include(CMakePackageConfigHelpers)
if(JKQtPlotter_BUILD_SHARED_LIBS)
add_library(${libsh_name} SHARED ${SOURCES} ${RESOURCES} ${HEADERS} )
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 JKQTCommonSharedLib)
target_compile_definitions(${libsh_name} PUBLIC JKQTMATHTEXT_LIB_IN_DLL)
target_compile_definitions(${libsh_name} PRIVATE JKQTMATHTEXT_LIB_EXPORT_LIBRARY)
function(JKQtMathText_setDefaultLibOptions TARGETNAME)
set_property(TARGET ${TARGETNAME} PROPERTY VERSION "${PROJECT_VERSION}")
target_link_libraries(${TARGETNAME} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets)
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)
set_property(TARGET ${TARGETNAME} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${TARGETNAME} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${TARGETNAME} 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)
set_property(TARGET ${TARGETNAME} PROPERTY CXX_STANDARD 17)
set_property(TARGET ${TARGETNAME} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${TARGETNAME} PUBLIC cxx_std_17)
endif()
if(MINGW)
# COMPILER-SETTINGS FOR MINGW
target_compile_options(${libsh_name} PUBLIC -fexceptions)
target_compile_options(${TARGETNAME} PUBLIC -fexceptions)
elseif(MSVC)
# COMPILER-SETTINGS FOR MS VISUAL C++
target_compile_options(${libsh_name} PUBLIC /EHsc)
target_compile_definitions(${libsh_name} PUBLIC NOMINMAX)
target_compile_options(${TARGETNAME} PUBLIC /EHsc)
target_compile_definitions(${TARGETNAME} PUBLIC NOMINMAX)
endif()
target_include_directories(${libsh_name} PUBLIC
target_include_directories(${TARGETNAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/../>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
if(JKQtPlotter_BUILD_INCLUDE_XITS_FONTS)
target_compile_definitions(${libsh_name} PRIVATE JKQTMATHTEXT_COMPILED_WITH_XITS)
target_compile_definitions(${TARGETNAME} PRIVATE JKQTMATHTEXT_COMPILED_WITH_XITS)
endif(JKQtPlotter_BUILD_INCLUDE_XITS_FONTS)
endfunction()
if(JKQtPlotter_BUILD_SHARED_LIBS)
add_library(${libsh_name} SHARED ${SOURCES} ${RESOURCES} ${HEADERS} )
JKQtMathText_setDefaultLibOptions(${libsh_name})
set_property(TARGET ${libsh_name} PROPERTY OUTPUT_NAME "${libsh_name_decorated}")
target_link_libraries(${libsh_name} PUBLIC JKQTCommonSharedLib)
target_compile_definitions(${libsh_name} PUBLIC JKQTMATHTEXT_LIB_IN_DLL)
target_compile_definitions(${libsh_name} PRIVATE JKQTMATHTEXT_LIB_EXPORT_LIBRARY)
set_target_properties(${libsh_name} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS "ON")
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${libsh_name}Version.cmake
VERSION ${PROJECT_VERSION}
@ -124,33 +129,10 @@ endif()
if(JKQtPlotter_BUILD_STATIC_LIBS)
add_library(${lib_name} STATIC ${SOURCES} ${RESOURCES} ${HEADERS})
set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}")
JKQtMathText_setDefaultLibOptions(${libsh_name})
set_property(TARGET ${lib_name} PROPERTY OUTPUT_NAME "${lib_name_decorated}")
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)
elseif(MSVC)
# COMPILER-SETTINGS FOR MS VISUAL C++
target_compile_options(${lib_name} PUBLIC /EHsc)
target_compile_definitions(${lib_name} PUBLIC NOMINMAX)
endif()
if(JKQtPlotter_BUILD_INCLUDE_XITS_FONTS)
target_compile_definitions(${lib_name} PRIVATE JKQTMATHTEXT_COMPILED_WITH_XITS)
endif(JKQtPlotter_BUILD_INCLUDE_XITS_FONTS)
target_link_libraries(${lib_name} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets JKQTCommonLib)
target_include_directories(${lib_name} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/../>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_link_libraries(${lib_name} PUBLIC JKQTCommonLib)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${lib_name}Version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion )

View File

@ -107,6 +107,8 @@ set(HEADERS_BASE
$<INSTALL_INTERFACE:jkqtpimagetools.h>
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/jkqtpgraphsbasestyle.h>
$<INSTALL_INTERFACE:jkqtpgraphsbasestyle.h>
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/jkqtplotter_configmacros.h>
$<INSTALL_INTERFACE:jkqtplotter_configmacros.h>
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/jkqtplotter_imexport.h>
$<INSTALL_INTERFACE:jkqtplotter_imexport.h>
)
@ -188,6 +190,38 @@ set(RESOURCES
include(CMakePackageConfigHelpers)
function(JKQtPlottter_setDefaultLibOptions TARGETNAME)
set_property(TARGET ${TARGETNAME} PROPERTY VERSION "${PROJECT_VERSION}")
target_link_libraries(${TARGETNAME} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Svg Qt${QT_VERSION_MAJOR}::Xml)
if(JKQtPlotter_HAS_NO_PRINTER_SUPPORT)
target_compile_definitions(${TARGETNAME} PUBLIC JKQTPLOTTER_HAS_NO_PRINTSUPPORT)
else()
target_link_libraries(${TARGETNAME} PUBLIC Qt${QT_VERSION_MAJOR}::PrintSupport)
target_compile_definitions(${TARGETNAME} PUBLIC JKQTPLOTTER_HAS_PRINTSUPPORT)
endif()
if(${QT_VERSION_MAJOR} VERSION_LESS "6")
set_property(TARGET ${TARGETNAME} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${TARGETNAME} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${TARGETNAME} PUBLIC cxx_std_11)
else()
set_property(TARGET ${TARGETNAME} PROPERTY CXX_STANDARD 17)
set_property(TARGET ${TARGETNAME} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${TARGETNAME} PUBLIC cxx_std_17)
endif()
if(MINGW)
# COMPILER-SETTINGS FOR MINGW
target_compile_options(${TARGETNAME} PUBLIC -fexceptions)
elseif(MSVC)
# COMPILER-SETTINGS FOR MS VISUAL C++
target_compile_options(${TARGETNAME} PUBLIC /EHsc)
target_compile_definitions(${TARGETNAME} PUBLIC NOMINMAX)
endif()
target_include_directories(${TARGETNAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/../>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
endfunction()
if(JKQtPlotter_BUILD_SHARED_LIBS)
add_library(${libsh_name} SHARED
@ -199,32 +233,11 @@ if(JKQtPlotter_BUILD_SHARED_LIBS)
${HEADERS_GRAPHS}
${HEADERS_GUI}
)
set_property(TARGET ${libsh_name} PROPERTY VERSION "${PROJECT_VERSION}")
JKQtPlottter_setDefaultLibOptions(${libsh_name})
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)
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_link_libraries(${libsh_name} PUBLIC JKQTCommonSharedLib JKQTMathTextSharedLib)
target_compile_definitions(${libsh_name} PUBLIC JKQTPLOTTER_LIB_IN_DLL)
target_compile_definitions(${libsh_name} PRIVATE JKQTPLOTTER_LIB_EXPORT_LIBRARY)
if(MINGW)
# COMPILER-SETTINGS FOR MINGW
target_compile_options(${libsh_name} PUBLIC -fexceptions)
elseif(MSVC)
# COMPILER-SETTINGS FOR MS VISUAL C++
target_compile_options(${libsh_name} PUBLIC /EHsc)
target_compile_definitions(${libsh_name} PUBLIC NOMINMAX)
endif()
target_include_directories(${libsh_name} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/../>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
set_target_properties(${libsh_name} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS "ON")
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${libsh_name}Version.cmake
VERSION ${PROJECT_VERSION}
@ -233,30 +246,9 @@ endif()
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}")
JKQtPlottter_setDefaultLibOptions(${lib_name})
set_property(TARGET ${lib_name} PROPERTY OUTPUT_NAME "${lib_name_decorated}")
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)
elseif(MSVC)
# COMPILER-SETTINGS FOR MS VISUAL C++
target_compile_options(${lib_name} PUBLIC /EHsc)
target_compile_definitions(${lib_name} PUBLIC NOMINMAX)
endif()
target_include_directories(${lib_name} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/../>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
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}::Svg Qt${QT_VERSION_MAJOR}::Xml JKQTCommonLib JKQTMathTextLib)
target_link_libraries(${lib_name} PUBLIC JKQTCommonLib JKQTMathTextLib)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${lib_name}Version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion )

View File

@ -6,7 +6,8 @@
#
# package requires Qt 5/6
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 Svg Xml OpenGL REQUIRED)
find_package(Qt@QT_VERSION_MAJOR@ OPTIONAL_COMPONENTS PrintSupport)
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

@ -32,7 +32,10 @@ Copyright (c) 2008-2020 Jan W. Krieger (<jan@jkrieger.de>)
#include <QCheckBox>
#include <QDialogButtonBox>
#include <QHeaderView>
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
# include <QPrintDialog>
# include <QPrinter>
#endif
#include <QLabel>
#include "jkqtplotter/jkqtptools.h"
#include "jkqtcommon/jkqtpenhancedpainter.h"
@ -57,10 +60,12 @@ JKQTPEnhancedTableView::JKQTPEnhancedTableView(QWidget *parent):
act=new QAction(QIcon(":/JKQTPlotter/jkqtp_copy16_nohead.png"), tr("Copy Selection to clipboard (as CSV ...) without header row/column"), this);
connect(act, SIGNAL(triggered()), this, SLOT(copySelectionToCSVNoHead()));
addAction(act);
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
act=new QAction(QIcon(":/JKQTPlotter/jkqtp_printtable.png"), tr("Print Table"), this);
connect(act, SIGNAL(triggered()), this, SLOT(print()));
addAction(act);
printAction=act;
#endif
}
JKQTPEnhancedTableView::~JKQTPEnhancedTableView()
@ -462,14 +467,16 @@ void JKQTPEnhancedTableView::keyPressEvent(QKeyEvent *event)
if (event->matches(QKeySequence::Copy)) {
copySelectionToExcel(Qt::EditRole, false);
event->accept();
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
} else if (event->matches(QKeySequence::Print)) {
print();
event->accept();
#endif
} else QTableView::keyPressEvent(event);
emit keyPressed(event->key(), event->modifiers(), event->text());
}
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
void JKQTPEnhancedTableView::print()
{
QPrinter* tablePrinter=getPrinter(nullptr);
@ -497,9 +504,9 @@ void JKQTPEnhancedTableView::print()
delete tablePrinter;
}
}
#endif
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
void JKQTPEnhancedTableView::print(QPrinter *printer, bool onePageWide, bool onePageHigh)
{
QPrinter* p=printer;
@ -607,6 +614,7 @@ void JKQTPEnhancedTableView::print(QPrinter *printer, bool onePageWide, bool one
/// PRINT DONE //////////////////////////////////////////////////////////////////////////////////
}
#endif
void JKQTPEnhancedTableView::paint(QPainter &painter, QRect pageRect)
{
@ -649,7 +657,11 @@ QSizeF JKQTPEnhancedTableView::getTotalSize() const
return QSizeF((totalWidth), (totalHeight));
}
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
void JKQTPEnhancedTableView::paint(QPainter &painter, double scale, int page, double hhh, double vhw, const QList<int>& pageCols, const QList<int>& pageRows, QPrinter* p)
#else
void JKQTPEnhancedTableView::paint(QPainter &painter, double scale, int page, double hhh, double vhw, const QList<int>& pageCols, const QList<int>& pageRows)
#endif
{
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
QStyleOptionViewItem option;
@ -736,17 +748,22 @@ void JKQTPEnhancedTableView::paint(QPainter &painter, double scale, int page, do
}
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
if (p && pw<pagesWide-1) p->newPage();
#endif
}
pageCnt++;
}
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
if (p && ph<pagesHigh-1) p->newPage();
#endif
}
}
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
QPrinter *JKQTPEnhancedTableView::getPrinter(QPrinter *printerIn, bool *localPrinter)
{
QPrinter* p=printerIn;
@ -767,4 +784,4 @@ QPrinter *JKQTPEnhancedTableView::getPrinter(QPrinter *printerIn, bool *localPri
return p;
}
#endif

View File

@ -21,8 +21,12 @@
#ifndef JKQTPEnhancedTableView_H_INCLUDED
#define JKQTPEnhancedTableView_H_INCLUDED
#include "jkqtplotter/jkqtplotter_imexport.h"
#include "jkqtplotter/jkqtplotter_configmacros.h"
#include <QTableView>
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
# include <QPrintDialog>
# include <QPrinter>
#endif
/*! \brief this class extends the <a href="http://doc.qt.io/qt-5/qtableview.html">QTableView</a>
\ingroup jkqtptools_qtwidgets
@ -46,6 +50,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPEnhancedTableView : public QTableView {
/** \brief return the contents of the table view as HTML fragment */
QString toHtml(int borderWidth=1, bool non_breaking=false, int fontSizePt=-1) const;
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
/** \brief print the contents of the table view
*
* \param printer the QPrinter to use for printing the table view
@ -62,7 +67,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPEnhancedTableView : public QTableView {
* \image html JKQTPEnhancedTableViewPrintSinglepage.png "Print on one page (onePageWide=true onePageHigh=true)"
*/
void print(QPrinter* printer, bool onePageWide=false, bool onePageHigh=false);
#endif
/** \brief draw the contents of the table-view into the given \a pageRect, using the given \a painter
*
* The output look like this:
@ -74,9 +79,10 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPEnhancedTableView : public QTableView {
void paint(QPainter& painter, QRect pageRec=QRect());
/** \brief returns the totoal size of the table-view \see paint() */
QSizeF getTotalSize() const;
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
/** \brief return a QAction that prints the table using the methode print() \see print() */
QAction* getActionPrint() const { return printAction; }
inline QAction* getActionPrint() { return printAction; }
#endif
signals:
/** \brief emitted when a key is pressed in the context of this widget */
void keyPressed(int key, Qt::KeyboardModifiers modifiers, const QString& text);
@ -106,6 +112,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPEnhancedTableView : public QTableView {
* \see copySelectionToCSV()
*/
void copySelectionToCSVNoHead(int copyrole=Qt::EditRole, const QString& separator=", ", const QChar& decimalpoint='.');
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
/** \brief print the table contents
*
* Before printing this function opens a <a href="http://doc.qt.io/qt-5/qprintdialog.html">QPrintDialog</a> to select a printer
@ -124,7 +131,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPEnhancedTableView : public QTableView {
*
*/
void print();
#endif
protected:
/** \brief handles key presses and reacts to some standard keys
* \internal
@ -133,11 +140,17 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPEnhancedTableView : public QTableView {
/** \brief internal paintig method
* \internal
*/
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
void paint(QPainter &painter, double scale, int page, double hhh, double vhw, const QList<int>& pageCols, const QList<int>& pageRows, QPrinter* p=nullptr);
#else
void paint(QPainter &painter, double scale, int page, double hhh, double vhw, const QList<int>& pageCols, const QList<int>& pageRows);
#endif
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
/** \brief select a printer, using a print-selection dialog if necessary */
QPrinter* getPrinter(QPrinter* printerIn=nullptr, bool *localPrinter=nullptr);
/** \brief action that calls print() */
QAction* printAction;
#endif
private:
};

View File

@ -28,14 +28,16 @@
#include <QSvgGenerator>
#include <QDebug>
#include <QElapsedTimer>
#include <QtPrintSupport/QPrintPreviewWidget>
#include <QDialog>
#include "jkqtplotter/jkqtpbaseplotter.h"
#include "jkqtplotter/gui/jkqtpgraphsmodel.h"
#include "jkqtplotter/gui/jkqtpenhancedtableview.h"
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
# include <QPrintDialog>
# include <QPrinter>
# include <QPrinterInfo>
#include <QPrintDialog>
# include <QtPrintSupport/QPrintPreviewWidget>
#endif
#include <QGridLayout>
#include <QCheckBox>
#include <QDialogButtonBox>
@ -191,7 +193,9 @@ JKQTBasePlotter::JKQTBasePlotter(bool datastore_internal, QObject* parent, JKQTP
lineWidthMultiplier=1;
userSettigsFilename=globalUserSettigsFilename;
userSettigsPrefix=globalUserSettigsPrefix;
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
currentPrinter=QPrinterInfo::defaultPrinter().printerName();
#endif
if (datastore_internal) {
datastore=new JKQTPDatastore();
@ -237,18 +241,22 @@ JKQTBasePlotter::JKQTBasePlotter(bool datastore_internal, QObject* parent, JKQTP
actCopyPixelImage->setToolTip(tr("Copy the plot as a pixel image to the clipboard"));
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
actSavePDF=new QAction(QIcon(":/JKQTPlotter/jkqtp_savepdf.png"), tr("Save P&DF"), this);
actSavePDF->setToolTip(tr("Save as PDF"));
//toolbar->addAction(actSavePDF);
actSaveSVG=new QAction(QIcon(":/JKQTPlotter/jkqtp_savesvg.png"), tr("Save S&VG"), this);
actSaveSVG->setToolTip(tr("Save as Scalable Vector Graphics (SVG)"));
//toolbar->addAction(actSaveSVG);
#endif
actSavePix=new QAction(QIcon(":/JKQTPlotter/jkqtp_savepix.png"), tr("Save &Image"), this);
actSavePix->setToolTip(tr("Save as Pixel Image (PNG, JPEG, TIFF ...)"));
//toolbar->addAction(actSavePix);
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
actPrint=new QAction(QIcon(":/JKQTPlotter/jkqtp_print.png"), tr("&Print"), this);
actPrint->setToolTip("Print");
#endif
//toolbar->addSeparator();
actSaveCSV=new QAction(QIcon(":/JKQTPlotter/jkqtp_savecsv.png"), tr("Save &CSV"), this);
actSaveCSV->setToolTip(tr("Save the data which is used for the plot as Comma Separated Values (CSV)"));
@ -273,11 +281,13 @@ JKQTBasePlotter::JKQTBasePlotter(bool datastore_internal, QObject* parent, JKQTP
connect(actCopyMatlab, SIGNAL(triggered()), this, SLOT(copyDataMatlab()));
connect(actShowPlotData, SIGNAL(triggered()), this, SLOT(showPlotData()));
connect(actSavePDF, SIGNAL(triggered()), this, SLOT(saveAsPDF()));
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
connect(actPrint, SIGNAL(triggered()), this, SLOT(print()));
connect(actSaveSVG, SIGNAL(triggered()), this, SLOT(saveAsSVG()));
connect(actSavePDF, SIGNAL(triggered()), this, SLOT(saveAsPDF()));
#endif
connect(actSavePix, SIGNAL(triggered()), this, SLOT(saveAsPixelImage()));
connect(actPrint, SIGNAL(triggered()), this, SLOT(print()));
connect(actSaveCSV, SIGNAL(triggered()), this, SLOT(saveAsCSV()));
connect(actZoomAll, SIGNAL(triggered()), this, SLOT(zoomToFit()));
connect(actZoomIn, SIGNAL(triggered()), this, SLOT(zoomIn()));
@ -1466,7 +1476,7 @@ void JKQTBasePlotter::gridPaint(JKQTPEnhancedPainter& painter, QSizeF pageRect,
}
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
void JKQTBasePlotter::print(QPrinter* printer, bool displayPreview) {
loadUserSettings();
QPrinter* p=printer;
@ -1503,12 +1513,14 @@ void JKQTBasePlotter::print(QPrinter* printer, bool displayPreview) {
if (delP) delete p;
saveUserSettings();
}
#endif
bool JKQTBasePlotter::printpreviewNew(QPaintDevice* paintDevice, bool setAbsolutePaperSize, double printsizeX_inMM, double printsizeY_inMM, bool displayPreview) {
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
QPrinter *printer=dynamic_cast<QPrinter*>(paintDevice);
QSvgGenerator* svg=dynamic_cast<QSvgGenerator*>(paintDevice);
#endif
double lw=lineWidthMultiplier;
double fs=fontSizeMultiplier;
double oldP=paintMagnification;
@ -1521,12 +1533,14 @@ bool JKQTBasePlotter::printpreviewNew(QPaintDevice* paintDevice, bool setAbsolut
paintMagnification=1.0;
gridPrintingCalc();
//double resolution=paintDevice->logicalDpiX();
//if (printer) resolution=printer->resolution();
printAspect=gridPrintingSize.height()/gridPrintingSize.width();
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
if (printer) printPageSizeMM=printer->pageLayout().pageSize().size(QPageSize::Millimeter);
else if (paintDevice) printPageSizeMM=QSizeF(paintDevice->widthMM(), paintDevice->heightMM());
#else
if (paintDevice) printPageSizeMM=QSizeF(paintDevice->widthMM(), paintDevice->heightMM());
#endif
printSizeX_Millimeter=double(gridPrintingSize.width())/96.0*25.4;//double(resolution)*25.4; // convert current widget size in pt to millimeters, assuming 96dpi (default screen resolution)
printSizeY_Millimeter=double(gridPrintingSize.height())/96.0*25.4;//double(resolution)*25.4;
if (printsizeX_inMM>0) printSizeX_Millimeter=printsizeX_inMM;
@ -1553,6 +1567,7 @@ bool JKQTBasePlotter::printpreviewNew(QPaintDevice* paintDevice, bool setAbsolut
dlg->setWindowTitle(tr("Graph print/export preview ..."));
dlg->setWindowIcon(QIcon(":/JKQTPlotter/jkqtp_exportprintpreview.png"));
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
bool delPrinter=false;
if (svg) {
printer=new QPrinter();
@ -1571,11 +1586,9 @@ bool JKQTBasePlotter::printpreviewNew(QPaintDevice* paintDevice, bool setAbsolut
delPrinter=true;
}
printPreview=new QPrintPreviewWidget(printer, dlg);
connect(printPreview, SIGNAL(paintRequested(QPrinter*)), this, SLOT(printpreviewPaintRequestedNew(QPrinter*)));
connect(printPreview, SIGNAL(paintRequested(QPrinter*)), this, SLOT(printpreviewPaintRequestedNewPrinter(QPrinter*)));
#endif
spinSizeX=new JKQTPEnhancedDoubleSpinBox(dlg);
spinSizeX->setRange(10,100000);
@ -1604,9 +1617,11 @@ bool JKQTBasePlotter::printpreviewNew(QPaintDevice* paintDevice, bool setAbsolut
if (setAbsolutePaperSize) {
layout->addWidget(new QLabel(tr("paper/plot size: ")), 0,layout->columnCount());
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
} else if (printer && !svg) {
int y=layout->columnCount();
layout->addWidget(new QLabel(tr("plot size: ")), 0,y);
#endif
} else {
int y=layout->columnCount();
layout->addWidget(new QLabel(tr("paper size: ")), 1,y);
@ -1616,6 +1631,7 @@ bool JKQTBasePlotter::printpreviewNew(QPaintDevice* paintDevice, bool setAbsolut
layout->addWidget(new QLabel(tr(" x ")), 0,layout->columnCount());
layout->addWidget(spinSizeY, 0,layout->columnCount());
layout->addWidget(chkAspect, 0,layout->columnCount());
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
if (!setAbsolutePaperSize && printer && !svg) {
layout->addWidget(new QLabel(tr("%1x%2 mm^2").arg(printer->pageLayout().pageSize().size(QPageSize::Millimeter).width()).arg(printer->pageLayout().pageSize().size(QPageSize::Millimeter).height())), 1,layout->columnCount()-4, 1, 4);
@ -1647,7 +1663,7 @@ bool JKQTBasePlotter::printpreviewNew(QPaintDevice* paintDevice, bool setAbsolut
layout->addWidget(chkSetMagnification, 0,layout->columnCount());
layout->addWidget(spinMagnification, 0,layout->columnCount());
}
#endif
JKQTPEnhancedDoubleSpinBox* spinLineWidthMult=new JKQTPEnhancedDoubleSpinBox(dlg);
@ -1685,7 +1701,9 @@ bool JKQTBasePlotter::printpreviewNew(QPaintDevice* paintDevice, bool setAbsolut
layout->addWidget(spinFontSizeMult, 1,gpos+1);
layout->addWidget(new QWidget(), 0,layout->columnCount());
layout->setColumnStretch(layout->columnCount()-1, 1);
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
layout->addWidget(printPreview, layout->rowCount(),0, 1, layout->columnCount());
#endif
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
connect(buttonBox, SIGNAL(accepted()), dlg, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), dlg, SLOT(reject()));
@ -1693,15 +1711,16 @@ bool JKQTBasePlotter::printpreviewNew(QPaintDevice* paintDevice, bool setAbsolut
dlg->resize(800,500);
bool res=false;
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
if (printer) {
if (!displayPreview || dlg->exec()==QDialog::Accepted) {
//qDebug()<<svg<<printer<<delPrinter;
if (svg) {
printpreviewPaintRequestedNew(svg);
printpreviewPaintRequestedNewPaintDevice(svg);
} else if (!delPrinter) {
printpreviewPaintRequestedNew(printer);
printpreviewPaintRequestedNewPrinter(printer);
} else {
printpreviewPaintRequestedNew(paintDevice);
printpreviewPaintRequestedNewPaintDevice(paintDevice);
}
res=true;
}
@ -1709,8 +1728,11 @@ bool JKQTBasePlotter::printpreviewNew(QPaintDevice* paintDevice, bool setAbsolut
if ((svg||delPrinter) && printer) {
delete printer;
}
#endif
delete dlg;
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
printPreview=nullptr;
#endif
lineWidthMultiplier=lw;
fontSizeMultiplier=fs;
plotterStyle.widgetBackgroundBrush=bc;
@ -1723,7 +1745,9 @@ bool JKQTBasePlotter::printpreviewNew(QPaintDevice* paintDevice, bool setAbsolut
}
bool JKQTBasePlotter::exportpreview(QSizeF pageSize, bool unitIsMM) {
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
printPreview=nullptr;
#endif
printSizeX_Millimeter=pageSize.width();
printSizeY_Millimeter=pageSize.height();
printAspect=1;
@ -1741,8 +1765,6 @@ bool JKQTBasePlotter::exportpreview(QSizeF pageSize, bool unitIsMM) {
dlg->setLayout(layout);
dlg->setWindowTitle(tr("Graph export preview ..."));
dlg->setWindowIcon(QIcon(":/JKQTPlotter/jkqtp_exportprintpreview.png"));
/*printPreview=new QPrintPreviewWidget(p, dlg);
connect(printPreview, SIGNAL(paintRequested(QPrinter*)), this, SLOT(printpreviewPaintRequested(QPrinter*)));*/
QScrollArea* scroll=new QScrollArea(dlg);
{
QPalette p(scroll->palette());
@ -1913,6 +1935,7 @@ void JKQTBasePlotter::updatePreviewLabel() {
}
}
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
void JKQTBasePlotter::printpreviewPaintRequested(QPrinter* printer) {
double lw=lineWidthMultiplier;
double fs=fontSizeMultiplier;
@ -1989,17 +2012,20 @@ void JKQTBasePlotter::printpreviewPaintRequested(QPrinter* printer) {
}
void JKQTBasePlotter::printpreviewPaintRequestedNew(QPrinter* printer) {
void JKQTBasePlotter::printpreviewPaintRequestedNewPrinter(QPrinter* printer) {
QPaintDevice* paintDevice=dynamic_cast<QPaintDevice*>(printer);
printpreviewPaintRequestedNew(paintDevice);
printpreviewPaintRequestedNewPaintDevice(paintDevice);
}
#endif
void JKQTBasePlotter::printpreviewPaintRequestedNew(QPaintDevice *paintDevice)
void JKQTBasePlotter::printpreviewPaintRequestedNewPaintDevice(QPaintDevice *paintDevice)
{
//QPaintDevice* paintDevice=dynamic_cast<QPaintDevice*>(printer);
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
QPrinter* printer=dynamic_cast<QPrinter*>(paintDevice);
QSvgGenerator* svg=dynamic_cast<QSvgGenerator*>(paintDevice);
#endif
double lw=lineWidthMultiplier;
double fs=fontSizeMultiplier;
@ -2021,6 +2047,7 @@ void JKQTBasePlotter::printpreviewPaintRequestedNew(QPaintDevice *paintDevice)
#ifdef SHOW_JKQTPLOTTER_DEBUG
qDebug()<<"set printing abs. size to "<<QSizeF(printSizeX_Millimeter, printSizeY_Millimeter)<<" mm^2";
#endif
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
if (printer) {
printer->setPageOrientation(QPageLayout::Portrait);
printer->setPageSize(QPageSize(QSizeF(printSizeX_Millimeter, printSizeY_Millimeter), QPageSize::Millimeter));
@ -2029,24 +2056,29 @@ void JKQTBasePlotter::printpreviewPaintRequestedNew(QPaintDevice *paintDevice)
svg->setSize(QSizeF(ceil(siz.width()*svg->resolution()/25.4), ceil(siz.height()*svg->resolution()/25.4)).toSize());
svg->setViewBox(QRect(0,0,-1,-1));//*25.4/double(svg->resolution()), printSizeY_Millimeter*25.4/double(svg->resolution())));
}
#endif
}
paintMagnification=gridPrintingSize.width()/(printSizeX_Millimeter/25.4*double(paintDevice->logicalDpiX()));
if (!gridPrinting) widgetHeight=jkqtp_roundTo<int>(widgetWidth*printSizeY_Millimeter/printSizeX_Millimeter);
JKQTPEnhancedPainter painter;
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
if (printer) painter.begin(printer);
else if (svg) painter.begin(svg);
else painter.begin(paintDevice);
#else
painter.begin(paintDevice);
#endif
if (printKeepAbsoluteFontSizes) {
fontSizeMultiplier=1.0;//1.0/paintMagnification;
}
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
if (svg) {
lineWidthMultiplier=lineWidthMultiplier*72.0/96.0;
fontSizeMultiplier=fontSizeMultiplier*72.0/96.0;
}
#endif
#ifdef SHOW_JKQTPLOTTER_DEBUG
qDebug()<<"\n\n\n==========================================================================";
qDebug()<<"printAspect = "<<printAspect;
@ -2074,9 +2106,13 @@ void JKQTBasePlotter::printpreviewPaintRequestedNew(QPaintDevice *paintDevice)
qDebug()<<"x-axis label fontsize = "<<xAxis->getLabelFontSize()<<" pt";
qDebug()<<"y-axis label fontsize = "<<yAxis->getLabelFontSize()<<" pt";
#endif
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
if (printer) gridPaint(painter, printer->pageLayout().paintRectPixels(printer->resolution()).size(), printScaleToPagesize, printScaleToPagesize);
else if (svg) gridPaint(painter, svg->size(), printScaleToPagesize, printScaleToPagesize);
else gridPaint(painter, QSizeF(paintDevice->width(), paintDevice->height()), printScaleToPagesize, printScaleToPagesize);
#else
gridPaint(painter, QSizeF(paintDevice->width(), paintDevice->height()), printScaleToPagesize, printScaleToPagesize);
#endif
painter.end();
widgetWidth=oldWidgetWidth;
widgetHeight=oldWidgetHeight;
@ -2118,7 +2154,9 @@ void JKQTBasePlotter::exportpreviewPaintRequested(JKQTPEnhancedPainter &painter,
void JKQTBasePlotter::printpreviewSetZoom(double value) {
printZoomFactor=value/100.0;
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
if (printPreview) printPreview->updatePreview();
#endif
if (exportPreviewLabel) updatePreviewLabel();
}
@ -2129,15 +2167,20 @@ void JKQTBasePlotter::printpreviewSetSizeX(double value) {
spinSizeY->setValue(printSizeY_Millimeter);
}
if (printDoUpdate) {
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
if (printPreview) printPreview->updatePreview();
#endif
if (exportPreviewLabel) updatePreviewLabel();
}
}
void JKQTBasePlotter::printpreviewSetSizeY(double value) {
if (printKeepAspect) return;
printSizeY_Millimeter=value;
if (printDoUpdate) {
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
if (printPreview) printPreview->updatePreview();
#endif
if (exportPreviewLabel) updatePreviewLabel();
}
}
@ -2148,16 +2191,17 @@ void JKQTBasePlotter::printpreviewSetSizeXNew(double value) {
printSizeY_Millimeter=printSizeX_Millimeter*printAspect;
spinSizeY->setValue(printSizeY_Millimeter);
}
}
void JKQTBasePlotter::printpreviewSetSizeYNew(double value) {
printSizeY_Millimeter=value;
}
void JKQTBasePlotter::printpreviewSetMagnification(double value) {
printMagnification=value/100.0;
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
if (printPreview) printPreview->updatePreview();
#endif
if (exportPreviewLabel) updatePreviewLabel();
}
@ -2183,14 +2227,18 @@ void JKQTBasePlotter::printpreviewSetAspectRatio(bool checked) {
printSizeY_Millimeter=printSizeX_Millimeter*printAspect;
spinSizeY->setValue(printSizeY_Millimeter);
}
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
if (printPreview) printPreview->updatePreview();
#endif
if (exportPreviewLabel) updatePreviewLabel();
}
void JKQTBasePlotter::printpreviewSetKeepAbsFontsize(bool checked)
{
printKeepAbsoluteFontSizes=checked;
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
if (printPreview) printPreview->updatePreview();
#endif
if (exportPreviewLabel) updatePreviewLabel();
}
@ -2204,20 +2252,26 @@ void JKQTBasePlotter::printpreviewToggleMagnification(bool checked)
void JKQTBasePlotter::printpreviewSetLineWidthMultiplier(double value) {
lineWidthPrintMultiplier=value/100.0;
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
if (printPreview) printPreview->updatePreview();
#endif
if (exportPreviewLabel) updatePreviewLabel();
}
void JKQTBasePlotter::printpreviewSetFontSizeMultiplier(double value) {
fontSizePrintMultiplier=value/100.0;
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
if (printPreview) printPreview->updatePreview();
#endif
if (exportPreviewLabel) updatePreviewLabel();
}
void JKQTBasePlotter::printpreviewUpdate()
{
if (printDoUpdate) {
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
if (printPreview) printPreview->updatePreview();
#endif
if (exportPreviewLabel) updatePreviewLabel();
}
}
@ -3201,14 +3255,7 @@ QAction *JKQTBasePlotter::getActionCopyMatlab() const {
return this->actCopyMatlab;
}
QAction *JKQTBasePlotter::getActionSavePDF() const {
return this->actSavePDF;
}
QAction *JKQTBasePlotter::getActionSavePix() const {
return this->actSavePix;
}
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
QAction *JKQTBasePlotter::getActionSaveSVG() const {
return this->actSaveSVG;
}
@ -3217,6 +3264,15 @@ QAction *JKQTBasePlotter::getActionPrint() const {
return this->actPrint;
}
QAction *JKQTBasePlotter::getActionSavePDF() const {
return this->actSavePDF;
}
#endif
QAction *JKQTBasePlotter::getActionSavePix() const {
return this->actSavePix;
}
QAction *JKQTBasePlotter::getActionSaveCSV() const {
return this->actSaveCSV;
}
@ -3577,6 +3633,7 @@ void JKQTBasePlotter::saveAsGerExcelCSV(const QString& filename) {
saveUserSettings();
}
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
void JKQTBasePlotter::saveAsPDF(const QString& filename, bool displayPreview) {
loadUserSettings();
QString fn=filename;
@ -3609,14 +3666,16 @@ void JKQTBasePlotter::saveAsPDF(const QString& filename, bool displayPreview) {
}
saveUserSettings();
}
#endif
void JKQTBasePlotter::saveImage(const QString& filename, bool displayPreview) {
loadUserSettings();
QString fn=filename;
QStringList filt;
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
filt<<tr("Portable Document Format PDF [Qt] (*.pdf)");
filt<<tr("Scalable Vector Graphics [Qt] (*.svg)");
#endif
filt<<tr("PNG Image [Qt] (*.png)");
filt<<tr("BMP Image [Qt] (*.bmp)");
filt<<tr("TIFF Image [Qt] (*.tif *.tiff)");
@ -3660,11 +3719,17 @@ void JKQTBasePlotter::saveImage(const QString& filename, bool displayPreview) {
}
}
//qDebug()<<"filtID="<<filtID<<" isWithSpecialDeviceAdapter="<<isWithSpecialDeviceAdapter<<" adapterID="<<adapterID;
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
if (filtID==0) {
saveAsPDF(fn, displayPreview);
} else if (filtID==1) {
return;
}
if (filtID==1) {
saveAsSVG(fn, displayPreview);
} else if (isWithSpecialDeviceAdapter && adapterID>=0 && adapterID<jkqtpPaintDeviceAdapters.size()) {
return;
}
#endif
if (isWithSpecialDeviceAdapter && adapterID>=0 && adapterID<jkqtpPaintDeviceAdapters.size()) {
QString tempFM="";
if (QFile::exists(fn)) {
#ifdef QFWIDLIB_LIBRARY
@ -3682,10 +3747,11 @@ void JKQTBasePlotter::saveImage(const QString& filename, bool displayPreview) {
mathText.setUseUnparsed(!jkqtpPaintDeviceAdapters[adapterID]->useLatexParser());
gridPrintingCalc();
QPaintDevice* svg=jkqtpPaintDeviceAdapters[adapterID]->createPaintdevice(fn, jkqtp_roundTo<int>(gridPrintingSize.width()), jkqtp_roundTo<int>(gridPrintingSize.height()));
QPaintDevice* paintDevice=jkqtpPaintDeviceAdapters[adapterID]->createPaintdevice(fn, jkqtp_roundTo<int>(gridPrintingSize.width()), jkqtp_roundTo<int>(gridPrintingSize.height()));
if (!printpreviewNew(svg, jkqtpPaintDeviceAdapters[adapterID]->getSetAbsolutePaperSize(), jkqtpPaintDeviceAdapters[adapterID]->getPrintSizeXInMM(), jkqtpPaintDeviceAdapters[adapterID]->getPrintSizeYInMM(), displayPreview)) {
delete svg;
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
if (!printpreviewNew(paintDevice, jkqtpPaintDeviceAdapters[adapterID]->getSetAbsolutePaperSize(), jkqtpPaintDeviceAdapters[adapterID]->getPrintSizeXInMM(), jkqtpPaintDeviceAdapters[adapterID]->getPrintSizeYInMM(), displayPreview)) {
delete paintDevice;
if (QFile::exists(tempFM)) {
@ -3693,10 +3759,13 @@ void JKQTBasePlotter::saveImage(const QString& filename, bool displayPreview) {
QFile::remove(tempFM);
}
} else {
delete svg;
svg=jkqtpPaintDeviceAdapters[adapterID]->createPaintdeviceMM(fn,printSizeX_Millimeter,printSizeY_Millimeter);
printpreviewPaintRequestedNew(svg);
delete svg;
#else
{
#endif
delete paintDevice;
paintDevice=jkqtpPaintDeviceAdapters[adapterID]->createPaintdeviceMM(fn,printSizeX_Millimeter,printSizeY_Millimeter);
printpreviewPaintRequestedNewPaintDevice(paintDevice);
delete paintDevice;
}
} else {
@ -3714,12 +3783,6 @@ void JKQTBasePlotter::saveAsPixelImage(const QString& filename, bool displayPrev
for (int i=0; i<writerformats.size(); i++) {
filt<<QString("%1 Image (*.%2)").arg(QString(writerformats[i]).toUpper()).arg(QString(writerformats[i].toLower()));
}
/*filt<<tr("PNG Image (*.png)");
filt<<tr("BMP Image (*.bmp)");
filt<<tr("TIFF Image (*.tif *.tiff)");
filt<<tr("JPEG Image (*.jpg *.jpeg)");
filt<<tr("X11 Bitmap (*.xbm)");
filt<<tr("X11 Pixmap (*.xpm)");*/
QString selFormat;
if (fn.isEmpty()) {
selFormat=currentFileFormat;
@ -3896,6 +3959,7 @@ void JKQTBasePlotter::copyPixelImage() {
}
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
void JKQTBasePlotter::saveAsSVG(const QString& filename, bool displayPreview) {
loadUserSettings();
QString fn=filename;
@ -3940,7 +4004,7 @@ void JKQTBasePlotter::saveAsSVG(const QString& filename, bool displayPreview) {
}
saveUserSettings();
}
#endif
void JKQTBasePlotter::setPlotBorder(int left, int right, int top, int bottom){
plotterStyle.plotBorderTop=top;
@ -4960,7 +5024,9 @@ void JKQTBasePlotter::showPlotData() {
JKQTPEnhancedTableView* tv=new JKQTPEnhancedTableView(dlg);
layout->addWidget(tv);
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
tb->addAction(tv->getActionPrint());
#endif
JKQTPDatastoreModel* model=new JKQTPDatastoreModel(getDatastore(), this);
tv->setModel(model);

View File

@ -20,6 +20,8 @@
#ifndef JKQTPBASEPLOTTER_H
#define JKQTPBASEPLOTTER_H
#include "jkqtplotter/jkqtplotter_configmacros.h"
#include "jkqtplotter/jkqtptools.h"
#include "jkqtplotter/jkqtpdatastorage.h"
#include "jkqtplotter/jkqtpbaseplotterstyle.h"
@ -37,7 +39,10 @@
#include <QMap>
#include <QVector>
#include <QPair>
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
# include <QPrinter>
# include <QtPrintSupport/QPrintPreviewWidget>
#endif
#include <QDoubleSpinBox>
#include <QLabel>
#include <QPointer>
@ -832,14 +837,16 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject {
QAction* getActionCopyPixelImage() const;
/** \copydoc actCopyMatlab */
QAction* getActionCopyMatlab() const;
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
/** \copydoc actSavePDF */
QAction* getActionSavePDF() const;
/** \copydoc actSavePix */
QAction* getActionSavePix() const;
/** \copydoc actSaveSVG */
QAction* getActionSaveSVG() const;
/** \copydoc actPrint */
QAction* getActionPrint() const;
#endif
/** \copydoc actSavePix */
QAction* getActionSavePix() const;
/** \copydoc actSaveCSV */
QAction* getActionSaveCSV() const;
/** \copydoc actZoomAll */
@ -1311,11 +1318,19 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject {
/** \brief copy the current plot as a pixel image to the clipboard */
void copyPixelImage();
/** \brief save the current plot as a SVG file, with the current widget aspect ratio, if filename is empty a file selection dialog is displayed */
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
/** \brief save the current plot as a SVG file, with the current widget aspect ratio, if filename is empty a file selection dialog is displayed
*
* \note Exporting to SVG requires QPrinter-support, if it is not available on your platform, this function will not be available either!
*/
void saveAsSVG(const QString& filename=QString(""), bool displayPreview=true);
/** \brief save the current plot as a PDF file, with the current widget aspect ratio, if filename is empty a file selection dialog is displayed */
/** \brief save the current plot as a PDF file, with the current widget aspect ratio, if filename is empty a file selection dialog is displayed
*
* \note Exporting to PDF requires QPrinter-support, if it is not available on your platform, this function will not be available either!
*/
void saveAsPDF(const QString& filename=QString(""), bool displayPreview=true);
#endif
/** \brief save the current plot as an image file, with the current widget aspect ratio, if filename is empty a file selection dialog is displayed.
* The image format is extracted from the file extension (jpeg, tiff, png, pdf, ...) */
@ -1386,8 +1401,13 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject {
*/
void saveAsGerExcelCSV(const QString& filename=QString(""));
/** \brief print the current plot, if printer is \c nullptr a printer selection dialog is displayed */
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
/** \brief print the current plot, if printer is \c nullptr a printer selection dialog is displayed
*
* \note This function is only available on platforms with QPrinter support!
*/
void print(QPrinter* printer=nullptr, bool displayPreview=true);
#endif
/** \brief this method zooms the graph so that all plotted datapoints are visible.
*
@ -1662,6 +1682,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject {
* The implementation in here returns zero size!
*/
void getKeyExtent(JKQTPEnhancedPainter& painter, double *width, double *height, double *text_width=nullptr, double *text_height=nullptr, int *columns_count=nullptr, int* lines_count=nullptr);
/** \brief show the print preview window for a given print \a p */
bool printpreviewNew(QPaintDevice* paintDevice, bool setAbsolutePaperSize=false, double printsizeX_inMM=-1.0, double printsizeY_inMM=-1.0, bool displayPreview=true);
@ -1687,6 +1708,8 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject {
* \internal
*/
void updatePreviewLabel();
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
/** \brief internal function for print preview
* \internal
*/
@ -1694,15 +1717,12 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject {
/** \brief internal function for print preview
* \internal
*/
void printpreviewPaintRequestedNew(QPrinter *printer);
void printpreviewPaintRequestedNewPrinter(QPrinter *printer);
#endif
/** \brief internal function for print preview
* \internal
*/
void printpreviewPaintRequestedNew(QPaintDevice *paintDevice);
/** \brief internal function for export preview
* \internal
*/
void exportpreviewPaintRequested(JKQTPEnhancedPainter& painter, QSize size);
void printpreviewPaintRequestedNewPaintDevice(QPaintDevice *paintDevice);
/** \brief internal function for print preview
* \internal
*/
@ -1755,6 +1775,12 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject {
* \internal
*/
void printpreviewUpdate();
/** \brief internal function for export preview
* \internal
*/
void exportpreviewPaintRequested(JKQTPEnhancedPainter& painter, QSize size);
/** \brief internal function for getDataColumnsByUser()
* \internal
*/
@ -2069,14 +2095,16 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject {
QAction* actCopyPixelImage;
/** \brief QAction which triggers copying of the data to the clipboard in Matlab format */
QAction* actCopyMatlab;
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
/** \brief QAction which triggers the saving as PDF */
QAction* actSavePDF;
/** \brief QAction which triggers the saving as pixel image */
QAction* actSavePix;
/** \brief QAction which triggers the saving as Scalable Vector Graphics (SVG) */
QAction* actSaveSVG;
/** \brief QAction which triggers the printing */
QAction* actPrint;
#endif
/** \brief QAction which triggers the saving as pixel image */
QAction* actSavePix;
/** \brief QAction which triggers the saving as CSV (data only) */
QAction* actSaveCSV;
/** \brief QAction which triggers zoom all */
@ -2126,7 +2154,9 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject {
double printSizeX_Millimeter;
double printSizeY_Millimeter;
double printMagnification;
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
QPointer<QPrintPreviewWidget> printPreview;
#endif
QPointer<JKQTPEnhancedDoubleSpinBox> spinSizeX;
QPointer<JKQTPEnhancedDoubleSpinBox> spinSizeY;
QPointer<QLabel> exportPreviewLabel;

View File

@ -1078,7 +1078,9 @@ void JKQTPlotter::initContextMenu()
contextMenu->addAction(plotter->getActionSaveData());
contextMenu->addAction(plotter->getActionSavePlot());
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
contextMenu->addAction(plotter->getActionPrint());
#endif
contextMenu->addSeparator();
contextMenu->addAction(plotter->getActionCopyPixelImage());
contextMenu->addAction(plotter->getActionCopyData());
@ -1616,7 +1618,9 @@ void JKQTPlotter::populateToolbar(QToolBar *toolbar) const
{
toolbar->addAction(plotter->getActionSaveData());
toolbar->addAction(plotter->getActionSavePlot());
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
toolbar->addAction(plotter->getActionPrint());
#endif
toolbar->addSeparator();
toolbar->addAction(plotter->getActionCopyPixelImage());
toolbar->addAction(plotter->getActionCopyData());
@ -1702,32 +1706,6 @@ void JKQTPlotter::openSpecialContextMenu(int x, int y)
{
//qDebug()<<"openSpecialContextMenu("<<x<<y<<menuSpecialContextMenu<<")";
if (menuSpecialContextMenu) {
/*
// reset the internal context menu ...
resetContextMenu(true);
// ... and add all actions from the special menu into the new menu: ...
for (int i=0; i<menuSpecialContextMenu->actions().size(); i++) {
//qDebug()<<" - "<<menuSpecialContextMenu->actions().at(i)->text();
contextMenu->addAction(menuSpecialContextMenu->actions().at(i));
}
// ... and copy the basic properties from the other menu
contextMenu->setIcon(menuSpecialContextMenu->icon());
contextMenu->setTitle(menuSpecialContextMenu->title());
contextMenu->setSeparatorsCollapsible(menuSpecialContextMenu->separatorsCollapsible());
contextMenu->setTearOffEnabled(menuSpecialContextMenu->isTearOffEnabled());
contextMenu->setToolTipsVisible(menuSpecialContextMenu->toolTipsVisible());
contextMenu->setFont(menuSpecialContextMenu->font());
contextMenu->setToolTip(menuSpecialContextMenu->toolTip());
contextMenu->setWhatsThis(menuSpecialContextMenu->whatsThis());
contextMenu->setWindowOpacity(menuSpecialContextMenu->windowOpacity());
mouseContextX=plotter->p2x(x/magnification);
mouseContextY=plotter->p2y((y-getPlotYOffset())/magnification);
contextMenu->popup(mapToGlobal(QPoint(x,y)));
contextMenu->resize(contextMenu->sizeHint());
//qDebug()<<" -> "<<mapToGlobal(QPoint(x,y))<<contextMenu->size()<<contextMenu->pos()<<contextMenu->parent();
emit contextMenuOpened(mouseContextX, mouseContextY, contextMenu);
//qDebug()<<"openSpecialContextMenu("<<x<<y<<contextMenu<<") ... DONE";
*/
mouseContextX=plotter->p2x(x/magnification);

View File

@ -1025,10 +1025,12 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPlotter: public QWidget {
plotter->saveData(filename, format);
}
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
/** \brief print the current plot, if printer is \c nullptr a printer selection dialog is displayed */
inline void print(QPrinter* printer=nullptr) {
plotter->print(printer);
}
#endif
/** \brief copy displayed data to cpliboard */
inline void copyData() {

View File

@ -0,0 +1,51 @@
#ifndef JKQTPLOTTER_CONFIGMACROS_H
#define JKQTPLOTTER_CONFIGMACROS_H
/*
Copyright (c) 2008-2022 Jan W. Krieger (<jan@jkrieger.de>)
last modification: $LastChangedDate: 2015-04-02 13:55:22 +0200 (Do, 02 Apr 2015) $ (revision $Rev: 3902 $)
This software is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License (LGPL) as published by
the Free Software Foundation, either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License (LGPL) for more details.
You should have received a copy of the GNU Lesser General Public License (LGPL)
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*! \def JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
\ingroup jkqtpplottersupprt
\brief This is defined if JKQtPlotter shall be compiled without print-support, or print-support is not available.
This can be used by surrounding code that is requires print-support with
\code
#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
// ...
// Code that require Print Support
// ...
#endif
\endcode
*/
#if defined(QT_NO_PRINTPREVIEWDIALOG) || defined(QT_NO_PRINTER) || defined(JKQTPLOTTER_HAS_NO_PRINTSUPPORT)
# define JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
#else
# ifdef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
# undef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
# endif
#endif
#endif // JKQTPLOTTER_CONFIGMACROS_H

View File

@ -31,14 +31,6 @@ Copyright (c) 2008-2020 Jan W. Krieger (<jan@jkrieger.de>)
#include <QKeyEvent>
#include <QAction>
#include <QLocale>
#include <QDialog>
#include <QCheckBox>
#include <QGridLayout>
#include <QLabel>
#include <QPrinter>
#include <QHeaderView>
#include <QPrintDialog>
#include <QDialogButtonBox>
#include <cstring>
#include <cstdlib>
#include <cstdio>