diff --git a/.gitignore b/.gitignore index 5fb4a67b32..2cec06d9ac 100644 --- a/.gitignore +++ b/.gitignore @@ -90,7 +90,5 @@ moc_predefs.h /lib/jkqtplotter/*.TMP /doc/doxygen_log.txt /doc/*.tmp -/staticlib/debug/*.prl -/staticlib/release/*.prl -/sharedlib/debug/jkqtplotterlib_debug.prl -/sharedlib/release/jkqtplotterlib.prl +*.prl +Sicherungskopie_* diff --git a/.travis.yml b/.travis.yml index fb36d1a500..cdb15ae319 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,7 +38,7 @@ script: - cd ${TRAVIS_BUILD_DIR} - cd doc - doxygen --version - - doxygen -d Markdown Doxyfile + - doxygen Doxyfile deploy: provider: pages diff --git a/JKQtPlotterBuildAllExamples.pro b/JKQtPlotterBuildAllExamples.pro index e86747d228..559f303dee 100644 --- a/JKQtPlotterBuildAllExamples.pro +++ b/JKQtPlotterBuildAllExamples.pro @@ -83,5 +83,6 @@ defineTest(addTest) { addTest(multiplot) addTest(user_interaction) +addTest(styling) #addTest(distributionplot) diff --git a/doc/Doxyfile b/doc/Doxyfile index 703b688b15..03bd8ca24c 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -419,7 +419,7 @@ INLINE_GROUPED_CLASSES = NO # Man pages) or section (for LaTeX and RTF). # The default value is: NO. -INLINE_SIMPLE_STRUCTS = NO +INLINE_SIMPLE_STRUCTS = YES # When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or # enum is documented as struct, union, or enum with the name of the typedef. So diff --git a/doc/dox/buildinstructions.dox b/doc/dox/buildinstructions.dox index f923aada6f..f9b2f3d52f 100644 --- a/doc/dox/buildinstructions.dox +++ b/doc/dox/buildinstructions.dox @@ -29,7 +29,9 @@ They will produce a static link library that you can include into your projects, \code{.qmake} # include JKQTPlotter library -DEPENDPATH += /lib +DEPENDPATH += \ + /lib \ + /staticlib INCLUDEPATH += /lib CONFIG (debug, debug|release) { LIBS += -L/staticlib/debug -ljkqtplotterlib_debug @@ -66,11 +68,13 @@ They will produce a dynamic link library that you can include into your projects \code{.qmake} # include JKQTPlotter library -DEPENDPATH += /lib +DEPENDPATH += \ + /lib \ + /sharedlib INCLUDEPATH += /lib CONFIG (debug, debug|release) { # ensure that DLLs are copied to the output directory - install_jkqtplotter_dll.files = /sharedlib/debu/jkqtplotterlib_debug.* + install_jkqtplotter_dll.files = /sharedlib/debug/jkqtplotterlib_debug.* install_jkqtplotter_dll.path = $$OUT_PWD INSTALLS += install_jkqtplotter_dll # link agains DLLs diff --git a/doc/dox/examples_and_tutorials.dox b/doc/dox/examples_and_tutorials.dox index e319fa042b..0d39b506c9 100644 --- a/doc/dox/examples_and_tutorials.dox +++ b/doc/dox/examples_and_tutorials.dox @@ -103,7 +103,7 @@ All test-projects are Qt-projects that use qmake to build. You can load them int `JKQTPColumnRGBMathImage`
image data copied from OpenCV cv::Mat-structure into three columns of the internal datastore - + \subsection jkqtp_extut_guitools GUI Tools diff --git a/doc/dox/jkqtplotter.dox b/doc/dox/jkqtplotter.dox index ff1c5fe47d..3a6fea2425 100644 --- a/doc/dox/jkqtplotter.dox +++ b/doc/dox/jkqtplotter.dox @@ -134,46 +134,46 @@ mainly used for the \ref jkqtplotter_imagelots "Image/Matrix graphs", but also b \ingroup jkqtplotter_graphsgroup \defgroup jkqtplotter_basegraphserrors Mix-In Classes for Error Indicators -\ingroup jkqtplotter_graphsgroup +\ingroup jkqtplotter_basegraphs \defgroup jkqtplotter_linesymbolgraphs Line/Symbol Graphs \ingroup jkqtplotter_graphsgroup This group assembles graphs that show their data with symbols and optionally with connecting lines in diferent styles: - - - - - - + + + + +
Screenshot - Classes -
\image html beeswarmplot_small.png - JKQTPSingleColumnSymbolsGraph -
\image html jkqtplotter_simpletest_symbols_and_styles_small.png - JKQTPXYLineGraph, JKQTPXYLineErrorGraph -
\image html jkqtplotter_simpletest_paramscatterplot_small.png - JKQTPXYParametrizedScatterGraph, JKQTPXYParametrizedErrorScatterGraph -
\image html jkqtplotter_simpletest_stepplots_small.png - JKQTPStepHorizontalGraph, JKQTPStepVerticalGraph +
Screenshot + Classes +
\image html beeswarmplot_small.png + JKQTPSingleColumnSymbolsGraph +
\image html jkqtplotter_simpletest_symbols_and_styles_small.png + JKQTPXYLineGraph, JKQTPXYLineErrorGraph +
\image html jkqtplotter_simpletest_paramscatterplot_small.png + JKQTPXYParametrizedScatterGraph, JKQTPXYParametrizedErrorScatterGraph +
\image html jkqtplotter_simpletest_stepplots_small.png + JKQTPStepHorizontalGraph, JKQTPStepVerticalGraph
\defgroup jkqtplotter_linesymbolgraphs_simple Basic Line/Scatter Graphs \ingroup jkqtplotter_linesymbolgraphs - - - - - + + + +
Screenshot - Classes -
\image html beeswarmplot_small.png - JKQTPSingleColumnSymbolsGraph -
\image html jkqtplotter_simpletest_symbols_and_styles_small.png - JKQTPXYLineGraph, JKQTPXYLineErrorGraph -
\image html jkqtplotter_simpletest_stepplots_small.png - JKQTPStepHorizontalGraph, JKQTPStepVerticalGraph +
Screenshot + Classes +
\image html beeswarmplot_small.png + JKQTPSingleColumnSymbolsGraph +
\image html jkqtplotter_simpletest_symbols_and_styles_small.png + JKQTPXYLineGraph, JKQTPXYLineErrorGraph +
\image html jkqtplotter_simpletest_stepplots_small.png + JKQTPStepHorizontalGraph, JKQTPStepVerticalGraph
@@ -181,129 +181,129 @@ This group assembles graphs that show their data with symbols and optionally wit \ingroup jkqtplotter_linesymbolgraphs - - - + +
Screenshot - Classes -
\image html jkqtplotter_simpletest_paramscatterplot_small.png - JKQTPXYParametrizedScatterGraph, JKQTPXYParametrizedErrorScatterGraph +
Screenshot + Classes +
\image html jkqtplotter_simpletest_paramscatterplot_small.png + JKQTPXYParametrizedScatterGraph, JKQTPXYParametrizedErrorScatterGraph
\defgroup jkqtplotter_filledgraphs Filled Polygon/Area Graphs \ingroup jkqtplotter_graphsgroup - - - - - + + + +
Screenshot - Classes -
\image html jkqtplotter_simpletest_filledgraphs_small.png - JKQTPFilledCurveXGraph, JKQTPFilledCurveYGraph -
\image html plot_filledcurvexerrorplots_small.png - JKQTPFilledCurveXErrorGraph, JKQTPFilledCurveYErrorGraph -
\image html JKQTPfilledVerticalRangeGraph_WithLines_small.png - JKQTPFilledVerticalRangeGraph +
Screenshot + Classes +
\image html jkqtplotter_simpletest_filledgraphs_small.png + JKQTPFilledCurveXGraph, JKQTPFilledCurveYGraph +
\image html plot_filledcurvexerrorplots_small.png + JKQTPFilledCurveXErrorGraph, JKQTPFilledCurveYErrorGraph +
\image html JKQTPfilledVerticalRangeGraph_WithLines_small.png + JKQTPFilledVerticalRangeGraph
\defgroup jkqtplotter_functiongraphs Function Graphs \ingroup jkqtplotter_linesymbolgraphs - - - + +
Screenshot - Classes -
\image html jkqtplotter_simpletest_functionplot_small.png - JKQTPXParsedFunctionLineGraph, JKQTPYParsedFunctionLineGraph +
Screenshot + Classes +
\image html jkqtplotter_simpletest_functionplot_small.png + JKQTPXParsedFunctionLineGraph, JKQTPYParsedFunctionLineGraph
\defgroup jkqtplotter_parsedFgraphs Parsed Function Graphs \ingroup jkqtplotter_linesymbolgraphs - - - + +
Screenshot - Classes -
\image html jkqtplotter_simpletest_functionplot_small.png - JKQTPXFunctionLineGraph, JKQTPYFunctionLineGraph +
Screenshot + Classes +
\image html jkqtplotter_simpletest_functionplot_small.png + JKQTPXFunctionLineGraph, JKQTPYFunctionLineGraph
\defgroup jkqtplotter_barssticks Barcharts, Impulse-Charts, ... \ingroup jkqtplotter_graphsgroup - - - - - - - + + + + + +
Screenshot - Classes -
\image html jkqtplotter_simpletest_barchart_small.png - JKQTPBarVerticalGraph, JKQTPBarHorizontalGraph -
\image html barchart_error_small.png - JKQTPBarVerticalErrorGraph, JKQTPBarHorizontalErrorGraph -
\image html JKQTPbarVerticalGraphStacked_small.png - JKQTPBarVerticalStackableGraph, JKQTPBarHorizontalStackableGraph -
\image html jkqtplotter_simpletest_impulsesplot_small.png - JKQTPImpulsesHorizontalGraph, JKQTPImpulsesVerticalGraph -
\image html impulses_errors_small.png - JKQTPImpulsesHorizontalErrorGraph, JKQTPImpulsesVerticalErrorGraph +
Screenshot + Classes +
\image html jkqtplotter_simpletest_barchart_small.png + JKQTPBarVerticalGraph, JKQTPBarHorizontalGraph +
\image html barchart_error_small.png + JKQTPBarVerticalErrorGraph, JKQTPBarHorizontalErrorGraph +
\image html JKQTPbarVerticalGraphStacked_small.png + JKQTPBarVerticalStackableGraph, JKQTPBarHorizontalStackableGraph +
\image html jkqtplotter_simpletest_impulsesplot_small.png + JKQTPImpulsesHorizontalGraph, JKQTPImpulsesVerticalGraph +
\image html impulses_errors_small.png + JKQTPImpulsesHorizontalErrorGraph, JKQTPImpulsesVerticalErrorGraph
\defgroup jkqtplotter_statgraphs Statistical Graphs (e.g. Boxplots ...) \ingroup jkqtplotter_graphsgroup - - - + +
Screenshot - Classes -
\image html jkqtplotter_simpletest_boxplot_small.png - JKQTPBoxplotVerticalGraph, JKQTPBoxplotHorizontalGraph +
Screenshot + Classes +
\image html jkqtplotter_simpletest_boxplot_small.png + JKQTPBoxplotVerticalGraph, JKQTPBoxplotHorizontalGraph
\defgroup jkqtplotter_geoplots Geometric Elements (Lines, Rectangles, ...) \ingroup jkqtplotter_graphsgroup - - - - - - - - - - - - + + + + + + + + + + +
Screenshot - Classes -
\image html symbol_symbol_filled_diamond.png - JKQTPGeoSymbol -
\image html geo_text_small.png - JKQTPGeoText -
\image html geo_line_small.png - JKQTPGeoLine, JKQTPGeoInfiniteLine, JKQTPGeoPolyLines -
\image html geo_rect_small.png - JKQTPGeoRectangle -
\image html geo_polygon_small.png - JKQTPGeoPolygon -
\image html geo_ellipse_small.png - JKQTPGeoEllipse -
\image html geo_arc_small.png - JKQTPGeoArc -
\image html geo_pie_small.png - JKQTPGeoPie -
\image html geo_chords_small.png - JKQTPGeoChord -
\image html geo_boxplot_small.png - JKQTPBoxplotVerticalElement, JKQTPBoxplotHorizontalElement +
Screenshot + Classes +
\image html symbol_symbol_filled_diamond.png + JKQTPGeoSymbol +
\image html geo_text_small.png + JKQTPGeoText +
\image html geo_line_small.png + JKQTPGeoLine, JKQTPGeoInfiniteLine, JKQTPGeoPolyLines +
\image html geo_rect_small.png + JKQTPGeoRectangle +
\image html geo_polygon_small.png + JKQTPGeoPolygon +
\image html geo_ellipse_small.png + JKQTPGeoEllipse +
\image html geo_arc_small.png + JKQTPGeoArc +
\image html geo_pie_small.png + JKQTPGeoPie +
\image html geo_chords_small.png + JKQTPGeoChord +
\image html geo_boxplot_small.png + JKQTPBoxplotVerticalElement, JKQTPBoxplotHorizontalElement
Examples: @@ -314,42 +314,42 @@ Examples: \ingroup jkqtplotter_graphsgroup - - - - + + +
Screenshot - Classes -
\image html JKQTPHorizontalRange_small.png - JKQTPHorizontalRange, JKQTPVerticalRange -
\image html JKQTPPeakStreamGraphY_small.png - JKQTPPeakStreamGraph +
Screenshot + Classes +
\image html JKQTPHorizontalRange_small.png + JKQTPHorizontalRange, JKQTPVerticalRange +
\image html JKQTPPeakStreamGraphY_small.png + JKQTPPeakStreamGraph
\defgroup jkqtplotter_imagelots Matrix/Image Plotting \ingroup jkqtplotter_graphsgroup - - - - - - - - + + + + + + +
Screenshot - Classes -
\image html jkqtplotter_simpletest_rgbimageplot_qt_small.png - JKQTPImage -
\image html JKQTPMathImageBaseModifyNone_small.png - JKQTPMathImage, JKQTPColumnMathImage -
\image html rgbimageplots_small.png - JKQTPRGBMathImage, JKQTPColumnRGBMathImage -
\image html overlayimage_small.png - JKQTPOverlayImage -
\image html overlayimageenhanced_small.png - JKQTPOverlayImageEnhanced, JKQTPColumnOverlayImageEnhanced -
\image html JKQTPContour_small.png - JKQTPContour +
Screenshot + Classes +
\image html jkqtplotter_simpletest_rgbimageplot_qt_small.png + JKQTPImage +
\image html JKQTPMathImageBaseModifyNone_small.png + JKQTPMathImage, JKQTPColumnMathImage +
\image html rgbimageplots_small.png + JKQTPRGBMathImage, JKQTPColumnRGBMathImage +
\image html overlayimage_small.png + JKQTPOverlayImage +
\image html overlayimageenhanced_small.png + JKQTPOverlayImageEnhanced, JKQTPColumnOverlayImageEnhanced +
\image html JKQTPContour_small.png + JKQTPContour
\defgroup jkqtplotter_imagelots_elements Matrix/Image Graphs @@ -357,33 +357,33 @@ Examples: - - - - - + + + +
Screenshot - Classes -
\image html jkqtplotter_simpletest_rgbimageplot_qt_small.png - JKQTPImage -
\image html JKQTPMathImageBaseModifyNone_small.png - JKQTPMathImage, JKQTPColumnMathImage -
\image html jkqtplotter_simpletest_rgbimageplot_opencv_small.png - JKQTPRGBMathImage, JKQTPColumnRGBMathImage +
Screenshot + Classes +
\image html jkqtplotter_simpletest_rgbimageplot_qt_small.png + JKQTPImage +
\image html JKQTPMathImageBaseModifyNone_small.png + JKQTPMathImage, JKQTPColumnMathImage +
\image html jkqtplotter_simpletest_rgbimageplot_opencv_small.png + JKQTPRGBMathImage, JKQTPColumnRGBMathImage
\defgroup jkqtplotter_imagelots_overlays Image/Matrix Overlay Graphs \ingroup jkqtplotter_imagelots - - - - + + +
Screenshot - Classes -
\image html overlayimage_small.png - JKQTPOverlayImage -
\image html overlayimageenhanced_small.png - JKQTPOverlayImageEnhanced, JKQTPColumnOverlayImageEnhanced +
Screenshot + Classes +
\image html overlayimage_small.png + JKQTPOverlayImage +
\image html overlayimageenhanced_small.png + JKQTPOverlayImageEnhanced, JKQTPColumnOverlayImageEnhanced
\defgroup jkqtplotter_imagelots_tools Tool Functions & Classes for Image Drawing @@ -393,34 +393,104 @@ Examples: \ingroup jkqtplotter_imagelots - - - + +
Screenshot - Classes -
\image html JKQTPContour_small.png - JKQTPContour +
Screenshot + Classes +
\image html JKQTPContour_small.png + JKQTPContour
\defgroup jkqtplotter_overlays Overlay Elements \ingroup jkqtplotter_elements - - - - - + + + +
Screenshot - Classes -
- JKQTPOverlayVerticalLine, JKQTPOverlayLine -
- JKQTPOverlayVerticalRange -
- JKQTPOverlayRectangle +
Screenshot + Classes +
+ JKQTPOverlayVerticalLine, JKQTPOverlayLine +
+ JKQTPOverlayVerticalRange +
+ JKQTPOverlayRectangle
+\defgroup jkqtpplotter_styling JKQTPlotter Styling System +\ingroup jkqtplotter + +\image html stylesbanner.png + +JKQTPlotter (and JKQTBasePlotter) offer a styling system, which allows to easily define and transfer plot styling from one object to another. +The system is based on a hirarchy of structs, which summarize properties, describing how a plot looks in general. The classes contained in this system are: + - JKQTPlotterStyle for JKQTPlotter: Defines e.g. basic user-interactions, the display options of the toolbar + - JKQTBasePlotterStyle for JKQTBasePlotter defines the appearance of the plot itself (colors, axis properties, key properties, default graph colors/styles, ...), contains JKQTPCoordinateAxisStyle instances to configrue the plot's coordinate axes + - JKQTPCoordinateAxisStyle for JKQTPCoordinateAxis defines the appearance of a coordinate axis (colors, axis properties, ...) + - JKQTPKeyStyle for the style of the key/legend in a JKQTBasePlotterStyle +. + +In addition there are static methods that allow to manage a system-wide (actually program-instance wide) style that is applied to any new instance of JKQTPlotter and JKQTBasePlotter on construction: + - JKQTPGetSystemDefaultStyle() / JKQTPSetSystemDefaultStyle() allows to access the central instace of JKQTPlotterStyle (mainly properties/style of the GUI-parts and user-action bindings) + - JKQTPGetSystemDefaultBaseStyle() / JKQTPSetSystemDefaultBaseStyle() accesses the central instance of JKQTBasePlotterStyle (styles the actual plot/graphs with colors, axes styles, ...) +. + +You can e.g. use these general methods to alter the styles for all JKQTPlotter instances, created in the future: +\code{.cpp} + // load the system-wide default settings from an INI-file: + QSettings plotSettings("JKQTPlotterSettings.ini", QSettings::IniFormat);; + JKQTPGetSystemDefaultStyle().loadSettings(plotSettings); + JKQTPGetSystemDefaultBaseStyle().loadSettings(plotSettings); + + // alter a system-wide default setting by hand (here: set color of zooming rect to red) + JKQTPGetSystemDefaultStyle().userActionColor=QColor("red"); +\endcode + +Several pre-made styles are available in the JKQTPlotter repository (https://github.com/jkriege2/JKQtPlotter/tree/master/lib/jkqtplotterressources/styles/). +These are also linked into the JKQTPlotter library as Qt ressource into the subdirectory \c :/JKQTPlotter/styles/ . You can use them as follows: + +\code{.cpp} + QSettings plotSettings(":/JKQTPlotter/styles/blackandwhite.ini", QSettings::IniFormat);; + JKQTPGetSystemDefaultStyle().loadSettings(plotSettings); + JKQTPGetSystemDefaultBaseStyle().loadSettings(plotSettings); +\endcode + +Here is a table with all available ready-made styles: + + + + + + + + + +
Style-file + Screenshot +
The Default Style + \image html style_default.png +
\c :/JKQTPlotter/styles/simple_gridandticks.ini + \image html style_simple_axesoffset_plotbox.png +
\c :/JKQTPlotter/styles/simple_axesoffset.ini + \image html style_simple_axesoffset.png +
\c :/JKQTPlotter/styles/simple_axesoffset_plotbox.ini + \image html style_simple_axesoffset_plotbox.png +
\c :/JKQTPlotter/styles/dark.ini + \image html style_dark.png +
\c :/JKQTPlotter/styles/blueprint.ini + \image html style_blueprint.png +
\c :/JKQTPlotter/styles/blackandwhite.ini + \image html style_blackandwhite.png +
+ +\see For a detailed example, see \ref JKQTPlotterStyling + + + \defgroup jkqtpqtwidgetsttools Qt Widgets/Tools to work with JKQTPlotter \ingroup jkqtplotter diff --git a/doc/dox/license.dox b/doc/dox/license.dox index 734721aafb..012269176b 100644 --- a/doc/dox/license.dox +++ b/doc/dox/license.dox @@ -1,8 +1,13 @@ /*! -\page licensesec License Terms (LGPL >= 2.1) +\page licensepage Licensing Terms for JKQTPlotter -This software is licensed under the term of the GNU Lesser General Public License 2.1 -(LGPL 2.1) or above. +\tableofcontents + +\section licensesec JKQTPlotter/JKQTFastPlotter/JKQTMathText: LGPL >= 2.1 + +This software is licensed under the term of the +GNU Lesser +General Public License 2.1 (LGPL 2.1) or above. \verbatim GNU LESSER GENERAL PUBLIC LICENSE @@ -71,7 +76,7 @@ any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser +ordinary GNU Lesser General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those @@ -218,14 +223,14 @@ the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, +that they refer to the ordinary GNU Lesser General Public License, version 2, instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify +ordinary GNU Lesser General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all +that copy, so the ordinary GNU Lesser General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of @@ -513,4 +518,42 @@ That's all there is to it! \endverbatim + + +\section extlicense_sec Licenses of 3rd Party Products Contained in JKQTPlotter + +JKQTPlotter is mostly self-conatined. The only exceptions are listed below + +\subsection extlicense_xits XITS Fonts for JKQTMathText +JKQTMathText comes prepackaged with the XITS fonts from https://www.stixfonts.org/. With these it can produceh +high-quality math rendering. It is possible to use the class with other fonts, but XITS is highly recommended. XITS fonts are licensed as follows: + +\verbatim + XITS is a Times-like typeface for mathematical and scientific publishing, + based on STIX fonts (https://www.stixfonts.org/). The main mission of XITS + is to provide a version of STIX fonts enriched with the OpenType MATH extension, + making it suitable for high quality mathematic typesetting with OpenType MATH + capable layout systems, like MS Office 2007 and the new TeX engines XeTeX and + LuaTeX. + + XITS font is free, open source font, under Open Font License + (https://scripts.sil.org/OFL), version 1.1. + + The current version of XITS is based on version 1.1.0-beta1 of STIX fonts. + + This is work in progress, feedback, bug reports and even patches are welcomed. +\endverbatim + +The source for this library can be found here: https://github.com/alif-type/xits + +\note The XITS fonts are distributed in + lib/jkqtplotterressources/math_fonts/xits + and are automatically added to the binary libraries as Qt Resources. You can prevent this by adding the line + \code + DEFINES += NO_XITS_FONTS + \endcode + To the QMake project that you use to build the JKQTPlotter/JKQTMathText libraries (see the ready-made \c .pro -files for static and dynamic libs, which + already contain this line, but commented out. QMake will tell you with a message whether XITS is linked in or not. + + */ \ No newline at end of file diff --git a/doc/dox/mainpage.dox b/doc/dox/mainpage.dox index 10f84ca334..2812a5b5c8 100644 --- a/doc/dox/mainpage.dox +++ b/doc/dox/mainpage.dox @@ -5,7 +5,7 @@ This is an extensive library of function/data plotter classes for Qt (>= 4.7, te 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. - + \image html examplesbanner.png \section jkqtp_main_features Main Features @@ -16,7 +16,7 @@ This software is licensed under the term of the GNU Lesser General Public Licens - 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, ...)" - \ref jkqtbaseplotter_dataexport_print "full print and export (PDF,PNG,...) support with preview and parametrization out-the-box " - - highly customizable look and feel + - \ref jkqtpplotter_styling "highly customizable look and feel (styling system)" - \ref JKQTBASEPLOTTER_SYNCMULTIPLOT "supports the Qt layout system for graphs and allows to symchronize several graphs with each other " - \ref jkqtpdatastorage "centralized data management in an internal datastore)": - data organized by columns, can also represent image data (row-major) diff --git a/doc/dox/whatsnew.dox b/doc/dox/whatsnew.dox index 797469ab77..cd8a6a7dd1 100644 --- a/doc/dox/whatsnew.dox +++ b/doc/dox/whatsnew.dox @@ -6,7 +6,7 @@ This page lists release notes for the diferent version of JKQTPlotter \tableofcontents - + \section WHATSNEW_TRUNK trunk: Major Update/Refactoring @@ -23,23 +23,36 @@ Changes, compared to \ref WHATSNEW_V2018_08 "v2018.08" include:
  • update: massively improved (doxygen-generated) Online-Documentation (http://jkriege2.github.io/JKQtPlotter/index.html) (automatically generated after each commit using ravis CI)
  • new: checked builds with continuous integration from AppVeyor: https://ci.appveyor.com/project/jkriege2/jkqtplotter/branch/master
  • new/update: support for building with Microsoft Visual Studio (Win), MinGW (Win), GCC (Linux/MacOS)
  • +
  • changed: using static const variables instead of \c #define for fixed default values (e.g. JKQTPImageTools::LUTSIZE, JKQTPImageTools::PALETTE_ICON_WIDTH, JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, JKQTMathText::ABS_MIN_LINEWIDTH ...)
  • Updates to JKQTPlotter:
    • update: \ref JKQTPLOTTER_USERINTERACTION "reworked user interactions API"
    • new: added JKQTPSingleColumnSymbolsGraph for single-column data, e.g. drawn as (random) scatter or bee-swar plots
    • new: stacked barcharts with JKQTPBarVerticalStackableGraph, JKQTPBarHorizontalStackableGraph
    • deprecated: Removed datarange-feature
    • -
    • new: use/support of C++11 features (e.g. \c std::function<> in JKQTPXFunctionLineGraph / JKQTPYFunctionLineGraph
    • +
    • new: use/support of C++11 features (e.g. \c std::function<> and lambda functions in JKQTPXFunctionLineGraph / JKQTPYFunctionLineGraph )
    • new: \ref jkqtpopencvinterface "optional OpenCV interface"
    • +
    • new: \ref jkqtpplotter_styling "Styling System for JKQTPlotter"
    • +
    • new: added debugging option, which surrounds different regions with visible rectangles (JKQTBasePlotter::enableDebugShowRegionBoxes() )
    • +
    • fixed: colorbars at top were positioned over the plot label
    • +
    • new: frames (plot viewport, key/legend ...) may be rounded off at the corners
    • +
    • new: diverse new styling options (default font name/size ...)
    • +
    • new: additionl options for styling coordinate axes
  • -
  • update/fix: several improvements and bugfixes to JKQTMathText
  • - +
  • Updates to JKQTMathText: +
      +
    • update/fix: several general improvements and bugfixes
    • +
    • update/fix: improved error handling
    • +
    • update: updated contained version of STIX fonts, better handling of different STIX versions
    • +
  • + \subsection WHATSNEW_TRUNK_DOWNLOAD trunk: Download This release is available from: - - Source code branch: https://github.com/jkriege2/JKQtPlotter/tree/v2018.08 - - Latest Release/Tag: https://github.com/jkriege2/JKQtPlotter/releases/tag/v2018.08 (2018-Aug-19) + - Source code branch: https://github.com/jkriege2/JKQtPlotter + - Source Code download (ZIP): https://github.com/jkriege2/JKQtPlotter/archive/master.zip + - Git-Link: https://github.com/jkriege2/JKQtPlotter.git . diff --git a/doc/images/plot_rotated_labels.png b/doc/images/plot_rotated_labels.png new file mode 100644 index 0000000000..522dfa980e Binary files /dev/null and b/doc/images/plot_rotated_labels.png differ diff --git a/doc/images/plot_rotated_labelsy.png b/doc/images/plot_rotated_labelsy.png new file mode 100644 index 0000000000..c4778f5e92 Binary files /dev/null and b/doc/images/plot_rotated_labelsy.png differ diff --git a/doc/images/plot_widget_orientation.cdr b/doc/images/plot_widget_orientation.cdr new file mode 100644 index 0000000000..5e0bad27be Binary files /dev/null and b/doc/images/plot_widget_orientation.cdr differ diff --git a/doc/images/plot_widget_orientation.png b/doc/images/plot_widget_orientation.png index 4042322ebc..f177eb202b 100644 Binary files a/doc/images/plot_widget_orientation.png and b/doc/images/plot_widget_orientation.png differ diff --git a/doc/images/plot_widget_orientation.svg b/doc/images/plot_widget_orientation.svg deleted file mode 100644 index 7730e90949..0000000000 --- a/doc/images/plot_widget_orientation.svg +++ /dev/null @@ -1,182 +0,0 @@ - - - - - - - - - - - image/svg+xml - - - - - - - - widgetWidth - widgetHeight - plotWidth - plotHeight - plotBorderLeft - plotBorderRight - plotBorderTop - plotBorderBottom - - - - - - diff --git a/examples/jkqtfastplotter_test/jkqtfastplotter_test.pro b/examples/jkqtfastplotter_test/jkqtfastplotter_test.pro index a2e4c5bb34..53c0a9aa53 100644 --- a/examples/jkqtfastplotter_test/jkqtfastplotter_test.pro +++ b/examples/jkqtfastplotter_test/jkqtfastplotter_test.pro @@ -29,7 +29,7 @@ DEFINES += DEBUG_TIMING greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport # include JKQTPlotter library -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug diff --git a/examples/jkqtmathtext_simpletest/jkqtmathtext_simpletest.pro b/examples/jkqtmathtext_simpletest/jkqtmathtext_simpletest.pro index 5c05b70cae..9cfe5384f3 100644 --- a/examples/jkqtmathtext_simpletest/jkqtmathtext_simpletest.pro +++ b/examples/jkqtmathtext_simpletest/jkqtmathtext_simpletest.pro @@ -8,7 +8,7 @@ QT += core gui xml svg greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug diff --git a/examples/jkqtmathtext_test/jkqtmathtext_test.pro b/examples/jkqtmathtext_test/jkqtmathtext_test.pro index 0c5a266cd1..495e428b22 100644 --- a/examples/jkqtmathtext_test/jkqtmathtext_test.pro +++ b/examples/jkqtmathtext_test/jkqtmathtext_test.pro @@ -35,7 +35,7 @@ DEFINES += AUTOLOAD_XITS_FONTS AUTOLOAD_Asana_FONTS greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug diff --git a/examples/jkqtplot_test/EmfEngine/src/EmfEngine.cpp b/examples/jkqtplot_test/EmfEngine/src/EmfEngine.cpp index 3e84eafda4..1eedf3622b 100644 --- a/examples/jkqtplot_test/EmfEngine/src/EmfEngine.cpp +++ b/examples/jkqtplot_test/EmfEngine/src/EmfEngine.cpp @@ -12,7 +12,7 @@ * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 3 of the License, or * + * 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, * diff --git a/examples/jkqtplot_test/EmfEngine/src/EmfEngine.h b/examples/jkqtplot_test/EmfEngine/src/EmfEngine.h index 945b5df281..ab215f1064 100644 --- a/examples/jkqtplot_test/EmfEngine/src/EmfEngine.h +++ b/examples/jkqtplot_test/EmfEngine/src/EmfEngine.h @@ -12,7 +12,7 @@ * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 3 of the License, or * + * 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, * diff --git a/examples/jkqtplot_test/EmfEngine/src/EmfPaintDevice.cpp b/examples/jkqtplot_test/EmfEngine/src/EmfPaintDevice.cpp index efcee0999b..397f922ae7 100644 --- a/examples/jkqtplot_test/EmfEngine/src/EmfPaintDevice.cpp +++ b/examples/jkqtplot_test/EmfEngine/src/EmfPaintDevice.cpp @@ -12,7 +12,7 @@ * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 3 of the License, or * + * 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, * diff --git a/examples/jkqtplot_test/QTeXEngine/src/QTeXEngine.h b/examples/jkqtplot_test/QTeXEngine/src/QTeXEngine.h index 8fd55e22cf..ef9f4faeca 100644 --- a/examples/jkqtplot_test/QTeXEngine/src/QTeXEngine.h +++ b/examples/jkqtplot_test/QTeXEngine/src/QTeXEngine.h @@ -11,7 +11,7 @@ * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 3 of the License, or * + * 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, * diff --git a/examples/jkqtplot_test/QTeXEngine/src/QTeXPaintDevice.cpp b/examples/jkqtplot_test/QTeXEngine/src/QTeXPaintDevice.cpp index e42630abe0..da5dedee36 100644 --- a/examples/jkqtplot_test/QTeXEngine/src/QTeXPaintDevice.cpp +++ b/examples/jkqtplot_test/QTeXEngine/src/QTeXPaintDevice.cpp @@ -11,7 +11,7 @@ * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 3 of the License, or * + * 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, * diff --git a/examples/jkqtplot_test/QTeXEngine/src/QTeXPaintEngine.cpp b/examples/jkqtplot_test/QTeXEngine/src/QTeXPaintEngine.cpp index 8fcc1dfea5..606cfabc1a 100644 --- a/examples/jkqtplot_test/QTeXEngine/src/QTeXPaintEngine.cpp +++ b/examples/jkqtplot_test/QTeXEngine/src/QTeXPaintEngine.cpp @@ -11,7 +11,7 @@ * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 3 of the License, or * + * 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, * diff --git a/examples/jkqtplot_test/TestWidgetContourPlots.h b/examples/jkqtplot_test/TestWidgetContourPlots.h index ca6bb7d522..59ff8f8d67 100644 --- a/examples/jkqtplot_test/TestWidgetContourPlots.h +++ b/examples/jkqtplot_test/TestWidgetContourPlots.h @@ -13,6 +13,7 @@ #include "jkqtplotter/jkqtplotter.h" #include "jkqtplotter/jkqtpgraphsgeometric.h" #include "jkqtplotter/jkqtpgraphsimage.h" +#include "jkqtplotter/jkqtpgraphscontour.h" #include "jkqtplotter/jkqtpelementsoverlay.h" #include "jkqtplotter/jkqtpgraphsparsedfunction.h" #include "jkqtplotter/jkqtpbaseelements.h" diff --git a/examples/jkqtplot_test/TestWidgetImages.cpp b/examples/jkqtplot_test/TestWidgetImages.cpp index 31c3157a22..1eccc1aa9a 100644 --- a/examples/jkqtplot_test/TestWidgetImages.cpp +++ b/examples/jkqtplot_test/TestWidgetImages.cpp @@ -4,6 +4,9 @@ #include #include #include "jkqtplottergui/jkqtpcomboboxes.h" +#include "jkqtplotter/jkqtpgraphsimageoverlays.h" +#include "jkqtplotter/jkqtpgraphsimagergb.h" + diff --git a/examples/jkqtplot_test/TestWidgetRGBImages.h b/examples/jkqtplot_test/TestWidgetRGBImages.h index aab8cb8c44..5bfb2ec8f0 100644 --- a/examples/jkqtplot_test/TestWidgetRGBImages.h +++ b/examples/jkqtplot_test/TestWidgetRGBImages.h @@ -13,6 +13,7 @@ #include "jkqtplotter/jkqtplotter.h" #include "jkqtplotter/jkqtpgraphsgeometric.h" #include "jkqtplotter/jkqtpgraphsimage.h" +#include "jkqtplotter/jkqtpgraphsimagergb.h" #include "jkqtplotter/jkqtpelementsoverlay.h" #include "jkqtplotter/jkqtpgraphsparsedfunction.h" #include "jkqtplotter/jkqtpbaseelements.h" diff --git a/examples/jkqtplot_test/jkqtplot_test.pro b/examples/jkqtplot_test/jkqtplot_test.pro index 146362c6f3..4930b84025 100644 --- a/examples/jkqtplot_test/jkqtplot_test.pro +++ b/examples/jkqtplot_test/jkqtplot_test.pro @@ -70,6 +70,6 @@ CONFIG (debug, debug|release) { message("LIBS = $$LIBS") -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + diff --git a/examples/simpletest/README.md b/examples/simpletest/README.md index dcbcc53f12..a4218e7d02 100644 --- a/examples/simpletest/README.md +++ b/examples/simpletest/README.md @@ -14,7 +14,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport TARGET = jkqtplotter_simpletest # include JKQTPlotter source headers and link against library -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug diff --git a/examples/simpletest/jkqtplotter_simpletest.pro b/examples/simpletest/jkqtplotter_simpletest.pro index fa3e13f58e..d18f67bace 100644 --- a/examples/simpletest/jkqtplotter_simpletest.pro +++ b/examples/simpletest/jkqtplotter_simpletest.pro @@ -10,7 +10,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport TARGET = jkqtplotter_simpletest # include JKQTPlotter source headers and link against library -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug @@ -21,6 +21,6 @@ message("LIBS = $$LIBS") win32-msvc*: DEFINES += _USE_MATH_DEFINES -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + diff --git a/examples/simpletest_barchart/jkqtplotter_simpletest_barchart.pro b/examples/simpletest_barchart/jkqtplotter_simpletest_barchart.pro index 61cb167ee8..094bc9b68a 100644 --- a/examples/simpletest_barchart/jkqtplotter_simpletest_barchart.pro +++ b/examples/simpletest_barchart/jkqtplotter_simpletest_barchart.pro @@ -10,7 +10,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport TARGET = jkqtplotter_simpletest_barchart # include JKQTPlotter source code -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug @@ -20,6 +20,6 @@ CONFIG (debug, debug|release) { message("LIBS = $$LIBS") -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + diff --git a/examples/simpletest_boxplot/jkqtplotter_simpletest_boxplot.pro b/examples/simpletest_boxplot/jkqtplotter_simpletest_boxplot.pro index 527fc862c3..3a8f61704d 100644 --- a/examples/simpletest_boxplot/jkqtplotter_simpletest_boxplot.pro +++ b/examples/simpletest_boxplot/jkqtplotter_simpletest_boxplot.pro @@ -10,7 +10,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport TARGET = jkqtplotter_simpletest_boxplot # include JKQTPlotter source code -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug @@ -20,6 +20,6 @@ CONFIG (debug, debug|release) { message("LIBS = $$LIBS") -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + diff --git a/examples/simpletest_dateaxes/jkqtplotter_simpletest_dateaxes.pro b/examples/simpletest_dateaxes/jkqtplotter_simpletest_dateaxes.pro index 78c49f5f87..9dd83cba8c 100644 --- a/examples/simpletest_dateaxes/jkqtplotter_simpletest_dateaxes.pro +++ b/examples/simpletest_dateaxes/jkqtplotter_simpletest_dateaxes.pro @@ -10,7 +10,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport TARGET = jkqtplotter_simpletest_dateaxes # include JKQTPlotter source code -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug @@ -20,9 +20,9 @@ CONFIG (debug, debug|release) { message("LIBS = $$LIBS") -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + RESOURCES += \ jkqtplotter_simpletest_dateaxes.qrc diff --git a/examples/simpletest_errorbarstyles/jkqtplotter_simpletest_errorbarstyles.pro b/examples/simpletest_errorbarstyles/jkqtplotter_simpletest_errorbarstyles.pro index 188f63b2e4..cd9fe66abe 100644 --- a/examples/simpletest_errorbarstyles/jkqtplotter_simpletest_errorbarstyles.pro +++ b/examples/simpletest_errorbarstyles/jkqtplotter_simpletest_errorbarstyles.pro @@ -10,7 +10,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport TARGET = jkqtplotter_simpletest_errorbarstyles # include JKQTPlotter source code -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug @@ -19,6 +19,6 @@ CONFIG (debug, debug|release) { } message("LIBS = $$LIBS") -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + diff --git a/examples/simpletest_filledgraphs/jkqtplotter_simpletest_filledgraphs.pro b/examples/simpletest_filledgraphs/jkqtplotter_simpletest_filledgraphs.pro index aa50d3c6e6..bd45664067 100644 --- a/examples/simpletest_filledgraphs/jkqtplotter_simpletest_filledgraphs.pro +++ b/examples/simpletest_filledgraphs/jkqtplotter_simpletest_filledgraphs.pro @@ -13,7 +13,7 @@ TARGET = jkqtplotter_simpletest_filledgraphs # include JKQTPlotter source code -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug @@ -23,6 +23,6 @@ CONFIG (debug, debug|release) { message("LIBS = $$LIBS") -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + diff --git a/examples/simpletest_functionplot/jkqtplotter_simpletest_functionplot.pro b/examples/simpletest_functionplot/jkqtplotter_simpletest_functionplot.pro index 832f437c1e..9f3375270b 100644 --- a/examples/simpletest_functionplot/jkqtplotter_simpletest_functionplot.pro +++ b/examples/simpletest_functionplot/jkqtplotter_simpletest_functionplot.pro @@ -11,7 +11,7 @@ TARGET = jkqtplotter_simpletest_functionplot # include JKQTPlotter source code -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug @@ -22,6 +22,6 @@ message("LIBS = $$LIBS") win32-msvc*: DEFINES += _USE_MATH_DEFINES -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + diff --git a/examples/simpletest_geometric/README.md b/examples/simpletest_geometric/README.md index 050c218118..7b42efd989 100644 --- a/examples/simpletest_geometric/README.md +++ b/examples/simpletest_geometric/README.md @@ -1,7 +1,7 @@ # Example (JKQTPlotter): Plotting Geometric Objects {#JKQTPlotterGeometricGraphs} This project (see `./test/simpletest_geometric/`) shows the capabilities of JKQTPlotter to also draw geometric elements, like circles, ellipses, rectangles etc. -The source code of the main application can be found in [`jkqtplotter_simpletest_geometric.cpp`](https://github.com/jkriege2/JKQtPlotter/tree/master/examples/simpletest_geometric/jkqtplotter_simpletest_geometric.cpp). First a plot is generated and the axis aspect ration is set to 1, so an accurate plot is generated. Then several geometric graphs are added to the plot. Here are some examples, you can find more more examples in the source code of the example: +The source code of the main application can be found in [`jkqtplotter_simpletest_geometric.cpp`](https://github.com/jkriege2/JKQtPlotter/tree/master/examples/simpletest_geometric/jkqtplotter_simpletest_geometric.cpp). First a plot is generated and the axis aspect ratio is set to 1, so an accurate plot is generated. Then several geometric graphs are added to the plot. Here are some examples, you can find more more examples in the source code of the example: ```.cpp // a text element diff --git a/examples/simpletest_geometric/jkqtplotter_simpletest_geometric.pro b/examples/simpletest_geometric/jkqtplotter_simpletest_geometric.pro index 17d5d12c5c..8b1193dc1a 100644 --- a/examples/simpletest_geometric/jkqtplotter_simpletest_geometric.pro +++ b/examples/simpletest_geometric/jkqtplotter_simpletest_geometric.pro @@ -10,7 +10,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport TARGET = jkqtplotter_simpletest_geometric # include JKQTPlotter source code -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug @@ -20,6 +20,6 @@ CONFIG (debug, debug|release) { message("LIBS = $$LIBS") -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + diff --git a/examples/simpletest_imageplot/jkqtplotter_simpletest_imageplot.pro b/examples/simpletest_imageplot/jkqtplotter_simpletest_imageplot.pro index f0d955ca3d..de1967ca09 100644 --- a/examples/simpletest_imageplot/jkqtplotter_simpletest_imageplot.pro +++ b/examples/simpletest_imageplot/jkqtplotter_simpletest_imageplot.pro @@ -10,7 +10,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport TARGET = jkqtplotter_simpletest_imageplot # include JKQTPlotter source code -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug @@ -20,6 +20,6 @@ CONFIG (debug, debug|release) { message("LIBS = $$LIBS") -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + diff --git a/examples/simpletest_imageplot_modifier/jkqtplotter_simpletest_imageplot_modifier.pro b/examples/simpletest_imageplot_modifier/jkqtplotter_simpletest_imageplot_modifier.pro index 1e0bb44246..79d790ed37 100644 --- a/examples/simpletest_imageplot_modifier/jkqtplotter_simpletest_imageplot_modifier.pro +++ b/examples/simpletest_imageplot_modifier/jkqtplotter_simpletest_imageplot_modifier.pro @@ -10,7 +10,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport TARGET = jkqtplotter_simpletest_imageplot_modifier # include JKQTPlotter source code -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug @@ -20,6 +20,6 @@ CONFIG (debug, debug|release) { message("LIBS = $$LIBS") -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + diff --git a/examples/simpletest_imageplot_nodatastore/jkqtplotter_simpletest_imageplot_nodatastore.pro b/examples/simpletest_imageplot_nodatastore/jkqtplotter_simpletest_imageplot_nodatastore.pro index 4108d93e1c..65849f207e 100644 --- a/examples/simpletest_imageplot_nodatastore/jkqtplotter_simpletest_imageplot_nodatastore.pro +++ b/examples/simpletest_imageplot_nodatastore/jkqtplotter_simpletest_imageplot_nodatastore.pro @@ -12,7 +12,7 @@ QT += core gui xml svg greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport # include JKQTPlotter source code -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug @@ -22,6 +22,6 @@ CONFIG (debug, debug|release) { message("LIBS = $$LIBS") -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + diff --git a/examples/simpletest_imageplot_opencv/jkqtplotter_simpletest_imageplot_opencv.pro b/examples/simpletest_imageplot_opencv/jkqtplotter_simpletest_imageplot_opencv.pro index 8d88220737..15c459c35d 100644 --- a/examples/simpletest_imageplot_opencv/jkqtplotter_simpletest_imageplot_opencv.pro +++ b/examples/simpletest_imageplot_opencv/jkqtplotter_simpletest_imageplot_opencv.pro @@ -14,9 +14,9 @@ DEFINES += JKQTPLOTTER_OPENCV_INTERFACE -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + # link agains OpenCV-3.4.1 diff --git a/examples/simpletest_impulsesplot/jkqtplotter_simpletest_impulsesplot.pro b/examples/simpletest_impulsesplot/jkqtplotter_simpletest_impulsesplot.pro index 8bd1b61a55..416f07af27 100644 --- a/examples/simpletest_impulsesplot/jkqtplotter_simpletest_impulsesplot.pro +++ b/examples/simpletest_impulsesplot/jkqtplotter_simpletest_impulsesplot.pro @@ -11,7 +11,7 @@ TARGET = jkqtplotter_simpletest_impulsesplot # include JKQTPlotter source code -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug @@ -22,6 +22,6 @@ message("LIBS = $$LIBS") win32-msvc*: DEFINES += _USE_MATH_DEFINES -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + diff --git a/examples/simpletest_logaxes/jkqtplotter_simpletest_logaxes.pro b/examples/simpletest_logaxes/jkqtplotter_simpletest_logaxes.pro index 4fdaadc499..c97ca65611 100644 --- a/examples/simpletest_logaxes/jkqtplotter_simpletest_logaxes.pro +++ b/examples/simpletest_logaxes/jkqtplotter_simpletest_logaxes.pro @@ -10,7 +10,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport TARGET = jkqtplotter_simpletest_logaxes # include JKQTPlotter source code -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug @@ -22,6 +22,6 @@ message("LIBS = $$LIBS") -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + diff --git a/examples/simpletest_parametriccurve/jkqtplotter_simpletest_parametriccurve.pro b/examples/simpletest_parametriccurve/jkqtplotter_simpletest_parametriccurve.pro index f64520574c..6a2599d741 100644 --- a/examples/simpletest_parametriccurve/jkqtplotter_simpletest_parametriccurve.pro +++ b/examples/simpletest_parametriccurve/jkqtplotter_simpletest_parametriccurve.pro @@ -11,7 +11,7 @@ TARGET = jkqtplotter_simpletest_parametriccurve # include JKQTPlotter source code -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug @@ -22,6 +22,6 @@ message("LIBS = $$LIBS") win32-msvc*: DEFINES += _USE_MATH_DEFINES -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + diff --git a/examples/simpletest_paramscatterplot/jkqtplotter_simpletest_paramscatterplot.pro b/examples/simpletest_paramscatterplot/jkqtplotter_simpletest_paramscatterplot.pro index da822b86c4..7e540406e8 100644 --- a/examples/simpletest_paramscatterplot/jkqtplotter_simpletest_paramscatterplot.pro +++ b/examples/simpletest_paramscatterplot/jkqtplotter_simpletest_paramscatterplot.pro @@ -11,7 +11,7 @@ TARGET = jkqtplotter_simpletest_paramscatterplot # include JKQTPlotter source code -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug @@ -22,6 +22,6 @@ message("LIBS = $$LIBS") win32-msvc*: DEFINES += _USE_MATH_DEFINES -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + diff --git a/examples/simpletest_paramscatterplot_image/README.md b/examples/simpletest_paramscatterplot_image/README.md index 61d7f09007..0949ba7ec1 100644 --- a/examples/simpletest_paramscatterplot_image/README.md +++ b/examples/simpletest_paramscatterplot_image/README.md @@ -66,7 +66,7 @@ Finally the plot is styled and the axis aspect ratios are fixed: // max. size is the size of the image plot.setXY(0,image.width()-1,0,image.height()-1); plot.setAbsoluteXY(0,image.width()-1,0,image.height()-1); - // ensure that axis aspect ration and coordinate system aspect ratio are maintained + // ensure that axis aspect ratio and coordinate system aspect ratio are maintained plot.getPlotter()->setMaintainAspectRatio(true); plot.getPlotter()->setAspectRatio(1); plot.getPlotter()->setMaintainAxisAspectRatio(true); diff --git a/examples/simpletest_paramscatterplot_image/jkqtplotter_simpletest_paramscatterplot_image.cpp b/examples/simpletest_paramscatterplot_image/jkqtplotter_simpletest_paramscatterplot_image.cpp index 4c8f202ac9..67244b9174 100644 --- a/examples/simpletest_paramscatterplot_image/jkqtplotter_simpletest_paramscatterplot_image.cpp +++ b/examples/simpletest_paramscatterplot_image/jkqtplotter_simpletest_paramscatterplot_image.cpp @@ -78,7 +78,7 @@ int main(int argc, char* argv[]) // max. size is the size of the image plot.setXY(0,image.width()-1,0,image.height()-1); plot.setAbsoluteXY(0,image.width()-1,0,image.height()-1); - // ensure that axis aspect ration and coordinate system aspect ratio are maintained + // ensure that axis aspect ratio and coordinate system aspect ratio are maintained plot.getPlotter()->setMaintainAspectRatio(true); plot.getPlotter()->setAspectRatio(1); plot.getPlotter()->setMaintainAxisAspectRatio(true); diff --git a/examples/simpletest_paramscatterplot_image/jkqtplotter_simpletest_paramscatterplot_image.pro b/examples/simpletest_paramscatterplot_image/jkqtplotter_simpletest_paramscatterplot_image.pro index 2d2cc05624..79fdc81ca5 100644 --- a/examples/simpletest_paramscatterplot_image/jkqtplotter_simpletest_paramscatterplot_image.pro +++ b/examples/simpletest_paramscatterplot_image/jkqtplotter_simpletest_paramscatterplot_image.pro @@ -13,7 +13,7 @@ TARGET = jkqtplotter_simpletest_paramscatterplot_image # include JKQTPlotter source code -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug @@ -24,6 +24,6 @@ message("LIBS = $$LIBS") win32-msvc*: DEFINES += _USE_MATH_DEFINES -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + diff --git a/examples/simpletest_parsedfunctionplot/jkqtplotter_simpletest_parsedfunctionplot.pro b/examples/simpletest_parsedfunctionplot/jkqtplotter_simpletest_parsedfunctionplot.pro index e55300e8af..a0b7664dd1 100644 --- a/examples/simpletest_parsedfunctionplot/jkqtplotter_simpletest_parsedfunctionplot.pro +++ b/examples/simpletest_parsedfunctionplot/jkqtplotter_simpletest_parsedfunctionplot.pro @@ -11,7 +11,7 @@ TARGET = jkqtplotter_simpletest_parsedfunctionplot # include JKQTPlotter source code -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug @@ -22,6 +22,6 @@ message("LIBS = $$LIBS") win32-msvc*: DEFINES += _USE_MATH_DEFINES -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + diff --git a/examples/simpletest_rgbimageplot_opencv/jkqtplotter_simpletest_rgbimageplot_opencv.cpp b/examples/simpletest_rgbimageplot_opencv/jkqtplotter_simpletest_rgbimageplot_opencv.cpp index e1a355af96..cb672b554b 100644 --- a/examples/simpletest_rgbimageplot_opencv/jkqtplotter_simpletest_rgbimageplot_opencv.cpp +++ b/examples/simpletest_rgbimageplot_opencv/jkqtplotter_simpletest_rgbimageplot_opencv.cpp @@ -8,7 +8,7 @@ #include #include "jkqtplotter/jkqtplotter.h" #include "jkqtplotter/jkqtpgraphs.h" -#include "jkqtplotter/jkqtpgraphsimage.h" +#include "jkqtplotter/jkqtpgraphsimagergb.h" #include "jkqtplotter/jkqtpopencvinterface.h" #include diff --git a/examples/simpletest_rgbimageplot_opencv/jkqtplotter_simpletest_rgbimageplot_opencv.pro b/examples/simpletest_rgbimageplot_opencv/jkqtplotter_simpletest_rgbimageplot_opencv.pro index d37a6ab92a..83db03a1af 100644 --- a/examples/simpletest_rgbimageplot_opencv/jkqtplotter_simpletest_rgbimageplot_opencv.pro +++ b/examples/simpletest_rgbimageplot_opencv/jkqtplotter_simpletest_rgbimageplot_opencv.pro @@ -13,9 +13,9 @@ TARGET = jkqtplotter_simpletest_rgbimageplot_opencv DEFINES += JKQTPLOTTER_OPENCV_INTERFACE -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + # link agains OpenCV-3.4.1 diff --git a/examples/simpletest_rgbimageplot_qt/jkqtplotter_simpletest_rgbimageplot_qt.cpp b/examples/simpletest_rgbimageplot_qt/jkqtplotter_simpletest_rgbimageplot_qt.cpp index 525c1c4e67..7630e29772 100644 --- a/examples/simpletest_rgbimageplot_qt/jkqtplotter_simpletest_rgbimageplot_qt.cpp +++ b/examples/simpletest_rgbimageplot_qt/jkqtplotter_simpletest_rgbimageplot_qt.cpp @@ -8,7 +8,7 @@ #include #include "jkqtplotter/jkqtplotter.h" #include "jkqtplotter/jkqtpgraphs.h" -#include "jkqtplotter/jkqtpgraphsimage.h" +#include "jkqtplotter/jkqtpgraphsimagergb.h" diff --git a/examples/simpletest_rgbimageplot_qt/jkqtplotter_simpletest_rgbimageplot_qt.pro b/examples/simpletest_rgbimageplot_qt/jkqtplotter_simpletest_rgbimageplot_qt.pro index cc26fdcccc..ab376fbfc1 100644 --- a/examples/simpletest_rgbimageplot_qt/jkqtplotter_simpletest_rgbimageplot_qt.pro +++ b/examples/simpletest_rgbimageplot_qt/jkqtplotter_simpletest_rgbimageplot_qt.pro @@ -13,7 +13,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport TARGET = jkqtplotter_simpletest_rgbimageplot_qt # include JKQTPlotter source code -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug @@ -22,6 +22,6 @@ CONFIG (debug, debug|release) { } message("LIBS = $$LIBS") -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + diff --git a/examples/simpletest_speed/jkqtplotter_simpletest_speed.pro b/examples/simpletest_speed/jkqtplotter_simpletest_speed.pro index eba29686df..1de558af5f 100644 --- a/examples/simpletest_speed/jkqtplotter_simpletest_speed.pro +++ b/examples/simpletest_speed/jkqtplotter_simpletest_speed.pro @@ -11,7 +11,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport TARGET = jkqtplotter_simpletest_speed # include JKQTPlotter source code -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug @@ -22,6 +22,6 @@ message("LIBS = $$LIBS") win32-msvc*: DEFINES += _USE_MATH_DEFINES -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + diff --git a/examples/simpletest_stackedbars/jkqtplotter_simpletest_stackedbars.pro b/examples/simpletest_stackedbars/jkqtplotter_simpletest_stackedbars.pro index 323f062d7a..2587617070 100644 --- a/examples/simpletest_stackedbars/jkqtplotter_simpletest_stackedbars.pro +++ b/examples/simpletest_stackedbars/jkqtplotter_simpletest_stackedbars.pro @@ -11,7 +11,7 @@ TARGET = jkqtplotter_simpletest_stackedbars # include JKQTPlotter source code -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug @@ -21,6 +21,6 @@ CONFIG (debug, debug|release) { message("LIBS = $$LIBS") -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + diff --git a/examples/simpletest_stepplots/jkqtplotter_simpletest_stepplots.pro b/examples/simpletest_stepplots/jkqtplotter_simpletest_stepplots.pro index 9e41f8e053..793f75bd37 100644 --- a/examples/simpletest_stepplots/jkqtplotter_simpletest_stepplots.pro +++ b/examples/simpletest_stepplots/jkqtplotter_simpletest_stepplots.pro @@ -11,7 +11,7 @@ TARGET = jkqtplotter_simpletest_stepplots # include JKQTPlotter source code -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug @@ -21,6 +21,6 @@ CONFIG (debug, debug|release) { message("LIBS = $$LIBS") -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + diff --git a/examples/simpletest_symbols_and_errors/README.md b/examples/simpletest_symbols_and_errors/README.md index ba2936fcfa..77943f4c16 100644 --- a/examples/simpletest_symbols_and_errors/README.md +++ b/examples/simpletest_symbols_and_errors/README.md @@ -54,8 +54,6 @@ int main(int argc, char* argv[]) // 7. set some axis properties (we use LaTeX for nice equation rendering) plot.getXAxis()->setAxisLabel(QObject::tr("x-axis $x$ [mm]")); plot.getYAxis()->setAxisLabel(QObject::tr("\\textbf{\\color{red}{y-axis} $\\left(y=\\sin(x)\\pm(0.2+0.25\\cdot x)\\right)$ [A.U.]}")); - plot.getXAxis()->setLabelFont("Arial"); - plot.getYAxis()->setLabelFont("Times New Roman"); plot.getYAxis()->setLabelFontSize(12); // large x-axis label plot.getYAxis()->setTickLabelFontSize(10); // and larger y-axis tick labels diff --git a/examples/simpletest_symbols_and_errors/jkqtplotter_simpletest_symbols_and_errors.cpp b/examples/simpletest_symbols_and_errors/jkqtplotter_simpletest_symbols_and_errors.cpp index e1f7f0542d..6edbcfff30 100644 --- a/examples/simpletest_symbols_and_errors/jkqtplotter_simpletest_symbols_and_errors.cpp +++ b/examples/simpletest_symbols_and_errors/jkqtplotter_simpletest_symbols_and_errors.cpp @@ -56,8 +56,6 @@ int main(int argc, char* argv[]) // 7. set some axis properties (we use LaTeX for nice equation rendering) plot.getXAxis()->setAxisLabel(QObject::tr("x-axis $x$ [mm]")); plot.getYAxis()->setAxisLabel(QObject::tr("\\textbf{\\color{red}{y-axis} $\\left(y=\\sin(x)\\pm(0.2+0.25\\cdot x)\\right)$ [A.U.]}")); - plot.getXAxis()->setLabelFont("Arial"); - plot.getYAxis()->setLabelFont("Times New Roman"); plot.getYAxis()->setLabelFontSize(12); // large x-axis label plot.getYAxis()->setTickLabelFontSize(10); // and larger y-axis tick labels diff --git a/examples/simpletest_symbols_and_errors/jkqtplotter_simpletest_symbols_and_errors.pro b/examples/simpletest_symbols_and_errors/jkqtplotter_simpletest_symbols_and_errors.pro index e2a9126bbe..bd53693b28 100644 --- a/examples/simpletest_symbols_and_errors/jkqtplotter_simpletest_symbols_and_errors.pro +++ b/examples/simpletest_symbols_and_errors/jkqtplotter_simpletest_symbols_and_errors.pro @@ -11,7 +11,7 @@ TARGET = jkqtplotter_simpletest_symbols_and_errors # include JKQTPlotter source code -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug @@ -22,6 +22,6 @@ message("LIBS = $$LIBS") win32-msvc*: DEFINES += _USE_MATH_DEFINES -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + diff --git a/examples/simpletest_symbols_and_styles/jkqtplotter_simpletest_symbols_and_styles.pro b/examples/simpletest_symbols_and_styles/jkqtplotter_simpletest_symbols_and_styles.pro index 3f915cf0c1..4bc363b129 100644 --- a/examples/simpletest_symbols_and_styles/jkqtplotter_simpletest_symbols_and_styles.pro +++ b/examples/simpletest_symbols_and_styles/jkqtplotter_simpletest_symbols_and_styles.pro @@ -11,7 +11,7 @@ TARGET = jkqtplotter_simpletest_symbols_and_styles # include JKQTPlotter source code -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug @@ -22,6 +22,6 @@ message("LIBS = $$LIBS") win32-msvc*: DEFINES += _USE_MATH_DEFINES -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + diff --git a/examples/simpletest_ui/README.md b/examples/simpletest_ui/README.md index 89dbb7b240..223ac371bf 100644 --- a/examples/simpletest_ui/README.md +++ b/examples/simpletest_ui/README.md @@ -37,7 +37,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport TARGET = jkqtplotter_simpletest_ui # include JKQTPlotter source headers and link against library -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug @@ -48,9 +48,9 @@ message("LIBS = $$LIBS") win32-msvc*: DEFINES += _USE_MATH_DEFINES -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + ``` As you can see there is a main CPP-file (shown below) and a `formwithjkqtplotter.ui`-file with the `formwithjkqtplotter.cpp/.h`-files that are used to implement the functionality behind the form (see next chapter). diff --git a/examples/simpletest_ui/jkqtplotter_simpletest_ui.pro b/examples/simpletest_ui/jkqtplotter_simpletest_ui.pro index 24d50e04e5..398fd8bfcd 100644 --- a/examples/simpletest_ui/jkqtplotter_simpletest_ui.pro +++ b/examples/simpletest_ui/jkqtplotter_simpletest_ui.pro @@ -15,7 +15,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport TARGET = jkqtplotter_simpletest_ui # include JKQTPlotter source headers and link against library -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug @@ -26,6 +26,6 @@ message("LIBS = $$LIBS") win32-msvc*: DEFINES += _USE_MATH_DEFINES -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + diff --git a/examples/test_distributionplot/test_distributionplot.pro b/examples/test_distributionplot/test_distributionplot.pro index ca32d4997a..b7c9645dca 100644 --- a/examples/test_distributionplot/test_distributionplot.pro +++ b/examples/test_distributionplot/test_distributionplot.pro @@ -10,7 +10,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport TARGET = test_distributionplot # include JKQTPlotter source code -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug @@ -20,6 +20,6 @@ CONFIG (debug, debug|release) { message("LIBS = $$LIBS") -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + diff --git a/examples/test_multiplot/README.md b/examples/test_multiplot/README.md index a6deaf4131..a9e6c76154 100644 --- a/examples/test_multiplot/README.md +++ b/examples/test_multiplot/README.md @@ -66,19 +66,19 @@ Finally the axes and plots need a bit of formatting to make them look nicer: plotResid->getYAxis()->setAxisLabel("residuals"); plotResidHist->getXAxis()->setAxisLabel("frequency"); // 6.2 switch off the tick labels on the axes that directly face another plot - plotMain->getXAxis()->setDrawMode1(JKQTPCADMticks); - plotResidHist->getYAxis()->setDrawMode1(JKQTPCADMticks); + plotMain->getXAxis()->setDrawMode1(JKQTPCADMLineTicks); + plotResidHist->getYAxis()->setDrawMode1(JKQTPCADMLineTicks); // 6.3 show tick labels on the rhs y-axis of the residual histogram plot - plotResidHist->getYAxis()->setDrawMode2(JKQTPCADMticksAndLabels); + plotResidHist->getYAxis()->setDrawMode2(JKQTPCADMLineTicksTickLabels); // 6.4 hide keys in all plots but the main plot plotResid->getPlotter()->setShowKey(false); plotResidHist->getPlotter()->setShowKey(false); // 6.5 hide position label and toolbars in the plots except main plot - plotResid->setToolbarVisible(false); + plotResid->setToolbarEnabled(false); plotResid->setMousePositionShown(false); - plotResidHist->setToolbarVisible(false); + plotResidHist->setToolbarEnabled(false); plotResidHist->setMousePositionShown(false); - plotMain->setToolbarVisible(true); + plotMain->setToolbarEnabled(true); ``` As a last step, the axes are scaled automatically, so the data fills the plots: diff --git a/examples/test_multiplot/test_multiplot.cpp b/examples/test_multiplot/test_multiplot.cpp index e1a4f1288b..a0eee41ec1 100644 --- a/examples/test_multiplot/test_multiplot.cpp +++ b/examples/test_multiplot/test_multiplot.cpp @@ -131,19 +131,19 @@ int main(int argc, char* argv[]) plotResid->getYAxis()->setAxisLabel("residuals"); plotResidHist->getXAxis()->setAxisLabel("frequency"); // 6.2 switch off the tick labels on the axes that directly face another plot - plotMain->getXAxis()->setDrawMode1(JKQTPCADMticks); - plotResidHist->getYAxis()->setDrawMode1(JKQTPCADMticks); + plotMain->getXAxis()->setDrawMode1(JKQTPCADMLineTicks); + plotResidHist->getYAxis()->setDrawMode1(JKQTPCADMLineTicks); // 6.3 show tick labels on the rhs y-axis of the residual histogram plot - plotResidHist->getYAxis()->setDrawMode2(JKQTPCADMticksAndLabels); + plotResidHist->getYAxis()->setDrawMode2(JKQTPCADMLineTicksTickLabels); // 6.4 hide keys in all plots but the main plot plotResid->getPlotter()->setShowKey(false); plotResidHist->getPlotter()->setShowKey(false); // 6.5 hide position label and toolbars in the plots except main plot - plotResid->setToolbarVisible(false); + plotResid->setToolbarEnabled(false); plotResid->setMousePositionShown(false); - plotResidHist->setToolbarVisible(false); + plotResidHist->setToolbarEnabled(false); plotResidHist->setMousePositionShown(false); - plotMain->setToolbarVisible(true); + plotMain->setToolbarEnabled(true); // 7. scale plots automatically to data diff --git a/examples/test_multiplot/test_multiplot.pro b/examples/test_multiplot/test_multiplot.pro index cd2388c470..44d4b7ab48 100644 --- a/examples/test_multiplot/test_multiplot.pro +++ b/examples/test_multiplot/test_multiplot.pro @@ -13,7 +13,7 @@ TARGET = test_multiplot # include JKQTPlotter source code -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug @@ -32,9 +32,9 @@ win32-msvc* { } -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + FORMS += \ test_multiplot_ui.ui diff --git a/examples/test_styling/README.md b/examples/test_styling/README.md new file mode 100644 index 0000000000..22c631a9d0 --- /dev/null +++ b/examples/test_styling/README.md @@ -0,0 +1,95 @@ +# Tutorial (JKQTPlotter): Styling a JKQtPlotter {#JKQTPlotterStyling} + +[TOC] + +## Basic Description +This project (see `./examples/test_styling/`) demonstrates different types of user-interactions in JKQTPlotter. + +It contains a simple plot with two graphs and provides several widgets that allow to modify the plot styling by editing an INI file: + +![](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/test_styling.png) + + +## Altering the Default Style + +### Global/System-wide Settings +The `main()`-function can be found in [`test_styling_main.cpp`](https://github.com/jkriege2/JKQtPlotter/tree/master/examples/test_styling/test_styling_main.cpp). Here the Qt application is initialized in the usual way and the main window `win` is created and shown. After instanciating the `QApplication`, but befor instanciating the window (and thus the JKQTPlotter), you can already alter the system-wide default styling. It is accessible via the function `JKQTPGetSystemDefaultStyle()`, which returns a reference to the central style object of type `JKQTPlotterStyle`. In the example below, the color of the user-actions (e.g. of the zooming rectangle, that can be drawn with the mouse) is set to red: + +```.cpp +int main(int argc, char* argv[]) +{ + QApplication app(argc, argv); + + // you can set the system-wide default style properties early on + // all JKQTPlotter instance created after this, will use these + // settings as their initial settings + JKQTPGetSystemDefaultStyle().userActionColor=QColor("red"); + + TestStyling win; + win.show(); + + return app.exec(); +} +``` + +In addition to `JKQTPGetSystemDefaultStyle()`, which allows to style the `JKQTPlotter` (mainly the GUI-parts and user-action bindings), there is also `JKQTPGetSystemDefaultBaseStyle()`, which accesses a central instance of `JKQTBasePlotterStyle`. The latter object contains the styling of the graph itself (colors, axis properties, ...). + +You can also store these settings in an INI-file (or any file supported by [`QSettings`](http://doc.qt.io/qt-5/qsettings.html)) and load such a file on startup, using: +```.cpp + QSettings plotSettings("JKQTPlotterSettings.ini", QSettings::IniFormat);; + JKQTPGetSystemDefaultStyle().loadSettings(plotSettings); + JKQTPGetSystemDefaultBaseStyle().loadSettings(plotSettings); +``` + +### Apply a new Style to an Existing JKQTPlotter + +The major part of the source code of the main application can be found in [`test_styling.cpp`](https://github.com/jkriege2/JKQtPlotter/tree/master/examples/test_styling/test_styling.cpp). It opens a window with a plotter, that contains a set of test graphs to demonstrate the styling. The following function is connected to the "Update Graph"-button and applys the style defined by the INI in the plainTextEdit to the plotter: +```.cpp + void TestStyling::on_btnUpdate_clicked() + { + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + // In this function, we store the data from the plainTextEdit into a temporary file + // tmpfn and the use that file's contents to create a QSettings object, which is used + // to read the plotterStyle into the JKQTPlotter-object ui->plot (using loadCurrentPlotterStyle(settings) ) + QString tmpfn=QDir::tempPath()+"/jkqtplotter_config.tmp"; + { + QFile data(tmpfn); + if (data.open(QFile::WriteOnly|QFile::Text)) { + QTextStream out(&data); + out << ui->plainTextEdit->toPlainText(); + } + } + { + QSettings settings(tmpfn, QSettings::IniFormat); + ui->plot->loadCurrentPlotterStyle(settings); + initPlot(); + ui->chkDebugBoxes->setChecked(ui->plot->getPlotter()->isDebugShowRegionBoxesEnabled()); + } + QFile::remove(tmpfn); + QApplication::restoreOverrideCursor(); + } +``` + + +## Some Example Styles +The following gallery shows a set of example styles: + + + +| Style-file | Screenshot | +|:-------------:| ------------- | +| The Default Style | ![](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/style_default.png) | +| [`lib/jkqtplotterressources/style/simple_gridandticks.ini`](https://github.com/jkriege2/JKQtPlotter/tree/master/lib/jkqtplotterressources/styles/simple_gridandticks.ini) | ![](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/style_simple_axesoffset_plotbox.png) | +| [`lib/jkqtplotterressources/style/simple_axesoffset.ini`](https://github.com/jkriege2/JKQtPlotter/tree/master/lib/jkqtplotterressources/styles/simple_axesoffset.ini) | ![](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/style_simple_axesoffset.png) | +| [`lib/jkqtplotterressources/style/simple_axesoffset_plotbox.ini`](https://github.com/jkriege2/JKQtPlotter/tree/master/lib/jkqtplotterressources/styles/simple_axesoffset_plotbox.ini) | ![](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/style_simple_axesoffset_plotbox.png) | +| [`lib/jkqtplotterressources/style/dark.ini`](https://github.com/jkriege2/JKQtPlotter/tree/master/lib/jkqtplotterressources/styles/dark.ini) | ![](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/style_dark.png) | +| [`lib/jkqtplotterressources/style/blueprint.ini`](https://github.com/jkriege2/JKQtPlotter/tree/master/lib/jkqtplotterressources/styles/blueprint.ini) | ![](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/style_blueprint.png) | +| [`lib/jkqtplotterressources/style/blackandwhite.ini`](https://github.com/jkriege2/JKQtPlotter/tree/master/lib/jkqtplotterressources/styles/blackandwhite.ini) | ![](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/style_blackandwhite.png) | + + +Note: The styles listed above are also linked into the executable as Qt ressource ... you can use them e.g. as follows: +```.cpp + QSettings plotSettings(":/JKQTPlotter/styles/blackandwhite.ini", QSettings::IniFormat);; + JKQTPGetSystemDefaultStyle().loadSettings(plotSettings); + JKQTPGetSystemDefaultBaseStyle().loadSettings(plotSettings); +``` diff --git a/examples/test_styling/test_styling.cpp b/examples/test_styling/test_styling.cpp new file mode 100644 index 0000000000..eb8fe8e949 --- /dev/null +++ b/examples/test_styling/test_styling.cpp @@ -0,0 +1,283 @@ +#include "test_styling.h" +#include "ui_test_styling.h" +#include "jkqtplotter/jkqtplotter.h" +#include "jkqtplotter/jkqtpgraphs.h" +#include "jkqtplotter/jkqtpgraphsbarchart.h" +#include "jkqtplotter/jkqtpgraphsimage.h" +#include "jkqtplotter/jkqtpgraphsgeometric.h" +#include +#include +#include + +TestStyling::TestStyling(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::TestStyling) +{ + // set up the GUI + ui->setupUi(this); + ui->splitter->setStretchFactor(0,1); + ui->splitter->setStretchFactor(1,1); + + // initialize a simple plot + initPlot(); + + // connect GUI to JKQTPlotter + connect(ui->chkGrid, SIGNAL(toggled(bool)), ui->plot, SLOT(setGrid(bool))); + connect(ui->chkLogX, SIGNAL(toggled(bool)), ui->plot->getXAxis(), SLOT(setLogAxis(bool))); + connect(ui->chkLogY, SIGNAL(toggled(bool)), ui->plot->getYAxis(), SLOT(setLogAxis(bool))); + connect(ui->chkDebugBoxes, SIGNAL(toggled(bool)), ui->plot->getPlotter(), SLOT(enableDebugShowRegionBoxes(bool))); + + // store JKQTPlotter plotterStyle to a temporary INI-file + // and then load that temporary file into the plainTextEdit, + // using on_btnLoad_clicked(tmpfn). This ensures that the currently + // set plotterStyle is visible in the plainTextEdit and can be edited + // by the user + QString tmpfn=QDir::tempPath()+"/jkqtplotter_config.tmp"; + { + QSettings settings(tmpfn, QSettings::IniFormat); + ui->plot->saveCurrentPlotterStyle(settings); + } + on_btnLoad_clicked(tmpfn); + QFile::remove(tmpfn); +} + +TestStyling::~TestStyling() +{ + delete ui; + if (!plotExtra.isNull()) { + plotExtra->close(); + plotExtra.clear(); + } +} + +void TestStyling::on_btnUpdate_clicked() +{ + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + // In this function, we store the data from the plainTextEdit into a temporary file + // tmpfn and the use that file's contents to create a QSettings object, which is used + // to read the plotterStyle into the JKQTPlotter-object ui->plot (using loadCurrentPlotterStyle(settings) ) + QString tmpfn=QDir::tempPath()+"/jkqtplotter_config.tmp"; + { + QFile data(tmpfn); + if (data.open(QFile::WriteOnly|QFile::Text)) { + QTextStream out(&data); + out << ui->plainTextEdit->toPlainText(); + } + } + { + QSettings settings(tmpfn, QSettings::IniFormat); + ui->plot->loadCurrentPlotterStyle(settings); + initPlot(); + ui->chkDebugBoxes->setChecked(ui->plot->getPlotter()->isDebugShowRegionBoxesEnabled()); + } + QFile::remove(tmpfn); + QApplication::restoreOverrideCursor(); +} + +void TestStyling::on_btnLoad_clicked(const QString& filename) +{ + // loads a plotterTsyle INI file from harddisk into the plainTextEdit + // and then calls on_btnUpdate_clicked() to apply it immediately to plot + QString fn=filename; + if (fn.size()==0) { + fn=QFileDialog::getOpenFileName(this, tr("Open Styling INI-File"), + "", + tr("Styling INI (*.ini *.cfg *.txt)")); + } + if (fn.size()>0) { + QFile data(fn); + if (data.open(QFile::ReadOnly|QFile::Text)) { + ui->plainTextEdit->setPlainText(data.readAll()); + } + } + on_btnUpdate_clicked(); +} + +void TestStyling::on_btnSave_clicked() +{ + // stores the contents of plainTextEdit into a file on the harddisk + QString fn=QFileDialog::getSaveFileName(this, tr("Save Styling INI-File"), + "", + tr("Styling INI (*.ini *.cfg *.txt)")); + if (fn.size()>0) { + QFile data(fn); + if (data.open(QFile::WriteOnly|QFile::Text)) { + QTextStream out(&data); + out << ui->plainTextEdit->toPlainText(); + } + QPixmap img=ui->plot->grab(); + img.save(fn+".png", "png"); + ui->plot->saveImage(fn+".export.png", false); + } +} + + + +void TestStyling::initPlot() +{ + + ui->plot->setPlotUpdateEnabled(false); + + // 0. get a pointer to the internal datastore (for convenience) + JKQTPDatastore* ds=ui->plot->getDatastore(); + + // 1. clear old graphs/data + ui->plot->clearGraphs(true); + ds->clear(); + + // 2. now we create data for a simple plot (a sine curve) + QVector X, Y1, Y2, img, X3, Y3, Y3err, Xbar, Ybar, Ybar2; + const int Ndata=100; + for (int i=0; i0 && i%20==0) { + Xbar<addCopiedColumn(X, "x"); + size_t columnY1=ds->addCopiedColumn(Y1, "y1"); + size_t columnY2=ds->addCopiedColumn(Y2, "y2"); + size_t columnImg=ds->addCopiedColumn(img, "img"); + size_t columnX3=ds->addCopiedColumn(X3, "x3"); + size_t columnY3=ds->addCopiedColumn(Y3, "y3"); + size_t columnY3err=ds->addCopiedColumn(Y3err, "y3err"); + size_t columnXbar=ds->addCopiedColumn(Xbar, "xbar"); + size_t columnYbar=ds->addCopiedColumn(Ybar, "ybar"); + size_t columnYbar2=ds->addCopiedColumn(Ybar2, "Ybar2"); + + // 4. create a graph in the plot, which plots the dataset X/Y: + JKQTPColumnMathImage* graphI=new JKQTPColumnMathImage(ui->plot); + graphI->setImageColumn(columnImg); + graphI->setNx(Ndata); + graphI->setNy(Ndata); + graphI->setColorBarTopVisible(true); + graphI->setColorBarRightVisible(true); + graphI->setX(0.5); + graphI->setY(-1.5); + graphI->setWidth(5); + graphI->setHeight(1); + graphI->setTitle(QObject::tr("2{\\times}Gauss")); + ui->plot->addGraph(graphI); + + JKQTPXYLineGraph* graph1=new JKQTPXYLineGraph(ui->plot); + graph1->setXColumn(columnX); + graph1->setYColumn(columnY1); + graph1->setTitle(QObject::tr("sine graph $f(x)=\\sin(x)$")); + ui->plot->addGraph(graph1); + + JKQTPXYLineGraph* graph2=new JKQTPXYLineGraph(ui->plot); + graph2->setXColumn(columnX); + graph2->setYColumn(columnY2); + graph2->setSymbol(JKQTPNoSymbol); + //graph2->setTitle(QObject::tr("sine{\\cdot}exp graph $f(x)=\\sin(x)\\cdot\\exp\\left(-\\frac{x}{5}\\right)$")); + graph2->setTitle(QObject::tr("sine*exp graph")); + ui->plot->addGraph(graph2); + + JKQTPXYLineErrorGraph* graph3=new JKQTPXYLineErrorGraph(ui->plot); + graph3->setXColumn(columnX3); + graph3->setYColumn(columnY3); + graph3->setYErrorColumn(columnY3err); + graph3->setDrawLine(false); + graph3->setTitle(QObject::tr("sine \\pm errors graph")); + ui->plot->addGraph(graph3); + + JKQTPBarVerticalGraph* graphb=new JKQTPBarVerticalGraph(ui->plot); + graphb->setXColumn(columnXbar); + graphb->setYColumn(columnYbar); + graphb->setTitle(QObject::tr("barchart")); + ui->plot->addGraph(graphb); + + JKQTPBarVerticalGraph* graphb2=new JKQTPBarVerticalGraph(ui->plot); + graphb2->setXColumn(columnXbar); + graphb2->setYColumn(columnYbar2); + graphb2->setTitle(QObject::tr("2^{nd} barchart")); + ui->plot->addGraph(graphb2); + graphb2->autoscaleBarWidthAndShiftSeparatedGroups(); + + + // 6. autoscale the plot so the graph is contained + ui->plot->zoomToFit(); + + ui->plot->getPlotter()->setPlotLabel("Sine Plots - User-Interaction Example"); + ui->plot->getXAxis()->setAxisLabel("x-axis"); + ui->plot->getYAxis()->setAxisLabel("y-axis"); + + ui->plot->setPlotUpdateEnabled(true); + ui->plot->redrawPlot(); + + if (!plotExtra) { + plotExtra=new JKQTPlotter; + plotExtra->show(); + plotExtra->resize(width(),300); + plotExtra->move(pos().x(), pos().y()+height()+32); + } + plotExtra->setPlotUpdateEnabled(false); + plotExtra->clearGraphs(true); + plotExtra->getPlotter()->setBackgroundColor(ui->plot->getPlotter()->getBackgroundColor()); + plotExtra->getPlotter()->setExportBackgroundColor(ui->plot->getPlotter()->getExportBackgroundColor()); + plotExtra->getPlotter()->setPlotBackgroundColor(ui->plot->getPlotter()->getPlotBackgroundColor()); + plotExtra->getXAxis()->setDrawMode1(JKQTPCADMnone); + plotExtra->getXAxis()->setDrawMode2(JKQTPCADMnone); + plotExtra->getYAxis()->setDrawMode1(JKQTPCADMnone); + plotExtra->getYAxis()->setDrawMode2(JKQTPCADMnone); + double x=1; + double xlineend=6; + double y=1; + double xmax=15; + int cnt=0; + for (auto s: ui->plot->getPlotter()->getCurrentPlotterStyle().defaultGraphSymbols) { + plotExtra->addGraph(new JKQTPGeoSymbol(plotExtra.data(), x, y, s, 12, QColor("red"), QColor("salmon") )); + x+=1; + xmax=qMax(x, xmax); + if (cnt>0 && cnt%25==0) { + x=1; + y+=1.0; + } + cnt++; + } + y=y+1; + double ycoltest=y; + for (auto s: ui->plot->getPlotter()->getCurrentPlotterStyle().defaultGraphPenStyles) { + plotExtra->addGraph(new JKQTPGeoLine(plotExtra.data(), 1,y,xlineend,y,QColor("red"), 2, s)); + plotExtra->addGraph(new JKQTPGeoLine(plotExtra.data(), 1,y-0.25,xlineend,y-0.25,QColor("maroon"), 1, s)); + y+=0.75; + } + x=xlineend+1; + double dx=(xmax-xlineend-1.0)/static_cast(ui->plot->getPlotter()->getCurrentPlotterStyle().defaultGraphColors.size()); + for (auto s: ui->plot->getPlotter()->getCurrentPlotterStyle().defaultGraphColors) { + plotExtra->addGraph(new JKQTPGeoLine(plotExtra.data(), x,ycoltest,x,y-0.5,s,5)); + plotExtra->addGraph(new JKQTPGeoRectangle(plotExtra.data(), x+dx/2,(ycoltest+y-0.5)/2.0, dx*0.5, y-ycoltest-0.5, s,1, Qt::SolidLine, JKQTPGetDerivedColor(ui->plot->getPlotter()->getCurrentPlotterStyle().graphFillColorDerivationMode, s))); + x+=dx; + } + plotExtra->zoomToFit(); + plotExtra->setX(0, plotExtra->getXMax()+2); + plotExtra->setY(0, plotExtra->getYMax()+1); + plotExtra->setGrid(false); + plotExtra->getPlotter()->setPlotLabel("default symbols/lines/colors"); + plotExtra->setPlotUpdateEnabled(true); + plotExtra->redrawPlot(); +} diff --git a/examples/test_styling/test_styling.h b/examples/test_styling/test_styling.h new file mode 100644 index 0000000000..998dcbf9e1 --- /dev/null +++ b/examples/test_styling/test_styling.h @@ -0,0 +1,30 @@ +#ifndef TEST_STYLING_H +#define TEST_STYLING_H + +#include +#include "jkqtplotter/jkqtplotter.h" + +namespace Ui { + class TestStyling; +} + +class TestStyling : public QMainWindow +{ + Q_OBJECT + + public: + explicit TestStyling(QWidget *parent = nullptr); + ~TestStyling(); + + protected slots: + void on_btnUpdate_clicked(); + void on_btnLoad_clicked(const QString &filename=QString()); + void on_btnSave_clicked(); + + private: + Ui::TestStyling *ui; + void initPlot(); + QPointer plotExtra; +}; + +#endif // TEST_STYLING_H diff --git a/examples/test_styling/test_styling.pro b/examples/test_styling/test_styling.pro new file mode 100644 index 0000000000..de8043e5a0 --- /dev/null +++ b/examples/test_styling/test_styling.pro @@ -0,0 +1,48 @@ + +# configure Qt +CONFIG += link_prl qt c++11 +QT += core gui xml svg +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport + +# output executable name +TARGET = test_styling + +# source code for this simple demo +SOURCES = test_styling_main.cpp \ + test_styling.cpp + +HEADERS += \ + test_styling.h + +FORMS += \ + test_styling.ui + +# include JKQTPlotter source code +DEPENDPATH += ../../lib \ + ../../staticlib +INCLUDEPATH += ../../lib + +CONFIG (debug, debug|release) { + + LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug +} else { + + LIBS += -L../../staticlib/release -ljkqtplotterlib +} +message("LIBS = $$LIBS") + + +win32-msvc* { + QMAKE_CXXFLAGS += /EHsc /std:c++14 + # To enable M_PI, M_E,... + DEFINES += _USE_MATH_DEFINES + # To fix error: C2338: va_start argument must not + # have reference type and must not be parenthesized + DEFINES += _CRT_NO_VA_START_VALIDATION +} + + + + + + diff --git a/examples/test_styling/test_styling.ui b/examples/test_styling/test_styling.ui new file mode 100644 index 0000000000..981cc39c32 --- /dev/null +++ b/examples/test_styling/test_styling.ui @@ -0,0 +1,238 @@ + + + TestStyling + + + + 0 + 0 + 863 + 559 + + + + Tutorial/TestApp: JKQTPlotter Styling + + + + + + + Qt::Horizontal + + + + + + + + + + + 75 + true + + + + debug-boxes: + + + + + + + enabled + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 75 + true + + + + log scales: + + + + + + + X + + + + + + + Y + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 75 + true + + + + grids: + + + + + + + X + Y + + + true + + + + + + + + + Qt::Horizontal + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Load + + + + + + + + 75 + true + + + + Update Graph + + + + + + + Save + + + + + + + + Courier New + 10 + + + + QPlainTextEdit::NoWrap + + + enter plotter style INI contents here ... + + + + + + + + 75 + true + + + + plotter style: + + + + + + + + + + + + + + + 0 + 0 + 863 + 21 + + + + + + + + JKQTPlotter + QWidget +
    jkqtplotter/jkqtplotter.h
    + 1 +
    +
    + + +
    diff --git a/examples/test_styling/test_styling_and_lib.pro b/examples/test_styling/test_styling_and_lib.pro new file mode 100644 index 0000000000..0fdbd85851 --- /dev/null +++ b/examples/test_styling/test_styling_and_lib.pro @@ -0,0 +1,8 @@ +TEMPLATE = subdirs + +jkqtplotterlib.file = ../../staticlib/jkqtplotterlib.pro + +test_styling.file=$$PWD/test_styling.pro +test_styling.depends = jkqtplotterlib + +SUBDIRS += jkqtplotterlib test_styling diff --git a/examples/test_styling/test_styling_main.cpp b/examples/test_styling/test_styling_main.cpp new file mode 100644 index 0000000000..ce1d1cf4da --- /dev/null +++ b/examples/test_styling/test_styling_main.cpp @@ -0,0 +1,19 @@ +#include +#include "test_styling.h" +#include "jkqtplotter/jkqtplotterstyle.h" + + +int main(int argc, char* argv[]) +{ + QApplication app(argc, argv); + + // you can set the system-wide default style properties early on + // all JKQTPlotter instance created after this, will use these + // settings as their initial settings + JKQTPGetSystemDefaultStyle().userActionColor=QColor("red"); + + TestStyling win; + win.show(); + + return app.exec(); +} diff --git a/examples/test_user_interaction/README.md b/examples/test_user_interaction/README.md index c593a11b7f..37711e1c18 100644 --- a/examples/test_user_interaction/README.md +++ b/examples/test_user_interaction/README.md @@ -34,26 +34,26 @@ The rest of the form contains several Qt widgets which switch diverse aspects of // add a QComboBox that allows to set the left mouse button action for the JKQTPlotter cmbLeftNoModMouseAction=new QComboBox(this); layForm->addRow("mouse action: left-click, no modifiers", cmbLeftNoModMouseAction); - cmbLeftNoModMouseAction->addItem("PanPlotOnMove"); - cmbLeftNoModMouseAction->addItem("PanPlotOnRelease"); - cmbLeftNoModMouseAction->addItem("ZoomRectangle"); - cmbLeftNoModMouseAction->addItem("DrawRectangleForEvent"); - cmbLeftNoModMouseAction->addItem("DrawCircleForEvent"); - cmbLeftNoModMouseAction->addItem("DrawEllipseForEvent"); - cmbLeftNoModMouseAction->addItem("DrawLineForEvent"); - cmbLeftNoModMouseAction->addItem("ScribbleForEvents"); + cmbLeftNoModMouseAction->addItem("jkqtpmdaPanPlotOnMove"); + cmbLeftNoModMouseAction->addItem("jkqtpmdaPanPlotOnRelease"); + cmbLeftNoModMouseAction->addItem("jkqtpmdaZoomByRectangle"); + cmbLeftNoModMouseAction->addItem("jkqtpmdaDrawRectangleForEvent"); + cmbLeftNoModMouseAction->addItem("jkqtpmdaDrawCircleForEvent"); + cmbLeftNoModMouseAction->addItem("jkqtpmdaDrawEllipseForEvent"); + cmbLeftNoModMouseAction->addItem("jkqtpmdaDrawLineForEvent"); + cmbLeftNoModMouseAction->addItem("jkqtpmdaScribbleForEvents"); cmbLeftNoModMouseAction->addItem("NoMouseAction"); cmbLeftNoModMouseAction->setCurrentIndex(2); connect(cmbLeftNoModMouseAction, SIGNAL(currentIndexChanged(int)), this, SLOT(setLeftMouseAction(int))); setLeftMouseAction(cmbLeftNoModMouseAction->currentIndex()); - // ...... - - void TestUserInteraction::setLeftMouseAction(int index) - { - if (index==cmbLeftNoModMouseAction->count()-1) plot->deregisterMouseDragAction(Qt::LeftButton, Qt::NoModifier); - else plot->registerMouseDragAction(Qt::LeftButton, Qt::NoModifier, static_cast(index)); - } + // ...... + + void TestUserInteraction::setLeftMouseAction(int index) + { + if (index==cmbLeftNoModMouseAction->count()-1) plot->deregisterMouseDragAction(Qt::LeftButton, Qt::NoModifier); + else plot->registerMouseDragAction(Qt::LeftButton, Qt::NoModifier, static_cast(index)); + } ``` As you can see, this QComboBox registers one of the available actions to the event of a left-button single mouse click without having modifiers pressed at the same time. The slot that actually reconfigures the JKQTPlotter uses the methods JKQTPlotter::deregisterMouseDragAction() and JKQTPlotter::registerMouseDragAction() to achieve this effect. @@ -85,7 +85,7 @@ The JKQTPlotter contains a small text display for the current mouse position (in ![](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/doc/images/mousepositiondisplay.gif) ### Drag the Plot Viewport -You can move the viewport of the graph using the mouse ("PanPlotOnMove"-action). If you drag inside the plot window, you can move in both directions, if you drag over one of the coordinate axes, you can change the range of this axis only: +You can move the viewport of the graph using the mouse ("jkqtpmdaPanPlotOnMove"-action). If you drag inside the plot window, you can move in both directions, if you drag over one of the coordinate axes, you can change the range of this axis only: ![](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/doc/images/drag_viewport.gif) @@ -93,7 +93,7 @@ You can move the viewport of the graph using the mouse ("PanPlotOnMove"-action). There are several options to zoom, using the mouse: * using the mouse wheel -* with double-click actions ClickZoomsOut, ClickZoomsIn +* with double-click actions jkqtpdcaClickZoomsOut, jkqtpdcaClickZoomsIn * using the context menu (or the toolbar)
    ![](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/doc/images/zoomin_mouse_contextmenu.gif) diff --git a/examples/test_user_interaction/test_user_interaction.cpp b/examples/test_user_interaction/test_user_interaction.cpp index 362aa1178e..61fa2c8692 100644 --- a/examples/test_user_interaction/test_user_interaction.cpp +++ b/examples/test_user_interaction/test_user_interaction.cpp @@ -51,8 +51,8 @@ TestUserInteraction::TestUserInteraction(QWidget *parent) : // add a checkbox to en-/disable the toolbar of the JKQTPlotter chkShowToolbar=new QCheckBox(tr("enable toolbar"), this); - chkShowToolbar->setChecked(plot->isToolbarVisible()); - connect(chkShowToolbar, SIGNAL(toggled(bool)), plot, SLOT(setToolbarVisible(bool))); + chkShowToolbar->setChecked(plot->isToolbarEnabled()); + connect(chkShowToolbar, SIGNAL(toggled(bool)), plot, SLOT(setToolbarEnabled(bool))); layChk->addWidget(chkShowToolbar); // add a checkbox to switch the toolbar between always visible and the hiding mode, @@ -68,7 +68,7 @@ TestUserInteraction::TestUserInteraction(QWidget *parent) : connect(chkGrid, SIGNAL(toggled(bool)), plot, SLOT(setGrid(bool))); layChk->addWidget(chkGrid); - // add a checkbox to switch the grid on and off + // add a checkbox to switch log-scale on each axis on or off chkLogX=new QCheckBox(tr("X log-scale"), this); chkLogX->setChecked(false); connect(chkLogX, SIGNAL(toggled(bool)), plot->getXAxis(), SLOT(setLogAxis(bool))); @@ -93,14 +93,14 @@ TestUserInteraction::TestUserInteraction(QWidget *parent) : // add a QComboBox that allows to set the left mouse button action for the JKQTPlotter cmbLeftNoModMouseAction=new QComboBox(this); layForm->addRow("mouse action: left-click, no modifiers", cmbLeftNoModMouseAction); - cmbLeftNoModMouseAction->addItem("PanPlotOnMove"); - cmbLeftNoModMouseAction->addItem("PanPlotOnRelease"); - cmbLeftNoModMouseAction->addItem("ZoomRectangle"); - cmbLeftNoModMouseAction->addItem("DrawRectangleForEvent"); - cmbLeftNoModMouseAction->addItem("DrawCircleForEvent"); - cmbLeftNoModMouseAction->addItem("DrawEllipseForEvent"); - cmbLeftNoModMouseAction->addItem("DrawLineForEvent"); - cmbLeftNoModMouseAction->addItem("ScribbleForEvents"); + cmbLeftNoModMouseAction->addItem("jkqtpmdaPanPlotOnMove"); + cmbLeftNoModMouseAction->addItem("jkqtpmdaPanPlotOnRelease"); + cmbLeftNoModMouseAction->addItem("jkqtpmdaZoomByRectangle"); + cmbLeftNoModMouseAction->addItem("jkqtpmdaDrawRectangleForEvent"); + cmbLeftNoModMouseAction->addItem("jkqtpmdaDrawCircleForEvent"); + cmbLeftNoModMouseAction->addItem("jkqtpmdaDrawEllipseForEvent"); + cmbLeftNoModMouseAction->addItem("jkqtpmdaDrawLineForEvent"); + cmbLeftNoModMouseAction->addItem("jkqtpmdaScribbleForEvents"); cmbLeftNoModMouseAction->addItem("NoMouseAction"); cmbLeftNoModMouseAction->setCurrentIndex(2); connect(cmbLeftNoModMouseAction, SIGNAL(currentIndexChanged(int)), this, SLOT(setLeftMouseAction(int))); @@ -109,14 +109,14 @@ TestUserInteraction::TestUserInteraction(QWidget *parent) : // add a QComboBox that allows to set the left mouse button action for the JKQTPlotter cmbLeftCtrlModMouseAction=new QComboBox(this); layForm->addRow("mouse action: left-click, Ctrl modifier", cmbLeftCtrlModMouseAction); - cmbLeftCtrlModMouseAction->addItem("PanPlotOnMove"); - cmbLeftCtrlModMouseAction->addItem("PanPlotOnRelease"); - cmbLeftCtrlModMouseAction->addItem("ZoomRectangle"); - cmbLeftCtrlModMouseAction->addItem("DrawRectangleForEvent"); - cmbLeftCtrlModMouseAction->addItem("DrawCircleForEvent"); - cmbLeftCtrlModMouseAction->addItem("DrawEllipseForEvent"); - cmbLeftCtrlModMouseAction->addItem("DrawLineForEvent"); - cmbLeftCtrlModMouseAction->addItem("ScribbleForEvents"); + cmbLeftCtrlModMouseAction->addItem("jkqtpmdaPanPlotOnMove"); + cmbLeftCtrlModMouseAction->addItem("jkqtpmdaPanPlotOnRelease"); + cmbLeftCtrlModMouseAction->addItem("jkqtpmdaZoomByRectangle"); + cmbLeftCtrlModMouseAction->addItem("jkqtpmdaDrawRectangleForEvent"); + cmbLeftCtrlModMouseAction->addItem("jkqtpmdaDrawCircleForEvent"); + cmbLeftCtrlModMouseAction->addItem("jkqtpmdaDrawEllipseForEvent"); + cmbLeftCtrlModMouseAction->addItem("jkqtpmdaDrawLineForEvent"); + cmbLeftCtrlModMouseAction->addItem("jkqtpmdaScribbleForEvents"); cmbLeftCtrlModMouseAction->addItem("NoMouseAction"); cmbLeftCtrlModMouseAction->setCurrentIndex(0); connect(cmbLeftCtrlModMouseAction, SIGNAL(currentIndexChanged(int)), this, SLOT(setLeftCtrlMouseAction(int))); @@ -125,14 +125,14 @@ TestUserInteraction::TestUserInteraction(QWidget *parent) : // add a QComboBox that allows to set the left mouse button action for the JKQTPlotter cmbRightNoModMouseAction=new QComboBox(this); layForm->addRow("mouse action: right-click, no modifiers", cmbRightNoModMouseAction); - cmbRightNoModMouseAction->addItem("PanPlotOnMove"); - cmbRightNoModMouseAction->addItem("PanPlotOnRelease"); - cmbRightNoModMouseAction->addItem("ZoomRectangle"); - cmbRightNoModMouseAction->addItem("DrawRectangleForEvent"); - cmbRightNoModMouseAction->addItem("DrawCircleForEvent"); - cmbRightNoModMouseAction->addItem("DrawEllipseForEvent"); - cmbRightNoModMouseAction->addItem("DrawLineForEvent"); - cmbRightNoModMouseAction->addItem("ScribbleForEvents"); + cmbRightNoModMouseAction->addItem("jkqtpmdaPanPlotOnMove"); + cmbRightNoModMouseAction->addItem("jkqtpmdaPanPlotOnRelease"); + cmbRightNoModMouseAction->addItem("jkqtpmdaZoomByRectangle"); + cmbRightNoModMouseAction->addItem("jkqtpmdaDrawRectangleForEvent"); + cmbRightNoModMouseAction->addItem("jkqtpmdaDrawCircleForEvent"); + cmbRightNoModMouseAction->addItem("jkqtpmdaDrawEllipseForEvent"); + cmbRightNoModMouseAction->addItem("jkqtpmdaDrawLineForEvent"); + cmbRightNoModMouseAction->addItem("jkqtpmdaScribbleForEvents"); cmbRightNoModMouseAction->addItem("ContextMenu"); cmbRightNoModMouseAction->setCurrentIndex(5); connect(cmbRightNoModMouseAction, SIGNAL(currentIndexChanged(int)), this, SLOT(setRightMouseAction(int))); @@ -140,10 +140,10 @@ TestUserInteraction::TestUserInteraction(QWidget *parent) : // add a QComboBox that allows to set whether the right mouse button may show the context menu on a single click cmbRightClickContextMenu=new QComboBox(this); - cmbRightClickContextMenu->addItem("StandardContextMenu"); - cmbRightClickContextMenu->addItem("SpecialContextMenu"); - cmbRightClickContextMenu->addItem("StandardAndSpecialContextMenu"); - cmbRightClickContextMenu->addItem("NoContextMenu"); + cmbRightClickContextMenu->addItem("jkqtpcmmStandardContextMenu"); + cmbRightClickContextMenu->addItem("jkqtpcmmSpecialContextMenu"); + cmbRightClickContextMenu->addItem("jkqtpcmmStandardAndSpecialContextMenu"); + cmbRightClickContextMenu->addItem("jkqtpcmmNoContextMenu"); cmbRightClickContextMenu->setCurrentIndex(0); layForm->addRow("mouse action: right-click context menu:", cmbRightClickContextMenu); connect(cmbRightClickContextMenu, SIGNAL(currentIndexChanged(int)), this, SLOT(setRightClickContextMenu(int))); @@ -158,11 +158,11 @@ TestUserInteraction::TestUserInteraction(QWidget *parent) : // add a QComboBox that allows to set the left mouse button double-click action for the JKQTPlotter cmbLeftDoubleClickMouseAction=new QComboBox(this); layForm->addRow("mouse action: left double-click, no modifiers", cmbLeftDoubleClickMouseAction); - cmbLeftDoubleClickMouseAction->addItem("ClickZoomsIn"); - cmbLeftDoubleClickMouseAction->addItem("ClickZoomsOut"); - cmbLeftDoubleClickMouseAction->addItem("ClickOpensContextMenu"); - cmbLeftDoubleClickMouseAction->addItem("ClickOpensSpecialContextMenu"); - cmbLeftDoubleClickMouseAction->addItem("ClickMovesViewport"); + cmbLeftDoubleClickMouseAction->addItem("jkqtpdcaClickZoomsIn"); + cmbLeftDoubleClickMouseAction->addItem("jkqtpdcaClickZoomsOut"); + cmbLeftDoubleClickMouseAction->addItem("jkqtpdcaClickOpensContextMenu"); + cmbLeftDoubleClickMouseAction->addItem("jkqtpdcaClickOpensSpecialContextMenu"); + cmbLeftDoubleClickMouseAction->addItem("jkqtpdcaClickMovesViewport"); cmbLeftDoubleClickMouseAction->addItem("NoAction"); cmbLeftDoubleClickMouseAction->setCurrentIndex(4); connect(cmbLeftDoubleClickMouseAction, SIGNAL(currentIndexChanged(int)), this, SLOT(setLeftDoubleClickMouseAction(int))); @@ -171,11 +171,11 @@ TestUserInteraction::TestUserInteraction(QWidget *parent) : // add a QComboBox that allows to set the left mouse button double-click action for the JKQTPlotter cmbRightDoubleClickMouseAction=new QComboBox(this); layForm->addRow("mouse action: right double-click, no modifiers", cmbRightDoubleClickMouseAction); - cmbRightDoubleClickMouseAction->addItem("ClickZoomsIn"); - cmbRightDoubleClickMouseAction->addItem("ClickZoomsOut"); - cmbRightDoubleClickMouseAction->addItem("ClickOpensContextMenu"); - cmbRightDoubleClickMouseAction->addItem("ClickOpensSpecialContextMenu"); - cmbRightDoubleClickMouseAction->addItem("ClickMovesViewport"); + cmbRightDoubleClickMouseAction->addItem("jkqtpdcaClickZoomsIn"); + cmbRightDoubleClickMouseAction->addItem("jkqtpdcaClickZoomsOut"); + cmbRightDoubleClickMouseAction->addItem("jkqtpdcaClickOpensContextMenu"); + cmbRightDoubleClickMouseAction->addItem("jkqtpdcaClickOpensSpecialContextMenu"); + cmbRightDoubleClickMouseAction->addItem("jkqtpdcaClickMovesViewport"); cmbRightDoubleClickMouseAction->addItem("NoAction"); cmbRightDoubleClickMouseAction->setCurrentIndex(1); connect(cmbRightDoubleClickMouseAction, SIGNAL(currentIndexChanged(int)), this, SLOT(setRightDoubleClickMouseAction(int))); @@ -185,8 +185,8 @@ TestUserInteraction::TestUserInteraction(QWidget *parent) : // add a QComboBox that allows to set the mouse wheel action without modifiers cmbMouseWheelAction=new QComboBox(this); layForm->addRow("mouse action: mouse wheel, no modifiers", cmbMouseWheelAction); - cmbMouseWheelAction->addItem("ZoomByWheel"); - cmbMouseWheelAction->addItem("PanByWheel"); + cmbMouseWheelAction->addItem("jkqtpmwaZoomByWheel"); + cmbMouseWheelAction->addItem("jkqtpmwaPanByWheel"); cmbMouseWheelAction->addItem("NoAction"); cmbMouseWheelAction->setCurrentIndex(0); connect(cmbMouseWheelAction, SIGNAL(currentIndexChanged(int)), this, SLOT(setMouseWheelNoModAction(int))); @@ -223,19 +223,19 @@ TestUserInteraction::TestUserInteraction(QWidget *parent) : void TestUserInteraction::setLeftMouseAction(int index) { if (index==cmbLeftNoModMouseAction->count()-1) plot->deregisterMouseDragAction(Qt::LeftButton, Qt::NoModifier); - else plot->registerMouseDragAction(Qt::LeftButton, Qt::NoModifier, static_cast(index)); + else plot->registerMouseDragAction(Qt::LeftButton, Qt::NoModifier, static_cast(index)); } void TestUserInteraction::setLeftCtrlMouseAction(int index) { if (index==cmbLeftCtrlModMouseAction->count()-1) plot->deregisterMouseDragAction(Qt::LeftButton, Qt::ControlModifier); - else plot->registerMouseDragAction(Qt::LeftButton, Qt::ControlModifier, static_cast(index)); + else plot->registerMouseDragAction(Qt::LeftButton, Qt::ControlModifier, static_cast(index)); } void TestUserInteraction::setRightMouseAction(int index) { if (index==cmbRightNoModMouseAction->count()-1) plot->deregisterMouseDragAction(Qt::RightButton, Qt::NoModifier); - else plot->registerMouseDragAction(Qt::RightButton, Qt::NoModifier, static_cast(index)); + else plot->registerMouseDragAction(Qt::RightButton, Qt::NoModifier, static_cast(index)); } void TestUserInteraction::setPlotMagnification(int index) @@ -245,25 +245,25 @@ void TestUserInteraction::setPlotMagnification(int index) void TestUserInteraction::setRightClickContextMenu(int index) { - plot->setContextMenuMode(static_cast(index)); + plot->setContextMenuMode(static_cast(index)); } void TestUserInteraction::setLeftDoubleClickMouseAction(int index) { if (index>=cmbLeftDoubleClickMouseAction->count()-1) plot->deregisterMouseDoubleClickAction(Qt::LeftButton, Qt::NoModifier); - else plot->registerMouseDoubleClickAction(Qt::LeftButton, Qt::NoModifier, static_cast(index)); + else plot->registerMouseDoubleClickAction(Qt::LeftButton, Qt::NoModifier, static_cast(index)); } void TestUserInteraction::setRightDoubleClickMouseAction(int index) { if (index>=cmbLeftDoubleClickMouseAction->count()-1) plot->deregisterMouseDoubleClickAction(Qt::RightButton, Qt::NoModifier); - else plot->registerMouseDoubleClickAction(Qt::RightButton, Qt::NoModifier, static_cast(index)); + else plot->registerMouseDoubleClickAction(Qt::RightButton, Qt::NoModifier, static_cast(index)); } void TestUserInteraction::setMouseWheelNoModAction(int index) { if (index>=cmbMouseWheelAction->count()-1) plot->deregisterMouseWheelAction(Qt::NoModifier); - else plot->registerMouseWheelAction(Qt::NoModifier, static_cast(index)); + else plot->registerMouseWheelAction(Qt::NoModifier, static_cast(index)); } void TestUserInteraction::plotMouseMove(double x, double y) diff --git a/examples/test_user_interaction/test_user_interaction.pro b/examples/test_user_interaction/test_user_interaction.pro index 1f25243746..b8d8f78921 100644 --- a/examples/test_user_interaction/test_user_interaction.pro +++ b/examples/test_user_interaction/test_user_interaction.pro @@ -16,7 +16,7 @@ HEADERS += \ test_user_interaction.h # include JKQTPlotter source code -DEPENDPATH += . ../../lib +DEPENDPATH += ../../lib ../../staticlib INCLUDEPATH += ../../lib CONFIG (debug, debug|release) { LIBS += -L../../staticlib/debug -ljkqtplotterlib_debug @@ -35,7 +35,7 @@ win32-msvc* { } -# here you can activate some debug options -#DEFINES += SHOW_JKQTPLOTTER_DEBUG -#DEFINES += JKQTBP_AUTOTIMER + + + diff --git a/lib/jkqtfastplotter.pri b/lib/jkqtfastplotter.pri index 6acf76b637..456e428707 100644 --- a/lib/jkqtfastplotter.pri +++ b/lib/jkqtfastplotter.pri @@ -1,3 +1,5 @@ +# uncomment this line to prevent linking in of the XITS fonts +#DEFINES += NO_XITS_FONTS include($$PWD/common.pri) diff --git a/lib/jkqtfastplotter/jkqtfastplotter.cpp b/lib/jkqtfastplotter/jkqtfastplotter.cpp index af4806f2fc..fba0070650 100644 --- a/lib/jkqtfastplotter/jkqtfastplotter.cpp +++ b/lib/jkqtfastplotter/jkqtfastplotter.cpp @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -20,6 +20,7 @@ #include "jkqtfastplotter.h" +#include "jkqtplottertools/jkqtptools.h" #include #include #include @@ -45,6 +46,8 @@ #define JKQTFPPROPERTYload(settings, group, var, varname, varconvert) \ var=(settings).value((group)+(varname), var).varconvert; +const double JKQTFastPlotter::ABS_MIN_LINEWIDTH=0.05; +const int JKQTFastPlotter::LUTSIZE=256; JKQTFPPlot::JKQTFPPlot(JKQTFastPlotter* parent): QObject(parent) @@ -286,7 +289,7 @@ void JKQTFastPlotter::plotSystem(QPainter& painter) { std::cout<<"timing plotSystem():\n"; timer.start(); #endif - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); /////////////////////////////////////////////////////////////////// // FILL WIDGET BACKGROUND /////////////////////////////////////////////////////////////////// @@ -309,11 +312,11 @@ void JKQTFastPlotter::plotSystem(QPainter& painter) { /////////////////////////////////////////////////////////////////// QPen p=painter.pen(); QPen pSystem(systemColor); - pSystem.setWidthF(qMax(JKQTFASTPLOTTER_ABS_MIN_LINEWIDTH, systemWidth)); + pSystem.setWidthF(qMax(JKQTFastPlotter::ABS_MIN_LINEWIDTH, systemWidth)); pSystem.setJoinStyle(Qt::MiterJoin); pSystem.setCapStyle(Qt::SquareCap); QPen pGrid(gridColor); - pGrid.setWidthF(qMax(JKQTFASTPLOTTER_ABS_MIN_LINEWIDTH, gridWidth)); + pGrid.setWidthF(qMax(JKQTFastPlotter::ABS_MIN_LINEWIDTH, gridWidth)); pGrid.setStyle(gridStyle); pGrid.setJoinStyle(Qt::MiterJoin); pGrid.setCapStyle(Qt::SquareCap); @@ -453,11 +456,11 @@ void JKQTFastPlotter::plotSystem(QPainter& painter) { painter.drawText(QPointF(internalPlotBorderLeft+plotWidth-fmLabels.width(xAxisLabel), internalPlotBorderTop+plotHeight+fmTicks.height()+fmTicks.width("x")/2.0+fmLabels.ascent()+tickLength), xAxisLabel); } if (yAxisLabelVisible) { - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.translate(fmLabels.ascent(), internalPlotBorderTop+fmLabels.width(yAxisLabel)); painter.rotate(-90); painter.drawText(QPointF(0, 0), yAxisLabel); - painter.restore(); + } #ifdef DEBUG_TIMING time_gt=timer.getTime(); @@ -489,7 +492,7 @@ void JKQTFastPlotter::plotSystem(QPainter& painter) { timer.start(); #endif - painter.restore(); + #ifdef DEBUG_TIMING time_gt=timer.getTime(); time_sum+=time_gt; @@ -506,7 +509,7 @@ void JKQTFastPlotter::plotGraphs(QPainter& painter) { std::cout<<"timing plotGraphs():\n"; timer.start(); #endif - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); for (int i=0; ix2p(x[i]); @@ -1370,7 +1373,7 @@ void JKQTFPimageOverlayPlot::drawGraph(QPainter& painter) { if (this->symboltype==stCircle) painter.drawEllipse(r); else painter.drawRect(r); } - painter.restore(); + } else { QImage img(width, height, QImage::Format_ARGB32); QColor tc(Qt::transparent); @@ -1419,7 +1422,7 @@ JKQTFPQScaleBarXPlot::JKQTFPQScaleBarXPlot(JKQTFastPlotter* parent, double width } void JKQTFPQScaleBarXPlot::drawGraph(QPainter& painter) { - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); QRectF r(QPointF(parent->getInternalPlotBorderLeft(), parent->getInternalPlotBorderTop()), QPointF(parent->getInternalPlotBorderLeft()+parent->getPlotWidth(), parent->getInternalPlotBorderTop()+parent->getPlotHeight())); @@ -1428,7 +1431,7 @@ void JKQTFPQScaleBarXPlot::drawGraph(QPainter& painter) { int yDistance=static_cast(parent->getPlotHeight())*borderfraction; QPen p(color); - p.setWidthF(qMax(JKQTFASTPLOTTER_ABS_MIN_LINEWIDTH, lineWidth)); + p.setWidthF(qMax(JKQTFastPlotter::ABS_MIN_LINEWIDTH, lineWidth)); p.setColor(color); QString s=label.arg(width); @@ -1481,7 +1484,7 @@ void JKQTFPQScaleBarXPlot::drawGraph(QPainter& painter) { } - painter.restore(); + } @@ -1500,10 +1503,10 @@ JKQTFPQOverlayLinearGridPlot::JKQTFPQOverlayLinearGridPlot(JKQTFastPlotter* pare } void JKQTFPQOverlayLinearGridPlot::drawGraph(QPainter& painter) { - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); QPen p(color); - p.setWidthF(qMax(JKQTFASTPLOTTER_ABS_MIN_LINEWIDTH, lineWidth)); + p.setWidthF(qMax(JKQTFastPlotter::ABS_MIN_LINEWIDTH, lineWidth)); p.setColor(color); p.setStyle(style); @@ -1539,7 +1542,7 @@ void JKQTFPQOverlayLinearGridPlot::drawGraph(QPainter& painter) { painter.setPen(p); painter.drawPath(gridPath); - painter.restore(); + } @@ -1779,7 +1782,7 @@ void JKQTFPYRangePlot::drawGraph(QPainter& painter) { b.setColor(fillColor); QPen p(color); p.setStyle(style); - p.setWidthF(qMax(JKQTFASTPLOTTER_ABS_MIN_LINEWIDTH, width)); + p.setWidthF(qMax(JKQTFastPlotter::ABS_MIN_LINEWIDTH, width)); painter.setPen(p); painter.fillRect(r, b); if (showCenterline) { @@ -1788,4 +1791,3 @@ void JKQTFPYRangePlot::drawGraph(QPainter& painter) { painter.drawRect(r); } - diff --git a/lib/jkqtfastplotter/jkqtfastplotter.h b/lib/jkqtfastplotter/jkqtfastplotter.h index 33ab78f08d..2ce809f02d 100644 --- a/lib/jkqtfastplotter/jkqtfastplotter.h +++ b/lib/jkqtfastplotter/jkqtfastplotter.h @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -47,7 +47,7 @@ # include "jkqtplottertools/jkqtphighrestimer.h" #endif -#define JKQTFASTPLOTTER_ABS_MIN_LINEWIDTH 0.05 + // forward declaration class JKQTFPPlot; @@ -84,7 +84,7 @@ class JKQTFPPlot; - plot may contain a grid (x and y grid may be switched on/off separately). - plots are represented by descendents of JKQTFPPlot and the plotting code is completely contained therein (and should be speed optimized). - - it is possible to keep a specified aspect ration + - it is possible to keep a specified aspect ratio - it is possible to couple different plots in a way, that they are plottetd with the same width/height both in pixel and world coordinates by using plotterSizesChanged() and synchronizeX() / synchronizeY(). . @@ -92,6 +92,16 @@ class JKQTFPPlot; */ class JKQTP_LIB_EXPORT JKQTFastPlotter : public QGLWidget { Q_OBJECT + public: + + /*! \brief smallest allowed line width for JKQTFastPlotter + */ + static const double ABS_MIN_LINEWIDTH; + + /*! \brief size of the lookup tables used by JKQTFPimagePlot_array2image() + */ + static const int LUTSIZE; + protected: /** \brief indicates whether to do full repaint (system and data) at the next repaint (any of the repaint meothods) */ bool doFullRepaint; @@ -294,7 +304,7 @@ class JKQTP_LIB_EXPORT JKQTFastPlotter : public QGLWidget { /** \brief synchronize y-axis settings to this plotter */ JKQTFastPlotter* synchronizeY; - /** \brief aspect ration of the plot, only used when maintainAspectRation is \c true + /** \brief aspect ratio of the plot, only used when maintainAspectRation is \c true * * The aspect ratio is defined as \c width/height of the plot in pt. * So if you want to have a plot spanning \c x=0..20 and \c y=0..10 where each 1x1 square should be @@ -2098,25 +2108,20 @@ enum JKQTFPImageFormat { }; -/*! \brief size of the lookup tables used by JKQTFPimagePlot_array2image() - \ingroup jkqtfastplotter -*/ -#define JKQTFPimagePlot_LUTSIZE 256 - /*! \brief convert a 2D image (as 1D array) into a QImage with given palette (see JKQTFPColorPalette) \ingroup jkqtfastplotter This method uses lookup tables which are saved as static variables to convert the 2D array into an image. The luts are only created once, and stored then, so mor CPU time is saved. The precompiler define - JKQTFPimagePlot_LUTSIZE sets the size of the LUTs. Note that if you don't use a specific color palette, + JKQTFastPlotter::LUTSIZE sets the size of the LUTs. Note that if you don't use a specific color palette, the according LUT won't be calculated and stored! */ template inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &img, JKQTFPColorPalette palette, double minColor, double maxColor) { - if (!dbl) - return; + if (!dbl) + return; #ifdef DEBUG_TIMING JKQTPHighResTimer timer; @@ -2126,21 +2131,21 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i timer.start(); #endif //std::cout<<"color range: "< max) - max = v; - } - } else { - min = minColor; - max = maxColor; - } + if (v < min) + min = v; + else if (v > max) + max = v; + } + } else { + min = minColor; + max = maxColor; + } #ifdef DEBUG_TIMING time_gt=timer.getTime(); time_sum+=time_gt; @@ -2149,7 +2154,7 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i #endif //std::cout<<"minColor="<(malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(QRgb))); + (*plut)=static_cast(malloc((JKQTFastPlotter::LUTSIZE+2)*sizeof(QRgb))); if ((*plut)!=nullptr) { - for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); + for (int l=0; l<=JKQTFastPlotter::LUTSIZE; l++) { + double v=l/static_cast(JKQTFastPlotter::LUTSIZE); (*plut)[l]=qRgb(static_cast(255.0*v), 0, 0); } } @@ -2194,122 +2199,122 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i } else if (palette == JKQTFP_GREEN) - { + { QRgb** plut=&lut_green; if ((*plut)==nullptr) { - (*plut)=static_cast(malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(QRgb))); + (*plut)=static_cast(malloc((JKQTFastPlotter::LUTSIZE+2)*sizeof(QRgb))); if ((*plut)!=nullptr) { - for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); + for (int l=0; l<=JKQTFastPlotter::LUTSIZE; l++) { + double v=l/static_cast(JKQTFastPlotter::LUTSIZE); (*plut)[l]=qRgb(0, static_cast(255.0*v), 0); } } } lut_used=(*plut); - } - else if (palette == JKQTFP_BLUE) - { + } + else if (palette == JKQTFP_BLUE) + { QRgb** plut=&lut_blue; if ((*plut)==nullptr) { - (*plut)=static_cast(malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(QRgb))); + (*plut)=static_cast(malloc((JKQTFastPlotter::LUTSIZE+2)*sizeof(QRgb))); if ((*plut)!=nullptr) { - for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); + for (int l=0; l<=JKQTFastPlotter::LUTSIZE; l++) { + double v=l/static_cast(JKQTFastPlotter::LUTSIZE); (*plut)[l]=qRgb(0, 0, static_cast(255.0*v)); } } } lut_used=(*plut); - } + } else if (palette == JKQTFP_GRAY) - { + { QRgb** plut=&lut_gray; if ((*plut)==nullptr) { - (*plut)=static_cast(malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(QRgb))); + (*plut)=static_cast(malloc((JKQTFastPlotter::LUTSIZE+2)*sizeof(QRgb))); if ((*plut)!=nullptr) { - for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); + for (int l=0; l<=JKQTFastPlotter::LUTSIZE; l++) { + double v=l/static_cast(JKQTFastPlotter::LUTSIZE); (*plut)[l]=qRgb(static_cast(255.0*v), - static_cast(255.0*v), - static_cast(255.0*v)); + static_cast(255.0*v), + static_cast(255.0*v)); } } } lut_used=(*plut); - } + } - else if (palette == JKQTFP_INVERTEDRED) - { + else if (palette == JKQTFP_INVERTEDRED) + { QRgb** plut=&lut_invred; if ((*plut)==nullptr) { - (*plut)=static_cast(malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(QRgb))); + (*plut)=static_cast(malloc((JKQTFastPlotter::LUTSIZE+2)*sizeof(QRgb))); if ((*plut)!=nullptr) { - for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); + for (int l=0; l<=JKQTFastPlotter::LUTSIZE; l++) { + double v=l/static_cast(JKQTFastPlotter::LUTSIZE); (*plut)[l]=qRgb(static_cast(255.0*(1.0-v)), 0, 0); } } } lut_used=(*plut); - } - else if (palette == JKQTFP_INVERTEDGREEN) - { + } + else if (palette == JKQTFP_INVERTEDGREEN) + { QRgb** plut=&lut_invgreen; if ((*plut)==nullptr) { - (*plut)=static_cast(malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(QRgb))); + (*plut)=static_cast(malloc((JKQTFastPlotter::LUTSIZE+2)*sizeof(QRgb))); if ((*plut)!=nullptr) { - for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); + for (int l=0; l<=JKQTFastPlotter::LUTSIZE; l++) { + double v=l/static_cast(JKQTFastPlotter::LUTSIZE); (*plut)[l]=qRgb(0, static_cast(255.0*(1.0-v)), 0); } } } lut_used=(*plut); - } - else if (palette == JKQTFP_INVERTEDBLUE) - { + } + else if (palette == JKQTFP_INVERTEDBLUE) + { QRgb** plut=&lut_invblue; if ((*plut)==nullptr) { - (*plut)=static_cast(malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(QRgb))); + (*plut)=static_cast(malloc((JKQTFastPlotter::LUTSIZE+2)*sizeof(QRgb))); if ((*plut)!=nullptr) { - for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); + for (int l=0; l<=JKQTFastPlotter::LUTSIZE; l++) { + double v=l/static_cast(JKQTFastPlotter::LUTSIZE); (*plut)[l]=qRgb(0, 0, static_cast(255.0*(1.0-v))); } } } lut_used=(*plut); - } - else if (palette == JKQTFP_INVERTEDGRAY) - { + } + else if (palette == JKQTFP_INVERTEDGRAY) + { QRgb** plut=&lut_invgray; if ((*plut)==nullptr) { - (*plut)=static_cast(malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(QRgb))); + (*plut)=static_cast(malloc((JKQTFastPlotter::LUTSIZE+2)*sizeof(QRgb))); if ((*plut)!=nullptr) { - for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { - double v=1.0-(l/static_cast(JKQTFPimagePlot_LUTSIZE)); + for (int l=0; l<=JKQTFastPlotter::LUTSIZE; l++) { + double v=1.0-(l/static_cast(JKQTFastPlotter::LUTSIZE)); (*plut)[l]=qRgb(static_cast(255.0*v), - static_cast(255.0*v), - static_cast(255.0*v)); + static_cast(255.0*v), + static_cast(255.0*v)); } } } lut_used=(*plut); - } + } - else if (palette == JKQTFP_MATLAB) - { + else if (palette == JKQTFP_MATLAB) + { QRgb** plut=&lut_matlab; if ((*plut)==nullptr) { - (*plut)=static_cast(malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(QRgb))); + (*plut)=static_cast(malloc((JKQTFastPlotter::LUTSIZE+2)*sizeof(QRgb))); if ((*plut)!=nullptr) { - for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); + for (int l=0; l<=JKQTFastPlotter::LUTSIZE; l++) { + double v=l/static_cast(JKQTFastPlotter::LUTSIZE); double r = 382.5 - 1020.0 * std::abs(v - 0.75); if (r > 255.0) r = 255.0; @@ -2334,15 +2339,15 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i } lut_used=(*plut); - } - else if (palette == JKQTFP_RYGB) //gnuplot: 30,-13,-23 - { + } + else if (palette == JKQTFP_RYGB) //gnuplot: 30,-13,-23 + { QRgb** plut=&lut_rygb; if ((*plut)==nullptr) { - (*plut)=static_cast(malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(QRgb))); + (*plut)=static_cast(malloc((JKQTFastPlotter::LUTSIZE+2)*sizeof(QRgb))); if ((*plut)!=nullptr) { - for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); + for (int l=0; l<=JKQTFastPlotter::LUTSIZE; l++) { + double v=l/static_cast(JKQTFastPlotter::LUTSIZE); double r = 796.875*v - 199.21875; if (r > 255.0) r = 255.0; @@ -2360,15 +2365,15 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i } lut_used=(*plut); - } - else if (palette == JKQTFP_HSV) - { + } + else if (palette == JKQTFP_HSV) + { QRgb** plut=&lut_hsv; if ((*plut)==nullptr) { - (*plut)=static_cast(malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(QRgb))); + (*plut)=static_cast(malloc((JKQTFastPlotter::LUTSIZE+2)*sizeof(QRgb))); if ((*plut)!=nullptr) { - for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); + for (int l=0; l<=JKQTFastPlotter::LUTSIZE; l++) { + double v=l/static_cast(JKQTFastPlotter::LUTSIZE); int h = static_cast(floor(6*v)); double f = 6*v-double(h); @@ -2386,15 +2391,15 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i } } lut_used=(*plut); - } - else if (palette == JKQTFP_INVERTED_HSV) - { + } + else if (palette == JKQTFP_INVERTED_HSV) + { QRgb** plut=&lut_invhsv; if ((*plut)==nullptr) { - (*plut)=static_cast(malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(QRgb))); + (*plut)=static_cast(malloc((JKQTFastPlotter::LUTSIZE+2)*sizeof(QRgb))); if ((*plut)!=nullptr) { - for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); + for (int l=0; l<=JKQTFastPlotter::LUTSIZE; l++) { + double v=l/static_cast(JKQTFastPlotter::LUTSIZE); int h = static_cast(floor(6.0-6.0*v)); double f = 6.0-6.0*v-double(h); @@ -2413,15 +2418,15 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i } lut_used=(*plut); - } - else if (palette == JKQTFP_RAINBOW) //gnuplot: 33,13,10 - { + } + else if (palette == JKQTFP_RAINBOW) //gnuplot: 33,13,10 + { if (lut_rainbow==nullptr) { - lut_rainbow=static_cast(malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(QRgb))); + lut_rainbow=static_cast(malloc((JKQTFastPlotter::LUTSIZE+2)*sizeof(QRgb))); //std::cout<<"!!! creating rainbow lut\n"; if (lut_rainbow!=nullptr) { - for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); + for (int l=0; l<=JKQTFastPlotter::LUTSIZE; l++) { + double v=l/static_cast(JKQTFastPlotter::LUTSIZE); double r = 255.0*std::abs(2.0*v-0.5); if (r > 255.0) r = 255.0; @@ -2434,43 +2439,43 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i } } } - lut_used=lut_rainbow; - } - else if (palette == JKQTFP_HOT) //gnuplot: 21,22,23 - { + lut_used=lut_rainbow; + } + else if (palette == JKQTFP_HOT) //gnuplot: 21,22,23 + { QRgb** plut=&lut_hot; if ((*plut)==nullptr) { - (*plut)=static_cast(malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(QRgb))); + (*plut)=static_cast(malloc((JKQTFastPlotter::LUTSIZE+2)*sizeof(QRgb))); if ((*plut)!=nullptr) { - for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); - double r = 765.0*v; - if (r > 255.0) - r = 255.0; + for (int l=0; l<=JKQTFastPlotter::LUTSIZE; l++) { + double v=l/static_cast(JKQTFastPlotter::LUTSIZE); + double r = 765.0*v; + if (r > 255.0) + r = 255.0; - double g = 765.0*v-255.0; - if (g > 255.0) - g = 255.0; - else if (g < 0.0) - g = 0.0; + double g = 765.0*v-255.0; + if (g > 255.0) + g = 255.0; + else if (g < 0.0) + g = 0.0; - double b = 765.0*v-510.0; - if (b < 0.0) - b = 0.0; + double b = 765.0*v-510.0; + if (b < 0.0) + b = 0.0; (*plut)[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); } } } lut_used=(*plut); - } - else if (palette == JKQTFP_OCEAN) //gnuplot: 23,28,3 - { + } + else if (palette == JKQTFP_OCEAN) //gnuplot: 23,28,3 + { QRgb** plut=&lut_ocean; if ((*plut)==nullptr) { - (*plut)=static_cast(malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(QRgb))); + (*plut)=static_cast(malloc((JKQTFastPlotter::LUTSIZE+2)*sizeof(QRgb))); if ((*plut)!=nullptr) { - for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); + for (int l=0; l<=JKQTFastPlotter::LUTSIZE; l++) { + double v=l/static_cast(JKQTFastPlotter::LUTSIZE); double r = 765.0*v-510.0; if (r < 0.0) r = 0.0; @@ -2483,15 +2488,15 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i } } lut_used=(*plut); - } - else if (palette == JKQTFP_BLUEMAGENTAYELLOW) //gnuplot: 30,31,32 - { + } + else if (palette == JKQTFP_BLUEMAGENTAYELLOW) //gnuplot: 30,31,32 + { QRgb** plut=&lut_bluemagentayellow; if ((*plut)==nullptr) { - (*plut)=static_cast(malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(QRgb))); + (*plut)=static_cast(malloc((JKQTFastPlotter::LUTSIZE+2)*sizeof(QRgb))); if ((*plut)!=nullptr) { - for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); + for (int l=0; l<=JKQTFastPlotter::LUTSIZE; l++) { + double v=l/static_cast(JKQTFastPlotter::LUTSIZE); double r = (v/0.32-0.78125); if (r < 0.0) r = 0.0; if (r > 1.0) r = 1.0; @@ -2512,15 +2517,15 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i } } lut_used=(*plut); - } - else if (palette == JKQTFP_BLUEYELLOW) //gnuplot: 8,9,10 - { + } + else if (palette == JKQTFP_BLUEYELLOW) //gnuplot: 8,9,10 + { QRgb** plut=&lut_blueyellow; if ((*plut)==nullptr) { - (*plut)=static_cast(malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(QRgb))); + (*plut)=static_cast(malloc((JKQTFastPlotter::LUTSIZE+2)*sizeof(QRgb))); if ((*plut)!=nullptr) { - for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); + for (int l=0; l<=JKQTFastPlotter::LUTSIZE; l++) { + double v=l/static_cast(JKQTFastPlotter::LUTSIZE); double r = sqrt(sqrt(v)); if (r < 0.0) r = 0.0; if (r > 1.0) r = 1.0; @@ -2539,15 +2544,15 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i } lut_used=(*plut); - } - else if (palette == JKQTFP_CYAN) - { + } + else if (palette == JKQTFP_CYAN) + { QRgb** plut=&lut_cyan; if ((*plut)==nullptr) { - (*plut)=static_cast(malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(QRgb))); + (*plut)=static_cast(malloc((JKQTFastPlotter::LUTSIZE+2)*sizeof(QRgb))); if ((*plut)!=nullptr) { - for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); + for (int l=0; l<=JKQTFastPlotter::LUTSIZE; l++) { + double v=l/static_cast(JKQTFastPlotter::LUTSIZE); double r = v*0.5; if (r < 0.0) r = 0.0; if (r > 1.0) r = 1.0; @@ -2565,15 +2570,15 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i } lut_used=(*plut); - } - else if (palette == JKQTFP_TRAFFICLIGHT) - { + } + else if (palette == JKQTFP_TRAFFICLIGHT) + { QRgb** plut=&lut_trafficlight; if ((*plut)==nullptr) { - (*plut)=static_cast(malloc((JKQTFPimagePlot_LUTSIZE+2)*sizeof(QRgb))); + (*plut)=static_cast(malloc((JKQTFastPlotter::LUTSIZE+2)*sizeof(QRgb))); if ((*plut)!=nullptr) { - for (int l=0; l<=JKQTFPimagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTFPimagePlot_LUTSIZE); + for (int l=0; l<=JKQTFastPlotter::LUTSIZE; l++) { + double v=l/static_cast(JKQTFastPlotter::LUTSIZE); double r = (v < 0.5) ? 128.0*sin(M_PI*(2.0*v-0.5))+128.0 : 255.0; if (r > 255.0) r = 255.0; @@ -2587,7 +2592,7 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i } lut_used=(*plut); - } + } #ifdef DEBUG_TIMING time_gt=timer.getTime(); @@ -2596,20 +2601,20 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i timer.start(); #endif if (lut_used!=nullptr) { - // LUT found: collor the image accordingly + // LUT found: collor the image accordingly for (int j=0; j(img.scanLine(height-1-j)); for (int i=0; i JKQTFPimagePlot_LUTSIZE) ? JKQTFPimagePlot_LUTSIZE : v); - line[i]=lut_used[v]; - } - } + int v = (dbl[j*width+i]-min)/delta*JKQTFastPlotter::LUTSIZE; + v = (v < 0) ? 0 : ( (v > JKQTFastPlotter::LUTSIZE) ? JKQTFastPlotter::LUTSIZE : v); + line[i]=lut_used[v]; + } + } } else { // no LUT found: paint a black image! - img.fill(0); - } - } + img.fill(0); + } + } #ifdef DEBUG_TIMING time_gt=timer.getTime(); time_sum+=time_gt; @@ -2681,6 +2686,8 @@ class JKQTP_LIB_EXPORT JKQTFPimagePlot: public JKQTFPPlot { /** \brief rotation of the image when plotting in units of 90 degrees (counter clock wise) */ int rotation; public: + + /*! \brief class constructor */ @@ -3120,21 +3127,21 @@ class JKQTP_LIB_EXPORT JKQTFPRGBImageOverlayPlot: public JKQTFPPlot { /*! \brief sets the properties imageRed and imageFormatRed to the specified \a __value and \a __value2. \details Description of the parameter imageRed is:
    \copydoc JKQTFPRGBImageOverlayPlot::imageRed
    \details Description of the parameter imageFormatRed is:
    \copydoc JKQTFPRGBImageOverlayPlot::imageFormatRed
    - \see imageRed and imageFormatRed for more information */ + \see imageRed and imageFormatRed for more information */ inline void setImageRed (void* __value, JKQTFPImageFormat __value2) { - bool set=false; - if (this->imageRed != __value) { - this->imageRed = __value; - set=true; - } - if (this->imageFormatRed != __value2) { - this->imageFormatRed = __value2; - set=true; - } - if (set) { - replot(); - } + bool set=false; + if (this->imageRed != __value) { + this->imageRed = __value; + set=true; + } + if (this->imageFormatRed != __value2) { + this->imageFormatRed = __value2; + set=true; + } + if (set) { + replot(); + } } /*! \brief returns the property imageRed ( \copybrief imageRed ). \details Description of the parameter imageRed is:
    \copydoc JKQTFPRGBImageOverlayPlot::imageRed
    \details Description of the parameter imageFormatRed is:
    \copydoc JKQTFPRGBImageOverlayPlot::imageFormatRed
    @@ -3146,21 +3153,21 @@ class JKQTP_LIB_EXPORT JKQTFPRGBImageOverlayPlot: public JKQTFPPlot { inline JKQTFPImageFormat getImageFormatRed () const { return this->imageFormatRed; } /*! \brief sets the properties imageGreen and imageFormatGreen to the specified \a __value and \a __value2. \details Description of the parameter imageGreen is:
    \copydoc JKQTFPRGBImageOverlayPlot::imageGreen
    \details Description of the parameter imageFormatGreen is:
    \copydoc JKQTFPRGBImageOverlayPlot::imageFormatGreen
    - \see imageGreen and imageFormatGreen for more information */ + \see imageGreen and imageFormatGreen for more information */ inline void setImageGreen (void* __value, JKQTFPImageFormat __value2) { - bool set=false; - if (this->imageGreen != __value) { - this->imageGreen = __value; - set=true; - } - if (this->imageFormatGreen != __value2) { - this->imageFormatGreen = __value2; - set=true; - } - if (set) { - replot(); - } + bool set=false; + if (this->imageGreen != __value) { + this->imageGreen = __value; + set=true; + } + if (this->imageFormatGreen != __value2) { + this->imageFormatGreen = __value2; + set=true; + } + if (set) { + replot(); + } } /*! \brief returns the property imageGreen ( \copybrief imageGreen ). \details Description of the parameter imageGreen is:
    \copydoc JKQTFPRGBImageOverlayPlot::imageGreen
    \details Description of the parameter imageFormatGreen is:
    \copydoc JKQTFPRGBImageOverlayPlot::imageFormatGreen
    @@ -3172,21 +3179,21 @@ class JKQTP_LIB_EXPORT JKQTFPRGBImageOverlayPlot: public JKQTFPPlot { inline JKQTFPImageFormat getImageFormatGreen () const { return this->imageFormatGreen; } /*! \brief sets the properties imageBlue and imageFormatBlue to the specified \a __value and \a __value2. \details Description of the parameter imageBlue is:
    \copydoc JKQTFPRGBImageOverlayPlot::imageBlue
    \details Description of the parameter imageFormatBlue is:
    \copydoc JKQTFPRGBImageOverlayPlot::imageFormatBlue
    - \see imageBlue and imageFormatBlue for more information */ + \see imageBlue and imageFormatBlue for more information */ inline void setImageBlue (void* __value, JKQTFPImageFormat __value2) { - bool set=false; - if (this->imageBlue != __value) { - this->imageBlue = __value; - set=true; - } - if (this->imageFormatBlue != __value2) { - this->imageFormatBlue = __value2; - set=true; - } - if (set) { - replot(); - } + bool set=false; + if (this->imageBlue != __value) { + this->imageBlue = __value; + set=true; + } + if (this->imageFormatBlue != __value2) { + this->imageFormatBlue = __value2; + set=true; + } + if (set) { + replot(); + } } /*! \brief returns the property imageBlue ( \copybrief imageBlue ). \details Description of the parameter imageBlue is:
    \copydoc JKQTFPRGBImageOverlayPlot::imageBlue
    \details Description of the parameter imageFormatBlue is:
    \copydoc JKQTFPRGBImageOverlayPlot::imageFormatBlue
    diff --git a/lib/jkqtmathtext.pri b/lib/jkqtmathtext.pri index 9e8cd8106b..cb2c082909 100644 --- a/lib/jkqtmathtext.pri +++ b/lib/jkqtmathtext.pri @@ -1,3 +1,5 @@ +# uncomment this line to prevent linking in of the XITS fonts +#DEFINES += NO_XITS_FONTS include($$PWD/common.pri) diff --git a/lib/jkqtmathtext/jkqtmathtext.cpp b/lib/jkqtmathtext/jkqtmathtext.cpp index ad16130415..952709fd59 100644 --- a/lib/jkqtmathtext/jkqtmathtext.cpp +++ b/lib/jkqtmathtext/jkqtmathtext.cpp @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -20,12 +20,12 @@ #include "jkqtmathtext/jkqtmathtext.h" +#include "jkqtplottertools/jkqtptools.h" #include #include #include #include #include -//#define jkqtp_QColor2String(color) QString(jkqtp_rgbtostring((color).red(), (color).green(), (color).blue(), (color).alpha()).c_str()) /** * \brief saves the given property (for which also a default_property exists) into the given settings object @@ -42,6 +42,7 @@ #define JKQTMTPROPERTYload(settings, group, var, varname, varconvert) \ var=settings.value(group+varname, var).varconvert; +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) { double xl1=x-(width)*cubicshrink+bw*cubicshrink; @@ -215,7 +216,7 @@ bool JKQTMathText::MTnode::toHtml(QString &/*html*/, JKQTMathText::MTenvironment void JKQTMathText::MTnode::doDrawBoxes(QPainter& painter, double x, double y, JKQTMathText::MTenvironment currentEv) { if (drawBoxes) { - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); double w, oh, bh, sp; getSize(painter, currentEv, w, bh, oh, sp); QPen p=painter.pen(); @@ -234,7 +235,7 @@ void JKQTMathText::MTnode::doDrawBoxes(QPainter& painter, double x, double y, JK painter.setPen(p); painter.drawLine(x-2.0, y, x+2.0, y); painter.drawLine(x, y-2, x, y+2.0); - painter.restore(); + } } @@ -667,10 +668,10 @@ double JKQTMathText::MTsqrtNode::draw(QPainter& painter, double x, double y, JKQ double w=fm.boundingRect("A").width(); double a=baselineHeight*1.15; double d=overallHeight-baselineHeight; - //painter.save(); + //painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); QPen p=painter.pen(); p.setColor(currentEv.color); - p.setWidthF(qMax(JKQTMATHTEXT_ABS_MIN_LINEWIDTH,ceil(currentEv.fontSize/16.0))); + p.setWidthF(qMax(JKQTMathText::ABS_MIN_LINEWIDTH,ceil(currentEv.fontSize/16.0))); //painter.setPen(p); QPainterPath path; if (w>0) { @@ -687,14 +688,14 @@ double JKQTMathText::MTsqrtNode::draw(QPainter& painter, double x, double y, JKQ } //painter.restore(); double xnew=child->draw(painter, x+1.2*w, y, currentEv); - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.setPen(p); if (w>0) { path.lineTo( xnew+0.2*w, y-a); path.lineTo(xnew+0.2*w, y-0.8*a); painter.drawPath(path); } - painter.restore(); + return xnew+0.33*w; } @@ -857,8 +858,8 @@ double JKQTMathText::MTfracNode::draw(QPainter& painter, double x, double y, JKQ QPen p=painter.pen(); p.setColor(ev1.color); p.setStyle(Qt::SolidLine); - p.setWidthF(qMax(JKQTMATHTEXT_ABS_MIN_LINEWIDTH, lw)); - painter.save(); + p.setWidthF(qMax(JKQTMathText::ABS_MIN_LINEWIDTH, lw)); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.setPen(p); if (mode==MTFMfrac || mode==MTFMdfrac || mode==MTFMtfrac) { QLineF l(x+xw/4.0, yline, x+width+xw/2.0, yline); @@ -884,17 +885,17 @@ double JKQTMathText::MTfracNode::draw(QPainter& painter, double x, double y, JKQ } else if (mode==MTFMoverbrace) { double ybrace=y-ascent1-bw/2.0; - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.translate(x+xw/2.0+(width1)/2.0, ybrace); painter.rotate(180); QPainterPath path=makeHBracePath(0,0, width, bw); painter.drawPath(path); - painter.restore(); + child1->draw(painter, x+xw/2.0+(width-width1)/2.0, y, ev1); child2->draw(painter, x+xw/2.0+(width-width2)/2.0, y-ascent1-bw-descent2, ev2); } - painter.restore(); + if (mode==MTFMstackrel) return x+width+ xw; return x+width+xw; @@ -1121,7 +1122,7 @@ double JKQTMathText::MTdecoratedNode::draw(QPainter& painter, double x, double y QPen pold=painter.pen(); QPen p=pold; p.setColor(ev.color); - p.setWidthF(qMax(JKQTMATHTEXT_ABS_MIN_LINEWIDTH, fm.lineWidth()));//ceil(currentEv.fontSize/16.0)); + p.setWidthF(qMax(JKQTMathText::ABS_MIN_LINEWIDTH, fm.lineWidth()));//ceil(currentEv.fontSize/16.0)); if (decoration==MTDbar) ev.overline=true; double xnew=child->draw(painter, x, y, ev); if (decoration==MTDvec) { @@ -1386,11 +1387,11 @@ double JKQTMathText::MTbraceNode::draw(QPainter& painter, double x, double y, JK painter.drawPath(path); } else if (openbrace=="{") { QPainterPath path=makeHBracePath(0,0,coverallHeight, bracewidth*brace_fraction); - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.translate(xnew+bracewidth*(1.0-brace_fraction), y-cbaselineHeight+coverallHeight/2.0); painter.rotate(90); painter.drawPath(path); - painter.restore(); + } else if (openbrace=="_") { QPainterPath path; double y1=y+(coverallHeight-cbaselineHeight); @@ -1456,11 +1457,11 @@ double JKQTMathText::MTbraceNode::draw(QPainter& painter, double x, double y, JK painter.drawPath(path); } else if (closebrace=="}") { QPainterPath path=makeHBracePath(0,0,coverallHeight, bracewidth*brace_fraction); - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.translate(xnew+bracewidth*brace_fraction, y-cbaselineHeight+coverallHeight/2.0); painter.rotate(270); painter.drawPath(path); - painter.restore(); + } else if (closebrace=="_") { QPainterPath path; double y1=y+(coverallHeight-cbaselineHeight); @@ -2828,7 +2829,7 @@ double JKQTMathText::MTsymbolNode::draw(QPainter& painter, double x, double y, J QPen p=painter.pen(); p.setColor(currentEv.color); - p.setWidthF(qMax(JKQTMATHTEXT_ABS_MIN_LINEWIDTH, fm.lineWidth())); + p.setWidthF(qMax(JKQTMathText::ABS_MIN_LINEWIDTH, fm.lineWidth())); p.setStyle(Qt::SolidLine); painter.setPen(p); double xwi=fm.width("x"); @@ -2846,22 +2847,22 @@ double JKQTMathText::MTsymbolNode::draw(QPainter& painter, double x, double y, J //std::cout<<"draw infty\n"; f1.setItalic(false); painter.setFont(f1); - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.translate(x+shift+fm1.width("8")/3.0, y-fm1.xHeight()); painter.rotate(90); painter.drawText(QPointF(0,0), "8"); - painter.restore(); + } else if (symbolName=="|") { //std::cout<<"draw infty\n"; f1.setItalic(false); painter.setFont(f1); - painter.save(); + 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.drawText(QPointF(0,0), "|"); - painter.restore(); + // here are some spaces } else if (symbolName==" ") { // full space @@ -3236,7 +3237,7 @@ JKQTMathText::~JKQTMathText() { void JKQTMathText::loadSettings(const QSettings& settings, const QString& group){ fontSize=settings.value(group+"font_size", fontSize).toDouble(); - fontColor=QColor(settings.value(group+"font_color", jkqtp_QColor2String(fontColor)).toString()); + fontColor=jkqtp_String2QColor(settings.value(group+"font_color", jkqtp_QColor2String(fontColor)).toString()); fontRoman=settings.value(group+"font_roman", fontRoman).toString(); fontSans=settings.value(group+"font_sans", fontSans).toString(); fontTypewriter=settings.value(group+"font_typewriter", fontTypewriter).toString(); @@ -3346,10 +3347,11 @@ void JKQTMathText::useSTIX() { void JKQTMathText::useXITS() { + //JKQTPAutoOutputTimer jkaaot(QString("JKQTMathText::useXITS():ALL")); QFontDatabase fdb; -#ifdef AUTOLOAD_XITS_FONTS //qDebug()<<"has XITS: "< #include -#define JKQTMATHTEXT_ABS_MIN_LINEWIDTH 0.02 - /** \brief initialized Qt-ressources necessary for JKQTMathText @@ -221,14 +219,17 @@ JKQTP_LIB_EXPORT void initJKQTMathTextResources(); class JKQTP_LIB_EXPORT JKQTMathText : public QObject { Q_OBJECT public: + /** \brief minimum linewidth allowed in a JKQTMathText (given in pt) */ + static const double ABS_MIN_LINEWIDTH; + /** \brief class constructor */ JKQTMathText(QObject * parent = nullptr); /** \brief class destructor */ ~JKQTMathText(); /** \brief load the object settings from the given QSettings object with the given name prefix */ - void loadSettings(const QSettings& settings, const QString& group=QString("mathtext")); + void loadSettings(const QSettings& settings, const QString& group=QString("mathtext/")); /** \brief store the object settings to the given QSettings object with the given name prefix */ - void saveSettings(QSettings& settings, const QString& group=QString("mathtext")) const; + void saveSettings(QSettings& settings, const QString& group=QString("mathtext/")) const; /** \brief parse the given enhanced string. Returns \c true on success. */ bool parse(QString text); /** \brief get the size of the drawn representation. returns an invalid size if no text has been parsed. */ @@ -303,241 +304,183 @@ class JKQTP_LIB_EXPORT JKQTMathText : public QObject { MTFElatex }; - /*! \brief sets the property fontColor ( \copybrief fontColor ) to the specified \a __value. - \details Description of the parameter fontColor is:
    \copydoc fontColor
    - \see fontColor for more information */ - inline virtual void setFontColor(const QColor & __value) + /*! \copydoc fontColor \see fontColor */ + inline void setFontColor(const QColor & __value) { this->fontColor = __value; } - /*! \brief returns the property fontColor ( \copybrief fontColor ). - \details Description of the parameter fontColor is:
    \copydoc fontColor
    - \see fontColor for more information */ - inline virtual QColor getFontColor() const + /*! \copydoc fontColor \see fontColor */ + inline QColor getFontColor() const { return this->fontColor; } - /*! \brief sets the property fontSize ( \copybrief fontSize ) to the specified \a __value. - \details Description of the parameter fontSize is:
    \copydoc fontSize
    - \see fontSize for more information */ - inline virtual void setFontSize(double __value) + /*! \copydoc fontSize \see fontSize */ + inline void setFontSize(double __value) { this->fontSize = __value; } - /*! \brief returns the property fontSize ( \copybrief fontSize ). - \details Description of the parameter fontSize is:
    \copydoc fontSize
    - \see fontSize for more information */ - inline virtual double getFontSize() const + /*! \copydoc fontSize \see fontSize */ + inline double getFontSize() const { return this->fontSize; } /*! \brief sets the property fontRoman ( \copybrief fontRoman ) to the specified \a __value. - \details Description of the parameter fontRoman is:
    \copydoc fontRoman
    - \see fontRoman for more information */ - inline virtual void setFontRoman(const QString & __value) + \details Description of the parameter fontRoman is:
    \copydoc fontRoman
    + \see fontRoman for more information */ + inline void setFontRoman(const QString & __value) { this->fontRoman = __value; - } - /*! \brief returns the property fontRoman ( \copybrief fontRoman ). - \details Description of the parameter fontRoman is:
    \copydoc fontRoman
    - \see fontRoman for more information */ - inline virtual QString getFontRoman() const + } + /*! \brief sets the property fontRoman ( \copybrief fontRoman ) to \a __value, or calls useXITS() if \a __value \c =="XITS". calls useSTIX() if \a __value \c =="STIX", ... + + \see fontRoman for more information */ + void setFontRomanOrSpecial(const QString & __value); + /*! \brief sets the property fontRoman ( \copybrief fontRoman ) to \a __value, or calls useXITS() if \a __value \c =="XITS". calls useSTIX() if \a __value \c =="STIX", ... + + \see fontRoman for more information */ + void setFontRomanOrSpecial(const QString & roman, const QString & math); + /*! \copydoc fontRoman \see fontRoman */ + inline QString getFontRoman() const { return this->fontRoman; } - /*! \brief sets the property fontSans ( \copybrief fontSans ) to the specified \a __value. - \details Description of the parameter fontSans is:
    \copydoc fontSans
    - \see fontSans for more information */ - inline virtual void setFontSans(const QString & __value) + /*! \copydoc fontSans \see fontSans */ + inline void setFontSans(const QString & __value) { this->fontSans = __value; } - /*! \brief returns the property fontSans ( \copybrief fontSans ). - \details Description of the parameter fontSans is:
    \copydoc fontSans
    - \see fontSans for more information */ - inline virtual QString getFontSans() const + /*! \copydoc fontSans \see fontSans */ + inline QString getFontSans() const { return this->fontSans; } - /*! \brief sets the property fontTypewriter ( \copybrief fontTypewriter ) to the specified \a __value. - \details Description of the parameter fontTypewriter is:
    \copydoc fontTypewriter
    - \see fontTypewriter for more information */ - inline virtual void setFontTypewriter(const QString & __value) + /*! \copydoc fontTypewriter \see fontTypewriter */ + inline void setFontTypewriter(const QString & __value) { this->fontTypewriter = __value; } - /*! \brief returns the property fontTypewriter ( \copybrief fontTypewriter ). - \details Description of the parameter fontTypewriter is:
    \copydoc fontTypewriter
    - \see fontTypewriter for more information */ - inline virtual QString getFontTypewriter() const + /*! \copydoc fontTypewriter \see fontTypewriter */ + inline QString getFontTypewriter() const { return this->fontTypewriter; } - /*! \brief sets the property fontScript ( \copybrief fontScript ) to the specified \a __value. - \details Description of the parameter fontScript is:
    \copydoc fontScript
    - \see fontScript for more information */ - inline virtual void setFontScript(const QString & __value) + /*! \copydoc fontScript \see fontScript */ + inline void setFontScript(const QString & __value) { this->fontScript = __value; } - /*! \brief returns the property fontScript ( \copybrief fontScript ). - \details Description of the parameter fontScript is:
    \copydoc fontScript
    - \see fontScript for more information */ - inline virtual QString getFontScript() const + /*! \copydoc fontScript \see fontScript */ + inline QString getFontScript() const { return this->fontScript; } - /*! \brief sets the property fontGreek ( \copybrief fontGreek ) to the specified \a __value. - \details Description of the parameter fontGreek is:
    \copydoc fontGreek
    - \see fontGreek for more information */ - inline virtual void setFontGreek(const QString & __value) + /*! \copydoc fontGreek \see fontGreek */ + inline void setFontGreek(const QString & __value) { this->fontGreek = __value; } - /*! \brief returns the property fontGreek ( \copybrief fontGreek ). - \details Description of the parameter fontGreek is:
    \copydoc fontGreek
    - \see fontGreek for more information */ - inline virtual QString getFontGreek() const + /*! \copydoc fontGreek \see fontGreek */ + inline QString getFontGreek() const { return this->fontGreek; } - /*! \brief sets the property fontSymbol ( \copybrief fontSymbol ) to the specified \a __value. - \details Description of the parameter fontSymbol is:
    \copydoc fontSymbol
    - \see fontSymbol for more information */ - inline virtual void setFontSymbol(const QString & __value) + /*! \copydoc fontSymbol \see fontSymbol */ + inline void setFontSymbol(const QString & __value) { this->fontSymbol = __value; } - /*! \brief returns the property fontSymbol ( \copybrief fontSymbol ). - \details Description of the parameter fontSymbol is:
    \copydoc fontSymbol
    - \see fontSymbol for more information */ - inline virtual QString getFontSymbol() const + /*! \copydoc fontSymbol \see fontSymbol */ + inline QString getFontSymbol() const { return this->fontSymbol; } - /*! \brief sets the property fontBraces ( \copybrief fontBraces ) to the specified \a __value. - \details Description of the parameter fontBraces is:
    \copydoc fontBraces
    - \see fontBraces for more information */ - inline virtual void setFontBraces(const QString & __value) + /*! \copydoc fontBraces \see fontBraces */ + inline void setFontBraces(const QString & __value) { this->fontBraces = __value; } - /*! \brief returns the property fontBraces ( \copybrief fontBraces ). - \details Description of the parameter fontBraces is:
    \copydoc fontBraces
    - \see fontBraces for more information */ - inline virtual QString getFontBraces() const + /*! \copydoc fontBraces \see fontBraces */ + inline QString getFontBraces() const { return this->fontBraces; } - /*! \brief sets the property fontIntegrals ( \copybrief fontIntegrals ) to the specified \a __value. - \details Description of the parameter fontIntegrals is:
    \copydoc fontIntegrals
    - \see fontIntegrals for more information */ - inline virtual void setFontIntegrals(const QString & __value) + /*! \copydoc fontIntegrals \see fontIntegrals */ + inline void setFontIntegrals(const QString & __value) { this->fontIntegrals = __value; } - /*! \brief returns the property fontIntegrals ( \copybrief fontIntegrals ). - \details Description of the parameter fontIntegrals is:
    \copydoc fontIntegrals
    - \see fontIntegrals for more information */ - inline virtual QString getFontIntegrals() const + /*! \copydoc fontIntegrals \see fontIntegrals */ + inline QString getFontIntegrals() const { return this->fontIntegrals; } - /*! \brief sets the property fontCaligraphic ( \copybrief fontCaligraphic ) to the specified \a __value. - \details Description of the parameter fontCaligraphic is:
    \copydoc fontCaligraphic
    - \see fontCaligraphic for more information */ - inline virtual void setFontCaligraphic(const QString & __value) + /*! \copydoc fontCaligraphic \see fontCaligraphic */ + inline void setFontCaligraphic(const QString & __value) { this->fontCaligraphic = __value; } - /*! \brief returns the property fontCaligraphic ( \copybrief fontCaligraphic ). - \details Description of the parameter fontCaligraphic is:
    \copydoc fontCaligraphic
    - \see fontCaligraphic for more information */ - inline virtual QString getFontCaligraphic() const + /*! \copydoc fontCaligraphic \see fontCaligraphic */ + inline QString getFontCaligraphic() const { return this->fontCaligraphic; } - /*! \brief sets the property fontBlackboard ( \copybrief fontBlackboard ) to the specified \a __value. - \details Description of the parameter fontBlackboard is:
    \copydoc fontBlackboard
    - \see fontBlackboard for more information */ - inline virtual void setFontBlackboard(const QString & __value) + /*! \copydoc fontBlackboard \see fontBlackboard */ + inline void setFontBlackboard(const QString & __value) { this->fontBlackboard = __value; } - /*! \brief returns the property fontBlackboard ( \copybrief fontBlackboard ). - \details Description of the parameter fontBlackboard is:
    \copydoc fontBlackboard
    - \see fontBlackboard for more information */ - inline virtual QString getFontBlackboard() const + /*! \copydoc fontBlackboard \see fontBlackboard */ + inline QString getFontBlackboard() const { return this->fontBlackboard; } - /*! \brief sets the property fontMathRoman ( \copybrief fontMathRoman ) to the specified \a __value. - \details Description of the parameter fontMathRoman is:
    \copydoc fontMathRoman
    - \see fontMathRoman for more information */ - inline virtual void setFontMathRoman(const QString & __value) + /*! \copydoc fontMathRoman \see fontMathRoman */ + inline void setFontMathRoman(const QString & __value) { this->fontMathRoman = __value; } - /*! \brief returns the property fontMathRoman ( \copybrief fontMathRoman ). - \details Description of the parameter fontMathRoman is:
    \copydoc fontMathRoman
    - \see fontMathRoman for more information */ - inline virtual QString getFontMathRoman() const + /*! \copydoc fontMathRoman \see fontMathRoman */ + inline QString getFontMathRoman() const { return this->fontMathRoman; } - /*! \brief sets the property fontMathSans ( \copybrief fontMathSans ) to the specified \a __value. - \details Description of the parameter fontMathSans is:
    \copydoc fontMathSans
    - \see fontMathSans for more information */ - inline virtual void setFontMathSans(const QString & __value) + /*! \copydoc fontMathSans \see fontMathSans */ + inline void setFontMathSans(const QString & __value) { this->fontMathSans = __value; } - /*! \brief returns the property fontMathSans ( \copybrief fontMathSans ). - \details Description of the parameter fontMathSans is:
    \copydoc fontMathSans
    - \see fontMathSans for more information */ - inline virtual QString getFontMathSans() const + /*! \copydoc fontMathSans \see fontMathSans */ + inline QString getFontMathSans() const { return this->fontMathSans; } - /*! \brief sets the property fontLatexPrefix ( \copybrief fontLatexPrefix ) to the specified \a __value. - \details Description of the parameter fontLatexPrefix is:
    \copydoc fontLatexPrefix
    - \see fontLatexPrefix for more information */ - inline virtual void setFontLatexPrefix(const QString & __value) + /*! \copydoc fontLatexPrefix \see fontLatexPrefix */ + inline void setFontLatexPrefix(const QString & __value) { this->fontLatexPrefix = __value; } - /*! \brief returns the property fontLatexPrefix ( \copybrief fontLatexPrefix ). - \details Description of the parameter fontLatexPrefix is:
    \copydoc fontLatexPrefix
    - \see fontLatexPrefix for more information */ - inline virtual QString getFontLatexPrefix() const + /*! \copydoc fontLatexPrefix \see fontLatexPrefix */ + inline QString getFontLatexPrefix() const { return this->fontLatexPrefix; } - /*! \brief sets the property fontLatexPostfix ( \copybrief fontLatexPostfix ) to the specified \a __value. - \details Description of the parameter fontLatexPostfix is:
    \copydoc fontLatexPostfix
    - \see fontLatexPostfix for more information */ - inline virtual void setFontLatexPostfix(const QString & __value) + /*! \copydoc fontLatexPostfix \see fontLatexPostfix */ + inline void setFontLatexPostfix(const QString & __value) { this->fontLatexPostfix = __value; } - /*! \brief returns the property fontLatexPostfix ( \copybrief fontLatexPostfix ). - \details Description of the parameter fontLatexPostfix is:
    \copydoc fontLatexPostfix
    - \see fontLatexPostfix for more information */ - inline virtual QString getFontLatexPostfix() const + /*! \copydoc fontLatexPostfix \see fontLatexPostfix */ + inline QString getFontLatexPostfix() const { return this->fontLatexPostfix; } - /*! \brief sets the property fontEncoding ( \copybrief fontEncoding ) to the specified \a __value. - \details Description of the parameter fontEncoding is:
    \copydoc fontEncoding
    - \see fontEncoding for more information */ - inline virtual void setFontEncoding(const MTfontEncoding & __value) + /*! \copydoc fontEncoding \see fontEncoding */ + inline void setFontEncoding(const MTfontEncoding & __value) { this->fontEncoding = __value; } - /*! \brief returns the property fontEncoding ( \copybrief fontEncoding ). - \details Description of the parameter fontEncoding is:
    \copydoc fontEncoding
    - \see fontEncoding for more information */ - inline virtual MTfontEncoding getFontEncoding() const + /*! \copydoc fontEncoding \see fontEncoding */ + inline MTfontEncoding getFontEncoding() const { return this->fontEncoding; } @@ -553,227 +496,163 @@ class JKQTP_LIB_EXPORT JKQTMathText : public QObject { inline bool isUsingXITSfonts() const { return this->useXITSfonts; } - /*! \brief sets the property brace_factor ( \copybrief brace_factor ) to the specified \a __value. - \details Description of the parameter brace_factor is:
    \copydoc brace_factor
    - \see brace_factor for more information */ - inline virtual void setBraceFactor(double __value) + /*! \copydoc brace_factor \see brace_factor */ + inline void setBraceFactor(double __value) { this->brace_factor = __value; } - /*! \brief returns the property brace_factor ( \copybrief brace_factor ). - \details Description of the parameter brace_factor is:
    \copydoc brace_factor
    - \see brace_factor for more information */ - inline virtual double getBraceFactor() const + /*! \copydoc brace_factor \see brace_factor */ + inline double getBraceFactor() const { return this->brace_factor; } - /*! \brief sets the property subsuper_size_factor ( \copybrief subsuper_size_factor ) to the specified \a __value. - \details Description of the parameter subsuper_size_factor is:
    \copydoc subsuper_size_factor
    - \see subsuper_size_factor for more information */ - inline virtual void setSubsuperSizeFactor(double __value) + /*! \copydoc subsuper_size_factor \see subsuper_size_factor */ + inline void setSubsuperSizeFactor(double __value) { this->subsuper_size_factor = __value; } - /*! \brief returns the property subsuper_size_factor ( \copybrief subsuper_size_factor ). - \details Description of the parameter subsuper_size_factor is:
    \copydoc subsuper_size_factor
    - \see subsuper_size_factor for more information */ - inline virtual double getSubsuperSizeFactor() const + /*! \copydoc subsuper_size_factor \see subsuper_size_factor */ + inline double getSubsuperSizeFactor() const { return this->subsuper_size_factor; } - /*! \brief sets the property italic_correction_factor ( \copybrief italic_correction_factor ) to the specified \a __value. - \details Description of the parameter italic_correction_factor is:
    \copydoc italic_correction_factor
    - \see italic_correction_factor for more information */ - inline virtual void setItalicCorrectionFactor(double __value) + /*! \copydoc italic_correction_factor \see italic_correction_factor */ + inline void setItalicCorrectionFactor(double __value) { this->italic_correction_factor = __value; } - /*! \brief returns the property italic_correction_factor ( \copybrief italic_correction_factor ). - \details Description of the parameter italic_correction_factor is:
    \copydoc italic_correction_factor
    - \see italic_correction_factor for more information */ - inline virtual double getItalicCorrectionFactor() const + /*! \copydoc italic_correction_factor \see italic_correction_factor */ + inline double getItalicCorrectionFactor() const { return this->italic_correction_factor; } - /*! \brief sets the property operatorsubsuper_size_factor ( \copybrief operatorsubsuper_size_factor ) to the specified \a __value. - \details Description of the parameter operatorsubsuper_size_factor is:
    \copydoc operatorsubsuper_size_factor
    - \see operatorsubsuper_size_factor for more information */ - inline virtual void setOperatorsubsuperSizeFactor(double __value) + /*! \copydoc operatorsubsuper_size_factor \see operatorsubsuper_size_factor */ + inline void setOperatorsubsuperSizeFactor(double __value) { this->operatorsubsuper_size_factor = __value; } - /*! \brief returns the property operatorsubsuper_size_factor ( \copybrief operatorsubsuper_size_factor ). - \details Description of the parameter operatorsubsuper_size_factor is:
    \copydoc operatorsubsuper_size_factor
    - \see operatorsubsuper_size_factor for more information */ - inline virtual double getOperatorsubsuperSizeFactor() const + /*! \copydoc operatorsubsuper_size_factor \see operatorsubsuper_size_factor */ + inline double getOperatorsubsuperSizeFactor() const { return this->operatorsubsuper_size_factor; } - /*! \brief sets the property mathoperator_width_factor ( \copybrief mathoperator_width_factor ) to the specified \a __value. - \details Description of the parameter mathoperator_width_factor is:
    \copydoc mathoperator_width_factor
    - \see mathoperator_width_factor for more information */ - inline virtual void setMathoperatorWidthFactor(double __value) + /*! \copydoc mathoperator_width_factor \see mathoperator_width_factor */ + inline void setMathoperatorWidthFactor(double __value) { this->mathoperator_width_factor = __value; } - /*! \brief returns the property mathoperator_width_factor ( \copybrief mathoperator_width_factor ). - \details Description of the parameter mathoperator_width_factor is:
    \copydoc mathoperator_width_factor
    - \see mathoperator_width_factor for more information */ - inline virtual double getMathoperatorWidthFactor() const + /*! \copydoc mathoperator_width_factor \see mathoperator_width_factor */ + inline double getMathoperatorWidthFactor() const { return this->mathoperator_width_factor; } - /*! \brief sets the property super_shift_factor ( \copybrief super_shift_factor ) to the specified \a __value. - \details Description of the parameter super_shift_factor is:
    \copydoc super_shift_factor
    - \see super_shift_factor for more information */ - inline virtual void setSuperShiftFactor(double __value) + /*! \copydoc super_shift_factor \see super_shift_factor */ + inline void setSuperShiftFactor(double __value) { this->super_shift_factor = __value; } - /*! \brief returns the property super_shift_factor ( \copybrief super_shift_factor ). - \details Description of the parameter super_shift_factor is:
    \copydoc super_shift_factor
    - \see super_shift_factor for more information */ - inline virtual double getSuperShiftFactor() const + /*! \copydoc super_shift_factor \see super_shift_factor */ + inline double getSuperShiftFactor() const { return this->super_shift_factor; } - /*! \brief sets the property sub_shift_factor ( \copybrief sub_shift_factor ) to the specified \a __value. - \details Description of the parameter sub_shift_factor is:
    \copydoc sub_shift_factor
    - \see sub_shift_factor for more information */ - inline virtual void setSubShiftFactor(double __value) + /*! \copydoc sub_shift_factor \see sub_shift_factor */ + inline void setSubShiftFactor(double __value) { this->sub_shift_factor = __value; } - /*! \brief returns the property sub_shift_factor ( \copybrief sub_shift_factor ). - \details Description of the parameter sub_shift_factor is:
    \copydoc sub_shift_factor
    - \see sub_shift_factor for more information */ - inline virtual double getSubShiftFactor() const + /*! \copydoc sub_shift_factor \see sub_shift_factor */ + inline double getSubShiftFactor() const { return this->sub_shift_factor; } - /*! \brief sets the property brace_shrink_factor ( \copybrief brace_shrink_factor ) to the specified \a __value. - \details Description of the parameter brace_shrink_factor is:
    \copydoc brace_shrink_factor
    - \see brace_shrink_factor for more information */ - inline virtual void setBraceShrinkFactor(double __value) + /*! \copydoc brace_shrink_factor \see brace_shrink_factor */ + inline void setBraceShrinkFactor(double __value) { this->brace_shrink_factor = __value; } - /*! \brief returns the property brace_shrink_factor ( \copybrief brace_shrink_factor ). - \details Description of the parameter brace_shrink_factor is:
    \copydoc brace_shrink_factor
    - \see brace_shrink_factor for more information */ - inline virtual double getBraceShrinkFactor() const + /*! \copydoc brace_shrink_factor \see brace_shrink_factor */ + inline double getBraceShrinkFactor() const { return this->brace_shrink_factor; } - /*! \brief sets the property underbrace_factor ( \copybrief underbrace_factor ) to the specified \a __value. - \details Description of the parameter underbrace_factor is:
    \copydoc underbrace_factor
    - \see underbrace_factor for more information */ - inline virtual void setUnderbraceFactor(double __value) + /*! \copydoc underbrace_factor \see underbrace_factor */ + inline void setUnderbraceFactor(double __value) { this->underbrace_factor = __value; } - /*! \brief returns the property underbrace_factor ( \copybrief underbrace_factor ). - \details Description of the parameter underbrace_factor is:
    \copydoc underbrace_factor
    - \see underbrace_factor for more information */ - inline virtual double getUnderbraceFactor() const + /*! \copydoc underbrace_factor \see underbrace_factor */ + inline double getUnderbraceFactor() const { return this->underbrace_factor; } - /*! \brief sets the property undersetFactor ( \copybrief undersetFactor ) to the specified \a __value. - \details Description of the parameter undersetFactor is:
    \copydoc undersetFactor
    - \see undersetFactor for more information */ - inline virtual void setUndersetFactor(double __value) + /*! \copydoc undersetFactor \see undersetFactor */ + inline void setUndersetFactor(double __value) { this->undersetFactor = __value; } - /*! \brief returns the property undersetFactor ( \copybrief undersetFactor ). - \details Description of the parameter undersetFactor is:
    \copydoc undersetFactor
    - \see undersetFactor for more information */ - inline virtual double getUndersetFactor() const + /*! \copydoc undersetFactor \see undersetFactor */ + inline double getUndersetFactor() const { return this->undersetFactor; } - /*! \brief sets the property frac_factor ( \copybrief frac_factor ) to the specified \a __value. - \details Description of the parameter frac_factor is:
    \copydoc frac_factor
    - \see frac_factor for more information */ - inline virtual void setFracFactor(double __value) + /*! \copydoc frac_factor \see frac_factor */ + inline void setFracFactor(double __value) { this->frac_factor = __value; } - /*! \brief returns the property frac_factor ( \copybrief frac_factor ). - \details Description of the parameter frac_factor is:
    \copydoc frac_factor
    - \see frac_factor for more information */ - inline virtual double getFracFactor() const + /*! \copydoc frac_factor \see frac_factor */ + inline double getFracFactor() const { return this->frac_factor; } - /*! \brief sets the property frac_shift_factor ( \copybrief frac_shift_factor ) to the specified \a __value. - \details Description of the parameter frac_shift_factor is:
    \copydoc frac_shift_factor
    - \see frac_shift_factor for more information */ - inline virtual void setFracShiftFactor(double __value) + /*! \copydoc frac_shift_factor \see frac_shift_factor */ + inline void setFracShiftFactor(double __value) { this->frac_shift_factor = __value; } - /*! \brief returns the property frac_shift_factor ( \copybrief frac_shift_factor ). - \details Description of the parameter frac_shift_factor is:
    \copydoc frac_shift_factor
    - \see frac_shift_factor for more information */ - inline virtual double getFracShiftFactor() const + /*! \copydoc frac_shift_factor \see frac_shift_factor */ + inline double getFracShiftFactor() const { return this->frac_shift_factor; } - /*! \brief sets the property brace_y_shift_factor ( \copybrief brace_y_shift_factor ) to the specified \a __value. - \details Description of the parameter brace_y_shift_factor is:
    \copydoc brace_y_shift_factor
    - \see brace_y_shift_factor for more information */ - inline virtual void setBraceYShiftFactor(double __value) + /*! \copydoc brace_y_shift_factor \see brace_y_shift_factor */ + inline void setBraceYShiftFactor(double __value) { this->brace_y_shift_factor = __value; } - /*! \brief returns the property brace_y_shift_factor ( \copybrief brace_y_shift_factor ). - \details Description of the parameter brace_y_shift_factor is:
    \copydoc brace_y_shift_factor
    - \see brace_y_shift_factor for more information */ - inline virtual double getBraceYShiftFactor() const + /*! \copydoc brace_y_shift_factor \see brace_y_shift_factor */ + inline double getBraceYShiftFactor() const { return this->brace_y_shift_factor; } - /*! \brief sets the property decoration_height_factor ( \copybrief decoration_height_factor ) to the specified \a __value. - \details Description of the parameter decoration_height_factor is:
    \copydoc decoration_height_factor
    - \see decoration_height_factor for more information */ - inline virtual void setDecorationHeightFactor(double __value) + /*! \copydoc decoration_height_factor \see decoration_height_factor */ + inline void setDecorationHeightFactor(double __value) { this->decoration_height_factor = __value; } - /*! \brief returns the property decoration_height_factor ( \copybrief decoration_height_factor ). - \details Description of the parameter decoration_height_factor is:
    \copydoc decoration_height_factor
    - \see decoration_height_factor for more information */ - inline virtual double getDecorationHeightFactor() const + /*! \copydoc decoration_height_factor \see decoration_height_factor */ + inline double getDecorationHeightFactor() const { return this->decoration_height_factor; } - /*! \brief sets the property expensiveRendering ( \copybrief expensiveRendering ) to the specified \a __value. - \details Description of the parameter expensiveRendering is:
    \copydoc expensiveRendering
    - \see expensiveRendering for more information */ - inline virtual void setExpensiveRendering(bool __value) + /*! \copydoc expensiveRendering \see expensiveRendering */ + inline void setExpensiveRendering(bool __value) { this->expensiveRendering = __value; } - /*! \brief returns the property expensiveRendering ( \copybrief expensiveRendering ). - \details Description of the parameter expensiveRendering is:
    \copydoc expensiveRendering
    - \see expensiveRendering for more information */ - inline virtual bool getExpensiveRendering() const + /*! \copydoc expensiveRendering \see expensiveRendering */ + inline bool getExpensiveRendering() const { return this->expensiveRendering; } - /*! \brief sets the property useUnparsed ( \copybrief useUnparsed ) to the specified \a __value. - \details Description of the parameter useUnparsed is:
    \copydoc useUnparsed
    - \see useUnparsed for more information */ - inline virtual void setUseUnparsed(bool __value) + /*! \copydoc useUnparsed \see useUnparsed */ + inline void setUseUnparsed(bool __value) { this->useUnparsed = __value; } - /*! \brief returns the property useUnparsed ( \copybrief useUnparsed ). - \details Description of the parameter useUnparsed is:
    \copydoc useUnparsed
    - \see useUnparsed for more information */ - inline virtual bool isUsingUnparsed() const + /*! \copydoc useUnparsed \see useUnparsed */ + inline bool isUsingUnparsed() const { return this->useUnparsed; } @@ -1355,6 +1234,10 @@ class JKQTP_LIB_EXPORT JKQTMathText : public QObject { bool default_useSTIXfonts; /** \brief indicates whether to use XITS fonts or not */ bool useXITSfonts; + /** \brief the first call to useXITS() determines this name for the default XITS fonts */ + QString defaultXITSFontName; + /** \brief the call to useXITS() determines this name for the default XITS Math fonts */ + QString defaultXITSMathFontName; /*! \brief default value for property useXITSfonts. \see useXITSfonts for more information */ bool default_useXITSfonts; diff --git a/lib/jkqtplotter.pri b/lib/jkqtplotter.pri index f6ada7414c..0bd7b42709 100644 --- a/lib/jkqtplotter.pri +++ b/lib/jkqtplotter.pri @@ -1,9 +1,12 @@ +# uncomment this line to prevent linking in of the XITS fonts +#DEFINES += NO_XITS_FONTS + include($$PWD/common.pri) HEADERS += \ - $$PWD/jkqtfastplotter/jkqtfastplotter.h \ + $$PWD/jkqtfastplotter/jkqtfastplotter.h \ $$PWD/jkqtmathtext/jkqtmathtext.h \ $$PWD/jkqtplotter/jkqtpbaseelements.h \ $$PWD/jkqtplotter/jkqtpbaseplotter.h \ @@ -12,6 +15,7 @@ HEADERS += \ $$PWD/jkqtplotter/jkqtpgraphs.h \ $$PWD/jkqtplotter/jkqtpgraphsbarchart.h \ $$PWD/jkqtplotter/jkqtpgraphsbase.h \ + $$PWD/jkqtplotter/jkqtpgraphsbaseerrors.h \ $$PWD/jkqtplotter/jkqtpgraphsboxplot.h \ $$PWD/jkqtplotter/jkqtpgraphsevaluatedfunction.h \ $$PWD/jkqtplotter/jkqtpgraphsfilledcurve.h \ @@ -21,7 +25,14 @@ HEADERS += \ $$PWD/jkqtplotter/jkqtpgraphsparsedfunction.h \ $$PWD/jkqtplotter/jkqtpgraphspeakstream.h \ $$PWD/jkqtplotter/jkqtpgraphssinglecolumnsymbols.h \ + $$PWD/jkqtplotter/jkqtpgraphsimageoverlays.h \ + $$PWD/jkqtplotter/jkqtpgraphscontour.h \ + $$PWD/jkqtplotter/jkqtpgraphsimagergb.h \ $$PWD/jkqtplotter/jkqtplotter.h \ + $$PWD/jkqtplotter/jkqtplotterstyle.h \ + $$PWD/jkqtplotter/jkqtpbaseplotterstyle.h \ + $$PWD/jkqtplotter/jkqtpcoordinateaxes.h \ + $$PWD/jkqtplotter/jkqtpcoordinateaxesstyle.h \ $$PWD/jkqtplottergui/jkqtpcomboboxes.h \ $$PWD/jkqtplottergui/jkqtpenhancedspinboxes.h \ $$PWD/jkqtplottergui/jkqtpenhancedtableview.h \ @@ -32,11 +43,12 @@ HEADERS += \ $$PWD/jkqtplottertools/jkqtphighrestimer.h \ $$PWD/jkqtplottertools/jkqtpimagetools.h \ $$PWD/jkqtplottertools/jkqtpmathparser.h \ - $$PWD/jkqtplottertools/jkqttools.h + $$PWD/jkqtplottertools/jkqttools.h \ + $$PWD/jkqtplotter/jkqtpkeystyle.h SOURCES += \ - $$PWD/jkqtfastplotter/jkqtfastplotter.cpp \ + $$PWD/jkqtfastplotter/jkqtfastplotter.cpp \ $$PWD/jkqtmathtext/jkqtmathtext.cpp \ $$PWD/jkqtplotter/jkqtpbaseelements.cpp \ $$PWD/jkqtplotter/jkqtpbaseplotter.cpp \ @@ -45,6 +57,7 @@ SOURCES += \ $$PWD/jkqtplotter/jkqtpgraphs.cpp \ $$PWD/jkqtplotter/jkqtpgraphsbarchart.cpp \ $$PWD/jkqtplotter/jkqtpgraphsbase.cpp \ + $$PWD/jkqtplotter/jkqtpgraphsbaseerrors.cpp \ $$PWD/jkqtplotter/jkqtpgraphsboxplot.cpp \ $$PWD/jkqtplotter/jkqtpgraphsevaluatedfunction.cpp \ $$PWD/jkqtplotter/jkqtpgraphsfilledcurve.cpp \ @@ -54,7 +67,14 @@ SOURCES += \ $$PWD/jkqtplotter/jkqtpgraphsparsedfunction.cpp \ $$PWD/jkqtplotter/jkqtpgraphspeakstream.cpp \ $$PWD/jkqtplotter/jkqtpgraphssinglecolumnsymbols.cpp \ + $$PWD/jkqtplotter/jkqtpgraphsimageoverlays.cpp \ + $$PWD/jkqtplotter/jkqtpgraphscontour.cpp \ + $$PWD/jkqtplotter/jkqtpgraphsimagergb.cpp \ $$PWD/jkqtplotter/jkqtplotter.cpp \ + $$PWD/jkqtplotter/jkqtplotterstyle.cpp \ + $$PWD/jkqtplotter/jkqtpbaseplotterstyle.cpp \ + $$PWD/jkqtplotter/jkqtpcoordinateaxes.cpp \ + $$PWD/jkqtplotter/jkqtpcoordinateaxesstyle.cpp \ $$PWD/jkqtplottergui/jkqtpcomboboxes.cpp \ $$PWD/jkqtplottergui/jkqtpenhancedspinboxes.cpp \ $$PWD/jkqtplottergui/jkqtpenhancedtableview.cpp \ @@ -65,10 +85,12 @@ SOURCES += \ $$PWD/jkqtplottertools/jkqtphighrestimer.cpp \ $$PWD/jkqtplottertools/jkqtpimagetools.cpp \ $$PWD/jkqtplottertools/jkqtpmathparser.cpp \ - $$PWD/jkqtplottertools/jkqttools.cpp + $$PWD/jkqtplottertools/jkqttools.cpp \ + $$PWD/jkqtplotter/jkqtpkeystyle.cpp -RESOURCES += $$PWD/jkqtplotterressources/jkqtpbaseplotter.qrc +RESOURCES += $$PWD/jkqtplotterressources/jkqtpbaseplotter.qrc \ + $$PWD/jkqtplotterressources/jkqtpstyles.qrc QT += xml svg opengl diff --git a/lib/jkqtplotter/jkqtpbaseelements.cpp b/lib/jkqtplotter/jkqtpbaseelements.cpp index c79743c328..86f11e987f 100644 --- a/lib/jkqtplotter/jkqtpbaseelements.cpp +++ b/lib/jkqtplotter/jkqtpbaseelements.cpp @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -20,2355 +20,4 @@ #include "jkqtplotter/jkqtpbaseelements.h" -#include "jkqtplotter/jkqtpbaseplotter.h" -#include -#include -#include -#include - - -//#undef SHOW_JKQTPLOTTER_DEBUG -//#define SHOW_JKQTPLOTTER_DEBUG - -JKQTPCoordinateAxis::JKQTPCoordinateAxis(JKQTBasePlotter* parent): QObject(parent) { - this->parent=parent; - - autoLabelDigits=true; - - tickMode=default_tickMode=JKQTPLTMLinOrPower; - - axisPrefix=""; - scaleSign=1; - doUpdateScaling=true; - - axismin=-10; - axismax=10; - axisabsoultemin=-DBL_MAX/100.0; - axisabsoultemax=DBL_MAX/100.0; - axisMinWidth=-1; - - width=20; - - scale=0; - offset=0; - inverted=false; - - tickSpacing=0; - tickSpacingLog=10; - tickStart=0; - labelDigits=3; - - autoAxisSpacing=default_autoAxisSpacing=true; - logAxis=default_logAxis=false; - minorTickLabelsEnabled=default_minorTickLabelsEnabled=false; - minorTickLabelFullNumber=default_minorTickLabelFullNumber=true; - logAxisBase=default_logAxisBase=10; - userTickSpacing=default_userTickSpacing=1; - userLogTickSpacing=default_userLogTickSpacing=10; - tickLabelAngle=default_tickLabelAngle=0; - - labelType=default_labelType=JKQTPCALTexponent; - - axisLabel=""; - - QFont f=QApplication::font(); - - labelPosition=default_labelPosition=JKQTPLabelCenter; - labelFont=default_labelFont=f.family(); //"Arial"; - labelFontSize=default_labelFontSize=f.pointSizeF()+1; //12; - tickLabelFont=default_tickLabelFont=f.family(); //"Arial"; - tickLabelFontSize=default_tickLabelFontSize=f.pointSizeF(); //10; - minorTickLabelFontSize=default_minorTickLabelFontSize=f.pointSizeF()*0.75; //10; - - tickTimeFormat=default_tickTimeFormat=QLocale().timeFormat(QLocale::NarrowFormat); - tickDateFormat=default_tickDateFormat=QLocale().dateFormat(QLocale::NarrowFormat); - tickDateTimeFormat=default_tickDateTimeFormat=QLocale().dateTimeFormat(QLocale::NarrowFormat); - - minTicks=default_minTicks=5; - minorTicks=default_minorTicks=1; - tickOutsideLength=default_tickOutsideLength=3; - minorTickOutsideLength=default_minorTickOutsideLength=1.5; - tickInsideLength=default_tickInsideLength=3; - minorTickInsideLength=default_minorTickInsideLength=1.5; - tickLabelDistance=default_tickLabelDistance=3; - labelDistance=default_labelDistance=5; - axisColor=default_axisColor=QColor("black"); - showZeroAxis=default_showZeroAxis=true; - drawMode1=default_drawMode1=JKQTPCADMcomplete; - drawMode2=default_drawMode2=JKQTPCADMticks; - minorTickWidth=default_minorTickWidth=1; - tickWidth=default_tickWidth=1.5; - lineWidth=default_lineWidth=1.5; - lineWidthZeroAxis=default_lineWidthZeroAxis=1.5; - - gridColor=default_gridColor=QColor("gray"); - gridWidth=default_gridWidth=0.75; - gridStyle=default_gridStyle=Qt::DashLine; - drawGrid=default_drawGrid=true; - minorGridColor=default_minorGridColor=QColor("gray"); - minorGridWidth=default_minorGridWidth=0.5; - minorGridStyle=default_minorGridStyle=Qt::DotLine; - drawMinorGrid=default_drawMinorGrid=false; - - paramsChanged=true; -} - -JKQTPCoordinateAxis::~JKQTPCoordinateAxis() = default; - -void JKQTPCoordinateAxis::setParent(JKQTBasePlotter* parent) { - this->parent=parent; - QObject::setParent(parent); -} - -void JKQTPCoordinateAxis::redrawPlot() { - //if (paramsChanged) { - calcPlotScaling(); - parent->redrawPlot(); - //} -} - -JKQTMathText* JKQTPCoordinateAxis::getParentMathText() { - return parent->getMathText(); -} - - - -#define JKQTPPROPERTYloadFromAxis(settings, param) this->param=settings->param - - -void JKQTPCoordinateAxis::loadSettings(JKQTPCoordinateAxis* settings) { - JKQTPPROPERTYloadFromAxis(settings, showZeroAxis); - JKQTPPROPERTYloadFromAxis(settings, autoAxisSpacing); - JKQTPPROPERTYloadFromAxis(settings, minorTickLabelsEnabled); - JKQTPPROPERTYloadFromAxis(settings, logAxis); - JKQTPPROPERTYloadFromAxis(settings, inverted); - JKQTPPROPERTYloadFromAxis(settings, logAxisBase); - JKQTPPROPERTYloadFromAxis(settings, userTickSpacing); - JKQTPPROPERTYloadFromAxis(settings, userLogTickSpacing); - JKQTPPROPERTYloadFromAxis(settings, minorTickWidth); - JKQTPPROPERTYloadFromAxis(settings, tickWidth); - JKQTPPROPERTYloadFromAxis(settings, lineWidth); - JKQTPPROPERTYloadFromAxis(settings, lineWidthZeroAxis); - - JKQTPPROPERTYloadFromAxis(settings, axisLabel); - - JKQTPPROPERTYloadFromAxis(settings, labelFont); - JKQTPPROPERTYloadFromAxis(settings, labelFontSize); - JKQTPPROPERTYloadFromAxis(settings, tickLabelFont); - JKQTPPROPERTYloadFromAxis(settings, tickLabelFontSize); - JKQTPPROPERTYloadFromAxis(settings, minorTickLabelFontSize); - JKQTPPROPERTYloadFromAxis(settings, minorTickLabelFullNumber); - - JKQTPPROPERTYloadFromAxis(settings, tickTimeFormat); - JKQTPPROPERTYloadFromAxis(settings, tickDateFormat); - JKQTPPROPERTYloadFromAxis(settings, tickDateTimeFormat); - - - JKQTPPROPERTYloadFromAxis(settings, minTicks); - JKQTPPROPERTYloadFromAxis(settings, minorTicks); - JKQTPPROPERTYloadFromAxis(settings, tickOutsideLength); - JKQTPPROPERTYloadFromAxis(settings, minorTickOutsideLength); - JKQTPPROPERTYloadFromAxis(settings, tickInsideLength); - JKQTPPROPERTYloadFromAxis(settings, minorTickInsideLength); - JKQTPPROPERTYloadFromAxis(settings, tickLabelDistance); - JKQTPPROPERTYloadFromAxis(settings, labelDistance); - JKQTPPROPERTYloadFromAxis(settings, gridWidth); - JKQTPPROPERTYloadFromAxis(settings, minorGridWidth); - JKQTPPROPERTYloadFromAxis(settings, drawGrid); - JKQTPPROPERTYloadFromAxis(settings, drawMinorGrid); - - JKQTPPROPERTYloadFromAxis(settings, labelPosition); - JKQTPPROPERTYloadFromAxis(settings, labelType); - JKQTPPROPERTYloadFromAxis(settings, axisColor); - - JKQTPPROPERTYloadFromAxis(settings, gridColor); - JKQTPPROPERTYloadFromAxis(settings, minorGridColor); - JKQTPPROPERTYloadFromAxis(settings, gridStyle); - JKQTPPROPERTYloadFromAxis(settings, minorGridStyle); - - JKQTPPROPERTYloadFromAxis(settings, drawMode1); - JKQTPPROPERTYloadFromAxis(settings, drawMode2); - JKQTPPROPERTYloadFromAxis(settings, tickMode); - paramsChanged=true; - calcPlotScaling(); -} - -void JKQTPCoordinateAxis::clearAxisTickLabels() { - tickLabels.clear(); - redrawPlot(); -} - -void JKQTPCoordinateAxis::addAxisTickLabel(double x, const QString& label) { - tickLabels.append(qMakePair(x, label)); - redrawPlot(); -} - -void JKQTPCoordinateAxis::addAxisTickLabels(const QVector &x, const QStringList &label) { - for (int i=0; i &x, const QString *label) { - for (int i=0; i0 && res[res.size()-1]=='0') { - res=res.left(res.size()-1); - } - if (res.size()>0 && res[res.size()-1]==loc.decimalPoint()) res=res.left(res.size()-1); - } - return res; - }; break; - case JKQTPCALTexponent: { - return QString(jkqtp_floattolatexstr(data, past_comma, remove_trail0, belowIsZero, pow(10, -past_comma), pow(10, past_comma+1)).c_str()); - }; break; - case JKQTPCALTexponentCharacter: { - return QString(jkqtp_floattounitstr(data, past_comma, remove_trail0).c_str()); - }; break; - case JKQTPCALTdate: { - QDateTime dt; - dt.setMSecsSinceEpoch(uint64_t(data)); - return dt.toString(tickDateFormat); - }; break; - case JKQTPCALTtime: { - QDateTime dt; - dt.setMSecsSinceEpoch(uint64_t(data)); - return dt.toString(tickTimeFormat); - }; break; - case JKQTPCALTdatetime: { - QDateTime dt; - dt.setMSecsSinceEpoch(uint64_t(data)); - return dt.toString(tickDateTimeFormat); - }; break; - default: - return QString(); - break; - } - - /* - tickTimeFormat - tickDateFormat - tickDateTimeFormat - **/ - - return QString(); -} - -QString JKQTPCoordinateAxis::floattolabel(double data, int past_comma) { - bool remove_trail0=true; - QLocale loc=QLocale::system(); - loc.setNumberOptions(QLocale::OmitGroupSeparator); - if (labelType==JKQTPCALTdefault) { - QString res=loc.toString(data, 'f', past_comma);//QString::number(data, 'f', past_comma); - if (remove_trail0 && res.contains(QLocale::system().decimalPoint())) { - while (res.size()>0 && res[res.size()-1]=='0') { - res=res.left(res.size()-1); - } - if (res.size()>0 && res[res.size()-1]==loc.decimalPoint()) res=res.left(res.size()-1); - } - return res; - } else if (labelType==JKQTPCALTexponent) return QString(jkqtp_floattolatexstr(data, past_comma, remove_trail0, 1e-300, pow(10, -past_comma), pow(10, past_comma+1)).c_str()); - else if (labelType==JKQTPCALTexponentCharacter) return QString(jkqtp_floattounitstr(data, past_comma, remove_trail0).c_str()); - return ""; -} - -int JKQTPCoordinateAxis::calcLinearUnitDigits() { - if (!autoLabelDigits) return labelDigits; - int unitdigits=-1; - double minval=tickStart; - bool equals=true; - /*for (int i=0; i<20; i++) { - equals=equals || (floattolabel((minval+static_cast(i)*tickSpacing), unitdigits)== floattolabel((minval+static_cast(i+1)*tickSpacing), unitdigits)); - }*/ - while ((unitdigits<20) && equals) { - unitdigits++; - equals=false; - for (int i=-10; i<10; i++) { - QString l1=floattolabel((minval+static_cast(i)*tickSpacing), unitdigits+2); - QString l2=floattolabel((minval+static_cast(i+1.0)*tickSpacing), unitdigits+2); - //qDebug()<<"unitdigits="<axismax) { - std::swap(axismin, axismax); - } else if (axismax==axismin) { - axismax=axismin+1.0; - } - if (isLogAxis()) { - - if (axismin<0) { - if (axismax>0) axismin=axismax/(logAxisBase*logAxisBase); - else axismin=1e-5; - } - if (axismax<=axismin) axismax=axismin*logAxisBase*logAxisBase; - //if (axismax<0) axismax=pow(10.0, ceil(log10(axismax-axismin)+1.0)); - - - if (axismin<=0) axismin=1e-5; - if (axismax<=0) axismax=axismin+pow(10.0, static_cast(log10(axismin))); - if (axismax(log10(axismin))); - } - } - - if (axismin>axismax) { - std::swap(axismin, axismax); - } else if (axismax==axismin) { - axismax=axismin+1.0; - } - - // this is the x- and y-range spanned by the plot - width=fabs(axismax-axismin); - //qDebug()<<"calcPlotScaling():\n"; - //qDebug()<<" width="<objectName()<<": inverted = "<objectName()<<": plotOffset = "<objectName()<<": plotWidth = "<0) { - offset=plotOffset-log(axismin)/log(logAxisBase)*scale; - } else { - offset=plotOffset+log(axismax)/log(logAxisBase)*scale; - } - } else { - scale=getParentPlotWidth()/width; - if (scaleSign>0) { - offset=plotOffset-axismin*scale; - } else { - offset=plotOffset+axismax*scale; - } - - } -#ifdef SHOW_JKQTPLOTTER_DEBUG - //qDebug()<objectName()<<": offset = "<objectName()<<": scale = "<objectName()<<": scaleSign = "<0 && fabs(amax-amin)axisabsoultemax) axismax=axisabsoultemax; - - if (axismin>axismax) { - axismin=amax; - axismax=amin; - } - if (isLogAxis()) { - if (axismin<=0) axismin=1e-306; - if (axismax<=0) axismax=1e-306; - if (fabs(axismin-axismax)<1e-306) { - axismax=10; - axismin=0.1; - } - } - - if (axisMinWidth>0 && fabs(axismax-axismin)tickSpacing = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setAxisMinWidth(double __value) { - this->axisMinWidth = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setAutoAxisSpacing(bool __value) { - this->autoAxisSpacing = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setMinorTickLabelsEnabled(bool __value) { - this->minorTickLabelsEnabled = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setLogAxis(bool __value) -{ - this->logAxis = __value; - this->paramsChanged=true; - if (this->isLogAxis()) { - if (axismin<0) axismin=pow(10.0, floor(log(axismax-axismin)/log(10.0)-1.0)); - if (axismax<0) axismax=pow(10.0, floor(log(axismax-axismin)/log(10.0)+1.0)); - } - if (this->isLogAxis() && this->minorTicks==default_minorTicks) { - this->minorTicks=9; - } - redrawPlot(); -} - -void JKQTPCoordinateAxis::setLogAxisBase(double __value) { - this->logAxisBase = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setUserTickSpacing(double __value) { - this->userTickSpacing = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setUserLogTickSpacing(double __value) { - this->userLogTickSpacing = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setLabelType(JKQTPCALabelType __value) { - this->labelType = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setTickMode(JKQTPLabelTickMode __value) -{ - this->tickMode = __value; - this->paramsChanged=true; - setLogAxis(this->logAxis); -} - -void JKQTPCoordinateAxis::setTickMode(int __value) { - setTickMode(JKQTPLabelTickMode(__value)); -} - -void JKQTPCoordinateAxis::setAxisLabel(const QString& __value) { - this->axisLabel = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setLabelPosition(JKQTPLabelPosition __value) { - this->labelPosition = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setLabelFont(const QString& __value) { - this->labelFont = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setLabelFontSize(double __value) { - this->labelFontSize = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setTickLabelFont(const QString& __value) { - this->tickLabelFont = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setTickTimeFormat(const QString& __value) { - this->tickTimeFormat = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setTickDateFormat(const QString& __value) { - this->tickDateFormat = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setTickDateTimeFormat(const QString& __value) { - this->tickDateTimeFormat = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setTickLabelFontSize(double __value) { - this->tickLabelFontSize = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setMinorTickLabelFontSize(double __value) { - this->minorTickLabelFontSize = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setMinorTickLabelFullNumber(bool __value) { - this->minorTickLabelFullNumber = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setMinTicks(unsigned int __value) { - this->minTicks = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setMinorTicks(unsigned int __value) { - this->minorTicks = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setMinorTicks(int __value) { - this->minorTicks = qMax(int(0), __value); - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setTickOutsideLength(double __value) { - this->tickOutsideLength = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setMinorTickOutsideLength(double __value) { - this->minorTickOutsideLength = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setTickInsideLength(double __value) { - this->tickInsideLength = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setMinorTickInsideLength(double __value) { - this->minorTickInsideLength = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setAxisColor(const QColor& __value) { - this->axisColor = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setShowZeroAxis(bool __value) { - this->showZeroAxis = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setInverted(bool __value) { - this->inverted = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setGridColor(const QColor& __value) { - this->gridColor = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setMinorGridColor(const QColor& __value) { - this->minorGridColor = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setGridWidth(double __value) { - this->gridWidth = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setGridStyle(Qt::PenStyle __value) { - this->gridStyle = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setMinorGridWidth(double __value) { - this->minorGridWidth = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setMinorGridStyle(Qt::PenStyle __value) { - this->minorGridStyle = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setDrawMode1(JKQTPCADrawMode __value) { - this->drawMode1 = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setDrawMode2(JKQTPCADrawMode __value) { - this->drawMode2 = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setMinorTickWidth(double __value) { - this->minorTickWidth = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setTickWidth(double __value) { - this->tickWidth = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setLineWidth(double __value) { - this->lineWidth = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setLineWidthZeroAxis(double __value) { - this->lineWidthZeroAxis = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setTickLabelDistance(double __value) { - this->tickLabelDistance = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setLabelDistance(double __value) { - this->labelDistance = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setLabelDigits(int __value) { - this->labelDigits = __value; - this->paramsChanged=true; - this->autoLabelDigits=false; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setDrawGrid(bool __value) { - this->drawGrid = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setDrawMinorGrid(bool __value) { - this->drawMinorGrid = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPCoordinateAxis::setTickLabelAngle(double __value) { - this->tickLabelAngle = __value; - this->paramsChanged=true; - redrawPlot(); -} - - -void JKQTPCoordinateAxis::setAbsoluteRange(double amin, double amax) { - axisabsoultemin=amin; - axisabsoultemax=amax; - - if (axisabsoultemin>axisabsoultemax) { - axisabsoultemin=amax; - axisabsoultemax=amin; - } - - if (axisabsoultemin==axisabsoultemax) { - axisabsoultemax=axisabsoultemin+1; - } - setRange(axismin, axismax); - /*paramsChanged=true; - calcPlotScaling(); - redrawPlot();*/ -} - -double JKQTPCoordinateAxis::getNextLabelDistance(double x) { - if (tickMode==JKQTPLTMLinOrPower) { - if (logAxis) { - return x*tickSpacingLog; - } else { - return tickSpacing; - } - } else if (tickMode==JKQTPLTMLin) { - return tickSpacing; - } else if (tickMode==JKQTPLTMPower) { - return x*tickSpacingLog; - } - return 0; -} - -bool JKQTPCoordinateAxis::getNextLabel(double& x, QString& label, bool init) { - //qDebug()<<"start JKQTPCoordinateAxis::getNextLabel("<=axismin && x<=axismax) { - label=floattolabel(x); - } - return (x<=axismax); - } else { - if (init) { - if (tickLabels.size()>0) { - x=tickLabels[0].first; - label=tickLabels[0].second; - } - return (tickLabels.size()>0); - } else { - for (int i=0; i=axismin && x<=axismax) { - label=tickLabels[i+1].second; - x=tickLabels[i+1].first; - return true; - } else { - return false; - } - } - } - } - } - return false; -} - -QSizeF JKQTPCoordinateAxis::getMaxTickLabelSize(JKQTPEnhancedPainter& painter, double* ascent, double* descent) { - double w=0, h=0, a=0; - calcPlotScaling(); - - double x=tickStart; - QString label=""; - getNextLabel(x, label, true); - QFont f; - f.setFamily(tickLabelFont); - f.setPointSizeF(tickLabelFontSize*parent->getFontSizeMultiplier()); - QFontMetricsF fm(f); - //getParentMathText()->setFontSize(f.pointSizeF()); - //getParentMathText()->setFontRoman(f.family()); - bool first=true; - int cnt=0; - while (getNextLabel(x, label, first) && cnt<50) { - double width, ascent, descent, strikeoutPos; - /*if (label.contains("\\") || label.contains("$") || label.contains("^") || label.contains("_")) { - getParentMathText()->parse(label); - getParentMathText()->getSizeDetail(painter, width, ascent, descent, strikeoutPos); - } else { - width=fm.width(label); - ascent=fm.ascent(); - descent=fm.descent(); - strikeoutPos=fm.strikeOutPos(); - }*/ - parent->getTextSizeDetail(f, label, painter, width, ascent, descent, strikeoutPos); - if (width>w) w=width; - if (ascent+descent>h) h=ascent+descent; - if (ascent>a) a=ascent; - first=false; - cnt++; - } - //qDebug()<<"getMaxTickLabelSize() = ["<getPlotHeight(); -} - -double JKQTPVerticalAxis::getParentPlotOffset() const { - return parent->getInternalPlotBorderTop(); -} - -QSize JKQTPVerticalAxis::getSize1(JKQTPEnhancedPainter& painter) { - if (drawMode1==JKQTPCADMnone || drawMode1==JKQTPCADMline) return QSize(0, getParentPlotWidth()); - if (drawMode1==JKQTPCADMticks) return QSize(parent->pt2px(painter, tickOutsideLength), getParentPlotWidth()); - // find out the maximum width over all visible plot labels - double tlwidth=getMaxTickLabelSize(painter).width(); - if (drawMode1==JKQTPCADMticksAndLabels) return QSize(parent->pt2px(painter, tickOutsideLength+tickLabelDistance)+tlwidth, getParentPlotWidth()); - - // find out size of axis label - /*getParentMathText()->setFontSize(labelFontSize*parent->getFontSizeMultiplier()); - getParentMathText()->setFontRoman(labelFont); - getParentMathText()->parse(axisLabel); - double lwidth=getParentMathText()->getSize(painter).height();*/ - double lwidth=parent->getTextSizeSize(labelFont, labelFontSize*parent->getFontSizeMultiplier(), axisLabel, painter).height(); - if (drawMode1==JKQTPCADMcomplete) return QSize(parent->pt2px(painter, tickOutsideLength+tickLabelDistance+labelDistance)+tlwidth+lwidth, getParentPlotWidth()); - - return QSize(0,0); -} - -QSize JKQTPVerticalAxis::getSize2(JKQTPEnhancedPainter& painter) { - if (drawMode2==JKQTPCADMnone || drawMode2==JKQTPCADMline) return QSize(0, getParentPlotWidth()); - if (drawMode2==JKQTPCADMticks) return QSize(parent->pt2px(painter, tickOutsideLength),getParentPlotWidth()); - // find out the maximum width over all visible plot labels - double tlwidth=getMaxTickLabelSize(painter).width(); - if (drawMode2==JKQTPCADMticksAndLabels) return QSize(parent->pt2px(painter, tickOutsideLength+tickLabelDistance)+tlwidth, getParentPlotWidth()); - - // find out size of axis label - /*getParentMathText()->setFontSize(labelFontSize*parent->getFontSizeMultiplier()); - getParentMathText()->setFontRoman(labelFont); - getParentMathText()->parse(axisLabel); - double lwidth=getParentMathText()->getSize(painter).height();*/ - double lwidth=parent->getTextSizeSize(labelFont, labelFontSize*parent->getFontSizeMultiplier(), axisLabel, painter).height(); - if (drawMode2==JKQTPCADMcomplete) return QSize(parent->pt2px(painter, tickOutsideLength+tickLabelDistance+labelDistance)+tlwidth+lwidth, getParentPlotWidth()); - - return QSize(0,0); -} - - -double JKQTPVerticalAxis::getParentOtheraxisOffset() const { - return parent->x2p(parent->getXMin()); -} - - -double JKQTPVerticalAxis::getParentOtheraxisWidth() const { - return fabs(parent->x2p(parent->getXMax())-parent->x2p(parent->getXMin())); -} - -bool JKQTPVerticalAxis::getParentOtheraxisInverted() const -{ - return parent->getXAxis()->getInverted(); -} - -void JKQTPVerticalAxis::drawGrids(JKQTPEnhancedPainter& painter) { - //qDebug()<<" start JKQTPVerticalAxis::drawGrids("; - painter.save(); - QPen pg=painter.pen(); - pg.setColor(gridColor); - pg.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, gridWidth*parent->getLineWidthMultiplier()))); - pg.setStyle(gridStyle); - QPen pmg=painter.pen(); - pmg.setColor(minorGridColor); - pmg.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH,parent->pt2px(painter, minorGridWidth*parent->getLineWidthMultiplier()))); - pmg.setStyle(minorGridStyle); - //double top=x2p(axismax); - //double bottom=x2p(axismin); - double left=0; - double right=0; - if (getParentOtheraxisInverted()) { - left=getParentOtheraxisOffset()-getParentOtheraxisWidth();//; - right=getParentOtheraxisOffset();//; - } else { - left=getParentOtheraxisOffset();//; - right=getParentOtheraxisOffset()+getParentOtheraxisWidth();//; - } - - double x=tickStart; - QString label=""; - bool first=true; - // loop through all labels, as they are at the major ticks, do not draw more than 200 labels (prevent hang ups) - int cnt=0; - QVector lines_pg; - QVector lines_pmg; - while (getNextLabel(x, label, first) && (cnt<200)) { - double w=getNextLabelDistance(x); - double mtdist=w/static_cast(minorTicks+1); - - double xx=x2p(x); - //qDebug()<<" tick @ x="<axismin) && (fabs(left-right)>0)) { - QLineF l(left, xx, right, xx); - if (l.length()>0) lines_pg.append(l);//painter.drawLine(l); - } - //qDebug()<<" 2"; - //painter.setPen(pmg); - //qDebug()<<" 3"; - if ((tickLabels.size()<=0) && drawMinorGrid && (minorTicks>0) && (fabs(right-left)>0)) { - //qDebug()<<" 3.1"; - double mx=x+mtdist; - //qDebug()<<" 3.2"; - for (int i=0; i(minorTicks); i++) { - //qDebug()<<" 3.2.1"; - double mxx=x2p(mx); - //qDebug()<<" 3.2.2"; - if ((mxaxismin) && (fabs(right-left)>0)) { - QLineF l(left, mxx, right, mxx); - if (l.length()>0) lines_pmg.append(l);//painter.drawLine(l); - } - //qDebug()<<" 3.2.3"; - mx=mx+mtdist; - //qDebug()<<" 3.2.4"; - } - } - first=false; - cnt++; - } - painter.setPen(pg); - painter.drawLines(lines_pg); - painter.setPen(pmg); - painter.drawLines(lines_pmg); - painter.restore(); - //qDebug()<<" end JKQTPVerticalAxis::drawGrids("; -} - -void JKQTPVerticalAxis::drawTickLabel1(JKQTPEnhancedPainter &painter, double xx, double yy, const QString& label, double fontSize) -{ - getParentMathText()->setFontSize(fontSize*parent->getFontSizeMultiplier()); - getParentMathText()->setFontRoman(tickLabelFont); - getParentMathText()->setFontColor(axisColor); - - getParentMathText()->parse(label); - double width, ascent, descent, strikeoutPos; - getParentMathText()->getSizeDetail(painter, width, ascent, descent, strikeoutPos); - if (drawMode1==JKQTPCADMticksAndLabels || drawMode1==JKQTPCADMcomplete) { - double lx=xx-parent->pt2px(painter, minorTickOutsideLength+tickLabelDistance)-width; - if (tickLabelAngle==90) { - painter.save(); - painter.translate(lx+width-1.25*strikeoutPos, yy-width/2.0); - painter.rotate(tickLabelAngle); - getParentMathText()->draw(painter, 0,0); - painter.restore(); - } else if (tickLabelAngle==-90) { - painter.save(); - painter.translate(lx+width-0.25*strikeoutPos, yy+width/2.0); - painter.rotate(tickLabelAngle); - getParentMathText()->draw(painter, 0,0); - painter.restore(); - } else if (tickLabelAngle!=0) { - painter.save(); - if (tickLabelAngle>0) { - painter.translate(lx-strikeoutPos+(width)*(1.0-cos(fabs(tickLabelAngle)/180.0*M_PI)), yy+strikeoutPos-width*sin(fabs(tickLabelAngle)/180.0*M_PI)); - painter.rotate(tickLabelAngle); - } else { - painter.translate(lx+strikeoutPos+(width-strikeoutPos)*(1.0-cos(fabs(tickLabelAngle)/180.0*M_PI)), yy+strikeoutPos+width*sin(fabs(tickLabelAngle)/180.0*M_PI)); - painter.rotate(tickLabelAngle); - } - getParentMathText()->draw(painter, 0,0); - painter.restore(); - } else { - getParentMathText()->draw(painter, lx, yy+strikeoutPos); - } - } -} - -void JKQTPVerticalAxis::drawTickLabel2(JKQTPEnhancedPainter &painter, double xx, double yy, const QString &label, double fontSize) -{ - getParentMathText()->setFontSize(fontSize*parent->getFontSizeMultiplier()); - getParentMathText()->setFontRoman(tickLabelFont); - getParentMathText()->setFontColor(axisColor); - - getParentMathText()->parse(label); - double width, ascent, descent, strikeoutPos; - getParentMathText()->getSizeDetail(painter, width, ascent, descent, strikeoutPos); - - if (drawMode2==JKQTPCADMticksAndLabels || drawMode2==JKQTPCADMcomplete) { - double lx=xx+parent->pt2px(painter, tickOutsideLength+tickLabelDistance); - if (tickLabelAngle==90) { - painter.save(); - painter.translate(lx+descent, yy-width/2.0); - painter.rotate(tickLabelAngle); - getParentMathText()->draw(painter, 0,0); - painter.restore(); - } else if (tickLabelAngle==-90) { - painter.save(); - painter.translate(lx+ascent, yy+width/2.0); - painter.rotate(tickLabelAngle); - getParentMathText()->draw(painter, 0,0); - painter.restore(); - } else if (tickLabelAngle!=0) { - painter.save(); - double shiftx=0; - if (tickLabelAngle>0) { - shiftx=strikeoutPos*sin(fabs(tickLabelAngle)/180.0*M_PI); - } else { - - } - painter.translate(lx+shiftx, yy+strikeoutPos); - painter.rotate(-tickLabelAngle); - getParentMathText()->draw(painter, 0,0); - painter.restore(); - } else { - getParentMathText()->draw(painter, lx, yy+strikeoutPos); - } - } -} - -void JKQTPVerticalAxis::drawAxes(JKQTPEnhancedPainter& painter) { - - // make shure all parameters are calculated correctly - calcPlotScaling(); - - // determine pixel coordinates of important positions - double top=x2p(axismax); - double bottom=x2p(axismin); - double left=0; - double right=0; - if (inverted) { - qSwap(top, bottom); - } - if (getParentOtheraxisInverted()) { - left=getParentOtheraxisOffset()-getParentOtheraxisWidth();//; - right=getParentOtheraxisOffset();//; - } else { - left=getParentOtheraxisOffset();//; - right=getParentOtheraxisOffset()+getParentOtheraxisWidth();//; - } - //qDebug()<<"JKQTPVerticalAxis:"; - //qDebug()<<" left="<pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); - pmain.setStyle(Qt::SolidLine); - - QPen ptick=pmain; - ptick.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, tickWidth*parent->getLineWidthMultiplier()))); - - QPen pmtick=ptick; - pmtick.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, minorTickWidth*parent->getLineWidthMultiplier()))); - - getParentMathText()->setFontSize(tickLabelFontSize*parent->getFontSizeMultiplier()); - getParentMathText()->setFontRoman(tickLabelFont); - getParentMathText()->setFontColor(axisColor); - - painter.setPen(pmain); - - // plot thick axis at y==0 - if (showZeroAxis && (0>axismin) && (0pt2px(painter, lineWidthZeroAxis*parent->getLineWidthMultiplier()))); - painter.setPen(pmain1); - QLineF l(left-parent->pt2px(painter, tickOutsideLength), x2p(0), right+parent->pt2px(painter, tickOutsideLength), x2p(0)); - painter.drawLine(l); - - painter.setPen(pmain); - } - - // draw thick axis lines, left and/or right - if (drawMode1!=JKQTPCADMnone) { - QLineF l(left, x2p(axismin), left, x2p(axismax)); - painter.drawLine(l); - } - if (drawMode2!=JKQTPCADMnone) { - QLineF l(right, x2p(axismin), right, x2p(axismax)); - painter.drawLine(l); - } - - // plot minor and major ticks + tick labels - QSizeF labelMax=getMaxTickLabelSize(painter); - double x=tickStart; - QString label=""; - bool first=true; - // loop through all labels, as they are at the major ticks - int cnt=0; - - QVector lines_ptick, lines_ptick2; - QVector lines_pmtick, lines_pmtick2; - - - while (getNextLabel(x, label, first) && cnt<200) { - double mtdist=getNextLabelDistance(x)/static_cast(minorTicks+1); - - double xleft=-1000000; - double xx=x2p(x); - //qDebug()<<" tick @ x="< "<=axismin) { - QLineF l(xleft=left-parent->pt2px(painter, minorTickOutsideLength), mxx, left+parent->pt2px(painter, minorTickInsideLength), mxx); - if (l.length()>0) lines_pmtick.append(l);//painter.drawLine(l); - double val= mx/pow(logAxisBase,floor(log(mx)/log(logAxisBase))); - - if (minorTickLabelsEnabled) { - if (minorTickLabelFullNumber) val=mx; - QString minorlabel=floattolabel(val); - drawTickLabel1(painter, left, mxx, minorlabel, minorTickLabelFontSize); - //drawTickLabel2(painter, right, xx, minorlabel, minorTickLabelFontSize); - } - } - mx=mx+mtdist; - - } - } - } - if (drawMode2==JKQTPCADMticks || drawMode2==JKQTPCADMticksAndLabels || drawMode2==JKQTPCADMcomplete) { - //painter.setPen(ptick); - if (x<=axismax && x>=axismin) { - QLineF l(right-parent->pt2px(painter, tickInsideLength), xx, right+parent->pt2px(painter, tickOutsideLength), xx); - if (l.length()>0) lines_ptick2.append(l);//painter.drawLine(l); - } - //painter.setPen(pmtick); - if ((tickLabels.size()<=0) && (minorTicks>0)) { - double mx=x+mtdist; - int minTickCnt=minorTicks; - if (isLogAxis()) { - if (mtdist>x) { - mx=mtdist; - } else { - minTickCnt--; - mx=2.0*mtdist; - } - - } - for (int i=0; i=axismin) { - QLineF l(right-parent->pt2px(painter, minorTickInsideLength), mxx, xleft=(right+parent->pt2px(painter, minorTickOutsideLength)), mxx); - if (l.length()>0) lines_pmtick2.append(l);//painter.drawLine(l); - double val= mx/pow(logAxisBase,floor(log(mx)/log(logAxisBase))); - - if (minorTickLabelsEnabled) { - if (minorTickLabelFullNumber) val=mx; - QString minorlabel=floattolabel(val); - //drawTickLabel1(painter, left, xx, minorlabel, minorTickLabelFontSize); - drawTickLabel2(painter, xleft, mxx, minorlabel, minorTickLabelFontSize); - } - } - mx=mx+mtdist; - } - } - } - - if ((label!="") && (x<=axismax && x>=axismin) && (drawMode1==JKQTPCADMticksAndLabels || drawMode1==JKQTPCADMcomplete || drawMode2==JKQTPCADMticksAndLabels || drawMode2==JKQTPCADMcomplete)) { - - - drawTickLabel1(painter, left, xx, label, tickLabelFontSize); - drawTickLabel2(painter, right, xx, label, tickLabelFontSize); - - } - first=false; - cnt++; - } - painter.setPen(ptick); - painter.drawLines(lines_ptick); - painter.drawLines(lines_ptick2); - painter.setPen(pmtick); - painter.drawLines(lines_pmtick); - painter.drawLines(lines_pmtick2); - - // plot axis label - if (!axisLabel.isEmpty() && (drawMode1==JKQTPCADMcomplete)) { - getParentMathText()->setFontSize(labelFontSize*parent->getFontSizeMultiplier()); - getParentMathText()->setFontRoman(labelFont); - getParentMathText()->parse(axisLabel); - double width, ascent, descent, strikeoutPos; - getParentMathText()->getSizeDetail(painter, width, ascent, descent, strikeoutPos); - - - QRectF rect(0,0, getParentPlotWidth(), ascent+descent);//plotBorderLeft-30); - painter.save(); - painter.translate(QPointF(left-parent->pt2px(painter, tickOutsideLength+tickLabelDistance+labelDistance)-descent-labelMax.width()-labelMax.height(), bottom)); - painter.rotate(-90); - //JKQTPEnhancedPainter::RenderHints h=painter.renderHints(); - //painter.drawRect(rect); - //painter.drawEllipse(-4, -4, 8, 8); - switch(labelPosition) { - case JKQTPLabelMax: - getParentMathText()->draw(painter, Qt::AlignBottom|Qt::AlignRight, rect); - break; - case JKQTPLabelMin: - getParentMathText()->draw(painter, Qt::AlignBottom|Qt::AlignLeft, rect); - break; - case JKQTPLabelCenter: - getParentMathText()->draw(painter, Qt::AlignBottom|Qt::AlignHCenter, rect); - break; - } - painter.resetTransform(); - painter.restore(); - } - if (!axisLabel.isEmpty() && (drawMode2==JKQTPCADMcomplete)) { - getParentMathText()->setFontSize(labelFontSize*parent->getFontSizeMultiplier()); - getParentMathText()->setFontRoman(labelFont); - getParentMathText()->parse(axisLabel); - - - QRectF rect(0,0, getParentPlotWidth(), getParentMathText()->getSize(painter).height());//plotBorderLeft-30); - painter.save(); - painter.translate(QPointF(right+parent->pt2px(painter, tickOutsideLength+tickLabelDistance+labelDistance)+labelMax.width(), bottom)); - painter.rotate(-90); - //JKQTPEnhancedPainter::RenderHints h=painter.renderHints(); - //painter.drawRect(rect); - //painter.drawEllipse(-4, -4, 8, 8); - switch(labelPosition) { - case JKQTPLabelMax: - getParentMathText()->draw(painter, Qt::AlignBottom|Qt::AlignRight, rect); - break; - case JKQTPLabelMin: - getParentMathText()->draw(painter, Qt::AlignBottom|Qt::AlignLeft, rect); - break; - case JKQTPLabelCenter: - getParentMathText()->draw(painter, Qt::AlignBottom|Qt::AlignHCenter, rect); - break; - } - //painter.resetTransform(); - painter.restore(); - } - painter.restore(); - //qDebug()<<" end JKQTPVerticalAxis::drawAxes("; -} - - - - - - - - - -JKQTPVerticalIndependentAxis::JKQTPVerticalIndependentAxis(double axisOffset, double axisWidth, double otherAxisOffset, double otherAxisWidth, JKQTBasePlotter* parent): - JKQTPVerticalAxis(parent) -{ - this->axisOffset=axisOffset; - this->axisWidth=axisWidth; - this->otherAxisOffset=otherAxisOffset; - this->otherAxisWidth=otherAxisWidth; - this->otherAxisInverted=false; -} - -void JKQTPVerticalIndependentAxis::setAxisOffset(double __value) { - this->axisOffset = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPVerticalIndependentAxis::setAxisWidth(double __value) { - this->axisWidth = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPVerticalIndependentAxis::setOtherAxisOffset(double __value) { - this->otherAxisOffset = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPVerticalIndependentAxis::setOtherAxisWidth(double __value) { - this->otherAxisWidth = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPVerticalIndependentAxis::setOtherAxisInverted(bool __value) { - this->otherAxisInverted = __value; - this->paramsChanged=true; - redrawPlot(); -} - -double JKQTPVerticalIndependentAxis::getParentPlotWidth() const { return axisWidth; } - -double JKQTPVerticalIndependentAxis::getParentPlotOffset() const { return axisOffset; } - -double JKQTPVerticalIndependentAxis::getParentOtheraxisWidth() const { return otherAxisWidth; } - -bool JKQTPVerticalIndependentAxis::getParentOtheraxisInverted() const { return otherAxisInverted; } - -double JKQTPVerticalIndependentAxis::getParentOtheraxisOffset() const { return otherAxisOffset; } - - - - - - - - - - -JKQTPHorizontalAxis::JKQTPHorizontalAxis(JKQTBasePlotter* parent): - JKQTPCoordinateAxis(parent) -{ - //axisPrefix="xaxis_"; - scaleSign=1; -} - -double JKQTPHorizontalAxis::getParentPlotWidth() const { - return parent->getPlotWidth(); -} - -double JKQTPHorizontalAxis::getParentPlotOffset() const { - return parent->getInternalPlotBorderLeft(); -} - -QSize JKQTPHorizontalAxis::getSize1(JKQTPEnhancedPainter& painter) { - if (drawMode1==JKQTPCADMnone || drawMode1==JKQTPCADMline) return QSize(getParentPlotWidth(), 0); - if (drawMode1==JKQTPCADMticks) return QSize(getParentPlotWidth(), parent->pt2px(painter, tickOutsideLength)); - // find out the maximum width over all visible plot labels - double tlwidth=getMaxTickLabelSize(painter).height(); - if (drawMode1==JKQTPCADMticksAndLabels) return QSize(getParentPlotWidth(),parent->pt2px(painter, tickOutsideLength+tickLabelDistance)+tlwidth); - - // find out size of axis label - /*getParentMathText()->setFontSize(labelFontSize*parent->getFontSizeMultiplier()); - getParentMathText()->setFontRoman(labelFont); - getParentMathText()->parse(axisLabel); - double lwidth=getParentMathText()->getSize(painter).height();*/ - double lwidth=parent->getTextSizeSize(labelFont, labelFontSize*parent->getFontSizeMultiplier(), axisLabel, painter).height(); - - if (drawMode1==JKQTPCADMcomplete) return QSize(getParentPlotWidth(),parent->pt2px(painter, tickOutsideLength+tickLabelDistance+labelDistance)+tlwidth+lwidth); - - return QSize(0,0); -} - -QSize JKQTPHorizontalAxis::getSize2(JKQTPEnhancedPainter& painter) { - if (drawMode2==JKQTPCADMnone || drawMode2==JKQTPCADMline) return QSize(getParentPlotWidth(), 0); - if (drawMode2==JKQTPCADMticks) return QSize(getParentPlotWidth(), parent->pt2px(painter, tickOutsideLength)); - // find out the maximum width over all visible plot labels - double tlwidth=getMaxTickLabelSize(painter).height(); - if (drawMode2==JKQTPCADMticksAndLabels) return QSize(getParentPlotWidth(),parent->pt2px(painter, tickOutsideLength+tickLabelDistance)+tlwidth); - - // find out size of axis label - /*getParentMathText()->setFontSize(labelFontSize*parent->getFontSizeMultiplier()); - getParentMathText()->setFontRoman(labelFont); - getParentMathText()->parse(axisLabel); - double lwidth=getParentMathText()->getSize(painter).height();*/ - double lwidth=parent->getTextSizeSize(labelFont, labelFontSize*parent->getFontSizeMultiplier(), axisLabel, painter).height(); - if (drawMode2==JKQTPCADMcomplete) return QSize(getParentPlotWidth(),parent->pt2px(painter, tickOutsideLength+tickLabelDistance+labelDistance)+tlwidth+lwidth); - - return QSize(0,0); -} - - -double JKQTPHorizontalAxis::getParentOtheraxisOffset() const { - return parent->y2p(parent->getYMax()); -} - - -double JKQTPHorizontalAxis::getParentOtheraxisWidth() const { - return fabs(parent->y2p(parent->getYMax())-parent->y2p(parent->getYMin())); -} - -bool JKQTPHorizontalAxis::getParentOtheraxisInverted() const -{ - return parent->getYAxis()->getInverted(); -} - -void JKQTPHorizontalAxis::drawGrids(JKQTPEnhancedPainter& painter) { - painter.save(); - //double right=x2p(axismax); - //double left=x2p(axismin); - double bottom=0; - double top=0; - if (getParentOtheraxisInverted()) { - top=getParentOtheraxisOffset()-getParentOtheraxisWidth();//; - bottom=getParentOtheraxisOffset();//; - } else { - top=getParentOtheraxisOffset();//; - bottom=getParentOtheraxisOffset()+getParentOtheraxisWidth();//; - } - QPen pg=painter.pen(); - pg.setColor(gridColor); - pg.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, gridWidth*parent->getFontSizeMultiplier()))); - pg.setStyle(gridStyle); - QPen pmg=painter.pen(); - pmg.setColor(minorGridColor); - pmg.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, minorGridWidth*parent->getLineWidthMultiplier()))); - pmg.setStyle(minorGridStyle); - - double x=tickStart; - QString label=""; - bool first=true; - // loop through all labels, as they are at the major ticks - int cnt=0; - QVector lines_pg; - QVector lines_pmg; - - while (getNextLabel(x, label, first) && cnt<200) { - double mtdist=getNextLabelDistance(x)/static_cast(minorTicks+1); - - double xx=x2p(x); - //qDebug()<<" tick @ x="<pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); - pmain.setStyle(Qt::SolidLine); - - QPen ptick=pmain; - ptick.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, tickWidth*parent->getLineWidthMultiplier()))); - - QPen pmtick=ptick; - pmtick.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, minorTickWidth*parent->getLineWidthMultiplier()))); - - getParentMathText()->setFontSize(tickLabelFontSize*parent->getFontSizeMultiplier()); - getParentMathText()->setFontRoman(tickLabelFont); - getParentMathText()->setFontColor(axisColor); - - painter.setPen(pmain); - - // plot thick axis at y==0 - if (showZeroAxis && (0>axismin) && (0pt2px(painter, tickOutsideLength), x2p(0), top-parent->pt2px(painter, tickOutsideLength)); - painter.drawLine(l); - } - - // draw thick axis lines, left and/or right - if (drawMode1!=JKQTPCADMnone) { - QLineF l(x2p(axismin), bottom, x2p(axismax), bottom); - painter.drawLine(l); - } - if (drawMode2!=JKQTPCADMnone) { - QLineF l(x2p(axismin), top, x2p(axismax), top); - painter.drawLine(l); - } - - // plot minor and major ticks + tick labels - double ascentMax, descentMax; - QSizeF labelMax=getMaxTickLabelSize(painter, &ascentMax, &descentMax); - double x=tickStart; - QString label=""; - bool first=true; - // loop through all labels, as they are at the major ticks - int cnt=0; - QVector lines_ptick, lines_ptick2; - QVector lines_pmtick, lines_pmtick2; - - - while (getNextLabel(x, label, first) && cnt<200) { - double mtdist=getNextLabelDistance(x)/static_cast(minorTicks+1); - - double xleft=-1000000; - double xx=x2p(x); - //qDebug()<<" tick @ x="<=axismin) && (drawMode1==JKQTPCADMticksAndLabels || drawMode1==JKQTPCADMcomplete || drawMode2==JKQTPCADMticksAndLabels || drawMode2==JKQTPCADMcomplete)) { - - - drawTickLabel1(painter, xx, bottom, label, tickLabelFontSize, ascentMax, descentMax); - drawTickLabel2(painter, xx, top, label, tickLabelFontSize, ascentMax, descentMax); - - /* - getParentMathText()->parse(label); - double width, ascent, descent, strikeoutPos; - getParentMathText()->getSizeDetail(painter, width, ascent, descent, strikeoutPos); - if (drawMode1==JKQTPCADMticksAndLabels || drawMode1==JKQTPCADMcomplete) { - double lx0=bottom+parent->pt2px(painter, tickOutsideLength+tickLabelDistance); - double lx=lx0+ascentMax; - if (tickLabelAngle!=0) { - painter.save(); - if (tickLabelAngle>0) { - painter.translate(xx-fabs(ascent*sin(tickLabelAngle/180.0*M_PI)/2.0), lx0+fabs(ascent*cos(tickLabelAngle/180.0*M_PI))); - painter.rotate(tickLabelAngle); - } else { - painter.translate(xx+fabs(ascent*sin(fabs(tickLabelAngle)/180.0*M_PI)/2.0)-width*fabs(cos(fabs(tickLabelAngle)/180.0*M_PI)), lx0+ascent*fabs(cos(fabs(tickLabelAngle)/180.0*M_PI))+fabs(width*sin(fabs(tickLabelAngle)/180.0*M_PI))); - painter.rotate(tickLabelAngle); - } - getParentMathText()->draw(painter, 0,0); - painter.restore(); - } else { - getParentMathText()->draw(painter, xx-width/2.0, lx); - } - } - if (drawMode2==JKQTPCADMticksAndLabels || drawMode2==JKQTPCADMcomplete) { - double lx0=top-parent->pt2px(painter, tickOutsideLength+tickLabelDistance); - double lx=lx0-descentMax; - if (tickLabelAngle!=0) { - painter.save(); - if (tickLabelAngle>0) { - painter.translate(xx+fabs(descent*sin(tickLabelAngle/180.0*M_PI)/2.0), lx0-fabs(descent*cos(tickLabelAngle/180.0*M_PI))); - painter.rotate(-tickLabelAngle); - } else { - painter.translate(xx-fabs(descent*sin(fabs(tickLabelAngle)/180.0*M_PI)/2.0)-width*fabs(cos(fabs(tickLabelAngle)/180.0*M_PI)), lx0-descent*fabs(cos(fabs(tickLabelAngle)/180.0*M_PI))-fabs(width*sin(fabs(tickLabelAngle)/180.0*M_PI))); - painter.rotate(-tickLabelAngle); - } - getParentMathText()->draw(painter, 0,0); - painter.restore(); - } else { - getParentMathText()->draw(painter, xx-width/2.0, lx); - } - - - }*/ - } - first=false; - cnt++; - } - painter.setPen(ptick); - painter.drawLines(lines_ptick); - painter.drawLines(lines_ptick2); - painter.setPen(pmtick); - painter.drawLines(lines_pmtick); - painter.drawLines(lines_pmtick2); - - // plot axis label - if (!axisLabel.isEmpty() && (drawMode1==JKQTPCADMcomplete)) { - getParentMathText()->setFontSize(labelFontSize*parent->getFontSizeMultiplier()); - getParentMathText()->setFontRoman(labelFont); - getParentMathText()->parse(axisLabel); - double width, ascent, descent, strikeoutPos; - getParentMathText()->getSizeDetail(painter, width, ascent, descent, strikeoutPos); - - - QRectF rect(0,0, getParentPlotWidth(), ascent+descent);//plotBorderLeft-30); - painter.save(); - painter.translate(QPointF(left, bottom+parent->pt2px(painter, tickOutsideLength+tickLabelDistance+labelDistance)+labelMax.height())); - //JKQTPEnhancedPainter::RenderHints h=painter.renderHints(); - //painter.drawRect(rect); - //painter.drawEllipse(-4, -4, 8, 8); - switch(labelPosition) { - case JKQTPLabelMax: - getParentMathText()->draw(painter, Qt::AlignBottom|Qt::AlignRight, rect); - break; - case JKQTPLabelMin: - getParentMathText()->draw(painter, Qt::AlignBottom|Qt::AlignLeft, rect); - break; - case JKQTPLabelCenter: - getParentMathText()->draw(painter, Qt::AlignBottom|Qt::AlignHCenter, rect); - break; - } - //painter.resetTransform(); - painter.restore(); - } - if (!axisLabel.isEmpty() && (drawMode2==JKQTPCADMcomplete)) { - getParentMathText()->setFontSize(labelFontSize*parent->getFontSizeMultiplier()); - getParentMathText()->setFontRoman(labelFont); - getParentMathText()->parse(axisLabel); - - - QRectF rect(0,0, getParentPlotWidth(), getParentMathText()->getSize(painter).height());//plotBorderLeft-30); - painter.save(); - painter.translate(QPointF(left, top-parent->pt2px(painter, tickOutsideLength+tickLabelDistance+labelDistance)-labelMax.height()-rect.height())); - //JKQTPEnhancedPainter::RenderHints h=painter.renderHints(); - //painter.drawRect(rect); - //painter.drawEllipse(-4, -4, 8, 8); - switch(labelPosition) { - case JKQTPLabelMax: - getParentMathText()->draw(painter, Qt::AlignBottom|Qt::AlignRight, rect); - break; - case JKQTPLabelMin: - getParentMathText()->draw(painter, Qt::AlignBottom|Qt::AlignLeft, rect); - break; - case JKQTPLabelCenter: - getParentMathText()->draw(painter, Qt::AlignBottom|Qt::AlignHCenter, rect); - break; - } - //painter.resetTransform(); - painter.restore(); - } -#ifdef SHOW_JKQTPLOTTER_DEBUG - QPen mp=QPen(QColor("blue")); - mp.setWidthF(3); - painter.setPen(mp); - painter.drawLine(QLineF(getParentPlotOffset(), top, getParentPlotOffset()+getParentPlotWidth(), bottom)); - painter.drawEllipse(QPointF(getParentPlotOffset(), top), 5,5); -#endif - painter.restore(); -} - - - - - - - - -JKQTPHorizontalIndependentAxis::JKQTPHorizontalIndependentAxis(double axisOffset, double axisWidth, double otherAxisOffset, double otherAxisWidth, JKQTBasePlotter* parent): - JKQTPHorizontalAxis(parent) -{ - this->axisOffset=axisOffset; - this->axisWidth=axisWidth; - this->otherAxisOffset=otherAxisOffset; - this->otherAxisWidth=otherAxisWidth; - this->otherAxisInverted=false; -} - -void JKQTPHorizontalIndependentAxis::setAxisOffset(double __value) { - this->axisOffset = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPHorizontalIndependentAxis::setAxisWidth(double __value) { - this->axisWidth = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPHorizontalIndependentAxis::setOtherAxisOffset(double __value) { - this->otherAxisOffset = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPHorizontalIndependentAxis::setOtherAxisWidth(double __value) { - this->otherAxisWidth = __value; - this->paramsChanged=true; - redrawPlot(); -} - -void JKQTPHorizontalIndependentAxis::setOtherAxisInverted(bool __value) { - this->otherAxisInverted = __value; - this->paramsChanged=true; - redrawPlot(); -} - -double JKQTPHorizontalIndependentAxis::getParentPlotWidth() const { return axisWidth; } - -double JKQTPHorizontalIndependentAxis::getParentPlotOffset() const { return axisOffset; } - -double JKQTPHorizontalIndependentAxis::getParentOtheraxisWidth() const { return otherAxisWidth; } - -bool JKQTPHorizontalIndependentAxis::getParentOtheraxisInverted() const { return otherAxisInverted; } - -double JKQTPHorizontalIndependentAxis::getParentOtheraxisOffset() const { return otherAxisOffset; } - diff --git a/lib/jkqtplotter/jkqtpbaseelements.h b/lib/jkqtplotter/jkqtpbaseelements.h index 820775521b..5a200a0ce5 100644 --- a/lib/jkqtplotter/jkqtpbaseelements.h +++ b/lib/jkqtplotter/jkqtpbaseelements.h @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -17,1055 +17,10 @@ along with this program. If not, see . */ - - - #ifndef JKQTPBASEELEMENTS_H #define JKQTPBASEELEMENTS_H +#include "jkqtplotter/jkqtpcoordinateaxes.h" -#include -#include -#include -#include -#include "jkqtplottertools/jkqtptools.h" -#include "jkqtmathtext/jkqtmathtext.h" -#include "jkqtplottertools/jkqtp_imexport.h" - -// forward declarations -class JKQTBasePlotter; - -/*! \brief this virtual class is the base for any type of coordinate axis, to be drawn by JKQTBasePlotter. - \ingroup jkqtpbaseplotter_elements - - This class implements all the functionality needed for a coordinate axis: - - transform world to screen coordinates and vice versa - - draw the axis (implemented by child classes!) with these elements: axis lines, ticks, tick labels, axis label, x/y=0 axis - - measure the axes in screen coordinates - - load and save the settings to an ini file - . - - Most of the actual draw and measure functions have to be implemented in descendents of this class (namely - JKQTPHorizontalAxis and JKQTPVerticalAxis, as they are specific to whether the axis is drawn horizontally or - vertically. - - Each axis is split up into several parts, as depicted in this image: - \image html jkqtpcoordinateaxis1.png - - Which parts to actually draw is set by the diverse properties. - - - \section jkqtplotter_base_systems_baseelements Coordinate Systems and Transformations - The plot itself is positioned inside the widget. You simply supply the widget dimensions and the border - widths between the plot and the widget. The Object then calculates the size of the plot: - - \image html plot_widget_orientation.png - - The plot shows the parameter range xmin ... xmax and ymin ... ymax. Note that if you plot logarithmic plots - you may only plot positive (>0) values. Any other value may lead to an error or unpredictable behaviour. - - From these parameters the object calculates the scaling laws for plotting pints to the screen. The next paragraphs - show all calculations for x- and y-coordinates, ahough this class only implements a generic form. The actual calculation - is also influenced by the parameters set in the child classes! - - -# width = xmax - xmin - -# height = ymax - ymin - -# plotWidth = widgetWidth - plotBorderLeft - plotBorderRight - -# plotHeight = widgetHeight - plotBorderTop - plotBorderBottom - -# xPlotOffset = plotBorderLeft - -# yPlotOffset = plotBorderTop - . - These parameters are common to all scaling laws. The next image explains these formulas: - \image html plot_coordinates.png - The actual scaling laws \f$ (x_p(x), y_p(y)) \f$ may be derived from these equations: - \f[ x_p(\mbox{xmin})=\mbox{xPlotOffset},\ \ \ \ \ x_p(\mbox{xmax})=\mbox{xPlotOffset}+\mbox{plotWidth} \f] - \f[ y_p(\mbox{ymax})=\mbox{yPlotOffset},\ \ \ \ \ y_p(\mbox{ymin})=\mbox{yPlotOffset}+\mbox{plotHeight} \f] - Here \f$ (x_p, y_p) \f$ denotes a point in pixel coordinates (green coordinate system) and \f$ (x,y) \f$ denotes a point in the - plotting coordinate system. - - If you assume a linear scaling law. \f[ x_p(x)=\mbox{xoffset}+x\cdot\mbox{xscale} \ \ \ \ \ \ \ \ \ y_p(y)=\mbox{yoffset}-y\cdot\mbox{yscale} \f] - you can derive: - \f[ \mbox{xscale}=\frac{\mbox{plotWidth}}{\mbox{xwidth}},\ \ \ \ \ \ \mbox{xoffset}=\mbox{xPlotOffset}-\mbox{xmin}\cdot\mbox{xscale} \f] - \f[ \mbox{yscale}=\frac{\mbox{plotHeight}}{\mbox{ywidth}},\ \ \ \ \ \ \mbox{yoffset}=\mbox{yPlotOffset}+\mbox{ymax}\cdot\mbox{yscale} \f] - - If you have a logarithmic axis (i.e. we plot \f$ \log_b(x) \f$ insetad of \f$ x \f$ for a given base \f$ b \f$ ) we get the same - formulas, but with \f$ x \f$ exchanged by \f$ \log_b(x) \f$. If we use the equation \f$ \log_b(x)=\log(x)/\log(b) \f$ we finally get - the scaling laws: - \f[ x_p(x)=\mbox{xoffset}+\frac{\log(x)}{\log(\mbox{logXAxisBase})}\cdot\mbox{xscale} \ \ \ \ \ \ \ \ \ y_p(y)=\mbox{yoffset}-\frac{\log(y)}{\log(\mbox{logYAxisBase})}\cdot\mbox{yscale} \f] - From these we can calculate their parameters with the same defining equations as above: - \f[ \mbox{xscale}=\frac{\mbox{plotWidth}\cdot\log(\mbox{logXAxisBase})}{\log(\mbox{xmax})-\log(\mbox{xmin})},\ \ \ \ \ \ \mbox{xoffset}=\mbox{xPlotOffset}-\frac{\log(\mbox{xmin})}{\log(\mbox{logXAxisBase})}\cdot\mbox{xscale} \f] - \f[ \mbox{yscale}=\frac{\mbox{plotHeight}\cdot\log(\mbox{logYAxisBase})}{\log(\mbox{ymax})-\log(\mbox{ymin})},\ \ \ \ \ \ \mbox{yoffset}=\mbox{yPlotOffset}+\frac{\log(\mbox{ymax})}{\log(\mbox{logYAxisBase})}\cdot\mbox{yscale} \f] - - The object implements the above coordinate transformations in the (inline) method x2p(). The inverse transformations - are implemented in p2x(). They can be used to show the system coordinates of the current mouse position. - - - \section jkqtplotter_base_grids_baseelemenets Axis Ticks and Grids - - This section explains how this component draws the ticks on coordinate axes and the grids that may be drawn below - the plots. In principle both - grids and axes - are drawn the same way, i.e. with the same step widths. There are - two types of ticks and grids: The major and the minor ticks/grids. The major ticks also show a label that denotes the - value they represent. Between two major ticks the axis shows \a minorTicks small ticks that are not - accompanied by a label. The next image shows an example of an axis: - \image html plot_axis_ticksandlabels.png - - For the labels this class also uses an algorithm that extimates the number of valid digits (after the comma) that are - needed so that two adjacent labels do not show the same text, so if you plot the range 1.10 .. 1.15 The algorithm will - show at least two valid digits, as with one digit the labels would be 1.1, 1.1, 1.1, 1.1, 1.1, 1.1. With two digits they - are 1.10, 1.11, 1.12, 1.13, 1.14, 1.15. The class may also use a method that can write \c 1m instead of \c 0.001 and \c 1k - instead of \c 1000 (the algorithm supports the "exponent letters" f, p, n, u, m, k, M, G, T, P. The latter option may - (de)activated by using showXExponentCharacter and showYExponentCharacter. - - For grids applies the same. There are two grids that are drawn in different styles (often the major grid is drawn - thicker and darker than the minor grid). - - The minor ticks and grid lines are generated automatically, depending in the setting of \a minorTicks. - These properties give the number of minor ticks between two major ticks, so if the major ticks are at 1,2,3,... and you - want minor ticks at 1.1, 1.2, 1.3,... then you will have to set \c minorTicks=9 as there are nine ticks between two major - ticks. So the minor tick spacing is calculated as: \f[ \Delta\mbox{MinorTicks}=\frac{\Delta\mbox{ticks}}{\mbox{minorTicks}+1} \f] - - The same applies for logarithmic axes. If the major ticks are at 1,10,100,... and you set \c minorTicks=9 the program will - generate 9 equally spaced minor ticks in between, so you have minor ticks at 2,3,4,...,11,12,13,... This results in a standard - logarithmic axis. If you set \c minorTicks=1 then you will get minor ticks at 5,15,150,... - \image html plot_logaxis_ticksandlabels.png - - The major tick-tick distances of linear axes may be calculated automatically in a way that the axis shows at least a given - number of ticks \c minTicks. The algorithm takes that tick spacing that will give a number of ticks per axis - nearest but \c ">=" to the given \c minTicks. The Algorithm is described in detail with the function - calcLinearTickSpacing(). To activate this automatic tick spacing you have to set autoAxisSpacing=true. - */ -class JKQTP_LIB_EXPORT JKQTPCoordinateAxis: public QObject { - Q_OBJECT - protected: - public: - - /** \brief class constructor */ - explicit JKQTPCoordinateAxis(JKQTBasePlotter* parent); - /** \brief class destructor */ - virtual ~JKQTPCoordinateAxis(); - virtual void setParent(JKQTBasePlotter* parent); - /** \brief loads the plot properties from a QSettings object */ - virtual void loadSettings(const QSettings &settings, const QString& group=QString("plots")); - - /** \brief saves the plot properties into a QSettings object. - * - * This method only saves those properties that differ from their default value. - */ - virtual void saveSettings(QSettings& settings, const QString& group=QString("plots")) const; - - /** \brief load settings from other axis */ - virtual void loadSettings(JKQTPCoordinateAxis* settings); - - /** \brief return x-pixel coordinate from time coordinate */ - inline double x2p(double x) const { - double r=0; - if (logAxis) { - if (x<=0) r= offset+scaleSign*log(axismin)/log(logAxisBase)*scale; - else r= offset+scaleSign*log(x)/log(logAxisBase)*scale; - } else { - r= offset+scaleSign*x*scale; - } - if (inverted) { - return 2.0*getParentPlotOffset()+getParentPlotWidth()-r;//getParentPlotOffset()+getParentPlotWidth()-(r-getParentPlotOffset()); - } else { - return r; - } - } - - /** \brief return time coordinate coordinate from x-pixel */ - inline double p2x(double x) const { - double xx=x; - if (inverted) { - xx=2.0*getParentPlotOffset()+getParentPlotWidth()-x; - } - xx=xx-offset; - if (logAxis) { - return exp(log(logAxisBase)*(xx)/(scaleSign*scale)); - } else { - return xx/(scaleSign*scale); - } - } - - - /** \brief clear axis tick labels. This switches back to automatic labels mode for the axis. */ - void clearAxisTickLabels(); - - /** \brief add a new tick label to the axis */ - void addAxisTickLabel(double x, const QString& label); - - - /** \brief add a new tick label to the axis */ - void addAxisTickLabels(const QVector& x, const QStringList& label); - /** \brief add a new tick label to the axis */ - void addAxisTickLabels(const double* x, const QStringList& label); - /** \brief add a new tick label to the axis */ - void addAxisTickLabels(const QVector& x, const QString* label); - /** \brief add a new tick label to the axis */ - void addAxisTickLabels(const double* x, const QString* label, int items); - - /** \brief returns the size of the left/bottom axis in pt */ - virtual QSize getSize1(JKQTPEnhancedPainter& painter)=0; - - /** \brief returns the size of the right/top axis in pt */ - virtual QSize getSize2(JKQTPEnhancedPainter& painter)=0; - - /** \brief draw axes */ - virtual void drawAxes(JKQTPEnhancedPainter& painter)=0; - - /** \brief draw grids */ - virtual void drawGrids(JKQTPEnhancedPainter& painter)=0; - - - /*! \brief returns the property tickSpacing ( \copybrief tickSpacing ). \details Description of the parameter tickSpacing is:
    \copydoc tickSpacing
    . \see tickSpacing for more information */ - inline double getTickSpacing() const { return this->tickSpacing; } - /*! \brief returns the property labelDigits ( \copybrief labelDigits ). \details Description of the parameter labelDigits is:
    \copydoc labelDigits
    . \see labelDigits for more information */ - inline int getLabelDigits() const { return this->labelDigits; } - /*! \brief returns the property autoAxisSpacing ( \copybrief autoAxisSpacing ). \details Description of the parameter autoAxisSpacing is:
    \copydoc autoAxisSpacing
    . \see autoAxisSpacing for more information */ - inline bool getAutoAxisSpacing() const { return this->autoAxisSpacing; } - /*! \brief returns the property minorTickLabelsEnabled ( \copybrief minorTickLabelsEnabled ). \details Description of the parameter minorTickLabelsEnabled is:
    \copydoc minorTickLabelsEnabled
    . \see minorTickLabelsEnabled for more information */ - inline bool getMinorTickLabelsEnabled() const { return this->minorTickLabelsEnabled; } - /*! \brief returns the property logAxis ( \copybrief logAxis ). \details Description of the parameter logAxis is:
    \copydoc logAxis
    . \see logAxis for more information */ - inline bool getLogAxis() const { return this->logAxis; } - /*! \brief returns the property inverted ( \copybrief inverted ). \details Description of the parameter inverted is:
    \copydoc inverted
    . \see inverted for more information */ - inline bool getInverted() const { return this->inverted; } - /*! \brief returns the property logAxisBase ( \copybrief logAxisBase ). \details Description of the parameter logAxisBase is:
    \copydoc logAxisBase
    . \see logAxisBase for more information */ - inline double getLogAxisBase() const { return this->logAxisBase; } - /*! \brief returns the property userTickSpacing ( \copybrief userTickSpacing ). \details Description of the parameter userTickSpacing is:
    \copydoc userTickSpacing
    . \see userTickSpacing for more information */ - inline double getUserTickSpacing() const { return this->userTickSpacing; } - /*! \brief returns the property userLogTickSpacing ( \copybrief userLogTickSpacing ). \details Description of the parameter userLogTickSpacing is:
    \copydoc userLogTickSpacing
    . \see userLogTickSpacing for more information */ - inline double getUserLogTickSpacing() const { return this->userLogTickSpacing; } - /*! \brief returns the property labelType ( \copybrief labelType ). \details Description of the parameter labelType is:
    \copydoc labelType
    . \see labelType for more information */ - inline JKQTPCALabelType getLabelType() const { return this->labelType; } - /*! \brief returns the property axisLabel ( \copybrief axisLabel ). \details Description of the parameter axisLabel is:
    \copydoc axisLabel
    . \see axisLabel for more information */ - inline QString getAxisLabel() const { return this->axisLabel; } - /*! \brief returns the property labelPosition ( \copybrief labelPosition ). \details Description of the parameter labelPosition is:
    \copydoc labelPosition
    . \see labelPosition for more information */ - inline JKQTPLabelPosition getLabelPosition() const { return this->labelPosition; } - /*! \brief returns the property labelFont ( \copybrief labelFont ). \details Description of the parameter labelFont is:
    \copydoc labelFont
    . \see labelFont for more information */ - inline QString getLabelFont() const { return this->labelFont; } - /*! \brief returns the property labelFontSize ( \copybrief labelFontSize ). \details Description of the parameter labelFontSize is:
    \copydoc labelFontSize
    . \see labelFontSize for more information */ - inline double getLabelFontSize() const { return this->labelFontSize; } - /*! \brief returns the property tickLabelFont ( \copybrief tickLabelFont ). \details Description of the parameter tickLabelFont is:
    \copydoc tickLabelFont
    . \see tickLabelFont for more information */ - inline QString getTickLabelFont() const { return this->tickLabelFont; } - /*! \brief returns the property tickLabelFontSize ( \copybrief tickLabelFontSize ). \details Description of the parameter tickLabelFontSize is:
    \copydoc tickLabelFontSize
    . \see tickLabelFontSize for more information */ - inline double getTickLabelFontSize() const { return this->tickLabelFontSize; } - /*! \brief returns the property minorTickLabelFontSize ( \copybrief minorTickLabelFontSize ). \details Description of the parameter minorTickLabelFontSize is:
    \copydoc minorTickLabelFontSize
    . \see minorTickLabelFontSize for more information */ - inline double getMinorTickLabelFontSize() const { return this->minorTickLabelFontSize; } - /*! \brief returns the property minorTickLabelFullNumber ( \copybrief minorTickLabelFullNumber ). \details Description of the parameter minorTickLabelFullNumber is:
    \copydoc minorTickLabelFullNumber
    . \see minorTickLabelFullNumber for more information */ - inline bool getMinorTickLabelFullNumber() const { return this->minorTickLabelFullNumber; } - /*! \brief returns the property tickLabelAngle ( \copybrief tickLabelAngle ). \details Description of the parameter tickLabelAngle is:
    \copydoc tickLabelAngle
    . \see tickLabelAngle for more information */ - inline double getTickLabelAngle() const { return this->tickLabelAngle; } - /*! \brief returns the property minTicks ( \copybrief minTicks ). \details Description of the parameter minTicks is:
    \copydoc minTicks
    . \see minTicks for more information */ - inline unsigned int getMinTicks() const { return this->minTicks; } - /*! \brief returns the property minorTicks ( \copybrief minorTicks ). \details Description of the parameter minorTicks is:
    \copydoc minorTicks
    . \see minorTicks for more information */ - inline unsigned int getMinorTicks() const { return this->minorTicks; } - /*! \brief returns the property tickOutsideLength ( \copybrief tickOutsideLength ). \details Description of the parameter tickOutsideLength is:
    \copydoc tickOutsideLength
    . \see tickOutsideLength for more information */ - inline double getTickOutsideLength() const { return this->tickOutsideLength; } - /*! \brief returns the property minorTickOutsideLength ( \copybrief minorTickOutsideLength ). \details Description of the parameter minorTickOutsideLength is:
    \copydoc minorTickOutsideLength
    . \see minorTickOutsideLength for more information */ - inline double getMinorTickOutsideLength() const { return this->minorTickOutsideLength; } - /*! \brief returns the property axisColor ( \copybrief axisColor ). \details Description of the parameter axisColor is:
    \copydoc axisColor
    . \see axisColor for more information */ - inline QColor getAxisColor() const { return this->axisColor; } - /*! \brief returns the property showZeroAxis ( \copybrief showZeroAxis ). \details Description of the parameter showZeroAxis is:
    \copydoc showZeroAxis
    . \see showZeroAxis for more information */ - inline bool getShowZeroAxis() const { return this->showZeroAxis; } - /*! \brief returns the property gridColor ( \copybrief gridColor ). \details Description of the parameter gridColor is:
    \copydoc gridColor
    . \see gridColor for more information */ - inline QColor getGridColor() const { return this->gridColor; } - /*! \brief returns the property minorGridColor ( \copybrief minorGridColor ). \details Description of the parameter minorGridColor is:
    \copydoc minorGridColor
    . \see minorGridColor for more information */ - inline QColor getMinorGridColor() const { return this->minorGridColor; } - /*! \brief returns the property gridWidth ( \copybrief gridWidth ). \details Description of the parameter gridWidth is:
    \copydoc gridWidth
    . \see gridWidth for more information */ - inline double getGridWidth() const { return this->gridWidth; } - /*! \brief returns the property gridStyle ( \copybrief gridStyle ). \details Description of the parameter gridStyle is:
    \copydoc gridStyle
    . \see gridStyle for more information */ - inline Qt::PenStyle getGridStyle() const { return this->gridStyle; } - /*! \brief returns the property minorGridWidth ( \copybrief minorGridWidth ). \details Description of the parameter minorGridWidth is:
    \copydoc minorGridWidth
    . \see minorGridWidth for more information */ - inline double getMinorGridWidth() const { return this->minorGridWidth; } - /*! \brief returns the property minorGridStyle ( \copybrief minorGridStyle ). \details Description of the parameter minorGridStyle is:
    \copydoc minorGridStyle
    . \see minorGridStyle for more information */ - inline Qt::PenStyle getMinorGridStyle() const { return this->minorGridStyle; } - /*! \brief returns the property tickTimeFormat ( \copybrief tickTimeFormat ). \details Description of the parameter tickTimeFormat is:
    \copydoc tickTimeFormat
    . \see tickTimeFormat for more information */ - inline QString getTickTimeFormat() const { return this->tickTimeFormat; } - /*! \brief returns the property tickDateFormat ( \copybrief tickDateFormat ). \details Description of the parameter tickDateFormat is:
    \copydoc tickDateFormat
    . \see tickDateFormat for more information */ - inline QString getTickDateFormat() const { return this->tickDateFormat; } - /*! \brief returns the property tickDateTimeFormat ( \copybrief tickDateTimeFormat ). \details Description of the parameter tickDateTimeFormat is:
    \copydoc tickDateTimeFormat
    . \see tickDateTimeFormat for more information */ - inline QString getTickDateTimeFormat() const { return this->tickDateTimeFormat; } - /*! \brief returns the property tickMode ( \copybrief tickMode ). \details Description of the parameter tickMode is:
    \copydoc tickMode
    . \see tickMode for more information */ - inline JKQTPLabelTickMode getTickMode() const { return this->tickMode; } - - /*! \brief returns the property drawMode1 ( \copybrief drawMode1 ). \details Description of the parameter drawMode1 is:
    \copydoc drawMode1
    . \see drawMode1 for more information */ - inline JKQTPCADrawMode getDrawMode1() const { return this->drawMode1; } - /*! \brief returns the property drawMode2 ( \copybrief drawMode2 ). \details Description of the parameter drawMode2 is:
    \copydoc drawMode2
    . \see drawMode2 for more information */ - inline JKQTPCADrawMode getDrawMode2() const { return this->drawMode2; } - /*! \brief returns the property minorTickWidth ( \copybrief minorTickWidth ). \details Description of the parameter minorTickWidth is:
    \copydoc minorTickWidth
    . \see minorTickWidth for more information */ - inline double getMinorTickWidth() const { return this->minorTickWidth; } - /*! \brief returns the property tickWidth ( \copybrief tickWidth ). \details Description of the parameter tickWidth is:
    \copydoc tickWidth
    . \see tickWidth for more information */ - inline double getTickWidth() const { return this->tickWidth; } - /*! \brief returns the property lineWidth ( \copybrief lineWidth ). \details Description of the parameter lineWidth is:
    \copydoc lineWidth
    . \see lineWidth for more information */ - inline double getLineWidth() const { return this->lineWidth; } - /*! \brief returns the property lineWidthZeroAxis ( \copybrief lineWidthZeroAxis ). \details Description of the parameter lineWidthZeroAxis is:
    \copydoc lineWidthZeroAxis
    . \see lineWidthZeroAxis for more information */ - inline double getLineWidthZeroAxis() const { return this->lineWidthZeroAxis; } - /*! \brief returns the property tickLabelDistance ( \copybrief tickLabelDistance ). \details Description of the parameter tickLabelDistance is:
    \copydoc tickLabelDistance
    . \see tickLabelDistance for more information */ - inline double getTickLabelDistance() const { return this->tickLabelDistance; } - /*! \brief returns the property labelDistance ( \copybrief labelDistance ). \details Description of the parameter labelDistance is:
    \copydoc labelDistance
    . \see labelDistance for more information */ - inline double getLabelDistance() const { return this->labelDistance; } - /*! \brief returns the property drawGrid ( \copybrief drawGrid ). \details Description of the parameter drawGrid is:
    \copydoc drawGrid
    . \see drawGrid for more information */ - inline bool getDrawGrid() const { return this->drawGrid; } - /*! \brief returns the property drawMinorGrid ( \copybrief drawMinorGrid ). \details Description of the parameter drawMinorGrid is:
    \copydoc drawMinorGrid
    . \see drawMinorGrid for more information */ - inline bool getDrawMinorGrid() const { return this->drawMinorGrid; } - /*! \brief sets the property autoLabelDigits ( \copybrief autoLabelDigits ) to the specified \a __value. - \details Description of the parameter autoLabelDigits is:
    \copydoc autoLabelDigits
    - \see autoLabelDigits for more information */ - inline virtual void setAutoLabelDigits(bool __value) - { - this->autoLabelDigits = __value; - } - /*! \brief returns the property autoLabelDigits ( \copybrief autoLabelDigits ). - \details Description of the parameter autoLabelDigits is:
    \copydoc autoLabelDigits
    - \see autoLabelDigits for more information */ - inline virtual bool getAutoLabelDigits() const - { - return this->autoLabelDigits; - } - /*! \brief returns the property parent ( \copybrief parent ). \details Description of the parameter parent is:
    \copydoc parent
    . \see parent for more information */ - inline JKQTBasePlotter* getParent() const { return this->parent; } - /*! \brief sets the property doUpdateScaling ( \copybrief doUpdateScaling ) to the specified \a __value. - \details Description of the parameter doUpdateScaling is:
    \copydoc doUpdateScaling
    - \see doUpdateScaling for more information */ - inline virtual void setDoUpdateScaling(bool __value) - { - this->doUpdateScaling = __value; - } - /*! \brief returns the property doUpdateScaling ( \copybrief doUpdateScaling ). - \details Description of the parameter doUpdateScaling is:
    \copydoc doUpdateScaling
    - \see doUpdateScaling for more information */ - inline virtual bool getDoUpdateScaling() const - { - return this->doUpdateScaling; - } - - - /** \brief returns the current min */ - inline double getMin() const {return axismin; } - - /** \brief returns the current max */ - inline double getMax() const {return axismax; } - - /** \brief returns the current absolute min */ - inline double getAbsoluteMin() const {return axisabsoultemin; } - - /** \brief returns the current absolute max */ - inline double getAbsoluteMax() const {return axisabsoultemax; } - /** \brief calculate the scaling and offset values from axis min/max values - * - * This is only executed when \c paramChanged==true, as otherwise the data has to be still - * correct. recalculating may be forced by caling calcPlotScaing(true); - */ - void calcPlotScaling(bool force=false); - - - bool isLogAxis() const; - - public slots: - /** \brief set range of plot axis */ - void setRange(double amin, double amax); - /** \brief set absolute range of plot axis */ - void setAbsoluteRange(double aamin, double aamax); - /** \brief do not use an absolute range of plot axis */ - void setNoAbsoluteRange(); - - /** \brief sets the property tickSpacing ( \copybrief tickSpacing ) to the specified \a __value. - * \details Description of the parameter tickSpacing is:
    \copydoc tickSpacing
    - * \see tickSpacing for more information */ - virtual void setTickSpacing(double __value); - - /** \brief sets the property axisMinWidth ( \copybrief axisMinWidth ) to the specified \a __value. - * \details Description of the parameter tickSpacing is:
    \copydoc axisMinWidth
    - * \see axisMinWidth for more information */ - virtual void setAxisMinWidth(double __value); - - /** \brief sets the property autoAxisSpacing ( \copybrief autoAxisSpacing ) to the specified \a __value. - * \details Description of the parameter autoAxisSpacing is:
    \copydoc autoAxisSpacing
    - * \see autoAxisSpacing for more information */ - virtual void setAutoAxisSpacing(bool __value); - - /** \brief sets the property minorTickLabelsEnabled ( \copybrief minorTickLabelsEnabled ) to the specified \a __value. - * \details Description of the parameter minorTickLabelsEnabled is:
    \copydoc minorTickLabelsEnabled
    - * \see autoAxisSpacing for more information */ - virtual void setMinorTickLabelsEnabled(bool __value); - - /** \brief sets the property logAxis ( \copybrief logAxis ) to the specified \a __value. - * \details Description of the parameter logAxis is:
    \copydoc logAxis
    - * \see logAxis for more information */ - virtual void setLogAxis(bool __value) ; - - /** \brief sets the property logAxisBase ( \copybrief logAxisBase ) to the specified \a __value. - * \details Description of the parameter logAxisBase is:
    \copydoc logAxisBase
    - * \see logAxisBase for more information */ - virtual void setLogAxisBase (double __value); - - /** \brief sets the property userTickSpacing ( \copybrief userTickSpacing ) to the specified \a __value. - * \details Description of the parameter userTickSpacing is:
    \copydoc userTickSpacing
    - * \see userTickSpacing for more information */ - virtual void setUserTickSpacing (double __value); - - /** \brief sets the property userLogTickSpacing ( \copybrief userLogTickSpacing ) to the specified \a __value. - * \details Description of the parameter userLogTickSpacing is:
    \copydoc userLogTickSpacing
    - * \see userLogTickSpacing for more information */ - virtual void setUserLogTickSpacing (double __value); - - /** \brief sets the property labelType ( \copybrief labelType ) to the specified \a __value. - * \details Description of the parameter labelType is:
    \copydoc labelType
    - * \see labelType for more information */ - virtual void setLabelType (JKQTPCALabelType __value); - - /** \brief sets the property tickMode ( \copybrief tickMode ) to the specified \a __value. - * \details Description of the parameter tickMode is:
    \copydoc tickMode
    - * \see tickMode for more information */ - virtual void setTickMode (JKQTPLabelTickMode __value); - /** \brief sets the property tickMode ( \copybrief tickMode ) to the specified \a __value. - * \details Description of the parameter tickMode is:
    \copydoc tickMode
    - * \see tickMode for more information */ - virtual void setTickMode (int __value); - - /** \brief sets the property axisLabel ( \copybrief axisLabel ) to the specified \a __value. - * \details Description of the parameter axisLabel is:
    \copydoc axisLabel
    - * \see axisLabel for more information */ - virtual void setAxisLabel (const QString& __value); - - /** \brief sets the property labelPosition ( \copybrief labelPosition ) to the specified \a __value. - * \details Description of the parameter labelPosition is:
    \copydoc labelPosition
    */ - virtual void setLabelPosition (JKQTPLabelPosition __value); - - /** \brief sets the property labelFont ( \copybrief labelFont ) to the specified \a __value. - * \details Description of the parameter labelFont is:
    \copydoc labelFont
    */ - virtual void setLabelFont (const QString& __value); - - /** \brief sets the property labelFontSize ( \copybrief labelFontSize ) to the specified \a __value. - * \details Description of the parameter labelFontSize is:
    \copydoc labelFontSize
    */ - virtual void setLabelFontSize (double __value); - - /** \brief sets the property tickLabelFont ( \copybrief tickLabelFont ) to the specified \a __value. - * \details Description of the parameter tickLabelFont is:
    \copydoc tickLabelFont
    */ - virtual void setTickLabelFont (const QString& __value); - - - /** \brief sets the property tickTimeFormat ( \copybrief tickTimeFormat ) to the specified \a __value. - * \details Description of the parameter tickTimeFormat is:
    \copydoc tickTimeFormat
    */ - virtual void setTickTimeFormat (const QString& __value); - - - /** \brief sets the property tickDateFormat ( \copybrief tickDateFormat ) to the specified \a __value. - * \details Description of the parameter tickDateFormat is:
    \copydoc tickDateFormat
    */ - virtual void setTickDateFormat (const QString& __value); - - - /** \brief sets the property tickDateTimeFormat ( \copybrief tickDateTimeFormat ) to the specified \a __value. - * \details Description of the parameter tickDateTimeFormat is:
    \copydoc tickDateTimeFormat
    */ - virtual void setTickDateTimeFormat (const QString& __value); - - - /** \brief sets the property tickLabelFontSize ( \copybrief tickLabelFontSize ) to the specified \a __value. - * \details Description of the parameter tickLabelFontSize is:
    \copydoc tickLabelFontSize
    */ - virtual void setTickLabelFontSize (double __value); - - /** \brief sets the property minorTickLabelFontSize ( \copybrief minorTickLabelFontSize ) to the specified \a __value. - * \details Description of the parameter minorTickLabelFontSize is:
    \copydoc minorTickLabelFontSize
    */ - virtual void setMinorTickLabelFontSize (double __value); - - /** \brief sets the property minorTickLabelFullNumber ( \copybrief minorTickLabelFullNumber ) to the specified \a __value. - * \details Description of the parameter minorTickLabelFullNumber is:
    \copydoc minorTickLabelFullNumber
    */ - virtual void setMinorTickLabelFullNumber (bool __value); - - /** \brief sets the property minTicks ( \copybrief minTicks ) to the specified \a __value. - * \details Description of the parameter minTicks is:
    \copydoc minTicks
    */ - virtual void setMinTicks(unsigned int __value); - - /** \brief sets the property minorTicks ( \copybrief minorTicks ) to the specified \a __value. - * \details Description of the parameter minorTicks is:
    \copydoc minorTicks
    \image html docu_logaxis_set_minorticks.png */ - virtual void setMinorTicks (unsigned int __value); - - /** \brief sets the property minorTicks ( \copybrief minorTicks ) to the specified \a __value. - * \details Description of the parameter minorTicks is:
    \copydoc minorTicks
    \image html docu_logaxis_set_minorticks.png */ - virtual void setMinorTicks (int __value); - - /** \brief sets the property tickOutsideLength ( \copybrief tickOutsideLength ) to the specified \a __value. - * \details Description of the parameter tickOutsideLength is:
    \copydoc tickOutsideLength
    */ - virtual void setTickOutsideLength(double __value); - - /** \brief sets the property minorTickOutsideLength ( \copybrief minorTickOutsideLength ) to the specified \a __value. - * \details Description of the parameter minorTickOutsideLength is:
    \copydoc minorTickOutsideLength
    */ - virtual void setMinorTickOutsideLength (double __value); - - /** \brief sets the property tickInsideLength ( \copybrief tickInsideLength ) to the specified \a __value. - * \details Description of the parameter tickInsideLength is:
    \copydoc tickInsideLength
    */ - virtual void setTickInsideLength(double __value); - - /** \brief sets the property minorTickInsideLength ( \copybrief minorTickInsideLength ) to the specified \a __value. - * \details Description of the parameter minorTickInsideLength is:
    \copydoc minorTickInsideLength
    */ - virtual void setMinorTickInsideLength (double __value); - - /** \brief sets the property axisColor ( \copybrief axisColor ) to the specified \a __value. - * \details Description of the parameter axisColor is:
    \copydoc axisColor
    */ - virtual void setAxisColor (const QColor& __value); - - /** \brief sets the property showZeroAxis ( \copybrief showZeroAxis ) to the specified \a __value. - * \details Description of the parameter showZeroAxis is:
    \copydoc showZeroAxis
    */ - virtual void setShowZeroAxis(bool __value); - - /** \brief sets the property inverted ( \copybrief inverted ) to the specified \a __value. - * \details Description of the parameter inverted is:
    \copydoc inverted
    */ - virtual void setInverted(bool __value); - - /** \brief sets the property gridColor ( \copybrief gridColor ) to the specified \a __value. - * \details Description of the parameter gridColor is:
    \copydoc gridColor
    */ - virtual void setGridColor(const QColor& __value); - - /** \brief sets the property minorGridColor ( \copybrief minorGridColor ) to the specified \a __value. - * \details Description of the parameter minorGridColor is:
    \copydoc minorGridColor
    */ - virtual void setMinorGridColor(const QColor& __value); - - /** \brief sets the property gridWidth ( \copybrief gridWidth ) to the specified \a __value. - * \details Description of the parameter gridWidth is:
    \copydoc gridWidth
    */ - virtual void setGridWidth (double __value); - - /** \brief sets the property gridStyle ( \copybrief gridStyle ) to the specified \a __value. - * \details Description of the parameter gridStyle is:
    \copydoc gridStyle
    */ - virtual void setGridStyle(Qt::PenStyle __value); - - /** \brief sets the property minorGridWidth ( \copybrief minorGridWidth ) to the specified \a __value. - * \details Description of the parameter minorGridWidth is:
    \copydoc minorGridWidth
    */ - virtual void setMinorGridWidth(double __value); - - /** \brief sets the property minorGridStyle ( \copybrief minorGridStyle ) to the specified \a __value. - * \details Description of the parameter minorGridStyle is:
    \copydoc minorGridStyle
    */ - virtual void setMinorGridStyle (Qt::PenStyle __value); - - - /** \brief sets the property drawMode1 ( \copybrief drawMode1 ) to the specified \a __value. - * \details Description of the parameter drawMode1 is:
    \copydoc drawMode1
    */ - virtual void setDrawMode1 (JKQTPCADrawMode __value); - - /** \brief sets the property drawMode2 ( \copybrief drawMode2 ) to the specified \a __value. - * \details Description of the parameter drawMode2 is:
    \copydoc drawMode2
    */ - virtual void setDrawMode2(JKQTPCADrawMode __value); - - /** \brief sets the property minorTickWidth ( \copybrief minorTickWidth ) to the specified \a __value. - * \details Description of the parameter minorTickWidth is:
    \copydoc minorTickWidth
    */ - virtual void setMinorTickWidth(double __value); - - /** \brief sets the property tickWidth ( \copybrief tickWidth ) to the specified \a __value. - * \details Description of the parameter tickWidth is:
    \copydoc tickWidth
    */ - virtual void setTickWidth (double __value); - - /** \brief sets the property lineWidth ( \copybrief lineWidth ) to the specified \a __value. - * \details Description of the parameter lineWidth is:
    \copydoc lineWidth
    */ - virtual void setLineWidth (double __value); - - /** \brief sets the property lineWidthZeroAxis ( \copybrief lineWidthZeroAxis ) to the specified \a __value. - * \details Description of the parameter lineWidthZeroAxis is:
    \copydoc lineWidthZeroAxis
    */ - virtual void setLineWidthZeroAxis (double __value); - - /** \brief sets the property tickLabelDistance ( \copybrief tickLabelDistance ) to the specified \a __value. - * \details Description of the parameter tickLabelDistance is:
    \copydoc tickLabelDistance
    */ - virtual void setTickLabelDistance(double __value); - - /** \brief sets the property labelDistance ( \copybrief labelDistance ) to the specified \a __value. - * \details Description of the parameter labelDistance is:
    \copydoc labelDistance
    */ - virtual void setLabelDistance(double __value); - /** \brief sets the property labelDigits ( \copybrief labelDigits ) to the specified \a __value. - * \details Description of the parameter labelDistance is:
    \copydoc labelDigits
    */ - virtual void setLabelDigits(int __value); - - /** \brief sets the property drawGrid ( \copybrief drawGrid ) to the specified \a __value. - * \details Description of the parameter drawGrid is:
    \copydoc drawGrid
    */ - virtual void setDrawGrid(bool __value); - - /** \brief sets the property drawMinorGrid ( \copybrief drawMinorGrid ) to the specified \a __value. - * \details Description of the parameter drawMinorGrid is:
    \copydoc drawMinorGrid
    */ - virtual void setDrawMinorGrid(bool __value); - - - /** \brief sets the property tickLabelAngle ( \copybrief tickLabelAngle ) to the specified \a __value. - * \details Description of the parameter tickLabelAngle is:
    \copydoc tickLabelAngle
    */ - virtual void setTickLabelAngle(double __value); - - protected: - /** \brief indicates whether one of the parameters has changed sinse the last recalculation of tickspacing ... */ - bool paramsChanged; - bool doUpdateScaling; - - /** \brief simply calls the redrawPlot method of the parent plotter class */ - void redrawPlot(); - /** \brief a list of tick labels. - * - * If this list contains items, this class will NOT plot a standard x-axis, - * but only mark the positions in this list. Every item is a x-position together with - * the label to be plotted there. The label may contain LaTeX markup. - */ - QVector > tickLabels; - /** \brief width of the plot in the direction of the axis */ - virtual double getParentPlotWidth() const=0; - /** \brief offset of the plot in the direction of the axis */ - virtual double getParentPlotOffset() const=0; - /** \brief width of other (perpendicular) axis (needed for grids) */ - virtual double getParentOtheraxisWidth() const=0; - /** \brief is other (perpendicular) axis inverted (needed for grids) */ - virtual bool getParentOtheraxisInverted() const=0; - /** \brief pixel offset of (perpendicular) other axis (needed for grids) */ - virtual double getParentOtheraxisOffset() const=0; - /** \brief retun parents JKQTMathText* object */ - virtual JKQTMathText* getParentMathText(); - - - /** \brief convert a float to a tick label string */ - QString floattolabel(double data); - - /** \brief convert a float to a tick label string with a given precision */ - QString floattolabel(double data, int past_comma); - /** \brief parent plotter class */ - JKQTBasePlotter* parent; - /** \brief current view: minimum of time axis */ - double axismin; - /** \brief current view: maximum of time axis */ - double axismax; - - /** \brief absoulte minimum of axis (axismin/axismax xan not be set below this) */ - double axisabsoultemin; - /** \brief absoulte maximum of axis (axismin/axismax xan not be set above this) */ - double axisabsoultemax; - - /** \brief absolute minimum range width, feature switched off when <0 */ - double axisMinWidth; - - /** \brief width of plot on time axis (calculated by calcPlotScaling() ) */ - double width; - - /** \brief time axis scaling factor (calculated by calcPlotScaling() ) */ - double scale; - /** \brief time axis offset (calculated by calcPlotScaling() ) */ - double offset; - /** \brief indicates whether the axis is to be inverted or not */ - bool inverted; - /** \brief axis tick spacing (calculated by calcPlotScaling() and calcTickSpacing() ) for logarithmic/linear axes. - */ - double tickSpacing; - /** \brief axis tick spacing for logarithmic ticks (calculated by calcPlotScaling() and calcTickSpacing() ) axes. - */ - double tickSpacingLog; - /** \brief digits used for tick labels */ - int labelDigits; - /** \brief x position of the first tick (calculated by calcPlotScaling() ). Given in system coordinates, not pixel coordinates. */ - double tickStart; - /** \brief when \c true, the digits of the labels are calculated automatically */ - bool autoLabelDigits; - /** \brief indicates whether the object should use automatic tick spacing for the x axis (calculated by calcPlotScaling() ) */ - bool autoAxisSpacing; - /*! \brief default value for property property autoAxisSpacing. \see autoAxisSpacing for more information */ - bool default_autoAxisSpacing; - /** \brief if \c true, the plotter displays minor axis labels as number between 1 and 10 in some cases */ - bool minorTickLabelsEnabled; - /*! \brief default value for property property minorTickLabelsEnabled. \see minorTickLabelsEnabled for more information */ - bool default_minorTickLabelsEnabled; - /** \brief indicates whether the y axis has a logarithmic scale */ - bool logAxis; - /*! \brief default value for property property logAxis. \see logAxis for more information */ - bool default_logAxis; - /** \brief the base for a logarithmic x axis */ - double logAxisBase; - /*! \brief default value for property property logAxisBase. \see logAxisBase for more information */ - double default_logAxisBase; - /** \brief if autoXAxisSpacing is \c false then this value is used for xTickSpacing. So this is the property which - * is editable by use of public access methods. - */ - double userTickSpacing; - /*! \brief default value for property property userTickSpacing. \see userTickSpacing for more information */ - double default_userTickSpacing; - /** \brief if autoXAxisSpacing is \c false then this value is used for xTickSpacing. So this is the property which - * is editable by use of public access methods. - */ - double userLogTickSpacing; - /*! \brief default value for property property userLogTickSpacing. \see userLogTickSpacing for more information */ - double default_userLogTickSpacing; - - /** \brief indicates how to draw the labels */ - JKQTPCALabelType labelType; - /*! \brief default value for property property labelType. \see labelType for more information */ - JKQTPCALabelType default_labelType; - - /** \brief mode of the major ticks */ - JKQTPLabelTickMode tickMode; - /*! \brief default value for property property tickMode. \see tickMode for more information */ - JKQTPLabelTickMode default_tickMode; - - /** \brief axis label of the axis */ - QString axisLabel; - - /** \brief position of the axis label */ - JKQTPLabelPosition labelPosition; - /*! \brief default value for property property labelPosition. \see labelPosition for more information */ - JKQTPLabelPosition default_labelPosition; - /** \brief font of the axis labels */ - QString labelFont; - /*! \brief default value for property property labelFont. \see labelFont for more information */ - QString default_labelFont; - /** \brief fontsize of the axis labels */ - double labelFontSize; - /*! \brief default value for property property labelFontSize. \see labelFontSize for more information */ - double default_labelFontSize; - /** \brief font of the axis tick labels */ - QString tickLabelFont; - /*! \brief default value for property property tickLabelFont. \see tickLabelFont for more information */ - QString default_tickLabelFont; - /** \brief fontsize of the axis tick labels */ - double tickLabelFontSize; - /*! \brief default value for property property tickLabelFontSize. \see tickLabelFontSize for more information */ - double default_tickLabelFontSize; - /** \brief fontsize of the minor axis tick labels */ - double minorTickLabelFontSize; - /*! \brief default value for property property minorTickLabelFontSize. \see minorTickLabelFontSize for more information */ - double default_minorTickLabelFontSize; - /** \brief indicates whether to draw a thick axis line at x=0 (zero axis) */ - bool showZeroAxis; - /*! \brief default value for property property showZeroAxis. \see showZeroAxis for more information */ - bool default_showZeroAxis; - /** \brief indicates whether the minor tick labels should be full numbers, or just a number between 0..10 */ - bool minorTickLabelFullNumber; - /*! \brief default value for property property minorTickLabelFullNumber. \see minorTickLabelFullNumber for more information */ - bool default_minorTickLabelFullNumber; - - - /** \brief draw mode of the main (left/bottom) axis */ - JKQTPCADrawMode drawMode1; - /*! \brief default value for property property drawMode1. \see drawMode1 for more information */ - JKQTPCADrawMode default_drawMode1; - /** \brief draw mode of the secondary (right/top) axis */ - JKQTPCADrawMode drawMode2; - /*! \brief default value for property property drawMode2. \see drawMode2 for more information */ - JKQTPCADrawMode default_drawMode2; - /** \brief line width of minor ticks in pt */ - double minorTickWidth; - /*! \brief default value for property property minorTickWidth. \see minorTickWidth for more information */ - double default_minorTickWidth; - /** \brief line width of ticks in pt */ - double tickWidth; - /*! \brief default value for property property tickWidth. \see tickWidth for more information */ - double default_tickWidth; - /** \brief line width of axis in pt */ - double lineWidth; - /*! \brief default value for property property lineWidth. \see lineWidth for more information */ - double default_lineWidth; - /** \brief line width of 0-line in pt */ - double lineWidthZeroAxis; - /*! \brief default value for property property lineWidthZeroAxis. \see lineWidthZeroAxis for more information */ - double default_lineWidthZeroAxis; - - - /** \brief format string for time tick labels, see see QDateTime::toString() documentation for details on format strings */ - QString tickTimeFormat; - /*! \brief default value for property property tickTimeFormat. \see tickTimeFormat for more information */ - QString default_tickTimeFormat; - /** \brief format string for date tick labels, see see QDateTime::toString() documentation for details on format strings */ - QString tickDateFormat; - /*! \brief default value for property property tickDateFormat. \see tickDateFormat for more information */ - QString default_tickDateFormat; - /** \brief format string for datetime tick labels, see see QDateTime::toString() documentation for details on format strings */ - QString tickDateTimeFormat; - /*! \brief default value for property property tickDateTimeFormat. \see tickDateTimeFormat for more information */ - QString default_tickDateTimeFormat; - - /** \brief calculates the tick spacing for a linear axis that spans \a awidth and that should - * show at least \a minTicks ticks. - * - * The algorithm used in here works as follows: - * - * There is only a limited subset of allowed tick distances. These distances are 1 (resulting in 10 ticks per decade, i.e. 0,1,2,3,4,...), - * 2 (5 ticks/decade, i.e. 0,2,4,...), 2.5 (4 ticks/decade, i.e. 0,2.5,5,...) and 5 (2 ticks/decade, i.e. 0,5,10,15,...). So the - * axis is divided into decades that each is divided into ticks, as defined above. With these preconditions the algorithm tries - * to find a tick increment \f$ \Delta\mbox{tick} \f$ which is one of the above distances multiplied by a power \f$ \rho \f$ of 10. - * This increment is determined in a way, that the axis contains at least \a minTicks ticks: - * \f[ \Delta\mbox{tick}=f\cdot 10^\rho,\ \ \ \ \ f\in\{1, 2, 2.5, 5\} \f] - * - * -# The algorithm starts by finding a start exponent \f$ \rho_s=\left\lfloor\log_{10}(\mbox{awidth})\right\rfloor+3 \f$. This - * is a good (over)estimate for the biggest possible power \f$ \rho \f$. - * -# now we set \f$ \rho=\rho_0 \f$ and \f$ f=10 \f$. - * -# now the algorithm cycles through all possible factors \f$ f\in\{1, 2, 2.5, 5, 10\} \f$ (starting from 10) and calculates - * \f$ \Delta\mbox{tick}=f\cdot 10^\rho \f$. Then it checks whether \f$ \mbox{tickcount}=\mbox{round}\left(\frac{\mbox{awidth}}{\Delta\mbox{tick}}\right) \f$ - * is smaller than \a minTicks (if yes the algorithm reached its end and \f$ \Delta\mbox{tick} \f$ can be used. - * -# if \f$ f=1 \f$ is reached and checked \c false, then the algorithm decreases the exponent \f$ \rho \leftarrow \rho-1 \f$ and returns to step 3. - * - */ - double calcLinearTickSpacing(); - double calcLogTickSpacing(); - - /** \brief Calculate the number of digits needed for the labels of an axis that starts at - * \a minval and where the tick spacing is \a tickSpacing. - * - * This method determines how many digits to output for the labels on a coordinate axis. - * This is done by testing different digit numbers and comparing subsequent labels. If two labels - * are equal, then we need more valid digits to distinguish them. - */ - int calcLinearUnitDigits(); - - /** \brief minimum number of axis ticks */ - unsigned int minTicks; - /*! \brief default value for property property minTicks. \see minTicks for more information */ - unsigned int default_minTicks; - /** \brief number of minor grid lines per axis tick interval - * - * \image html docu_logaxis_set_minorticks.png - **/ - unsigned int minorTicks; - /*! \brief default value for property property minorTicks. \see minorTicks for more information - * - * \image html docu_logaxis_set_minorticks.png - */ - unsigned int default_minorTicks; - /** \brief length of an axis tick outside the plot border in pt */ - double tickOutsideLength; - /*! \brief default value for property property tickOutsideLength. \see tickOutsideLength for more information */ - double default_tickOutsideLength; - /** \brief length of a minor axis tick outside the plot border in pt */ - double minorTickOutsideLength; - /*! \brief default value for property property minorTickOutsideLength. \see minorTickOutsideLength for more information */ - double default_minorTickOutsideLength; - /** \brief length of an axis tick inside the plot border in pt */ - double tickInsideLength; - /*! \brief default value for property property tickInsideLength. \see tickInsideLength for more information */ - double default_tickInsideLength; - /** \brief length of a minor axis tick inside the plot border in pt */ - double minorTickInsideLength; - /*! \brief default value for property property minorTickInsideLength. \see minorTickInsideLength for more information */ - double default_minorTickInsideLength; - /** \brief color of the axis (labels, ticks, axis itself ...) */ - QColor axisColor; - /*! \brief default value for property property axisColor. \see axisColor for more information */ - QColor default_axisColor; - /** \brief distance between tick end and label start in pt */ - double tickLabelDistance; - /*! \brief default value for property property tickLabelDistance. \see tickLabelDistance for more information */ - double default_tickLabelDistance; - /** \brief distance between tick label and axis label in pt */ - double labelDistance; - /*! \brief default value for property property labelDistance. \see labelDistance for more information */ - double default_labelDistance; - /** \brief rotation angle of tick labels [-180..180], i.e. given in degrees, default is 0 (horizontal) */ - double tickLabelAngle; - /*! \brief default value for property property tickLabelAngle. \see tickLabelAngle for more information */ - double default_tickLabelAngle; - - /** \brief indicates whether to draw the major grid lines */ - bool drawGrid; - /*! \brief default value for property property drawGrid. \see drawGrid for more information */ - bool default_drawGrid; - /** \brief indicates whether to draw the minor grid lines */ - bool drawMinorGrid; - /*! \brief default value for property property drawMinorGrid. \see drawMinorGrid for more information */ - bool default_drawMinorGrid; - /** \brief color of the grid*/ - QColor gridColor; - /*! \brief default value for property property gridColor. \see gridColor for more information */ - QColor default_gridColor; - /** \brief color of the minor grid lines */ - QColor minorGridColor; - /*! \brief default value for property property minorGridColor. \see minorGridColor for more information */ - QColor default_minorGridColor; - /** \brief width of the grid lines (in pixel) */ - double gridWidth; - /*! \brief default value for property property gridWidth. \see gridWidth for more information */ - double default_gridWidth; - /** \brief line stye of the grid lines */ - Qt::PenStyle gridStyle; - /*! \brief default value for property property gridStyle. \see gridStyle for more information */ - Qt::PenStyle default_gridStyle; - /** \brief width of the minor grid lines (in pixel) */ - double minorGridWidth; - /*! \brief default value for property property minorGridWidth. \see minorGridWidth for more information */ - double default_minorGridWidth; - /** \brief line stye of the minor grid lines */ - Qt::PenStyle minorGridStyle; - /*! \brief default value for property property minorGridStyle. \see minorGridStyle for more information */ - Qt::PenStyle default_minorGridStyle; - - /** \brief axis prefix for storage of parameters */ - QString axisPrefix; - /** \brief this is used by x2p() and p2x() to determine the sign */ - double scaleSign; - - /** \brief calculates the next label from the given parameters. - * - * \return \c true on success and \c false if there is no more label - * \param x \b before \b call: the position of the label for which the text should be returned (or tickStart for first call), - * \b after \b call: position of the next label (given in world coordinates!) - * \param label \b after \b call: text of the (input) tick label This is an empty string, if the label is not visible! - * \param init call this function with \c init=true to obtain the first label (at tickStart) - */ - bool getNextLabel(double& x, QString& label, bool init=false); - - /** \brief returns the distance from the current tick position (x before call) to the next tick position */ - double getNextLabelDistance(double x); - - /** \brief calculates the maximum width and height (returned as QSize) of all tick labels. - * Ascent and descent may also be returned in the two additional pointer arguments- */ - QSizeF getMaxTickLabelSize(JKQTPEnhancedPainter& painter, double* ascent=nullptr, double* descent=nullptr); -}; - - - - - -/*! \brief implements a vertical axis, based on JKQTPCoordinateAxis (for most of documentation: see JKQTPCoordinateAxis). - \ingroup jkqtpbaseplotter_elements - - */ -class JKQTP_LIB_EXPORT JKQTPVerticalAxis: public JKQTPCoordinateAxis { - Q_OBJECT - protected: - public: - /** \brief class constructor */ - JKQTPVerticalAxis(JKQTBasePlotter* parent); - - /** \brief returns the size of the left/bottom axis in pt */ - virtual QSize getSize1(JKQTPEnhancedPainter& painter) override; - - /** \brief returns the size of the right/top axis in pt */ - virtual QSize getSize2(JKQTPEnhancedPainter& painter) override; - - /** \brief draw axes */ - virtual void drawAxes(JKQTPEnhancedPainter& painter) override; - - /** \brief draw grids */ - virtual void drawGrids(JKQTPEnhancedPainter& painter) override; - - - protected: - /** \brief width of the plot in the direction of the axis */ - virtual double getParentPlotWidth() const override; - /** \brief offset of the plot in the direction of the axis */ - virtual double getParentPlotOffset() const override; - /** \brief pixel of other (perpendicular) axis (needed for grids) */ - virtual double getParentOtheraxisWidth() const override; - virtual bool getParentOtheraxisInverted() const override; - /** \brief pixel offset of (perpendicular) other axis (needed for grids) */ - virtual double getParentOtheraxisOffset() const override; - - virtual void drawTickLabel1(JKQTPEnhancedPainter& painter, double xx, double yy, const QString &label, double fontSize) ; - virtual void drawTickLabel2(JKQTPEnhancedPainter& painter, double xx, double yy, const QString &label, double fontSize) ; -}; - - -/*! \brief implements a position-indipendent vertical axis, based on JKQTPCoordinateAxis (for most of documentation: see JKQTPCoordinateAxis). - \ingroup jkqtpbaseplotter_elements - - This axis may be draw at a user-supplied position (used e.g. for color bar axes) - */ -class JKQTP_LIB_EXPORT JKQTPVerticalIndependentAxis: public JKQTPVerticalAxis { - Q_OBJECT - protected: - public: - /** \brief class constructor */ - JKQTPVerticalIndependentAxis(double axisOffset, double axisWidth, double otherAxisOffset, double otherAxisWidth, JKQTBasePlotter* parent); - /** \brief set the axis offset */ - virtual void setAxisOffset(double __value) ; - /** \brief set the axis width */ - virtual void setAxisWidth(double __value) ; - /** \brief set the other axis offset */ - virtual void setOtherAxisOffset(double __value) ; - /** \brief set the other axis width */ - virtual void setOtherAxisWidth(double __value) ; - /** \brief set the other axis width */ - virtual void setOtherAxisInverted(bool __value) ; - protected: - /** \brief width of the plot in the direction of the axis */ - virtual double getParentPlotWidth() const override; - /** \brief offset of the plot in the direction of the axis */ - virtual double getParentPlotOffset() const override; - /** \brief pixel of other (perpendicular) axis (needed for grids) */ - virtual double getParentOtheraxisWidth() const override; - virtual bool getParentOtheraxisInverted() const override; - /** \brief pixel offset of (perpendicular) other axis (needed for grids) */ - virtual double getParentOtheraxisOffset() const override; - - double axisOffset; - double axisWidth; - double otherAxisWidth; - double otherAxisOffset; - bool otherAxisInverted; -}; - - - -/*! \brief implements a horizontal axis, based on JKQTPCoordinateAxis (for most of documentation: see JKQTPCoordinateAxis). - \ingroup jkqtpbaseplotter_elements - - */ -class JKQTP_LIB_EXPORT JKQTPHorizontalAxis: public JKQTPCoordinateAxis { - Q_OBJECT - protected: - public: - /** \brief class constructor */ - JKQTPHorizontalAxis(JKQTBasePlotter* parent); - - /** \brief returns the size of the left/bottom axis in pt */ - virtual QSize getSize1(JKQTPEnhancedPainter& painter) override; - - /** \brief returns the size of the right/top axis in pt */ - virtual QSize getSize2(JKQTPEnhancedPainter& painter) override; - - /** \brief draw axes */ - virtual void drawAxes(JKQTPEnhancedPainter& painter) override; - - /** \brief draw grids */ - virtual void drawGrids(JKQTPEnhancedPainter& painter) override; - - protected: - /** \brief width of the plot in the direction of the axis */ - virtual double getParentPlotWidth() const override; - /** \brief offset of the plot in the direction of the axis */ - virtual double getParentPlotOffset() const override; - /** \brief pixel of other (perpendicular) axis (needed for grids) */ - virtual double getParentOtheraxisWidth() const override; - virtual bool getParentOtheraxisInverted() const override; - /** \brief pixel offset of (perpendicular) other axis (needed for grids) */ - virtual double getParentOtheraxisOffset() const override; - - - virtual void drawTickLabel1(JKQTPEnhancedPainter& painter, double xx, double yy, const QString &label, double fontSize, double ascentMax, double descentMax) ; - virtual void drawTickLabel2(JKQTPEnhancedPainter& painter, double xx, double yy, const QString &label, double fontSize, double ascentMax, double descentMax) ; - -}; - - -/*! \brief implements a position-indipendent horizontal axis, based on JKQTPCoordinateAxis (for most of documentation: see JKQTPCoordinateAxis). - \ingroup jkqtpbaseplotter_elements - - This axis may be draw at a user-supplied position (used e.g. for color bar axes) - */ -class JKQTP_LIB_EXPORT JKQTPHorizontalIndependentAxis: public JKQTPHorizontalAxis { - Q_OBJECT - protected: - public: - /** \brief class constructor */ - JKQTPHorizontalIndependentAxis(double axisOffset, double axisWidth, double otherAxisOffset, double otherAxisWidth, JKQTBasePlotter* parent); - /** \brief se the axis offset */ - virtual void setAxisOffset(double __value); - /** \brief se the axis width */ - virtual void setAxisWidth(double __value); - /** \brief set the other axis offset */ - virtual void setOtherAxisOffset(double __value); - /** \brief set the other axis width */ - virtual void setOtherAxisWidth(double __value); - virtual void setOtherAxisInverted(bool __value); - protected: - /** \brief width of the plot in the direction of the axis */ - virtual double getParentPlotWidth() const override; - /** \brief offset of the plot in the direction of the axis */ - virtual double getParentPlotOffset() const override; - /** \brief pixel of other (perpendicular) axis (needed for grids) */ - virtual double getParentOtheraxisWidth() const override; - virtual bool getParentOtheraxisInverted() const override; - /** \brief pixel offset of (perpendicular) other axis (needed for grids) */ - virtual double getParentOtheraxisOffset() const override; - - double axisOffset; - double axisWidth; - double otherAxisWidth; - double otherAxisOffset; - bool otherAxisInverted; -}; #endif // JKQTPBASEELEMENTS_H diff --git a/lib/jkqtplotter/jkqtpbaseplotter.cpp b/lib/jkqtplotter/jkqtpbaseplotter.cpp index da49d08fcb..10475673fb 100644 --- a/lib/jkqtplotter/jkqtpbaseplotter.cpp +++ b/lib/jkqtplotter/jkqtpbaseplotter.cpp @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -53,6 +53,7 @@ #include "jkqtplotter/jkqtpgraphs.h" #include "jkqtplotter/jkqtpgraphsgeometric.h" #include "jkqtplotter/jkqtpgraphsimage.h" +#include "jkqtplotter/jkqtpgraphsimagergb.h" static QString globalUserSettigsFilename=""; static QString globalUserSettigsPrefix=""; @@ -60,16 +61,13 @@ static QList jkqtpPaintDeviceAdapters; static QList jkqtpSaveDataAdapters; + void initJKQTBasePlotterResources() { Q_INIT_RESOURCE(jkqtpbaseplotter); initJKQTMathTextResources(); } -JKQTBasePlotter::JKQTBasePlotter() -{ - initJKQTBasePlotterResources(); -} void JKQTBasePlotter::setDefaultJKQTBasePrinterUserSettings(QString userSettigsFilename, const QString& userSettigsPrefix) { @@ -116,24 +114,31 @@ JKQTBasePlotter::textSizeData JKQTBasePlotter::getTextSizeDetail(const QFont &fm JKQTBasePlotter::textSizeData JKQTBasePlotter::getTextSizeDetail(const QString &fontName, double fontSize, const QString &text, QPainter& painter) { JKQTBasePlotter::textSizeKey dh(fontName, fontSize, text, painter.device()); - if (tbrh.contains(dh)) return tbrh[dh]; + if (s_TextSizeDataCache.contains(dh)) return s_TextSizeDataCache[dh]; JKQTBasePlotter::textSizeData d; - mathText.setFontRoman(fontName); + mathText.setFontRomanOrSpecial(fontName); mathText.setFontSize(fontSize); mathText.parse(text); mathText.getSizeDetail(painter, d.width, d.ascent, d.descent, d.strikeoutPos); - tbrh[dh]=d; + s_TextSizeDataCache[dh]=d; //qDebug()<<"+++ textsize hash size: "<setRange(-10, 10); yAxis->setRange(-10, 10); - default_keyFont="Arial"; keyFont=default_keyFont; - default_keyFontSize=9; keyFontSize=default_keyFontSize; - - - default_keyXOffset=0.5; keyXOffset=default_keyXOffset; - default_keyYOffset=0.5; keyYOffset=default_keyYOffset; - default_keyXSeparation=0.75; keyXSeparation=default_keyXSeparation; - default_keyYSeparation=0.75; keyYSeparation=default_keyYSeparation; - default_keyFrameColor=QColor("black"); keyFrameColor=default_keyFrameColor; - default_keyFrameWidth=1; keyFrameWidth=default_keyFrameWidth; - default_showKeyFrame=true; showKeyFrame=default_showKeyFrame; - default_keyBackgroundColor=QColor("white"); keyBackgroundColor=default_keyBackgroundColor; - default_showKey=true; showKey=default_showKey; - default_key_item_width=20; key_item_width=default_key_item_width; - default_key_item_height=2.2; key_item_height=default_key_item_height; - default_key_line_length=3; key_line_length=default_key_line_length; - default_keyXMargin=0.5; keyXMargin=default_keyXMargin; - default_keyYMargin=0.5; keyYMargin=default_keyYMargin; - default_keyPosition=JKQTPKeyInsideTopRight; keyPosition=default_keyPosition; - default_keyLayout=JKQTPKeyLayoutOneColumn; keyLayout=default_keyLayout; - default_keyAutosize=true; keyAutosize=default_keyAutosize; - - default_exportBackgroundColor=QColor("white"); exportBackgroundColor=default_exportBackgroundColor; - default_backgroundColor=QColor("white"); backgroundColor=default_backgroundColor; - default_plotBackgroundColor=QColor("white"); plotBackgroundColor=default_plotBackgroundColor; - default_graphColor=QColor("red"); graphColor=default_graphColor; - manyGraphsColorCount=15; - default_manyGraphsColor[0]=graphColor; - default_manyGraphsColor[1]=QColor("green"); - default_manyGraphsColor[2]=QColor("blue"); - default_manyGraphsColor[3]=QColor("fuchsia"); - default_manyGraphsColor[4]=QColor("darkorange"); - default_manyGraphsColor[5]=QColor("navy"); - default_manyGraphsColor[6]=QColor("firebrick"); - default_manyGraphsColor[7]=QColor("darkgreen"); - default_manyGraphsColor[8]=QColor("darkmagenta"); - default_manyGraphsColor[9]=QColor("darkgreen"); - default_manyGraphsColor[10]=QColor("darkslateblue"); - default_manyGraphsColor[11]=QColor("maroon"); - default_manyGraphsColor[12]=QColor("indianred"); - default_manyGraphsColor[13]=QColor("darkolivegreen"); - default_manyGraphsColor[14]=QColor("mediumpurple"); - default_manyGraphsColor[15]=QColor("darkcyan"); - for (int i=0; idelta()/120.0<<": "<(round(static_cast(plotWidth)/2.0-static_cast(plotWidth)/(2.0*factor)))); - double xmax=p2x(static_cast(round(static_cast(plotWidth)/2.0+static_cast(plotWidth)/(2.0*factor)))); - double ymin=p2y(static_cast(round(static_cast(plotHeight)/2.0+static_cast(plotHeight)/(2.0*factor)))); - double ymax=p2y(static_cast(round(static_cast(plotHeight)/2.0-static_cast(plotHeight)/(2.0*factor)))); + double xmin=p2x(static_cast(round(static_cast(internalPlotWidth)/2.0-static_cast(internalPlotWidth)/(2.0*factor)))); + double xmax=p2x(static_cast(round(static_cast(internalPlotWidth)/2.0+static_cast(internalPlotWidth)/(2.0*factor)))); + double ymin=p2y(static_cast(round(static_cast(internalPlotHeight)/2.0+static_cast(internalPlotHeight)/(2.0*factor)))); + double ymax=p2y(static_cast(round(static_cast(internalPlotHeight)/2.0-static_cast(internalPlotHeight)/(2.0*factor)))); xAxis->setRange(xmin, xmax); @@ -452,6 +390,20 @@ void JKQTBasePlotter::zoomIn(double factor) { if (emitSignals) emit zoomChangedLocally(xAxis->getMin(), xAxis->getMax(), yAxis->getMin(), yAxis->getMax(), this); } +void JKQTBasePlotter::zoomOut(double factor) { + zoomIn(1.0/factor); +} + +void JKQTBasePlotter::setMaintainAspectRatio(bool value) { + maintainAspectRatio=value; + redrawPlot(); +} + +void JKQTBasePlotter::setMaintainAxisAspectRatio(bool value) { + maintainAxisAspectRatio=value; + redrawPlot(); +} + void JKQTBasePlotter::zoom(double nxmin, double nxmax, double nymin, double nymax){ // only react on double clicks inside event double xmin=nxmin; @@ -465,96 +417,149 @@ void JKQTBasePlotter::zoom(double nxmin, double nxmax, double nymin, double nyma if (emitSignals) emit zoomChangedLocally(xAxis->getMin(), xAxis->getMax(), yAxis->getMin(), yAxis->getMax(), this); } -void JKQTBasePlotter::resize(int wid, int heigh) { +void JKQTBasePlotter::setWidgetSize(int wid, int heigh) { widgetWidth=wid; widgetHeight=heigh; if (emitPlotSignals) emit plotUpdated(); } +int JKQTBasePlotter::getWidth() { + return widgetWidth; +} -void JKQTBasePlotter::setWidth(int wid) { +int JKQTBasePlotter::getHeight() { + return widgetHeight; +} + +double JKQTBasePlotter::getXMin() const { + return xAxis->getMin(); +} + +double JKQTBasePlotter::getXMax() const { + return xAxis->getMax(); +} + +double JKQTBasePlotter::getYMin() const { + return yAxis->getMin(); +} + +double JKQTBasePlotter::getYMax() const { + return yAxis->getMax(); +} + +double JKQTBasePlotter::getAbsoluteXMin() const { + return xAxis->getAbsoluteMin(); +} + +double JKQTBasePlotter::getAbsoluteXMax() const { + return xAxis->getAbsoluteMax(); +} + +double JKQTBasePlotter::getAbsoluteYMin() const { + return yAxis->getAbsoluteMin(); +} + +double JKQTBasePlotter::getAbsoluteYMax() const { + return yAxis->getAbsoluteMax(); +} + +void JKQTBasePlotter::addGridPrintingPlotter(size_t x, size_t y, JKQTBasePlotter *plotter) { + JKQTPGridPrintingItem i; + i.x=x; + i.y=y; + i.plotter=plotter; + gridPrintingList.push_back(i); +} + +void JKQTBasePlotter::clearGridPrintingPlotters() { + gridPrintingList.clear(); +} + + +void JKQTBasePlotter::setWidgetWidth(int wid) { widgetWidth=wid; if (emitPlotSignals) emit plotUpdated(); } -void JKQTBasePlotter::setHeight(int heigh) { +void JKQTBasePlotter::setWidgetHeight(int heigh) { widgetHeight=heigh; if (emitPlotSignals) emit plotUpdated(); } void JKQTBasePlotter::saveSettings(QSettings& settings, const QString& group) const{ - QString g=group+"/"; - if (group.isEmpty()) g=""; - if (aspectRatio!=default_aspectRatio) settings.setValue(g+"apect_ratio", aspectRatio); - if (maintainAspectRatio!=default_maintainAspectRatio) settings.setValue(g+"maintain_apect_ratio", maintainAspectRatio); - if (axisAspectRatio!=default_axisAspectRatio) settings.setValue(g+"axis_apect_ratio", axisAspectRatio); - if (maintainAxisAspectRatio!=default_maintainAxisAspectRatio) settings.setValue(g+"maintain_axis_apect_ratio", maintainAxisAspectRatio); - if (CSVdecimalSeparator!=default_CSVdecimalSeparator) settings.setValue(g+"csv_decimal_separator", CSVdecimalSeparator); - if (CSVcommentInitializer!=default_CSVcommentInitializer) settings.setValue(g+"csv_comment_initializer", CSVcommentInitializer); + plotterStyle.saveSettings(settings, group); - if (plotBorderLeft!=default_plotBorderLeft) settings.setValue(g+"plot_border_left", plotBorderLeft); - if (plotBorderRight!=default_plotBorderRight) settings.setValue(g+"plot_border_right", plotBorderRight); - if (plotBorderTop!=default_plotBorderTop) settings.setValue(g+"plot_border_top", plotBorderTop); - if (plotBorderBottom!=default_plotBorderBottom) settings.setValue(g+"plot_border_bottom", plotBorderBottom); - - if (keyXOffset!=default_keyXOffset) settings.setValue(g+"key_xoffset", keyXOffset); - if (keyYOffset!=default_keyYOffset) settings.setValue(g+"key_yoffset", keyYOffset); - if (keyXMargin!=default_keyXMargin) settings.setValue(g+"key_xmargin", keyXMargin); - if (keyYMargin!=default_keyYMargin) settings.setValue(g+"key_ymargin", keyYMargin); - if (keyXSeparation!=default_keyXSeparation) settings.setValue(g+"key_xseparation", keyXSeparation); - if (keyYSeparation!=default_keyYSeparation) settings.setValue(g+"key_yseparation", keyYSeparation); - if (keyFrameColor!=default_keyFrameColor) settings.setValue(g+"key_frame_color", jkqtp_QColor2String(keyFrameColor)); - if (keyFrameWidth!=default_keyFrameWidth) settings.setValue(g+"key_frame_width", keyFrameWidth); - if (showKeyFrame!=default_showKeyFrame) settings.setValue(g+"show_key_frame", showKeyFrame); - if (keyBackgroundColor!=default_keyBackgroundColor) settings.setValue(g+"key_background_color", jkqtp_QColor2String(keyBackgroundColor)); - if (showKey!=default_showKey) settings.setValue(g+"show_key", showKey); - if (keyPosition!=default_keyPosition) settings.setValue(g+"key_position", JKQTPKeyPosition2String(keyPosition)); - if (keyLayout!=default_keyLayout) settings.setValue(g+"key_layout", JKQTPKeyLayout2String(keyLayout)); - - if (useAntiAliasingForSystem!=default_useAntiAliasingForSystem) settings.setValue(g+"use_antialiasing_for_system", useAntiAliasingForSystem); - if (useAntiAliasingForGraphs!=default_useAntiAliasingForGraphs) settings.setValue(g+"use_antialiasing_for_graphs", useAntiAliasingForGraphs); - if (useAntiAliasingForText!=default_useAntiAliasingForText) settings.setValue(g+"use_antialiasing_for_text", useAntiAliasingForText); - - if (backgroundColor!=default_backgroundColor) settings.setValue(g+"background_color", jkqtp_QColor2String(backgroundColor)); - if (exportBackgroundColor!=default_exportBackgroundColor) settings.setValue(g+"exportBackgroundColor", jkqtp_QColor2String(exportBackgroundColor)); - if (plotBackgroundColor!=default_plotBackgroundColor) settings.setValue(g+"plot_background_color", jkqtp_QColor2String(plotBackgroundColor)); - if (graphColor!=default_graphColor) settings.setValue(g+"graph_color", jkqtp_QColor2String(graphColor)); - if (graphWidth!=default_graphWidth) settings.setValue(g+"graph_linewidth", graphWidth); + settings.setValue(group+"apect_ratio", aspectRatio); + settings.setValue(group+"maintain_apect_ratio", maintainAspectRatio); + settings.setValue(group+"axis_apect_ratio", axisAspectRatio); + settings.setValue(group+"maintain_axis_apect_ratio", maintainAxisAspectRatio); - if (keyFont!=default_keyFont) settings.setValue(g+"key_fontname", keyFont); - if (keyFontSize!=default_keyFontSize) settings.setValue(g+"key_fontsize", keyFontSize); - if (key_item_width!=default_key_item_width) settings.setValue(g+"key_item_width", key_item_width); - if (key_item_height!=default_key_item_height) settings.setValue(g+"key_item_height", key_item_height); - if (key_line_length!=default_key_line_length) settings.setValue(g+"key_line_width", key_line_length); - if (keyAutosize!=default_keyAutosize) settings.setValue(g+"key_autosize", keyAutosize); + mathText.saveSettings(settings, group+"math_text."); - if (plotLabelFontname!=default_plotLabelFontname) settings.setValue(g+"plotLabelFontname", plotLabelFontname); - if (plotLabelFontSize!=default_plotLabelFontSize) settings.setValue(g+"plotLabelFontSize", plotLabelFontSize); - - bool palette_changed=false; - for (int cnt=0; cntsaveSettings(settings, g+"xaxis_"); - yAxis->saveSettings(settings, g+"yaxis_"); + xAxis->saveSettings(settings, group+"xaxis_"); + yAxis->saveSettings(settings, group+"yaxis_"); saveUserSettings(); } +const JKQTBasePlotterStyle &JKQTBasePlotter::getCurrentPlotterStyle() const +{ + return plotterStyle; +} + +void JKQTBasePlotter::setCurrentPlotterStyle(const JKQTBasePlotterStyle &style) +{ + plotterStyle=style; + propagateStyle(); +} + +void JKQTBasePlotter::propagateStyle() { + bool old=emitPlotSignals; + emitPlotSignals=false; + xAxis->setCurrentAxisStyle(plotterStyle.xAxisStyle); + yAxis->setCurrentAxisStyle(plotterStyle.yAxisStyle); + for (int i=0; i(graphs[i]); + if (palTools) { + palTools->getColorBarRightAxis()->setCurrentAxisStyle(plotterStyle.rightColorbarAxisStyle); + palTools->getColorBarTopAxis()->setCurrentAxisStyle(plotterStyle.topColorbarAxisStyle); + } + JKQTPMathImage* matImg=dynamic_cast(graphs[i]); + if (matImg) { + matImg->getColorBarRightAxis()->setCurrentAxisStyle(plotterStyle.rightColorbarAxisStyle); + matImg->getColorBarTopAxis()->setCurrentAxisStyle(plotterStyle.topColorbarAxisStyle); + matImg->getModifierColorBarRightAxis()->setCurrentAxisStyle(plotterStyle.rightColorbarAxisStyle); + matImg->getModifierColorBarTopAxis()->setCurrentAxisStyle(plotterStyle.topColorbarAxisStyle); + } + JKQTPRGBMathImage* matImgRGB=dynamic_cast(graphs[i]); + if (matImgRGB) { + matImgRGB->getColorBarRightAxis()->setCurrentAxisStyle(plotterStyle.rightColorbarAxisStyle); + matImgRGB->getColorBarTopAxis()->setCurrentAxisStyle(plotterStyle.topColorbarAxisStyle); + matImgRGB->getColorBarRightAxisG()->setCurrentAxisStyle(plotterStyle.rightColorbarAxisStyle); + matImgRGB->getColorBarTopAxisG()->setCurrentAxisStyle(plotterStyle.topColorbarAxisStyle); + matImgRGB->getColorBarRightAxisB()->setCurrentAxisStyle(plotterStyle.rightColorbarAxisStyle); + matImgRGB->getColorBarTopAxisB()->setCurrentAxisStyle(plotterStyle.topColorbarAxisStyle); + } + } + emitPlotSignals=old; + if (emitPlotSignals) emit plotUpdated(); +} + +void JKQTBasePlotter::loadCurrentPlotterStyle(const QSettings &settings, const QString &group) +{ + plotterStyle.loadSettings(settings, group); + propagateStyle(); +} + +void JKQTBasePlotter::saveCurrentPlotterStyle(QSettings &settings, const QString &group) const +{ + plotterStyle.saveSettings(settings, group); +} + void JKQTBasePlotter::loadUserSettings(const QSettings &settings, const QString& group) { currentSaveDirectory=settings.value(group+"currentSaveDirectory", currentSaveDirectory).toString(); currentFileFormat=settings.value(group+"currentFileFormat", currentFileFormat).toString(); @@ -570,12 +575,12 @@ void JKQTBasePlotter::loadUserSettings(const QSettings &settings, const QString& printKeepAspect=settings.value(group+"printKeepAspect", printKeepAspect).toBool(); exportUnitInMM=settings.value(group+"exportUnitInMM", exportUnitInMM).toBool(); currentPrinter=settings.value(group+"printer", currentPrinter).toString(); - int count=settings.value(group+"selections.count", 0).toInt(); + int count=settings.value(group+"selections/count", 0).toInt(); getDataColumnsByUserSaved.clear(); for (int i=0; iloadSettings(settings, g+"yaxis_"); @@ -754,62 +700,54 @@ void JKQTBasePlotter::calcPlotScaling(JKQTPEnhancedPainter& painter){ if (emitSignals) emit beforePlotScalingRecalculate(); //qDebug()<<"start JKQTBasePlotter::calcPlotScaling"; // if the key is plotted outside , then we have to add place for it (i.e. change the plotBorders - iplotBorderBottom=plotBorderBottom; - iplotBorderLeft=plotBorderLeft; - iplotBorderRight=plotBorderRight; - iplotBorderTop=plotBorderTop; - iTitleHeight=0; + internalPlotBorderBottom=plotterStyle.plotBorderBottom; + internalPlotBorderLeft=plotterStyle.plotBorderLeft; + internalPlotBorderRight=plotterStyle.plotBorderRight; + internalPlotBorderTop=plotterStyle.plotBorderTop; + internalTitleHeight=0; if (!plotLabel.isEmpty()) { - /*JKQTMathText mt; - mt.setFontSize(plotLabelFontSize*fontSizeMultiplier); - mt.setFontRoman(plotLabelFontname); -#ifdef USE_XITS_FONTS - mt.useXITS(); -#endif - mt.parse(plotLabel); - QSizeF s=mt.getSize(painter);*/ - QSizeF s=getTextSizeSize(plotLabelFontname, plotLabelFontSize*fontSizeMultiplier, plotLabel, painter); - iplotBorderTop+=s.height()*1.2; - iTitleHeight=s.height()*1.2; + QSizeF s=getTextSizeSize(plotterStyle.plotLabelFontName, plotterStyle.plotLabelFontSize*fontSizeMultiplier, plotLabel, painter); + internalPlotBorderTop+=s.height()*1.2; + internalTitleHeight=s.height()*1.2; } double keyWidth, keyHeight; QFont f=painter.font(); - f.setFamily(keyFont); - f.setPointSizeF(keyFontSize*fontSizeMultiplier); + f.setFamily(plotterStyle.defaultFontName); + f.setPointSizeF(plotterStyle.keyStyle.fontSize*fontSizeMultiplier); QFontMetricsF kfm(f); getKeyExtent(painter, &keyWidth, &keyHeight); - iplotKeyBorderTop=0; - iplotKeyBorderBottom=0; - iplotKeyBorderLeft=0; - iplotKeyBorderRight=0; - if (keyPosition==JKQTPKeyOutsideTopRight) { - iplotKeyBorderTop=keyHeight+2*keyYMargin*kfm.width('X')+ceil(2*keyFrameWidth)+keyYOffset*kfm.width('X')+2; - iplotBorderTop = iplotBorderTop + iplotKeyBorderTop; - } else if (keyPosition==JKQTPKeyOutsideTopLeft) { - iplotKeyBorderTop=keyHeight+2*keyYMargin*kfm.width('X')+ceil(2*keyFrameWidth)+keyYOffset*kfm.width('X')+2; - iplotBorderTop = iplotBorderTop + iplotKeyBorderTop; - } else if (keyPosition==JKQTPKeyOutsideLeftTop) { - iplotKeyBorderLeft=keyWidth+2*keyXMargin*kfm.width('X')+ceil(2*keyFrameWidth)+keyXOffset*kfm.width('X')+2; - iplotBorderLeft = iplotBorderLeft + iplotKeyBorderLeft; - } else if (keyPosition==JKQTPKeyOutsideLeftBottom) { - iplotKeyBorderLeft=keyWidth+2*keyXMargin*kfm.width('X')+ceil(2*keyFrameWidth)+keyXOffset*kfm.width('X')+2; - iplotBorderLeft = iplotBorderLeft + iplotKeyBorderLeft; - } else if (keyPosition==JKQTPKeyOutsideBottomRight) { - iplotKeyBorderBottom=keyHeight+2*keyYMargin*kfm.width('X')+ceil(2*keyFrameWidth)+keyYOffset*kfm.width('X')+2; - iplotBorderBottom = iplotBorderBottom + iplotKeyBorderBottom; - } else if (keyPosition==JKQTPKeyOutsideBottomLeft) { - iplotKeyBorderBottom=keyHeight+2*keyYMargin*kfm.width('X')+ceil(2*keyFrameWidth)+keyYOffset*kfm.width('X')+2; - iplotBorderBottom = iplotBorderBottom + iplotKeyBorderBottom; - } else if (keyPosition==JKQTPKeyOutsideRightTop) { - iplotKeyBorderRight = keyWidth+2*keyXMargin*kfm.width('X')+ceil(2*keyFrameWidth)+keyXOffset*kfm.width('X')+2; - iplotBorderRight = iplotBorderRight + iplotKeyBorderRight; - } else if (keyPosition==JKQTPKeyOutsideRightBottom) { - iplotKeyBorderRight = keyWidth+2*keyXMargin*kfm.width('X')+ceil(2*keyFrameWidth)+keyXOffset*kfm.width('X')+2; - iplotBorderRight = iplotBorderRight + iplotKeyBorderRight; + internalPlotKeyBorderTop=0; + internalPlotKeyBorderBottom=0; + internalPlotKeyBorderLeft=0; + internalPlotKeyBorderRight=0; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + internalPlotBorderRight = internalPlotBorderRight + internalPlotKeyBorderRight; } @@ -819,24 +757,24 @@ void JKQTBasePlotter::calcPlotScaling(JKQTPEnhancedPainter& painter){ QString test="�Aquator"; int labelHeight=fm.size(Qt::TextSingleLine, test).height()*1.5; //if (mousePosLabel!=nullptr) labelHeight=mousePosLabel->height(); - iplotBorderTop=iplotBorderTop+(labelHeight-plotBorderTop)*1.1; + internalPlotBorderTop=internalPlotBorderTop+(labelHeight-plotBorderTop)*1.1; }*/ // read additional size required for coordinate axes QSizeF s=xAxis->getSize1(painter); - iplotBorderBottom+=s.height(); + internalPlotBorderBottom+=s.height(); s=xAxis->getSize2(painter); - iplotBorderTop+=s.height(); + internalPlotBorderTop+=s.height(); s=yAxis->getSize1(painter); - iplotBorderLeft+=s.width(); + internalPlotBorderLeft+=s.width(); s=yAxis->getSize2(painter); - iplotBorderRight+=s.width(); + internalPlotBorderRight+=s.width(); - iplotBorderTop_nographs=iplotBorderTop; - iplotBorderLeft_nographs=iplotBorderLeft; - iplotBorderBottom_nographs=iplotBorderBottom; - iplotBorderRight_nographs=iplotBorderRight; + internalPlotBorderTop_notIncludingOutsidePlotSections=internalPlotBorderTop; + internalPlotBorderLeft_notIncludingOutsidePlotSections=internalPlotBorderLeft; + internalPlotBorderBottom_notIncludingOutsidePlotSections=internalPlotBorderBottom; + internalPlotBorderRight_notIncludingOutsidePlotSections=internalPlotBorderRight; @@ -847,10 +785,10 @@ void JKQTBasePlotter::calcPlotScaling(JKQTPEnhancedPainter& painter){ if (graphs[i]->isVisible()) { int leftSpace, rightSpace, topSpace, bottomSpace; graphs[i]->getOutsideSize(painter, leftSpace, rightSpace, topSpace, bottomSpace); - iplotBorderBottom+=bottomSpace; - iplotBorderTop+=topSpace; - iplotBorderLeft+=leftSpace; - iplotBorderRight+=rightSpace; + internalPlotBorderBottom+=bottomSpace; + internalPlotBorderTop+=topSpace; + internalPlotBorderLeft+=leftSpace; + internalPlotBorderRight+=rightSpace; } } @@ -860,64 +798,64 @@ void JKQTBasePlotter::calcPlotScaling(JKQTPEnhancedPainter& painter){ // synchronize to a master-plotter if (masterPlotterX) { if (masterSynchronizeWidth) { - iplotBorderLeft=masterPlotterX->iplotBorderLeft; - iplotBorderRight=masterPlotterX->iplotBorderRight; + internalPlotBorderLeft=masterPlotterX->internalPlotBorderLeft; + internalPlotBorderRight=masterPlotterX->internalPlotBorderRight; } } if (masterPlotterY) { if (masterSynchronizeHeight) { - iplotBorderTop=masterPlotterY->iplotBorderTop; - iplotBorderBottom=masterPlotterY->iplotBorderBottom; + internalPlotBorderTop=masterPlotterY->internalPlotBorderTop; + internalPlotBorderBottom=masterPlotterY->internalPlotBorderBottom; } } // first we calculate the width and height of the plot from the widget dimensions and // the supplied border sizes - plotWidth=widgetWidth/paintMagnification-iplotBorderLeft-iplotBorderRight; - plotHeight=widgetHeight/paintMagnification-iplotBorderTop-iplotBorderBottom; + internalPlotWidth=widgetWidth/paintMagnification-internalPlotBorderLeft-internalPlotBorderRight; + internalPlotHeight=widgetHeight/paintMagnification-internalPlotBorderTop-internalPlotBorderBottom; //////////////////////////////////////////////////////////////////// // ENSURE ASPECT RATIO (if activated) //////////////////////////////////////////////////////////////////// if (maintainAspectRatio && (!xAxis->isLogAxis()) && (!xAxis->isLogAxis())) { - double currRatio=static_cast(plotWidth)/static_cast(plotHeight); - double newPlotWidth=plotWidth; - double newPlotHeight=plotHeight; + double currRatio=static_cast(internalPlotWidth)/static_cast(internalPlotHeight); + double newPlotWidth=internalPlotWidth; + double newPlotHeight=internalPlotHeight; double dx=0; double dy=0; if (currRatio!=aspectRatio) { if (aspectRatio>=currRatio) { - newPlotWidth=aspectRatio*static_cast(plotHeight); + newPlotWidth=aspectRatio*static_cast(internalPlotHeight); } else { - newPlotHeight=static_cast(plotWidth)/aspectRatio; + newPlotHeight=static_cast(internalPlotWidth)/aspectRatio; } - dx=plotWidth-newPlotWidth; - dy=plotHeight-newPlotHeight; + dx=internalPlotWidth-newPlotWidth; + dy=internalPlotHeight-newPlotHeight; if (dx<0) { - newPlotWidth=plotWidth; - newPlotHeight=static_cast(plotWidth)/aspectRatio; + newPlotWidth=internalPlotWidth; + newPlotHeight=static_cast(internalPlotWidth)/aspectRatio; } else if (dy<0) { - newPlotWidth=aspectRatio*static_cast(plotHeight); - newPlotHeight=plotHeight; + newPlotWidth=aspectRatio*static_cast(internalPlotHeight); + newPlotHeight=internalPlotHeight; } - dx=plotWidth-newPlotWidth; - dy=plotHeight-newPlotHeight; + dx=internalPlotWidth-newPlotWidth; + dy=internalPlotHeight-newPlotHeight; if ((dx<0)||(dy<0)) { - newPlotWidth=plotWidth; - newPlotHeight=plotHeight; + newPlotWidth=internalPlotWidth; + newPlotHeight=internalPlotHeight; } } - //if (newPlotWidth>widgetWidth-iplotBorderLeft-iplotBorderRight) newPlotWidth=widgetWidth-iplotBorderLeft-iplotBorderRight; - //if (newPlotHeight>widgetHeight-iplotBorderTop-iplotBorderBottom) newPlotHeight=widgetHeight-iplotBorderTop-iplotBorderBottom; - dx=plotWidth-newPlotWidth; - dy=plotHeight-newPlotHeight; - iplotBorderBottom+=dy/2.0; - iplotBorderTop+=dy/2.0; - iplotBorderLeft+=dx/2.0; - iplotBorderRight+=dx/2.0; - plotWidth=widgetWidth/paintMagnification-iplotBorderLeft-iplotBorderRight; - plotHeight=widgetHeight/paintMagnification-iplotBorderTop-iplotBorderBottom; + //if (newPlotWidth>widgetWidth-internalPlotBorderLeft-internalPlotBorderRight) newPlotWidth=widgetWidth-internalPlotBorderLeft-internalPlotBorderRight; + //if (newPlotHeight>widgetHeight-internalPlotBorderTop-internalPlotBorderBottom) newPlotHeight=widgetHeight-internalPlotBorderTop-internalPlotBorderBottom; + dx=internalPlotWidth-newPlotWidth; + dy=internalPlotHeight-newPlotHeight; + internalPlotBorderBottom+=dy/2.0; + internalPlotBorderTop+=dy/2.0; + internalPlotBorderLeft+=dx/2.0; + internalPlotBorderRight+=dx/2.0; + internalPlotWidth=widgetWidth/paintMagnification-internalPlotBorderLeft-internalPlotBorderRight; + internalPlotHeight=widgetHeight/paintMagnification-internalPlotBorderTop-internalPlotBorderBottom; } @@ -954,56 +892,70 @@ void JKQTBasePlotter::calcPlotScaling(JKQTPEnhancedPainter& painter){ } -void JKQTBasePlotter::plotSystemGrid(JKQTPEnhancedPainter& painter) { +void JKQTBasePlotter::drawSystemGrid(JKQTPEnhancedPainter& painter) { #ifdef JKQTBP_AUTOTIMER - JKQTPAutoOutputTimer jkaaot("JKQTBasePlotter::plotSystemGrid"); + JKQTPAutoOutputTimer jkaaot("JKQTBasePlotter::drawSystemGrid"); #endif - //qDebug()<<"start JKQTBasePlotter::plotSystemGrid"; + //qDebug()<<"start JKQTBasePlotter::drawSystemGrid"; xAxis->drawGrids(painter); yAxis->drawGrids(painter); - //qDebug()<<" end JKQTBasePlotter::plotSystemGrid"; + //qDebug()<<" end JKQTBasePlotter::drawSystemGrid"; } -void JKQTBasePlotter::plotSystemXAxis(JKQTPEnhancedPainter& painter) { +void JKQTBasePlotter::drawSystemXAxis(JKQTPEnhancedPainter& painter) { #ifdef JKQTBP_AUTOTIMER - JKQTPAutoOutputTimer jkaaot("JKQTBasePlotter::plotSystemXAxis"); + JKQTPAutoOutputTimer jkaaot("JKQTBasePlotter::drawSystemXAxis"); #endif - //qDebug()<<"start JKQTBasePlotter::plotSystemXAxis"; + //qDebug()<<"start JKQTBasePlotter::drawSystemXAxis"; xAxis->drawAxes(painter); - //qDebug()<<" end JKQTBasePlotter::plotSystemXAxis"; + //qDebug()<<" end JKQTBasePlotter::drawSystemXAxis"; } -void JKQTBasePlotter::plotSystemYAxis(JKQTPEnhancedPainter& painter) { +void JKQTBasePlotter::drawSystemYAxis(JKQTPEnhancedPainter& painter) { #ifdef JKQTBP_AUTOTIMER - JKQTPAutoOutputTimer jkaaot("JKQTBasePlotter::plotSystemYAxis"); + JKQTPAutoOutputTimer jkaaot("JKQTBasePlotter::drawSystemYAxis"); #endif - //qDebug()<<"start JKQTBasePlotter::plotSystemYAxis"; + //qDebug()<<"start JKQTBasePlotter::drawSystemYAxis"; yAxis->drawAxes(painter); - //qDebug()<<" end JKQTBasePlotter::plotSystemYAxis"; + //qDebug()<<" end JKQTBasePlotter::drawSystemYAxis"; } - - - JKQTBasePlotter::JKQTPPen JKQTBasePlotter::getPlotStyle(int i) const{ int colorI=-1; int styleI=0; + int symbolI=0; + int brushI=0; for (int k=0; k<=i; k++) { colorI++; - if (colorI>=manyGraphsColorCount) { + if (colorI>=plotterStyle.defaultGraphColors.size()) { styleI++; + brushI++; colorI=0; - if (styleI>=5) styleI=0; + if (styleI>=plotterStyle.defaultGraphPenStyles.size()) styleI=0; + if (brushI>=plotterStyle.defaultGraphFillStyles.size()) brushI=0; + } + symbolI++; + if (symbolI>=plotterStyle.defaultGraphSymbols.size()) { + symbolI=0; } } JKQTPPen p; //std::cout<<"plotstyle "<0 && keyHeight>0 draw the frame and the contents double keyWidth=0; double keyHeight=0; getKeyExtent(painter, &keyWidth, &keyHeight); - double keyrWidth=keyWidth+2.0*keyXMargin*kfm.width('X')+2.0*keyFrameWidth*lineWidthPrintMultiplier; - double keyrHeight=keyHeight+2.0*keyYMargin*kfm.width('X')+2.0*keyFrameWidth*lineWidthPrintMultiplier; + 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; if ((keyWidth>0) && (keyHeight>0)) { // key position - double x,y; - switch(keyPosition) { + double x0,y0; // Position without plotterStyle.keyStyle.xOffset/plotterStyle.keyStyle.yOffset + double x,y; // position of the key rectangle (=x0+plotterStyle.keyStyle.xOffset, y0+plotterStyle.keyStyle.yOffset) + switch(plotterStyle.keyStyle.position) { case JKQTPKeyOutsideTopRight: - x=iplotBorderLeft+plotWidth+iplotBorderRight-keyrWidth-keyXOffset*kfm.width('X'); - y=keyYOffset*kfm.width('X')+iTitleHeight; + x0=internalPlotBorderLeft+internalPlotWidth+internalPlotBorderRight-keyRectangleWidth; + x=x0-plotterStyle.keyStyle.xOffset*kfm.width('X'); + y0=internalTitleHeight; + y=y0+plotterStyle.keyStyle.yOffset*kfm.width('X'); break; case JKQTPKeyOutsideTopLeft: - x=iplotBorderLeft+keyXOffset*kfm.width('X'); - y=keyYOffset*kfm.width('X')+iTitleHeight; + x0=internalPlotBorderLeft; + x=x0+plotterStyle.keyStyle.xOffset*kfm.width('X'); + y0=internalTitleHeight; + y=y0+plotterStyle.keyStyle.yOffset*kfm.width('X'); break; case JKQTPKeyOutsideBottomRight: - x=iplotBorderLeft+plotWidth-keyrWidth-keyXOffset*kfm.width('X'); - y=iplotBorderTop+plotHeight+iplotBorderBottom-keyrHeight-keyYOffset*kfm.width('X'); + x0=internalPlotBorderLeft+internalPlotWidth-keyRectangleWidth; + x=x0-plotterStyle.keyStyle.xOffset*kfm.width('X'); + y0=internalPlotBorderTop+internalPlotHeight+internalPlotBorderBottom-keyRectangleHeight; + y=y0-plotterStyle.keyStyle.yOffset*kfm.width('X'); break; case JKQTPKeyOutsideBottomLeft: - x=iplotBorderLeft+keyXOffset*kfm.width('X'); - y=iplotBorderTop+plotHeight+iplotBorderBottom-keyrHeight-keyYOffset*kfm.width('X'); + x0=internalPlotBorderLeft; + x=x0+plotterStyle.keyStyle.xOffset*kfm.width('X'); + y0=internalPlotBorderTop+internalPlotHeight+internalPlotBorderBottom-keyRectangleHeight; + y=y0-plotterStyle.keyStyle.yOffset*kfm.width('X'); break; case JKQTPKeyOutsideRightTop: - x=iplotBorderLeft+plotWidth+iplotBorderRight-keyrWidth-keyXOffset*kfm.width('X'); - y=iplotBorderTop+keyYOffset*kfm.width('X'); + x0=internalPlotBorderLeft+internalPlotWidth+internalPlotBorderRight-keyRectangleWidth; + x=x0-plotterStyle.keyStyle.xOffset*kfm.width('X'); + y0=internalPlotBorderTop; + y=y0+plotterStyle.keyStyle.yOffset*kfm.width('X'); break; case JKQTPKeyOutsideRightBottom: - x=iplotBorderLeft+plotWidth+iplotBorderRight-keyrWidth-keyXOffset*kfm.width('X'); - y=iplotBorderTop+plotHeight-keyrHeight-keyYOffset*kfm.width('X'); + x0=internalPlotBorderLeft+internalPlotWidth+internalPlotBorderRight-keyRectangleWidth; + x=x0-plotterStyle.keyStyle.xOffset*kfm.width('X'); + y0=internalPlotBorderTop+internalPlotHeight-keyRectangleHeight; + y=y0-plotterStyle.keyStyle.yOffset*kfm.width('X'); break; case JKQTPKeyOutsideLeftTop: - x=keyXOffset*kfm.width('X'); - y=iplotBorderTop+keyYOffset*kfm.width('X'); + x0=0; + x=x0+plotterStyle.keyStyle.xOffset*kfm.width('X'); + y0=internalPlotBorderTop; + y=y0+plotterStyle.keyStyle.yOffset*kfm.width('X'); break; case JKQTPKeyOutsideLeftBottom: - x=keyXOffset*kfm.width('X'); - y=iplotBorderTop+plotHeight-keyrHeight-keyYOffset*kfm.width('X'); + x0=0; + x=x0+plotterStyle.keyStyle.xOffset*kfm.width('X'); + y0=internalPlotBorderTop+internalPlotHeight-keyRectangleHeight; + y=y0-plotterStyle.keyStyle.yOffset*kfm.width('X'); break; case JKQTPKeyInsideBottomRight: - x=iplotBorderLeft+plotWidth-keyrWidth-keyXOffset*kfm.width('X'); - y=iplotBorderTop+plotHeight-keyrHeight-keyYOffset; + x0=internalPlotBorderLeft+internalPlotWidth-keyRectangleWidth; + x=x0-plotterStyle.keyStyle.xOffset*kfm.width('X'); + y0=internalPlotBorderTop+internalPlotHeight-keyRectangleHeight; + y=y0-plotterStyle.keyStyle.yOffset*kfm.width('X'); break; case JKQTPKeyInsideBottomLeft: - x=iplotBorderLeft+keyXOffset*kfm.width('X'); - y=iplotBorderTop+plotHeight-keyrHeight-keyYOffset*kfm.width('X'); + x0=internalPlotBorderLeft; + x=x0+plotterStyle.keyStyle.xOffset*kfm.width('X'); + y0=internalPlotBorderTop+internalPlotHeight-keyRectangleHeight; + y=y0-plotterStyle.keyStyle.yOffset*kfm.width('X'); break; case JKQTPKeyInsideTopLeft: - x=iplotBorderLeft+keyXOffset*kfm.width('X'); - y=iplotBorderTop+keyYOffset*kfm.width('X'); + x0=internalPlotBorderLeft; + x=x0+plotterStyle.keyStyle.xOffset*kfm.width('X'); + y0=internalPlotBorderTop; + y=y0+plotterStyle.keyStyle.yOffset*kfm.width('X'); break; case JKQTPKeyInsideTopRight: default: - x=iplotBorderLeft+plotWidth-keyrWidth-keyXOffset*kfm.width('X'); - y=iplotBorderTop+keyYOffset*kfm.width('X'); + x0=internalPlotBorderLeft+internalPlotWidth-keyRectangleWidth; + x=x0-plotterStyle.keyStyle.xOffset*kfm.width('X'); + y0=internalPlotBorderTop; + y=y0+plotterStyle.keyStyle.yOffset*kfm.width('X'); break; } + QRectF rectKey; + { + // save old brushes and pens + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + QPen pf=painter.pen(); + QBrush bf=painter.brush(); + pf.setColor(plotterStyle.keyStyle.frameColor); + pf.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, pt2px(painter, plotterStyle.keyStyle.frameWidth*lineWidthMultiplier))); + pf.setStyle(Qt::SolidLine); + bf.setColor(plotterStyle.keyStyle.backgroundColor); + bf.setStyle(Qt::SolidPattern); + painter.setBrush(bf); + if (!plotterStyle.keyStyle.frameVisible) { + QPen pff=pf; + pff.setColor(plotterStyle.keyStyle.backgroundColor); + pff.setWidthF(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH); + painter.setPen(pff); + } else { + painter.setPen(pf); + } + + rectKey=QRectF(x,y,keyRectangleWidth, keyRectangleHeight); + if (plotterStyle.keyStyle.frameRounding<=0) { + painter.drawRect(rectKey); + } 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; - // save old brushes and pens - painter.save(); - QPen pf=painter.pen(); - QBrush bf=painter.brush(); - pf.setColor(keyFrameColor); - pf.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, pt2px(painter, keyFrameWidth*lineWidthMultiplier))); - pf.setStyle(Qt::SolidLine); - bf.setColor(keyBackgroundColor); - bf.setStyle(Qt::SolidPattern); - painter.setBrush(bf); - if (!showKeyFrame) { - QPen pff=pf; - pff.setColor(keyBackgroundColor); - pff.setWidthF(JKQTPLOTTER_ABS_MIN_LINEWIDTH); - painter.setPen(pff); - } else { painter.setPen(pf); + + if (useClipping) { + QRegion cregion(x,y,keyRectangleWidth, keyRectangleHeight); + painter.setClipping(true); + painter.setClipRegion(cregion); + painter.setClipping(true); + } + + drawKeyContents(painter, x, y, keyWidth, keyHeight); + + if (useClipping) painter.setClipping(false); + } + + if (plotterStyle.debugShowRegionBoxes) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + QPen p("orange"); + QColor col=p.color(); col.setAlphaF(0.8); p.setColor(col); + p.setWidthF(plotterStyle.debugRegionLineWidth); + p.setStyle(Qt::DashLine); + painter.setPen(p); + painter.setBrush(QBrush(QColor(Qt::transparent))); + painter.drawRect(rectKey); + p.setStyle(Qt::SolidLine); + painter.setPen(p); + painter.drawLine(x0,y0,rectKey.x(), rectKey.y()); + } - painter.drawRect(QRectF(x,y,keyrWidth, keyrHeight)); - y=y+keyYMargin*kfm.width('X')+keyFrameWidth*lineWidthMultiplier/2.0; - x=x+keyXMargin*kfm.width('X')+keyFrameWidth*lineWidthMultiplier/2.0; - - painter.setPen(pf); - - if (useClipping) { - QRegion cregion(x,y,keyrWidth, keyrHeight); - painter.setClipping(true); - painter.setClipRegion(cregion); - painter.setClipping(true); - } - - plotKeyContents(painter, x, y, keyWidth, keyHeight); - - if (useClipping) painter.setClipping(false); - painter.restore(); } //qDebug()<<" end JKQTBasePlotter::plotKey"; } -void JKQTBasePlotter::plotOverlays(JKQTPEnhancedPainter &painter) { + + +void JKQTBasePlotter::drawPlot(JKQTPEnhancedPainter& painter, bool showOverlays) { #ifdef JKQTBP_AUTOTIMER - JKQTPAutoOutputTimer jkaaot("JKQTBasePlotter::plotOverlays"); + JKQTPAutoOutputTimer jkaaot("JKQTBasePlotter::paintPlot"); +#endif + //qDebug()<<"start JKQTBasePlotter::paintPlot"; + // draw background + { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.setPen(plotterStyle.widgetBackgroundColor); + if (plotterStyle.widgetBackgroundColor!=Qt::transparent) painter.fillRect(QRectF(0,0,widgetWidth/paintMagnification, widgetHeight/paintMagnification), QBrush(plotterStyle.widgetBackgroundColor)); + } + QRectF rPlotBack(internalPlotBorderLeft, internalPlotBorderTop, internalPlotWidth, internalPlotHeight); + painter.setRenderHint(JKQTPEnhancedPainter::NonCosmeticDefaultPen, true); + painter.setRenderHint(JKQTPEnhancedPainter::Antialiasing, plotterStyle.useAntiAliasingForSystem); + painter.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing, plotterStyle.useAntiAliasingForText); + if (plotterStyle.plotFrameVisible) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + QPen p(plotterStyle.plotFrameColor); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, pt2px(painter, plotterStyle.plotFrameWidth*lineWidthMultiplier))); + painter.setPen(p); + painter.setBrush(QBrush(plotterStyle.plotBackgroundColor)); + if (plotterStyle.plotFrameRounding<=0) { + painter.drawRect(rPlotBack); + } else { + painter.drawRoundedRect(rPlotBack, pt2px(painter, plotterStyle.plotFrameRounding), pt2px(painter, plotterStyle.plotFrameRounding)); + } + + } else { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.setBrush(QBrush(plotterStyle.plotBackgroundColor)); + QPen p(plotterStyle.plotBackgroundColor); + p.setWidthF(0); + painter.setPen(p); + if (plotterStyle.plotFrameRounding<=0) { + painter.drawRect(rPlotBack); + } else { + painter.drawRoundedRect(rPlotBack, pt2px(painter, plotterStyle.plotFrameRounding), pt2px(painter, plotterStyle.plotFrameRounding)); + } + + } + + drawSystemGrid(painter); + + if (!plotLabel.isEmpty()) { + mathText.setFontSize(plotterStyle.plotLabelFontSize*fontSizeMultiplier); + mathText.setFontRomanOrSpecial(plotterStyle.plotLabelFontName); + + mathText.parse(plotLabel); + double a=0,d=0,so=0,w=0; + getTextSizeDetail(plotterStyle.plotLabelFontName,plotterStyle.plotLabelFontSize*fontSizeMultiplier,plotLabel, painter, w, a, d, so); + QSizeF s=QSizeF(w, a+d); + mathText.draw(painter, internalPlotBorderLeft+(internalPlotWidth-s.width())/2.0,plotterStyle.plotBorderTop+a*1.2); + if (plotterStyle.debugShowRegionBoxes) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + QPen p("blue"); + QColor col=p.color(); col.setAlphaF(0.8); p.setColor(col); + p.setWidthF(plotterStyle.debugRegionLineWidth); + painter.setBrush(QBrush(QColor(Qt::transparent))); + painter.setPen(p); + painter.drawRect(internalPlotBorderLeft, plotterStyle.plotBorderTop, internalPlotWidth, s.height()); + + } + } + + painter.setRenderHint(JKQTPEnhancedPainter::Antialiasing, plotterStyle.useAntiAliasingForGraphs); + painter.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing, plotterStyle.useAntiAliasingForText); + { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + drawGraphs(painter); + } + + painter.setRenderHint(JKQTPEnhancedPainter::Antialiasing, plotterStyle.useAntiAliasingForSystem); + painter.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing, plotterStyle.useAntiAliasingForText); + + drawSystemXAxis(painter); + drawSystemYAxis(painter); + painter.setRenderHint(JKQTPEnhancedPainter::Antialiasing, plotterStyle.useAntiAliasingForGraphs); + painter.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing, plotterStyle.useAntiAliasingForText); + if (plotterStyle.keyStyle.visible) drawKey(painter); + painter.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing, plotterStyle.useAntiAliasingForText); + if (showOverlays) drawOverlaysWithHints(painter); + + if (plotterStyle.debugShowRegionBoxes) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + QPen p("red"); + QColor col=p.color(); col.setAlphaF(0.8); p.setColor(col); + p.setWidthF(plotterStyle.debugRegionLineWidth); + p.setStyle(Qt::DashLine); + painter.setPen(p); + painter.setBrush(QBrush(QColor(Qt::transparent))); + painter.drawRect(internalPlotBorderLeft, internalPlotBorderTop, internalPlotWidth, internalPlotHeight); + p.setColor(QColor("maroon")); + col=p.color(); col.setAlphaF(0.8); p.setColor(col); + p.setWidthF(plotterStyle.debugRegionLineWidth); + p.setStyle(Qt::DotLine); + painter.setPen(p); + painter.drawRect(internalPlotBorderLeft_notIncludingOutsidePlotSections, internalPlotBorderTop_notIncludingOutsidePlotSections, widgetWidth-internalPlotBorderLeft_notIncludingOutsidePlotSections-internalPlotBorderRight_notIncludingOutsidePlotSections, widgetHeight-internalPlotBorderTop_notIncludingOutsidePlotSections-internalPlotBorderBottom_notIncludingOutsidePlotSections); + p.setColor(QColor("yellow")); + col=p.color(); col.setAlphaF(0.8); p.setColor(col); + p.setWidthF(plotterStyle.debugRegionLineWidth); + p.setStyle(Qt::SolidLine); + painter.setPen(p); + painter.drawRect(0, 0, widgetWidth, widgetHeight); + + } + + //qDebug()<<" end JKQTBasePlotter::paintPlot"; +} + +void JKQTBasePlotter::drawOverlaysWithHints(JKQTPEnhancedPainter &painter) { + painter.setRenderHint(JKQTPEnhancedPainter::NonCosmeticDefaultPen, true); + painter.setRenderHint(JKQTPEnhancedPainter::Antialiasing, plotterStyle.useAntiAliasingForGraphs); + painter.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing, plotterStyle.useAntiAliasingForText); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); +#ifdef JKQTBP_AUTOTIMER + JKQTPAutoOutputTimer jkaaot("JKQTBasePlotter::drawOverlaysWithHints"); #endif if (overlays.isEmpty()) return; if (useClipping) { - QRegion cregion(iplotBorderLeft, iplotBorderTop, plotWidth, plotHeight); + QRegion cregion(internalPlotBorderLeft, internalPlotBorderTop, internalPlotWidth, internalPlotHeight); painter.setClipping(true); painter.setClipRegion(cregion); } @@ -1157,62 +1271,7 @@ void JKQTBasePlotter::plotOverlays(JKQTPEnhancedPainter &painter) { if (useClipping) { painter.setClipping(false); } -} - - -void JKQTBasePlotter::paintPlot(JKQTPEnhancedPainter& painter, bool drawOverlays) { -#ifdef JKQTBP_AUTOTIMER - JKQTPAutoOutputTimer jkaaot("JKQTBasePlotter::paintPlot"); -#endif - //qDebug()<<"start JKQTBasePlotter::paintPlot"; - // draw background - painter.save(); - painter.setPen(backgroundColor); - if (backgroundColor!=Qt::transparent) painter.fillRect(QRectF(0,0,widgetWidth/paintMagnification, widgetHeight/paintMagnification), QBrush(backgroundColor)); - painter.fillRect(QRectF(iplotBorderLeft, iplotBorderTop, plotWidth, plotHeight), QBrush(plotBackgroundColor)); - painter.restore(); - painter.setRenderHint(JKQTPEnhancedPainter::NonCosmeticDefaultPen, true); - painter.setRenderHint(JKQTPEnhancedPainter::Antialiasing, useAntiAliasingForSystem); - painter.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing, useAntiAliasingForText); - plotSystemGrid(painter); - - if (!plotLabel.isEmpty()) { - mathText.setFontSize(plotLabelFontSize*fontSizeMultiplier); - mathText.setFontRoman(plotLabelFontname); - - mathText.parse(plotLabel); - double a=0,d=0,so=0,w=0; - getTextSizeDetail(plotLabelFontname,plotLabelFontSize*fontSizeMultiplier,plotLabel, painter, w, a, d, so); - QSizeF s=QSizeF(w, a+d); - mathText.draw(painter, iplotBorderLeft+(plotWidth-s.width())/2.0,plotBorderTop+a*1.2); - } - - painter.setRenderHint(JKQTPEnhancedPainter::Antialiasing, useAntiAliasingForGraphs); - painter.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing, useAntiAliasingForText); - painter.save(); - plotGraphs(painter); - painter.restore(); - painter.setRenderHint(JKQTPEnhancedPainter::Antialiasing, useAntiAliasingForSystem); - painter.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing, useAntiAliasingForText); - - plotSystemXAxis(painter); - plotSystemYAxis(painter); - painter.setRenderHint(JKQTPEnhancedPainter::Antialiasing, useAntiAliasingForGraphs); - painter.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing, useAntiAliasingForText); - if (showKey) plotKey(painter); - painter.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing, useAntiAliasingForText); - if (drawOverlays) plotOverlays(painter); - //qDebug()<<" end JKQTBasePlotter::paintPlot"; -} - -void JKQTBasePlotter::paintOverlays(JKQTPEnhancedPainter &painter) { - painter.setRenderHint(JKQTPEnhancedPainter::NonCosmeticDefaultPen, true); - painter.setRenderHint(JKQTPEnhancedPainter::Antialiasing, useAntiAliasingForGraphs); - painter.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing, useAntiAliasingForText); - painter.save(); - plotOverlays(painter); - painter.restore(); } void JKQTBasePlotter::gridPrintingCalc() { @@ -1257,7 +1316,7 @@ void JKQTBasePlotter::gridPrintingCalc() { } } -void JKQTBasePlotter::gridPaint(JKQTPEnhancedPainter& painter, QSizeF pageRect, bool drawOverlays, bool scaleIfTooLarge, bool scaleIfTooSmall) { +void JKQTBasePlotter::gridPaint(JKQTPEnhancedPainter& painter, QSizeF pageRect, bool showOverlays, bool scaleIfTooLarge, bool scaleIfTooSmall) { #ifdef JKQTBP_AUTOTIMER JKQTPAutoOutputTimer jkaaot("JKQTBasePlotter::gridPaint"); #endif @@ -1273,11 +1332,11 @@ void JKQTBasePlotter::gridPaint(JKQTPEnhancedPainter& painter, QSizeF pageRect, #ifdef SHOW_JKQTPLOTTER_DEBUG qDebug()<<"gridPaint: scale="< fsm, lwm, pm; @@ -1304,47 +1363,48 @@ void JKQTBasePlotter::gridPaint(JKQTPEnhancedPainter& painter, QSizeF pageRect, #ifdef SHOW_JKQTPLOTTER_DEBUG qDebug()<<"gridPaint: scale="<paintPlot(painter, drawOverlays); - painter.restore(); - } + drawPlot(painter, showOverlays); + + //std::cout<<"this printed ...\n"; + + // plot all the other plotters + for (int i=0; i< gridPrintingList.size(); i++) { + //std::cout<<"printing "<drawPlot(painter, showOverlays); + + } - painter.restore(); - for (int i=0; i< gridPrintingList.size(); i++) { - gridPrintingList[i].plotter->setFontSizeMultiplier(fsm[i]); - gridPrintingList[i].plotter->setLineWidthMultiplier(lwm[i]); - gridPrintingList[i].plotter->setPaintMagnification(pm[i]); - gridPrintingList[i].plotter->setBackgroundColor(backg[i]); - gridPrintingList[i].plotter->redrawPlot(); + + for (int i=0; i< gridPrintingList.size(); i++) { + gridPrintingList[i].plotter->setFontSizeMultiplier(fsm[i]); + gridPrintingList[i].plotter->setLineWidthMultiplier(lwm[i]); + gridPrintingList[i].plotter->setPaintMagnification(pm[i]); + gridPrintingList[i].plotter->setBackgroundColor(backg[i]); + gridPrintingList[i].plotter->redrawPlot(); + } } } @@ -1358,11 +1418,11 @@ void JKQTBasePlotter::gridPaintOverlays(JKQTPEnhancedPainter &painter, QSizeF pa if (/*(scale*static_cast(widgetWidth)/paintMagnification>static_cast(pageRect.width())) ||*/ (scale*static_cast(widgetHeight)>static_cast(pageRect.height()))) { scale=static_cast(pageRect.height())/static_cast(widgetHeight); } - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); // scale the plot so it fits on the page painter.scale(scale, scale); - paintOverlays(painter); - painter.restore(); + drawOverlaysWithHints(painter); + } else { gridPrintingCalc(); // ensure the grid plot has been calculated // scale the plot so it fits on the page @@ -1370,42 +1430,42 @@ void JKQTBasePlotter::gridPaintOverlays(JKQTPEnhancedPainter &painter, QSizeF pa if (/*(scale*static_cast(gridPrintingSize.width())>static_cast(pageRect.width())) ||*/ (scale*static_cast(gridPrintingSize.height())>static_cast(pageRect.height()))) { scale=static_cast(pageRect.height())/static_cast(gridPrintingSize.height()); } - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.scale(scale, scale); - - // plot this plotter - painter.save(); - int t_x=0; - int t_y=0; - //std::cout<<"printing this ...\n"; - for (size_t i=0; ipaintOverlays(painter); - painter.restore(); + drawOverlaysWithHints(painter); + + //std::cout<<"this printed ...\n"; + + // plot all the other plotters + for (int i=0; i< gridPrintingList.size(); i++) { + //std::cout<<"printing "<drawOverlaysWithHints(painter); + + } + } - painter.restore(); - } } @@ -1426,11 +1486,11 @@ void JKQTBasePlotter::print(QPrinter* printer, bool displayPreview) { dialog->setWindowTitle(tr("Print Plot")); if (dialog->exec() != QDialog::Accepted) { delete p; - delete dialog; + delete dialog; return; } currentPrinter=p->printerName(); - delete dialog; + delete dialog; } p->setPageMargins(10,10,10,10,QPrinter::Millimeter); @@ -1448,147 +1508,6 @@ void JKQTBasePlotter::print(QPrinter* printer, bool displayPreview) { } -void JKQTBasePlotter::printpreview(QPrinter *p, bool setabsolutesize) { - double lw=lineWidthMultiplier; - double fs=fontSizeMultiplier; - QColor bc=backgroundColor; - backgroundColor=exportBackgroundColor; - lineWidthMultiplier=lineWidthPrintMultiplier; - fontSizeMultiplier=fontSizePrintMultiplier; - exportPreviewLabel=nullptr; - printSizeX_Millimeter=widgetWidth; - printSizeY_Millimeter=widgetHeight; - printAspect=1; - printKeepAspect=false; - - printSetAbsolutePageSize=setabsolutesize; - printKeepAbsoluteFontSizes=false; - printScaleToPagesize=true; - QDialog* dlg=new QDialog(nullptr, Qt::WindowMinMaxButtonsHint); - dlg->setSizeGripEnabled(true); - //printZoomFactor=0.95; - //printMagnification=1.5; - QGridLayout* layout=new QGridLayout(); - dlg->setLayout(layout); - dlg->setWindowTitle(tr("Graph print/export preview ...")); - dlg->setWindowIcon(QIcon(":/JKQTPlotter/jkqtp_exportprintpreview.png")); - printPreview=new QPrintPreviewWidget(p, dlg); - connect(printPreview, SIGNAL(paintRequested(QPrinter*)), this, SLOT(printpreviewPaintRequested(QPrinter*))); - - if (!setabsolutesize) { - JKQTPEnhancedDoubleSpinBox* spinZoom=new JKQTPEnhancedDoubleSpinBox(dlg); - spinZoom->setRange(0.0001,10000); - spinZoom->setValue(printZoomFactor*100.0); - spinZoom->setSingleStep(5); - spinZoom->setDecimals(0); - spinZoom->setSuffix(tr(" %")); - spinZoom->setToolTip(tr("use this setting to scale the plot)")); - connect(spinZoom, SIGNAL(editingFinished(double)), this, SLOT(printpreviewSetZoom(double))); - layout->addWidget(new QLabel(tr("size on paper: ")), 0,layout->columnCount()); - layout->addWidget(spinZoom, 0,layout->columnCount()); - } else { - printSizeX_Millimeter=100; - printAspect=double(widgetHeight)/double(widgetWidth); - - if (gridPrinting) { - gridPrintingCalc(); - printAspect=double(gridPrintingSize.height())/double(gridPrintingSize.width()); - } - - printSizeY_Millimeter=printSizeX_Millimeter*printAspect; - printKeepAspect=true; - - JKQTPEnhancedDoubleSpinBox* spinSizeX=new JKQTPEnhancedDoubleSpinBox(dlg); - spinSizeX->setRange(1,10000); - spinSizeX->setValue(printSizeX_Millimeter); - spinSizeX->setSingleStep(10); - spinSizeX->setDecimals(1); - spinSizeX->setSuffix(tr(" mm")); - spinSizeX->setToolTip(tr("set the size of the output page")); - connect(spinSizeX, SIGNAL(editingFinished(double)), this, SLOT(printpreviewSetSizeX(double))); - spinSizeY=new JKQTPEnhancedDoubleSpinBox(dlg); - spinSizeY->setRange(1,10000); - spinSizeY->setValue(printSizeY_Millimeter); - spinSizeY->setSingleStep(10); - spinSizeY->setDecimals(1); - spinSizeY->setSuffix(tr(" mm")); - spinSizeY->setToolTip(tr("set the size of the output page")); - spinSizeY->setEnabled(false); - connect(spinSizeY, SIGNAL(valueChanged(double)), this, SLOT(printpreviewSetSizeY(double))); - QCheckBox* chkAspect=new QCheckBox(tr("keep aspect ratio"), dlg); - chkAspect->setChecked(true); - chkAspect->setToolTip(tr("choose whether to keep the aspect ratio for the print/export, as on the screen.")); - connect(chkAspect, SIGNAL(toggled(bool)), spinSizeY, SLOT(setDisabled(bool))); - connect(chkAspect, SIGNAL(toggled(bool)), this, SLOT(printpreviewSetAspectRatio(bool))); - - layout->addWidget(new QLabel(tr("page size: ")), 0,layout->columnCount()); - layout->addWidget(spinSizeX, 0,layout->columnCount()); - layout->addWidget(new QLabel(tr(" x ")), 0,layout->columnCount()); - layout->addWidget(spinSizeY, 0,layout->columnCount()); - layout->addWidget(chkAspect, 0,layout->columnCount()); - } - - JKQTPEnhancedDoubleSpinBox* spinMagnification=new JKQTPEnhancedDoubleSpinBox(dlg); - spinMagnification->setRange(1,1000); - spinMagnification->setValue(printMagnification*100.0); - spinMagnification->setSingleStep(10); - spinMagnification->setDecimals(0); - spinMagnification->setSuffix(tr(" %")); - spinMagnification->setToolTip(tr("use this to change the base size of the plot
    " - "This will not change the size of the plot on
    " - "the page, only it's appearance. A magn. of 100%
    " - "will print the plot in the same proportions as
    " - "on the screen, whereas 50% will use twice as much
    " - "space for the plot, as on the screen. This mainly
    " - "influences the relative font size!
    ")); - connect(spinMagnification, SIGNAL(editingFinished(double)), this, SLOT(printpreviewSetMagnification(double))); - - JKQTPEnhancedDoubleSpinBox* spinLineWidthMult=new JKQTPEnhancedDoubleSpinBox(dlg); - spinLineWidthMult->setRange(1,1000); - spinLineWidthMult->setValue(lineWidthPrintMultiplier*100.0); - spinLineWidthMult->setSingleStep(10); - spinLineWidthMult->setDecimals(0); - spinLineWidthMult->setSuffix(tr(" %")); - spinLineWidthMult->setToolTip(tr("use this to change the relative width of the lines\n" - "in the exported/printed plot.")); - connect(spinLineWidthMult, SIGNAL(editingFinished(double)), this, SLOT(printpreviewSetLineWidthMultiplier(double))); - - JKQTPEnhancedDoubleSpinBox* spinFontSizeMult=new JKQTPEnhancedDoubleSpinBox(dlg); - spinFontSizeMult->setRange(1,1000); - spinFontSizeMult->setValue(fontSizePrintMultiplier*100.0); - spinFontSizeMult->setSingleStep(10); - spinFontSizeMult->setDecimals(0); - spinFontSizeMult->setSuffix(tr(" %")); - spinFontSizeMult->setToolTip(tr("use this to change the relative size of the text fonts\n" - "in the exported/printed plot.")); - connect(spinFontSizeMult, SIGNAL(editingFinished(double)), this, SLOT(printpreviewSetFontSizeMultiplier(double))); - - - //layout->addWidget(new QLabel(tr("magnification: ")), 0,layout->columnCount()); - //layout->addWidget(spinMagnification, 0,layout->columnCount()); - layout->addWidget(new QLabel(tr("linewidth mult.: ")), 0,layout->columnCount()); - layout->addWidget(spinLineWidthMult, 0,layout->columnCount()); - layout->addWidget(new QLabel(tr("font size mult.: ")), 0,layout->columnCount()); - layout->addWidget(spinFontSizeMult, 0,layout->columnCount()); - layout->addWidget(new QWidget(), 0,layout->columnCount()); - layout->setColumnStretch(layout->columnCount()-1, 1); - layout->addWidget(printPreview, layout->rowCount(),0, 1, layout->columnCount()); - QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - connect(buttonBox, SIGNAL(accepted()), dlg, SLOT(accept())); - connect(buttonBox, SIGNAL(rejected()), dlg, SLOT(reject())); - layout->addWidget(buttonBox, layout->rowCount(),0, 1, layout->columnCount()); - dlg->resize(800,500); - - if (dlg->exec()==QDialog::Accepted) { - printpreviewPaintRequested(p); - } - delete dlg; - printPreview=nullptr; - lineWidthMultiplier=lw; - fontSizeMultiplier=fs; - backgroundColor=bc; - -} bool JKQTBasePlotter::printpreviewNew(QPaintDevice* paintDevice, bool setAbsolutePaperSize, double printsizeX_inMM, double printsizeY_inMM, bool displayPreview) { QPrinter *printer=dynamic_cast(paintDevice); @@ -1596,8 +1515,8 @@ bool JKQTBasePlotter::printpreviewNew(QPaintDevice* paintDevice, bool setAbsolut double lw=lineWidthMultiplier; double fs=fontSizeMultiplier; double oldP=paintMagnification; - QColor bc=backgroundColor; - backgroundColor=exportBackgroundColor; + QColor bc=plotterStyle.widgetBackgroundColor; + plotterStyle.widgetBackgroundColor=plotterStyle.exportBackgroundColor; lineWidthMultiplier=lineWidthPrintMultiplier; fontSizeMultiplier=fontSizePrintMultiplier; exportPreviewLabel=nullptr; @@ -1801,7 +1720,7 @@ bool JKQTBasePlotter::printpreviewNew(QPaintDevice* paintDevice, bool setAbsolut printPreview=nullptr; lineWidthMultiplier=lw; fontSizeMultiplier=fs; - backgroundColor=bc; + plotterStyle.widgetBackgroundColor=bc; paintMagnification=oldP; mathText.setUseUnparsed(false); @@ -1954,6 +1873,36 @@ bool JKQTBasePlotter::exportpreview(QSizeF pageSize, bool unitIsMM) { return result; } +void JKQTBasePlotter::setFontSizeMultiplier(double __value) +{ + this->fontSizeMultiplier = __value; +} + +void JKQTBasePlotter::setLineWidthMultiplier(double __value) +{ + this->lineWidthMultiplier = __value; +} + +void JKQTBasePlotter::setPrintMagnification(double __value) +{ + this->printMagnification = __value; +} + +double JKQTBasePlotter::getPrintMagnification() const +{ + return this->printMagnification; +} + +void JKQTBasePlotter::setPaintMagnification(double __value) +{ + this->paintMagnification = __value; +} + +double JKQTBasePlotter::getPaintMagnification() const +{ + return this->paintMagnification; +} + void JKQTBasePlotter::updatePreviewLabel() { double factor=1; if (exportUnitInMM) factor=600.0/double(printSizeX_Millimeter); @@ -1974,8 +1923,8 @@ void JKQTBasePlotter::updatePreviewLabel() { void JKQTBasePlotter::printpreviewPaintRequested(QPrinter* printer) { double lw=lineWidthMultiplier; double fs=fontSizeMultiplier; - QColor bc=backgroundColor; - backgroundColor=exportBackgroundColor; + QColor bc=plotterStyle.widgetBackgroundColor; + plotterStyle.widgetBackgroundColor=plotterStyle.exportBackgroundColor; lineWidthMultiplier=lineWidthPrintMultiplier; fontSizeMultiplier=fontSizePrintMultiplier; @@ -2027,8 +1976,8 @@ void JKQTBasePlotter::printpreviewPaintRequested(QPrinter* printer) { qDebug()<<"lineWidthMultiplier = "<(rect.width())/static_cast(widgetWidth)*paintMagnification; - if ((scale*static_cast(widgetWidth)/paintMagnification>static_cast(rect.width())) || (scale*static_cast(widgetHeight)/paintMagnification>static_cast(rect.height()))) { - scale=static_cast(rect.height())/static_cast(widgetHeight)*paintMagnification; + { + double scale=static_cast(rect.width())/static_cast(widgetWidth)*paintMagnification; + if ((scale*static_cast(widgetWidth)/paintMagnification>static_cast(rect.width())) || (scale*static_cast(widgetHeight)/paintMagnification>static_cast(rect.height()))) { + scale=static_cast(rect.height())/static_cast(widgetHeight)*paintMagnification; + } + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + // scale the plot so it fits on the page + painter.scale(scale, scale); + #ifdef JKQTBP_DEBUGTIMING + time.start(); + #endif + drawPlot(painter, showOverlays); + #ifdef JKQTBP_DEBUGTIMING + qDebug()<(rect.width())/static_cast(widgetWidth)*paintMagnification; - if ((scale*static_cast(widgetWidth)/paintMagnification>static_cast(rect.width())) || (scale*static_cast(widgetHeight)/paintMagnification>static_cast(rect.height()))) { - scale=static_cast(rect.height())/static_cast(widgetHeight)*paintMagnification; + { + double scale=static_cast(rect.width())/static_cast(widgetWidth)*paintMagnification; + if ((scale*static_cast(widgetWidth)/paintMagnification>static_cast(rect.width())) || (scale*static_cast(widgetHeight)/paintMagnification>static_cast(rect.height()))) { + scale=static_cast(rect.height())/static_cast(widgetHeight)*paintMagnification; + } + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + // scale the plot so it fits on the page + painter.scale(scale, scale); + #ifdef JKQTBP_DEBUGTIMING + time.start(); + #endif + drawPlot(painter, showOverlays); + #ifdef JKQTBP_DEBUGTIMING + qDebug()<(rect.width())/static_cast(widgetWidth)*paintMagnification; if ((scale*static_cast(widgetWidth)/paintMagnification>static_cast(rect.width())) || (scale*static_cast(widgetHeight)/paintMagnification>static_cast(rect.height()))) { scale=static_cast(rect.height())/static_cast(widgetHeight)*paintMagnification; } - painter.save(); - // scale the plot so it fits on the page - painter.scale(scale, scale); - paintOverlays(painter); - painter.restore(); - painter.restore(); + { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + // scale the plot so it fits on the page + painter.scale(scale, scale); + drawOverlaysWithHints(painter); + } + + } void JKQTBasePlotter::setEmittingPlotSignalsEnabled(bool __value) @@ -2469,6 +2426,529 @@ bool JKQTBasePlotter::isEmittingPlotSignalsEnabled() const return this->emitPlotSignals; } +int JKQTBasePlotter::getPlotBorderTop() const { return this->plotterStyle.plotBorderTop; } + +int JKQTBasePlotter::getPlotBorderLeft() const { return this->plotterStyle.plotBorderLeft; } + +int JKQTBasePlotter::getPlotBorderBottom() const { return this->plotterStyle.plotBorderBottom; } + +int JKQTBasePlotter::getPlotBorderRight() const { return this->plotterStyle.plotBorderRight; } + +bool JKQTBasePlotter::doesMaintainAspectRatio() const { return this->maintainAspectRatio; } + +void JKQTBasePlotter::setAspectRatio(double __value) +{ + if (this->aspectRatio != __value) { + this->aspectRatio = __value; + redrawPlot(); + } +} + +double JKQTBasePlotter::getAspectRatio() const +{ + return this->aspectRatio; +} + +bool JKQTBasePlotter::doesMaintainAxisAspectRatio() const { return this->maintainAxisAspectRatio; } + +double JKQTBasePlotter::getAxisAspectRatio() const +{ + return this->axisAspectRatio; +} + +bool JKQTBasePlotter::isUsingAntiAliasingForSystem() const +{ + return this->plotterStyle.useAntiAliasingForSystem; +} + +bool JKQTBasePlotter::isUsingAntiAliasingForGraphs() const +{ + return this->plotterStyle.useAntiAliasingForGraphs; +} + +bool JKQTBasePlotter::isUsingAntiAliasingForText() const +{ + return this->plotterStyle.useAntiAliasingForText; +} + + +void JKQTBasePlotter::setGraphWidth(double __value) +{ + if (this->plotterStyle.defaultGraphWidth != __value) { + this->plotterStyle.defaultGraphWidth = __value; + redrawPlot(); + } +} + +double JKQTBasePlotter::getGraphWidth() const +{ + return this->plotterStyle.defaultGraphWidth; +} + +void JKQTBasePlotter::setBackgroundColor(const QColor &__value) +{ + if (this->plotterStyle.widgetBackgroundColor != __value) { + this->plotterStyle.widgetBackgroundColor = __value; + redrawPlot(); + } +} + +QColor JKQTBasePlotter::getBackgroundColor() const +{ + return this->plotterStyle.widgetBackgroundColor; +} + +void JKQTBasePlotter::setExportBackgroundColor(const QColor &__value) +{ + if (this->plotterStyle.exportBackgroundColor != __value) { + this->plotterStyle.exportBackgroundColor = __value; + redrawPlot(); + } +} + +QColor JKQTBasePlotter::getExportBackgroundColor() const +{ + return this->plotterStyle.exportBackgroundColor; +} + +QColor JKQTBasePlotter::getPlotBackgroundColor() const +{ + return this->plotterStyle.plotBackgroundColor; +} + + + +void JKQTBasePlotter::setKeyFontSize(double __value) +{ + if (this->plotterStyle.keyStyle.fontSize != __value) { + this->plotterStyle.keyStyle.fontSize = __value; + redrawPlot(); + } +} + +double JKQTBasePlotter::getKeyFontSize() const +{ + return this->plotterStyle.keyStyle.fontSize; +} + + +void JKQTBasePlotter::setKeyTextColor(const QColor& __value) +{ + if (this->plotterStyle.keyStyle.textColor != __value) { + this->plotterStyle.keyStyle.textColor = __value; + redrawPlot(); + } +} + +QColor JKQTBasePlotter::getKeyTextColor() const +{ + return this->plotterStyle.keyStyle.textColor; +} + +void JKQTBasePlotter::setKeyItemWidth(double __value) +{ + if (this->plotterStyle.keyStyle.itemWidth != __value) { + this->plotterStyle.keyStyle.itemWidth = __value; + redrawPlot(); + } +} + +double JKQTBasePlotter::getKeyItemWidth() const +{ + return this->plotterStyle.keyStyle.itemWidth; +} + +void JKQTBasePlotter::setKeyItemHeight(double __value) +{ + if (this->plotterStyle.keyStyle.itemHeight != __value) { + this->plotterStyle.keyStyle.itemHeight = __value; + redrawPlot(); + } +} + +double JKQTBasePlotter::getKeyItemHeight() const +{ + return this->plotterStyle.keyStyle.itemHeight; +} + +void JKQTBasePlotter::setKeyYSeparation(double __value) +{ + if (this->plotterStyle.keyStyle.ySeparation != __value) { + this->plotterStyle.keyStyle.ySeparation = __value; + redrawPlot(); + } +} + +double JKQTBasePlotter::getKeyYSeparation() const +{ + return this->plotterStyle.keyStyle.ySeparation; +} + +void JKQTBasePlotter::setKeyLineLength(double __value) +{ + if (this->plotterStyle.keyStyle.sampleLineLength != __value) { + this->plotterStyle.keyStyle.sampleLineLength = __value; + redrawPlot(); + } +} + +double JKQTBasePlotter::getKeyLineLength() const +{ + return this->plotterStyle.keyStyle.sampleLineLength; +} + +void JKQTBasePlotter::setKeyXMargin(double __value) +{ + if (this->plotterStyle.keyStyle.xMargin != __value) { + this->plotterStyle.keyStyle.xMargin = __value; + redrawPlot(); + } +} + +double JKQTBasePlotter::getKeyXMargin() const +{ + return this->plotterStyle.keyStyle.xMargin; +} + +void JKQTBasePlotter::setKeyYMargin(double __value) +{ + if (this->plotterStyle.keyStyle.yMargin != __value) { + this->plotterStyle.keyStyle.yMargin = __value; + redrawPlot(); + } +} + +double JKQTBasePlotter::getKeyYMargin() const +{ + return this->plotterStyle.keyStyle.yMargin; +} + +void JKQTBasePlotter::setKeyXSeparation(double __value) +{ + if (this->plotterStyle.keyStyle.xSeparation != __value) { + this->plotterStyle.keyStyle.xSeparation = __value; + redrawPlot(); + } +} + +double JKQTBasePlotter::getKeyXSeparation() const +{ + return this->plotterStyle.keyStyle.xSeparation; +} + +void JKQTBasePlotter::setKeyXOffset(double __value) +{ + if (this->plotterStyle.keyStyle.xOffset != __value) { + this->plotterStyle.keyStyle.xOffset = __value; + redrawPlot(); + } +} + +double JKQTBasePlotter::getKeyXOffset() const +{ + return this->plotterStyle.keyStyle.xOffset; +} + +void JKQTBasePlotter::setKeyYOffset(double __value) +{ + if (this->plotterStyle.keyStyle.yOffset != __value) { + this->plotterStyle.keyStyle.yOffset = __value; + redrawPlot(); + } +} + +double JKQTBasePlotter::getKeyYOffset() const +{ + return this->plotterStyle.keyStyle.yOffset; +} + +void JKQTBasePlotter::setShowKey(bool __value) +{ + if (this->plotterStyle.keyStyle.visible != __value) { + this->plotterStyle.keyStyle.visible = __value; + redrawPlot(); + } +} + +bool JKQTBasePlotter::getShowKey() const +{ + return this->plotterStyle.keyStyle.visible; +} + +void JKQTBasePlotter::setShowKeyFrame(bool __value) +{ + if (this->plotterStyle.keyStyle.frameVisible != __value) { + this->plotterStyle.keyStyle.frameVisible = __value; + redrawPlot(); + } +} + +bool JKQTBasePlotter::getShowKeyFrame() const +{ + return this->plotterStyle.keyStyle.frameVisible; +} + +void JKQTBasePlotter::setKeyFrameColor(const QColor &__value) +{ + if (this->plotterStyle.keyStyle.frameColor != __value) { + this->plotterStyle.keyStyle.frameColor = __value; + redrawPlot(); + } +} + +QColor JKQTBasePlotter::getKeyFrameColor() const +{ + return this->plotterStyle.keyStyle.frameColor; +} + +void JKQTBasePlotter::setKeyBackgroundColor(const QColor &__value) +{ + if (this->plotterStyle.keyStyle.backgroundColor != __value) { + this->plotterStyle.keyStyle.backgroundColor = __value; + redrawPlot(); + } +} + +void JKQTBasePlotter::setKeyFrameWidth(double __value) +{ + if (this->plotterStyle.keyStyle.frameWidth != __value) { + this->plotterStyle.keyStyle.frameWidth = __value; + redrawPlot(); + } +} + +void JKQTBasePlotter::setKeyFrameRounding(double __value) +{ + if (this->plotterStyle.keyStyle.frameRounding != __value) { + this->plotterStyle.keyStyle.frameRounding = __value; + redrawPlot(); + } +} + +double JKQTBasePlotter::getKeyFrameWidth() const +{ + return this->plotterStyle.keyStyle.frameWidth; +} + +double JKQTBasePlotter::getKeyFrameRounding() const +{ + return this->plotterStyle.keyStyle.frameRounding; +} + +void JKQTBasePlotter::setKeyAutosize(bool __value) +{ + if (this->plotterStyle.keyStyle.autosize != __value) { + this->plotterStyle.keyStyle.autosize = __value; + redrawPlot(); + } +} + +bool JKQTBasePlotter::getKeyAutosize() const +{ + return this->plotterStyle.keyStyle.autosize; +} + +void JKQTBasePlotter::setKeyPosition(const JKQTPKeyPosition &__value) +{ + if (this->plotterStyle.keyStyle.position != __value) { + this->plotterStyle.keyStyle.position = __value; + redrawPlot(); + } +} + +JKQTPKeyPosition JKQTBasePlotter::getKeyPosition() const +{ + return this->plotterStyle.keyStyle.position; +} + +void JKQTBasePlotter::setKeyLayout(const JKQTPKeyLayout &__value) +{ + if (this->plotterStyle.keyStyle.layout != __value) { + this->plotterStyle.keyStyle.layout = __value; + redrawPlot(); + } +} + +JKQTPKeyLayout JKQTBasePlotter::getKeyLayout() const +{ + return this->plotterStyle.keyStyle.layout; +} + +QColor JKQTBasePlotter::getDefaultTextColor() const +{ + return this->plotterStyle.defaultTextColor; +} + +double JKQTBasePlotter::getDefaultTextSize() const +{ + return this->plotterStyle.defaultFontSize; +} + +QString JKQTBasePlotter::getDefaultTextFontName() const +{ + return this->plotterStyle.defaultFontName; +} + +void JKQTBasePlotter::setDefaultTextColor(QColor __value) +{ + if (this->plotterStyle.defaultTextColor != __value) { + this->plotterStyle.defaultTextColor = __value; + redrawPlot(); + } +} + +void JKQTBasePlotter::setDefaultTextSize(float __value) +{ + if (this->plotterStyle.defaultFontSize != __value) { + this->plotterStyle.defaultFontSize = __value; + redrawPlot(); + } +} + +void JKQTBasePlotter::setDefaultTextFontName(const QString &__value) +{ + if (this->plotterStyle.defaultFontName != __value) { + this->plotterStyle.defaultFontName = __value; + redrawPlot(); + } +} + +void JKQTBasePlotter::setPlotLabelFontSize(double __value) +{ + if (this->plotterStyle.plotLabelFontSize != __value) { + this->plotterStyle.plotLabelFontSize = __value; + redrawPlot(); + } +} + +double JKQTBasePlotter::getPlotLabelFontSize() const +{ + return this->plotterStyle.plotLabelFontSize; +} + +void JKQTBasePlotter::setplotLabelFontName(const QString &__value) +{ + if (this->plotterStyle.plotLabelFontName != __value) { + this->plotterStyle.plotLabelFontName = __value; + redrawPlot(); + } +} + +QString JKQTBasePlotter::getplotLabelFontName() const +{ + return this->plotterStyle.plotLabelFontName; +} + +void JKQTBasePlotter::setPlotLabel(const QString &__value) +{ + if (this->plotLabel != __value) { + this->plotLabel = __value; + redrawPlot(); + } +} + +QString JKQTBasePlotter::getPlotLabel() const +{ + return this->plotLabel; +} + +QColor JKQTBasePlotter::getKeyBackgroundColor() const +{ + return this->plotterStyle.keyStyle.backgroundColor; +} + +void JKQTBasePlotter::setPlotBackgroundColor(const QColor &__value) +{ + if (this->plotterStyle.plotBackgroundColor != __value) { + this->plotterStyle.plotBackgroundColor = __value; + redrawPlot(); + } +} + +bool JKQTBasePlotter::isPlotFrameVisible() const +{ + return plotterStyle.plotFrameVisible; +} + +QColor JKQTBasePlotter::getPlotFrameColor() const +{ + return plotterStyle.plotFrameColor; +} + +double JKQTBasePlotter::getPlotFrameWidth() const +{ + return plotterStyle.plotFrameWidth; +} + +double JKQTBasePlotter::getPlotFrameRounding() const +{ + return plotterStyle.plotFrameRounding; +} + +void JKQTBasePlotter::setPlotFrameWidth(double __value) +{ + if (this->plotterStyle.plotFrameWidth != __value) { + this->plotterStyle.plotFrameWidth = __value; + redrawPlot(); + } +} + +void JKQTBasePlotter::setPlotFrameRounding(double __value) +{ + if (this->plotterStyle.plotFrameRounding != __value) { + this->plotterStyle.plotFrameRounding = __value; + redrawPlot(); + } +} + +void JKQTBasePlotter::setPlotFrameColor(QColor __value) +{ + if (this->plotterStyle.plotFrameColor != __value) { + this->plotterStyle.plotFrameColor = __value; + redrawPlot(); + } +} + +void JKQTBasePlotter::setPlotFrameVisible(bool __value) +{ + if (this->plotterStyle.plotFrameVisible != __value) { + this->plotterStyle.plotFrameVisible = __value; + redrawPlot(); + } +} + +void JKQTBasePlotter::setUseAntiAliasingForText(bool __value) +{ + if (this->plotterStyle.useAntiAliasingForText != __value) { + this->plotterStyle.useAntiAliasingForText = __value; + redrawPlot(); + } +} + +void JKQTBasePlotter::setUseAntiAliasingForGraphs(bool __value) +{ + if (this->plotterStyle.useAntiAliasingForGraphs != __value) { + this->plotterStyle.useAntiAliasingForGraphs = __value; + redrawPlot(); + } +} + +void JKQTBasePlotter::setUseAntiAliasingForSystem(bool __value) +{ + if (this->plotterStyle.useAntiAliasingForSystem != __value) { + this->plotterStyle.useAntiAliasingForSystem = __value; + redrawPlot(); + } +} + +void JKQTBasePlotter::setAxisAspectRatio(double __value) +{ + if (this->axisAspectRatio != __value) { + this->axisAspectRatio = __value; + redrawPlot(); + } +} + void JKQTBasePlotter::setGridPrinting(bool __value) { this->gridPrinting = __value; @@ -2505,6 +2985,117 @@ void JKQTBasePlotter::setGridPrintingCurrentPos(size_t x, size_t y) gridPrintingCurrentY=y; } +void JKQTBasePlotter::setCurrentSaveDirectory(const QString &__value) +{ + this->currentSaveDirectory = __value; +} + +QString JKQTBasePlotter::getCurrentSaveDirectory() const +{ + return this->currentSaveDirectory; +} + +void JKQTBasePlotter::setCurrentFileFormat(const QString &__value) +{ + this->currentFileFormat = __value; +} + +QString JKQTBasePlotter::getCurrentFileFormat() const +{ + return this->currentFileFormat; +} + +void JKQTBasePlotter::setCSVdecimalSeparator(const QString &__value) +{ + plotterStyle.CSVdecimalSeparator = __value; +} + +void JKQTBasePlotter::setCSVcommentInitializer(const QString &__value) +{ + plotterStyle.CSVcommentInitializer = __value; +} + +void JKQTBasePlotter::enableDebugShowRegionBoxes(bool enabled) +{ + if (plotterStyle.debugShowRegionBoxes != enabled) { + plotterStyle.debugShowRegionBoxes = enabled; + redrawPlot(); + } +} + +bool JKQTBasePlotter::isDebugShowRegionBoxesEnabled() const +{ + return plotterStyle.debugShowRegionBoxes; +} + +QString JKQTBasePlotter::getCSVcommentInitializer() const +{ + return plotterStyle.CSVcommentInitializer; +} + +JKQTMathText *JKQTBasePlotter::getMathText() { + return &mathText; +} + +const JKQTMathText *JKQTBasePlotter::getMathText() const { + return &mathText; +} + +JKQTPHorizontalAxis *JKQTBasePlotter::getXAxis() { + return xAxis; +} + +JKQTPVerticalAxis *JKQTBasePlotter::getYAxis() { + return yAxis; +} + +const JKQTPHorizontalAxis *JKQTBasePlotter::getXAxis() const { + return xAxis; +} + +const JKQTPVerticalAxis *JKQTBasePlotter::getYAxis() const { + return yAxis; +} + +QAction *JKQTBasePlotter::getActionSavePlot() const { return this->actSavePlot; } + +QAction *JKQTBasePlotter::getActionSaveData() const { return this->actSaveData; } + +QAction *JKQTBasePlotter::getActionCopyData() const { return this->actCopyData; } + +QAction *JKQTBasePlotter::getActionCopyPixelImage() const { return this->actCopyPixelImage; } + +QAction *JKQTBasePlotter::getActionCopyMatlab() const { return this->actCopyMatlab; } + +QAction *JKQTBasePlotter::getActionSavePDF() const { return this->actSavePDF; } + +#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) +QAction *JKQTBasePlotter::getActionSavePS() const { return this->actSavePS; } +#endif + +QAction *JKQTBasePlotter::getActionSavePix() const { return this->actSavePix; } + +QAction *JKQTBasePlotter::getActionSaveSVG() const { return this->actSaveSVG; } + +QAction *JKQTBasePlotter::getActionPrint() const { return this->actPrint; } + +QAction *JKQTBasePlotter::getActionSaveCSV() const { return this->actSaveCSV; } + +QAction *JKQTBasePlotter::getActionZoomAll() const { return this->actZoomAll; } + +QAction *JKQTBasePlotter::getActionZoomIn() const { return this->actZoomIn; } + +QAction *JKQTBasePlotter::getActionZoomOut() const { return this->actZoomOut; } + +QAction *JKQTBasePlotter::getActionShowPlotData() const { return this->actShowPlotData; } + +JKQTBasePlotter::AdditionalActionsMap JKQTBasePlotter::getLstAdditionalPlotterActions() const { return this->lstAdditionalPlotterActions; } + +QString JKQTBasePlotter::getCSVdecimalSeparator() const +{ + return plotterStyle.CSVdecimalSeparator; +} + void JKQTBasePlotter::registerAdditionalAction(const QString &key, QAction *act) { if (!lstAdditionalPlotterActions.contains(key)) { @@ -2537,6 +3128,35 @@ void JKQTBasePlotter::deregisterAdditionalAction(QAction *act) } } +bool JKQTBasePlotter::getMasterSynchronizeWidth() const { return this->masterSynchronizeWidth; } + +bool JKQTBasePlotter::getMasterSynchronizeHeight() const { return this->masterSynchronizeHeight; } + + +void JKQTBasePlotter::setFontSizePrintMultiplier(double __value) +{ + this->fontSizePrintMultiplier = __value; +} + +double JKQTBasePlotter::getFontSizePrintMultiplier() const +{ + return this->fontSizePrintMultiplier; +} + +void JKQTBasePlotter::setLineWidthPrintMultiplier(double __value) +{ + this->lineWidthPrintMultiplier = __value; +} + +double JKQTBasePlotter::getLineWidthPrintMultiplier() const +{ + return this->lineWidthPrintMultiplier; +} + +double JKQTBasePlotter::getFontSizeMultiplier() const { return this->fontSizeMultiplier; } + +double JKQTBasePlotter::getLineWidthMultiplier() const { return this->lineWidthMultiplier; } + void JKQTBasePlotter::copyData() { loadUserSettings(); QString result=""; @@ -2674,6 +3294,11 @@ void JKQTBasePlotter::saveData(const QString& filename, const QString &format) { } void JKQTBasePlotter::saveAsCSV(const QString& filename) { + saveAsCSV(filename, plotterStyle.CSVdecimalSeparator, plotterStyle.CSVcommentInitializer); +} + +void JKQTBasePlotter::saveAsCSV(const QString &filename, const QString &decimalSeparator, const QString &commentInitializer) +{ loadUserSettings(); QString fn=filename; if (fn.isEmpty()) { @@ -2684,7 +3309,47 @@ void JKQTBasePlotter::saveAsCSV(const QString& filename) { } if (!fn.isEmpty()) { - datastore->saveCSV(fn, getDataColumnsByUser(), ", ", CSVdecimalSeparator, CSVcommentInitializer); + datastore->saveCSV(fn, getDataColumnsByUser(), ", ", decimalSeparator, commentInitializer); + } + saveUserSettings(); + +} +void JKQTBasePlotter::saveAsSemicolonSV(const QString& filename) { + saveAsSemicolonSV(filename, plotterStyle.CSVdecimalSeparator, plotterStyle.CSVcommentInitializer); +} + +void JKQTBasePlotter::saveAsSemicolonSV(const QString& filename, const QString &decimalSeparator, const QString &commentInitializer) { + loadUserSettings(); + QString fn=filename; + if (fn.isEmpty()) { + fn = QFileDialog::getSaveFileName(nullptr, tr("Save Plot Data"), + currentSaveDirectory, + tr("Comma Separated Values (*.csv *.dat)")); + if (!fn.isEmpty()) currentSaveDirectory=QFileInfo(fn).absolutePath(); + } + + if (!fn.isEmpty()) { + datastore->saveCSV(fn, getDataColumnsByUser(), ";", decimalSeparator, commentInitializer); + } + saveUserSettings(); +} + +void JKQTBasePlotter::saveAsTabSV(const QString& filename) { + saveAsTabSV(filename, plotterStyle.CSVdecimalSeparator, plotterStyle.CSVcommentInitializer); +} + +void JKQTBasePlotter::saveAsTabSV(const QString& filename, const QString &decimalSeparator, const QString &commentInitializer) { + loadUserSettings(); + QString fn=filename; + if (fn.isEmpty()) { + fn = QFileDialog::getSaveFileName(nullptr, tr("Save Plot Data"), + currentSaveDirectory, + tr("Tabulator Separated Values (*.txt)")); + if (!fn.isEmpty()) currentSaveDirectory=QFileInfo(fn).absolutePath(); + } + + if (!fn.isEmpty()) { + datastore->saveCSV(fn, getDataColumnsByUser(), "\t", decimalSeparator, commentInitializer); } saveUserSettings(); } @@ -2737,37 +3402,6 @@ void JKQTBasePlotter::saveAsDIF(const QString& filename) { saveUserSettings(); } -void JKQTBasePlotter::saveAsSemicolonSV(const QString& filename) { - loadUserSettings(); - QString fn=filename; - if (fn.isEmpty()) { - fn = QFileDialog::getSaveFileName(nullptr, tr("Save Plot Data"), - currentSaveDirectory, - tr("Comma Separated Values (*.csv *.dat)")); - if (!fn.isEmpty()) currentSaveDirectory=QFileInfo(fn).absolutePath(); - } - - if (!fn.isEmpty()) { - datastore->saveCSV(fn, getDataColumnsByUser(), ";", CSVdecimalSeparator, CSVcommentInitializer); - } - saveUserSettings(); -} - -void JKQTBasePlotter::saveAsTabSV(const QString& filename) { - loadUserSettings(); - QString fn=filename; - if (fn.isEmpty()) { - fn = QFileDialog::getSaveFileName(nullptr, tr("Save Plot Data"), - currentSaveDirectory, - tr("Tabulator Separated Values (*.txt)")); - if (!fn.isEmpty()) currentSaveDirectory=QFileInfo(fn).absolutePath(); - } - - if (!fn.isEmpty()) { - datastore->saveCSV(fn, getDataColumnsByUser(), "\t", CSVdecimalSeparator, CSVcommentInitializer); - } - saveUserSettings(); -} void JKQTBasePlotter::saveAsGerExcelCSV(const QString& filename) { loadUserSettings(); @@ -3192,15 +3826,39 @@ void JKQTBasePlotter::saveAsSVG(const QString& filename, bool displayPreview) { } -void JKQTBasePlotter::setBorder(int left, int right, int top, int bottom){ - plotBorderTop=top; - plotBorderLeft=left; - plotBorderBottom=bottom; - plotBorderRight=right; +void JKQTBasePlotter::setPlotBorder(int left, int right, int top, int bottom){ + plotterStyle.plotBorderTop=top; + plotterStyle.plotBorderLeft=left; + plotterStyle.plotBorderBottom=bottom; + plotterStyle.plotBorderRight=right; //updateGeometry(); if (emitPlotSignals) emit plotUpdated(); } +void JKQTBasePlotter::setPlotBorderLeft(int left) +{ + plotterStyle.plotBorderLeft=left; + if (emitPlotSignals) emit plotUpdated(); +} + +void JKQTBasePlotter::setPlotBorderRight(int right) +{ + plotterStyle.plotBorderRight=right; + if (emitPlotSignals) emit plotUpdated(); +} + +void JKQTBasePlotter::setPlotBorderTop(int top) +{ + plotterStyle.plotBorderTop=top; + if (emitPlotSignals) emit plotUpdated(); +} + +void JKQTBasePlotter::setPlotBorderBottom(int bottom) +{ + plotterStyle.plotBorderBottom=bottom; + if (emitPlotSignals) emit plotUpdated(); +} + void JKQTBasePlotter::synchronizeToMaster(JKQTBasePlotter* master, SynchronizationDirection synchronizeDirection, bool synchronizeAxisLength, bool synchronizeZoomingMasterToSlave, bool synchronizeZoomingSlaveToMaster) { // remove old connections if (masterPlotterX && (synchronizeDirection==sdXAxis || synchronizeDirection==sdXYAxes)) { @@ -3361,7 +4019,6 @@ size_t JKQTBasePlotter::addGraph(size_t xColumn, size_t yColumn, const QString& gr->setTitle(title); gr->setXColumn(xColumn); gr->setYColumn(yColumn); - gr->setColor(QColor("black")); gr->setLineWidth(width); gr->setStyle(penstyle); gr->setFillColor(color); @@ -3371,7 +4028,6 @@ size_t JKQTBasePlotter::addGraph(size_t xColumn, size_t yColumn, const QString& gr->setTitle(title); gr->setXColumn(xColumn); gr->setYColumn(yColumn); - gr->setColor(QColor("black")); gr->setLineWidth(width); gr->setStyle(penstyle); gr->setFillColor(color); @@ -3381,7 +4037,6 @@ size_t JKQTBasePlotter::addGraph(size_t xColumn, size_t yColumn, const QString& gr->setTitle(title); gr->setXColumn(xColumn); gr->setYColumn(yColumn); - gr->setColor(QColor("black")); gr->setLineWidth(width); gr->setStyle(penstyle); gr->setFillColor(color); @@ -3391,7 +4046,6 @@ size_t JKQTBasePlotter::addGraph(size_t xColumn, size_t yColumn, const QString& gr->setTitle(title); gr->setXColumn(xColumn); gr->setYColumn(yColumn); - gr->setColor(QColor("black")); gr->setLineWidth(width); gr->setStyle(penstyle); gr->setFillColor(color); @@ -3581,22 +4235,22 @@ size_t JKQTBasePlotter::addGraphWithXYError(size_t xColumn, size_t yColumn, size -void JKQTBasePlotter::plotGraphs(JKQTPEnhancedPainter& painter){ +void JKQTBasePlotter::drawGraphs(JKQTPEnhancedPainter& painter){ #ifdef JKQTBP_AUTOTIMER JKQTPAutoOutputTimer jkaaot(QString("JKQTBasePlotter::plotGraphs")); #endif if (datastore==nullptr || graphs.isEmpty()) return; //qDebug()<<"start JKQTBasePlotter::plotGraphs()"; if (useClipping) { - QRegion cregion(iplotBorderLeft, iplotBorderTop, plotWidth, plotHeight); + QRegion cregion(internalPlotBorderLeft, internalPlotBorderTop, internalPlotWidth, internalPlotHeight); painter.setClipping(true); painter.setClipRegion(cregion); } - int ibTop=iplotBorderTop_nographs-plotBorderTop; - int ibLeft=iplotBorderLeft_nographs-plotBorderLeft; - int ibBottom=iplotBorderBottom_nographs-plotBorderBottom; - int ibRight=iplotBorderRight_nographs-plotBorderRight; + int ibTop=internalPlotBorderTop_notIncludingOutsidePlotSections-plotterStyle.plotBorderTop-internalTitleHeight; + int ibLeft=internalPlotBorderLeft_notIncludingOutsidePlotSections-plotterStyle.plotBorderLeft; + int ibBottom=internalPlotBorderBottom_notIncludingOutsidePlotSections-plotterStyle.plotBorderBottom; + int ibRight=internalPlotBorderRight_notIncludingOutsidePlotSections-plotterStyle.plotBorderRight; for (int j=0; jgetOutsideSize(painter, leftSpace, rightSpace, topSpace, bottomSpace); ibTop+=topSpace; ibLeft+=leftSpace; - g->drawOutside(painter, QRect(iplotBorderLeft+iplotKeyBorderLeft-ibLeft, iplotBorderTop, leftSpace, plotHeight), - QRect(iplotBorderLeft+plotWidth+ibRight-iplotKeyBorderRight, iplotBorderTop, rightSpace, plotHeight), - QRect(iplotBorderLeft, iplotBorderTop-ibTop+iplotKeyBorderTop, plotWidth, topSpace), - QRect(iplotBorderLeft, iplotBorderTop+plotHeight+ibBottom, plotWidth, bottomSpace) - ); + QRect rleft(internalPlotBorderLeft+internalPlotKeyBorderLeft-ibLeft, internalPlotBorderTop, leftSpace, internalPlotHeight); + QRect rright(internalPlotBorderLeft+internalPlotWidth+ibRight-internalPlotKeyBorderRight, internalPlotBorderTop, rightSpace, internalPlotHeight); + QRect rtop(internalPlotBorderLeft, internalPlotBorderTop-ibTop+internalPlotKeyBorderTop, internalPlotWidth, topSpace); + QRect rbottom(internalPlotBorderLeft, internalPlotBorderTop+internalPlotHeight+ibBottom, internalPlotWidth, bottomSpace); + g->drawOutside(painter, rleft, rright, rtop, rbottom ); + + if (plotterStyle.debugShowRegionBoxes) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + QPen p("green"); + p.setWidthF(plotterStyle.debugRegionLineWidth); + QColor col=p.color(); col.setAlphaF(0.8); p.setColor(col); + painter.setPen(p); + painter.setBrush(QBrush(QColor(Qt::transparent))); + if (rleft.width()>0 && rleft.height()>0) painter.drawRect(rleft); + if (rright.width()>0 && rright.height()>0) painter.drawRect(rright); + if (rtop.width()>0 && rtop.height()>0) painter.drawRect(rtop); + if (rbottom.width()>0 && rbottom.height()>0) painter.drawRect(rbottom); + + } + ibRight+=rightSpace; ibBottom+=bottomSpace; } @@ -3631,11 +4300,11 @@ void JKQTBasePlotter::plotGraphs(JKQTPEnhancedPainter& painter){ } -void JKQTBasePlotter::plotKeyContents(JKQTPEnhancedPainter& painter, double x, double y, double /*width*/, double /*height*/){ +void JKQTBasePlotter::drawKeyContents(JKQTPEnhancedPainter& painter, double x, double y, double width, double height){ #ifdef JKQTBP_AUTOTIMER JKQTPAutoOutputTimer jkaaot(QString("JKQTBasePlotter::plotKeyContents(%1, %2, %3, %4)").arg(x).arg(y).arg(width).arg(height)); #endif - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); double key_text_width=0; double key_text_height=0; @@ -3646,12 +4315,12 @@ void JKQTBasePlotter::plotKeyContents(JKQTPEnhancedPainter& painter, double x, d #ifdef SHOW_JKQTPLOTTER_DEBUG qDebug()<<"key_item_height="<getTitle())); #endif if (!g->getTitle().isEmpty() && g->isVisible()) { - QSizeF fs=getTextSizeSize(keyFont,keyFontSize*fontSizeMultiplier,g->getTitle(),painter);// mt.getSize(painter); - double itheight=qMax(key_item_height*kfm.width('X'), fs.height()); - QRectF rect(x, y+1.5*lineWidthMultiplier, key_line_length*kfm.width('X'), itheight-3.0*lineWidthMultiplier); - g->drawKeyMarker(painter, rect); - mathText.setFontColor(QColor("black")); - mathText.setFontSize(keyFontSize*fontSizeMultiplier); - mathText.setFontRoman(keyFont); + 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); + g->drawKeyMarker(painter, markerRect); + mathText.setFontColor(plotterStyle.keyStyle.textColor); + mathText.setFontSize(plotterStyle.keyStyle.fontSize*fontSizeMultiplier); + mathText.setFontRomanOrSpecial(plotterStyle.defaultFontName); mathText.parse(g->getTitle()); - mathText.draw(painter, Qt::AlignLeft|Qt::AlignVCenter, QRectF(x+(key_line_length+keyXSeparation)*kfm.width('X'),y, key_text_width, itheight)); + QRectF txtRect(x+(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation)*kfm.width('X'),y, key_text_width, itheight); + mathText.draw(painter, Qt::AlignLeft|Qt::AlignVCenter, txtRect); //if (itheightgetTitle())); #endif if (!g->getTitle().isEmpty() && g->isVisible()) { - QSizeF fs=getTextSizeSize(keyFont,keyFontSize*fontSizeMultiplier,g->getTitle(),painter);// mt.getSize(painter); - double itheight=qMax(key_item_height*kfm.width('X'), fs.height()); - QRectF rect(x, y+1.5*lineWidthMultiplier, key_line_length*kfm.width('X'), itheight-3.0*lineWidthMultiplier); - g->drawKeyMarker(painter, rect); - mathText.setFontColor(QColor("black")); - mathText.setFontSize(keyFontSize*fontSizeMultiplier); - mathText.setFontRoman(keyFont); + 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); + g->drawKeyMarker(painter, markerRect); + mathText.setFontColor(plotterStyle.keyStyle.textColor); + mathText.setFontSize(plotterStyle.keyStyle.fontSize*fontSizeMultiplier); + mathText.setFontRomanOrSpecial(plotterStyle.defaultFontName); mathText.parse(g->getTitle()); - mathText.draw(painter, Qt::AlignLeft|Qt::AlignVCenter, QRectF(x+(key_line_length+keyXSeparation)*kfm.width('X'),y, fs.width(), itheight)); + QRectF txtRect(x+(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation)*kfm.width('X'),y, fs.width(), itheight); + mathText.draw(painter, Qt::AlignLeft|Qt::AlignVCenter, txtRect); + if (plotterStyle.debugShowRegionBoxes) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + QPen p("orange"); + QColor col=p.color(); col.setAlphaF(0.8); p.setColor(col); + p.setWidthF(plotterStyle.debugRegionLineWidth/2.0); + p.setStyle(Qt::DashLine); + painter.setPen(p); + painter.setBrush(QBrush(QColor(Qt::transparent))); + painter.drawRect(txtRect); + painter.drawRect(markerRect); + + } //if (itheight(plotWidth)/static_cast(key_item_width*kfm.width('X'))); bool colfirst=true; - if (keyPosition==JKQTPKeyInsideTopLeft || keyPosition==JKQTPKeyInsideTopRight - || keyPosition==JKQTPKeyOutsideTopLeft || keyPosition==JKQTPKeyOutsideTopRight) { + if (plotterStyle.keyStyle.position==JKQTPKeyInsideTopLeft || plotterStyle.keyStyle.position==JKQTPKeyInsideTopRight + || plotterStyle.keyStyle.position==JKQTPKeyOutsideTopLeft || plotterStyle.keyStyle.position==JKQTPKeyOutsideTopRight) { colfirst=false; } @@ -3716,38 +4412,52 @@ void JKQTBasePlotter::plotKeyContents(JKQTPEnhancedPainter& painter, double x, d jkaaot.write(QString("multi-col: graph %1: %2").arg(i).arg(g->getTitle())); #endif if (!g->getTitle().isEmpty() && g->isVisible()) { - //QSizeF fs=getTextSizeSize(keyFont,keyFontSize*fontSizeMultiplier,g->getTitle(),painter);// mt.getSize(painter); - double itheight=qMax(key_item_height*kfm.width('X'), key_text_height); - QRectF rect(xx, yy+1.5*lineWidthMultiplier, key_line_length*kfm.width('X'), itheight-3.0*lineWidthMultiplier); - g->drawKeyMarker(painter, rect); - mathText.setFontColor(QColor("black")); - mathText.setFontSize(keyFontSize*fontSizeMultiplier); - mathText.setFontRoman(keyFont); + //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); + 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); - mathText.draw(painter, Qt::AlignLeft|Qt::AlignVCenter, QRectF(xx+(key_line_length+keyXSeparation)*kfm.width('X'),yy, key_text_width, key_text_height)); + QRectF txtRect(xx+(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation)*kfm.width('X'),yy, key_text_width, key_text_height); + mathText.draw(painter, Qt::AlignLeft|Qt::AlignVCenter, txtRect); + + if (plotterStyle.debugShowRegionBoxes) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + QPen p("orange"); + QColor col=p.color(); col.setAlphaF(0.8); p.setColor(col); + p.setWidthF(plotterStyle.debugRegionLineWidth/2.0); + p.setStyle(Qt::DashLine); + painter.setPen(p); + painter.setBrush(QBrush(QColor(Qt::transparent))); + painter.drawRect(txtRect); + painter.drawRect(markerRect); + + } if (colfirst) { - yy=yy+key_text_height+(keyYSeparation)*kfm.width('X'); + yy=yy+key_text_height+(plotterStyle.keyStyle.ySeparation)*kfm.width('X'); l++; if (l>lines) { l=1; c++; - xx=xx+key_text_width+(key_line_length+2.0*keyXSeparation)*kfm.width('X'); - /*if (keyAutosize) xx=xx+key_text_width+(key_line_length+3.0*keyXSeparation)*kfm.width('X'); - else xx=xx+(key_item_width+2.0*keyXSeparation)*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)*kfm.width('X'); + else xx=xx+(key_item_width+2.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X');*/ yy=y; } } else { - /*if (keyAutosize) xx=xx+key_text_width+(key_line_length+3.0*keyXSeparation)*kfm.width('X'); - else xx=xx+(key_item_width+2.0*keyXSeparation)*kfm.width('X');*/ - xx=xx+key_text_width+(key_line_length+2.0*keyXSeparation)*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)*kfm.width('X'); c++; if (c>columns) { c=1; l++; - //yy=yy+(key_item_height+keyYSeparation)*kfm.height(); - yy=yy+itheight+(keyYSeparation)*kfm.width('X'); + //yy=yy+(key_item_height+plotterStyle.keyStyle.ySeparation)*kfm.height(); + yy=yy+itheight+(plotterStyle.keyStyle.ySeparation)*kfm.width('X'); xx=x; } } @@ -3758,7 +4468,7 @@ void JKQTBasePlotter::plotKeyContents(JKQTPEnhancedPainter& painter, double x, d /*painter.setPen(pold); painter.setBrush(bold);*/ - painter.restore(); + } void JKQTBasePlotter::getKeyExtent(JKQTPEnhancedPainter& painter, double* width, double* height, double* text_width, double* text_height, int* columns_count, int *lines_count) { @@ -3766,11 +4476,11 @@ void JKQTBasePlotter::getKeyExtent(JKQTPEnhancedPainter& painter, double* width, JKQTPAutoOutputTimer jkaaot("JKQTBasePlotter::getKeyExtent"); #endif QFont f=painter.font(); - f.setFamily(keyFont); - f.setPointSizeF(keyFontSize*fontSizeMultiplier); + f.setFamily(plotterStyle.defaultFontName); + f.setPointSizeF(plotterStyle.keyStyle.fontSize*fontSizeMultiplier); QFontMetricsF kfm(f); - if (text_height!=nullptr) *text_height=key_item_height*kfm.width('X'); - if (keyLayout==JKQTPKeyLayoutOneColumn) { + if (text_height!=nullptr) *text_height=plotterStyle.keyStyle.itemHeight*kfm.width('X'); + if (plotterStyle.keyStyle.layout==JKQTPKeyLayoutOneColumn) { int keyHeight=graphs.size(); double w=0; double h=0; @@ -3784,24 +4494,24 @@ void JKQTBasePlotter::getKeyExtent(JKQTPEnhancedPainter& painter, double* width, } else { //mt.parse(graphs[i]->getTitle()); //QSizeF fs=mt.getSize(painter); - QSizeF fs=getTextSizeSize(keyFont, keyFontSize*fontSizeMultiplier, graphs[i]->getTitle(), painter); + 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(key_item_height*kfm.width('X'), fs.height())+keyYSeparation*kfm.width('X'); + h=h+qMax(plotterStyle.keyStyle.itemHeight*kfm.width('X'), fs.height())+plotterStyle.keyStyle.ySeparation*kfm.width('X'); } } - if (keyAutosize) { - if (width) *width=w+(key_line_length+2.0*keyXSeparation)*kfm.width('X'); + 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'); } else { - if (width) *width=key_item_width*kfm.width('X'); - if (text_width!=nullptr) *text_width=(key_item_width-(key_line_length+keyXSeparation))*kfm.width('X'); + 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 (h>keyYSeparation*kfm.width('X')) h=h-keyYSeparation*kfm.width('X'); + 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 (columns_count) *columns_count=1; if (lines_count) *lines_count=keyHeight; - } else if (keyLayout==JKQTPKeyLayoutOneRow) { + } else if (plotterStyle.keyStyle.layout==JKQTPKeyLayoutOneRow) { int keyWidth=graphs.size(); double w=0; double h=0; @@ -3815,33 +4525,33 @@ void JKQTBasePlotter::getKeyExtent(JKQTPEnhancedPainter& painter, double* width, } else { //mt.parse(graphs[i]->getTitle()); //QSizeF fs=mt.getSize(painter); - QSizeF fs=getTextSizeSize(keyFont, keyFontSize*fontSizeMultiplier, graphs[i]->getTitle(), painter); + 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()+(key_line_length+2.0*keyXSeparation)*kfm.width('X'); + w=w+fs.width()+(plotterStyle.keyStyle.sampleLineLength+2.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X'); } } - if (h(keyXSeparation)*kfm.width('X')) w=w-(keyXSeparation)*kfm.width('X'); + 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 (columns_count) *columns_count=keyWidth; if (lines_count) *lines_count=1; - } else if (keyLayout==JKQTPKeyLayoutMultiColumn) { + } else if (plotterStyle.keyStyle.layout==JKQTPKeyLayoutMultiColumn) { // copied code in plotKeyContents()!!! double keyHeight=graphs.size(); double w=0; double txtH=0; QFont f=painter.font(); - f.setFamily(keyFont); - f.setPointSizeF(keyFontSize*fontSizeMultiplier); + f.setFamily(plotterStyle.defaultFontName); + f.setPointSizeF(plotterStyle.keyStyle.fontSize*fontSizeMultiplier); painter.setFont(f); @@ -3851,30 +4561,30 @@ void JKQTBasePlotter::getKeyExtent(JKQTPEnhancedPainter& painter, double* width, } else { //mt.parse(graphs[i]->getTitle()); //QSizeF fs=mt.getSize(painter); - QSizeF fs=getTextSizeSize(keyFont, keyFontSize*fontSizeMultiplier, graphs[i]->getTitle(), painter); + QSizeF fs=getTextSizeSize(plotterStyle.defaultFontName, plotterStyle.keyStyle.fontSize*fontSizeMultiplier, graphs[i]->getTitle(), painter); if (fs.width()>w) w=fs.width(); if ( fs.height()>txtH) txtH=fs.height(); } } if (text_height) { - if (keyAutosize) *text_height=txtH; - else *text_height=key_item_height*kfm.width('X'); + if (plotterStyle.keyStyle.autosize) *text_height=txtH; + else *text_height=plotterStyle.keyStyle.itemHeight*kfm.width('X'); } - double columns=floor(double(plotWidth)/(w+(2.0*keyXSeparation+key_line_length)*kfm.width('X'))); - if (!keyAutosize) columns=floor(double(plotWidth)/((key_item_width+2.0*keyXSeparation+key_line_length)*kfm.width('X'))); + 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'))); columns=qMin(columns, keyHeight); int lines=static_cast(ceil(static_cast(keyHeight)/static_cast(columns))); lines=qMin(static_cast(lines), keyHeight); - if (keyPosition==JKQTPKeyInsideTopLeft || keyPosition==JKQTPKeyInsideTopRight - || keyPosition==JKQTPKeyOutsideTopLeft || keyPosition==JKQTPKeyOutsideTopRight) { - if (keyAutosize) { - lines=static_cast(floor(static_cast(plotHeight)/static_cast(txtH+(keyYSeparation)*kfm.width('X')))); + if (plotterStyle.keyStyle.position==JKQTPKeyInsideTopLeft || plotterStyle.keyStyle.position==JKQTPKeyInsideTopRight + || plotterStyle.keyStyle.position==JKQTPKeyOutsideTopLeft || plotterStyle.keyStyle.position==JKQTPKeyOutsideTopRight) { + if (plotterStyle.keyStyle.autosize) { + lines=static_cast(floor(static_cast(internalPlotHeight)/static_cast(txtH+(plotterStyle.keyStyle.ySeparation)*kfm.width('X')))); } else { - lines=static_cast(floor(static_cast(plotHeight)/static_cast((key_item_height+keyYSeparation)*kfm.width('X')))); + lines=static_cast(floor(static_cast(internalPlotHeight)/static_cast((plotterStyle.keyStyle.itemHeight+plotterStyle.keyStyle.ySeparation)*kfm.width('X')))); } columns=static_cast(ceil(static_cast(keyHeight)/static_cast(lines))); lines=qMin(static_cast(lines), keyHeight); @@ -3884,16 +4594,16 @@ void JKQTBasePlotter::getKeyExtent(JKQTPEnhancedPainter& painter, double* width, if (columns_count) *columns_count=columns; if (lines_count) *lines_count=lines; - if (keyAutosize) { - if (width) *width=(w+(key_line_length+3.0*keyXSeparation)*kfm.width('X'))*columns; - if (height) *height=lines*(txtH+keyYSeparation*kfm.width('X')); - if (lines>0) *height=*height-keyYSeparation*kfm.width('X'); + 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 (text_width!=nullptr) *text_width=w; } else { - if (width) *width=(key_item_width+2.0*keyXSeparation)*kfm.width('X')*columns; - if (height) *height=lines*(key_item_height+keyYSeparation)*kfm.width('X'); - if (lines>0) *height=*height-keyYSeparation*kfm.width('X'); - if (text_width!=nullptr) *text_width=(key_item_width-(key_line_length+keyXSeparation))*kfm.width('X'); + 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'); } #ifdef SHOW_JKQTPLOTTER_DEBUG qDebug()<<"getKeyExtent(): mult-column: columns="< > > AdditionalActionsMap; typedef QMapIterator > > AdditionalActionsMapIterator; - protected: - /** \brief used to plot LaTeX markup */ - JKQTMathText mathText; - - /** \brief model representing all Plots in this plotter and showing their visible/invisible state */ - JKQTPGraphsModel* m_plotsModel; - - /** \brief object used for the x-axis */ - JKQTPHorizontalAxis* xAxis; - /** \brief object used for the y-axis */ - JKQTPVerticalAxis* yAxis; - - /** \brief filename for the ini file in which to save the user settings - * \see jkqtplotter_base_userprops + /** \brief set a global preset/default value for the userSettigsFilename and userSettigsPrefix properties of JKQTBasePlotter + * + * These presets are application global and will be used ONLY on initialization of a JKQTBasePlotter. You can overwrite them + * on a local-basis for each JKQTBasePrinter separately. The changed values from this function call will only take effect for + * newly created plotters AFTER the function call! */ - QString userSettigsFilename; - /** \brief prefix for the ini file in which to save the user settings - * \see jkqtplotter_base_userprops - */ - QString userSettigsPrefix; + static void setDefaultJKQTBasePrinterUserSettings(QString userSettigsFilename, const QString& userSettigsPrefix); + /** \brief register a user-defined QPaintDevice (with factory JKQTPPaintDeviceAdapter) as a plugin to JKQTBasePlotter/JKQTPlotter, + * which will use it to export graphics */ + static void registerPaintDeviceAdapter(JKQTPPaintDeviceAdapter* adapter); + /** \brief de-register a JKQTPPaintDeviceAdapter from JKQTBasePlotter/JKQTPlotter */ + static void deregisterPaintDeviceAdapter(JKQTPPaintDeviceAdapter* adapter); - /** \brief indicates whether the \ref jkqtplotter_base_saveprint is activated .*/ - bool gridPrinting; - /** \brief x position of the current graph in \ref jkqtplotter_base_saveprint */ - size_t gridPrintingCurrentX; - /** \brief y position of the current graph in \ref jkqtplotter_base_saveprint */ - size_t gridPrintingCurrentY; - /** \brief list that manages all the additional graphs for grid printing mode */ - QList gridPrintingList; - /** \brief this list contains all the rows of the current printing grid and stores its heights */ - QList gridPrintingRows; - /** \brief this list contains all the columns of the current printing grid and stores its widths */ - QList gridPrintingColumns; - /** \brief size of all plots in grid printing mode, filled by gridPrintingCalc() */ - QSizeF gridPrintingSize; - /** \brief this is an internal property that is used by the export/print system to control the "magnification". Usually this is 1.0 - * but if set !=1.0, it is used to scale the widgetWidth and widgetHeight before painting! */ - double paintMagnification; - /** \brief the decimal separator used when exporting data to text files */ - QString CSVdecimalSeparator; - /*! \brief default value for property property CSVdecimalSeparator. \see CSVdecimalSeparator for more information */ - QString default_CSVdecimalSeparator; - /** \brief this string is used to introduce comments in text output when exporting data */ - QString CSVcommentInitializer; - /*! \brief default value for property property CSVcommentInitializer. \see CSVcommentInitializer for more information */ - QString default_CSVcommentInitializer; - /** \brief an object which manages all data columns for this plotter class */ - JKQTPDatastore* datastore; - /** \brief indicates whether the datastore is managed (allocated/freed) internally or externally */ - bool datastoreInternal; + /** \brief register a JKQTPSaveDataAdapter with JKQTPlotter/JKQTBasePlotter that can be used to export data from the internal datastore into a file */ + static bool registerSaveDataAdapter(JKQTPSaveDataAdapter* adapter); + /** \brief de-register a JKQTPSaveDataAdapter from JKQTPlotter/JKQTBasePlotter */ + static bool deregisterSaveDataAdapter(JKQTPSaveDataAdapter* adapter); - /** \brief width of the plot widget */ - int widgetWidth; - /** \brief height of the plot widget */ - int widgetHeight; - - - /** \brief free space between widget top border and plot top border, this property may be set by the user and is possibly altered - * by the key positioning algorithm. The altered value is written to iplotBorderTop */ - int plotBorderTop; - /*! \brief default value for property property plotBorderTop. \see plotBorderTop for more information */ - int default_plotBorderTop; - /** \brief free space between widget top border and plot top border, as used to plot the graph (mnay be altered from user input ) */ - double iplotBorderTop; - double iplotKeyBorderTop; - /** \brief height of the plot title (or 0 if no title) */ - double iTitleHeight; - /** \brief free space between widget left border and plot left border, this property may be set by the user and is possibly altered - * by the key positioning algorithm. The altered value is written to iplotBorderLeft */ - int plotBorderLeft; - /*! \brief default value for property property plotBorderLeft. \see plotBorderLeft for more information */ - int default_plotBorderLeft; - /** \brief free space between widget top border and plot top border, as used to plot the graph (mnay be altered from user input ) */ - double iplotBorderLeft; - double iplotKeyBorderLeft; - /** \brief free space between widget bottom border and plot bottom border, this property may be set by the user and is possibly altered - * by the key positioning algorithm. The altered value is written to iplotBorderBottom */ - int plotBorderBottom; - /*! \brief default value for property property plotBorderBottom. \see plotBorderBottom for more information */ - int default_plotBorderBottom; - /** \brief free space between widget top border and plot top border, as used to plot the graph (mnay be altered from user input ) */ - double iplotBorderBottom; - double iplotKeyBorderBottom; - /** \brief free space between widget right border and plot right border, this property may be set by the user and is possibly altered - * by the key positioning algorithm. The altered value is written to iplotBorderRight */ - int plotBorderRight; - /*! \brief default value for property property plotBorderRight. \see plotBorderRight for more information */ - int default_plotBorderRight; - /** \brief free space between widget top border and plot top border, as used to plot the graph (mnay be altered from user input ) */ - double iplotBorderRight; - double iplotKeyBorderRight; - - - - /** \brief free space between widget top border and plot top border (including coordinate axes) */ - double iplotBorderTop_nographs; - /** \brief free space between widget left border and plot left border (including coordinate axes) */ - double iplotBorderLeft_nographs; - /** \brief free space between widget right border and plot right border (including coordinate axes) */ - double iplotBorderBottom_nographs; - /** \brief free space between widget bottom border and plot bottom border (including coordinate axes) */ - double iplotBorderRight_nographs; - - /** \brief indicates whether the widget should maintain an aspect ratio of plotwidth and plotheight */ - bool maintainAspectRatio; - /*! \brief default value for property property maintainAspectRatio. \see maintainAspectRatio for more information */ - bool default_maintainAspectRatio; - /** \brief the aspect ratio of plotwidth and plotheight to maintain, if \c maintainAspectRatio==true */ - double aspectRatio; - /*! \brief default value for property property aspectRatio. \see aspectRatio for more information */ - double default_aspectRatio; - - /** \brief indicates whether the axes should maintain an aspect ratio */ - bool maintainAxisAspectRatio; - /*! \brief default value for property property maintainAxisAspectRatio. \see maintainAxisAspectRatio for more information */ - bool default_maintainAxisAspectRatio; - /** \brief the aspect ratio of axis widths to maintain, if \c maintainAxisAspectRatio==true */ - double axisAspectRatio; - /*! \brief default value for property property axisAspectRatio. \see axisAspectRatio for more information */ - double default_axisAspectRatio; - - /** \brief plot width in pt inside the widget (calculated by calcPlotScaling() from plotBorderLeft, plotBorderRight and widgetWidth) */ - int plotWidth; - /** \brief plot height in pt inside the widget (calculated by calcPlotScaling() from plotBorderTop, plotBorderBottom and widgetHeight) */ - int plotHeight; - - - - /** \brief color of the plotted graph */ - QColor graphColor; - /*! \brief default value for property property graphColor. \see graphColor for more information */ - QColor default_graphColor; - /** \brief colors used in modes where more than one graph is beeing plottet */ - QColor manyGraphsColor[50]; - QColor default_manyGraphsColor[50]; - /** \brief number of actually defined items in manyGraphsColor */ - int manyGraphsColorCount; - /** \brief pen styles used in modes where more than one graph is beeing plottet */ - Qt::PenStyle manyGraphsStyle[5]; - /*! \brief default value for property property manyGraphsStyle. \see manyGraphsStyle[5] for more information */ - Qt::PenStyle default_manyGraphsStyle[5]; - /** \brief width of the plotted graph (in pixel) */ - double graphWidth; - /*! \brief default value for property property graphWidth. \see graphWidth for more information */ - double default_graphWidth; - - - - /** \brief indicates whether to use clipping (hack for printing, see print() ) */ - bool useClipping; - - - - /** \brief color of the coordinate system */ - QColor systemColor; - /*! \brief default value for property property systemColor. \see systemColor for more information */ - QColor default_systemColor; - /** \brief width of the coordinate (in pixel) */ - double systemWidth; - /*! \brief default value for property property systemWidth. \see systemWidth for more information */ - double default_systemWidth; - /** \brief color of the background*/ - QColor backgroundColor; - /*! \brief default value for property property backgroundColor. \see backgroundColor for more information */ - QColor default_backgroundColor; - /** \brief color of the background when exporting*/ - QColor exportBackgroundColor; - /*! \brief default value for property property exportBackgroundColor. \see exportBackgroundColor for more information */ - QColor default_exportBackgroundColor; - /** \brief color of the plot's background*/ - QColor plotBackgroundColor; - /*! \brief default value for property property plotBackgroundColor. \see plotBackgroundColor for more information */ - QColor default_plotBackgroundColor; - - - /** \brief indicates whether to plot a frame around the key */ - bool showKeyFrame; - /*! \brief default value for property property showKeyFrame. \see showKeyFrame for more information */ - bool default_showKeyFrame; - /** \brief color of the key frame line */ - QColor keyFrameColor; - /*! \brief default value for property property keyFrameColor. \see keyFrameColor for more information */ - QColor default_keyFrameColor; - /** \brief width of the key frame line */ - double keyFrameWidth; - /*! \brief default value for property property keyFrameWidth. \see keyFrameWidth for more information */ - double default_keyFrameWidth; - /** \brief color of the key background */ - QColor keyBackgroundColor; - /*! \brief default value for property property keyBackgroundColor. \see keyBackgroundColor for more information */ - QColor default_keyBackgroundColor; - /** \brief indicates whether to plot a key */ - bool showKey; - /*! \brief default value for property property showKey. \see showKey for more information */ - bool default_showKey; - /** \brief font face for key labels */ - QString keyFont; - /*! \brief default value for property property keyFont. \see keyFont for more information */ - QString default_keyFont; - /** \brief font size for key labels [in points] */ - double keyFontSize; - /*! \brief default value for property property keyFontSize. \see keyFontSize for more information */ - double default_keyFontSize; - /** \brief width of a key item in pt [in units of width of 'X' set in keyFont, keyFontSize] */ - double key_item_width; - /*! \brief default value for property property key_item_width. \see key_item_width for more information */ - double default_key_item_width; - /** \brief height of a key item in pt [in units of height keyFont, keyFontSize] */ - double key_item_height; - /*! \brief default value for property property key_item_height. \see key_item_height for more information */ - double default_key_item_height; - /** \brief length of the line samples in the key in pt [in units of width of 'X' set in keyFont, keyFontSize] */ - double key_line_length; - /*! \brief default value for property property key_line_length. \see key_line_length for more information */ - double default_key_line_length; - /** \brief x-distance between key frame and key content [in units of width of 'X' set in keyFont, keyFontSize] */ - double keyXMargin; - /*! \brief default value for property property keyXMargin. \see keyXMargin for more information */ - double default_keyXMargin; - /** \brief y-distance between key frame and key content [in units of width of 'x' set in keyFont, keyFontSize] */ - double keyYMargin; - /*! \brief default value for property property keyYMargin. \see keyYMargin for more information */ - double default_keyYMargin; - /** \brief x-offset of the key from the border of the plot [in units of width of 'X' set in keyFont, keyFontSize] */ - double keyXOffset; - /*! \brief default value for property property keyXOffset. \see keyXOffset for more information */ - double default_keyXOffset; - /** \brief y-offset of the key from the border of the plot [in units of width of 'x' set in keyFont, keyFontSize] */ - double keyYOffset; - /*! \brief default value for property property keyYOffset. \see keyYOffset for more information */ - double default_keyYOffset; - /** \brief distance between key line example and key text [in units of width of 'X' set in keyFont, keyFontSize] */ - double keyXSeparation; - /*! \brief default value for property property keyXSeparation. \see keyXSeparation for more information */ - double default_keyXSeparation; - /** \brief distance between two key entries [in units of height of keyFont, keyFontSize] */ - double keyYSeparation; - /*! \brief default value for property property keyYSeparation. \see keyYSeparation for more information */ - double default_keyYSeparation; - /** \brief key position */ - JKQTPKeyPosition keyPosition; - /*! \brief default value for property property keyPosition. \see keyPosition for more information */ - JKQTPKeyPosition default_keyPosition; - /** \brief the key layout */ - JKQTPKeyLayout keyLayout; - /*! \brief default value for property property keyLayout. \see keyLayout for more information */ - JKQTPKeyLayout default_keyLayout; - /** \brief determine width of the key automatically */ - bool keyAutosize; - /*! \brief default value for property property keyAutosize. \see keyAutosize for more information */ - bool default_keyAutosize; - - /** \brief the plot label text */ - QString plotLabel; - - /** \brief the plot label font name */ - QString plotLabelFontname; - /*! \brief default value for property property plotLabelFontname. \see plotLabelFontname for more information */ - QString default_plotLabelFontname; - - /** \brief the plot label font size */ - double plotLabelFontSize; - /*! \brief default value for property property plotLabelFontSize. \see plotLabelFontSize for more information */ - double default_plotLabelFontSize; - - /** \brief calculate the scaling and offset values from axis min/max values */ - void calcPlotScaling(JKQTPEnhancedPainter& painter); - - /** \brief set the standard settings (colors, line widths ...) */ - void initSettings(); - - - /** \brief specifies whether this class emits signals, like zoomChangedLocally() or beforePlotScalingRecaluclate() */ - bool emitSignals; - - /** \brief specifies whether to use antialiasing for plotting the coordinate system */ - bool useAntiAliasingForSystem; - /*! \brief default value for property property useAntiAliasingForSystem. \see useAntiAliasingForSystem for more information */ - bool default_useAntiAliasingForSystem; - - /** \brief specifies whether to use antialiasing for plotting the graphs - * - * \note You can set this property \c false to increase plotting speed of complex plots (with many graphs inside). You can reach a - * roughly three-fold speed improvement! -*/ - bool useAntiAliasingForGraphs; - /*! \brief default value for property property useAntiAliasingForGraphs. \see useAntiAliasingForGraphs for more information */ - bool default_useAntiAliasingForGraphs; - - /** \brief specifies whether to use antialiasing when drawing any text - * \note You can set this property \c false to increase plotting speed of complex plots (with many graphs inside). You can reach a - * roughly three-fold speed improvement! -*/ - bool useAntiAliasingForText; - /*! \brief default value for property property useAntiAliasingForText. \see useAntiAliasingForText for more information */ - bool default_useAntiAliasingForText; - - /** \brief multiplier which is used for font sizes when the plot is exported/printed */ - double fontSizePrintMultiplier; - - /** \brief multiplier which is used for linewidths when the plot is exported/printed */ - double lineWidthPrintMultiplier; - - /** \brief multiplier for the font size */ - double fontSizeMultiplier; - /** \brief multiplier or the line widths */ - double lineWidthMultiplier; - - /** \brief internal: used to store a list of all currently used plot styles */ - QList usedStyles; - - - /** \brief a vector that contains all graphs to be plottet in the system */ - QList graphs; - - - QList overlays; - - - /** \brief used as maximum/minimum pixel value for plotting */ - double plot_minmaxcoorinate; - - - - - /** \brief hidden default constructor */ - JKQTBasePlotter(); - - - - /** \brief paints the plot onto the given JKQTPEnhancedPainter object */ - void paintPlot(JKQTPEnhancedPainter& painter, bool drawOverlays=true); - void paintOverlays(JKQTPEnhancedPainter& painter); - /** \brief simply calls paintPlot() if grid printing mode is deactivated and prints the graph grid otherwise - * \a pageRect is used to determine the size of the page to draw on. If this does not coincide with - * the widget extents this function calculates a scaling factor so the graphs fit onto the page. This - * is especially usefull when printing! - */ - void gridPaint(JKQTPEnhancedPainter& painter, QSizeF pageRect, bool drawOverlays=true, bool scaleIfTooLarge=true, bool scaleIfTooSmall=true); - void gridPaintOverlays(JKQTPEnhancedPainter& painter, QSizeF pageRect); - - /** \brief This method goes through all registered plotters and calculates the width of every column and - * height of every row as the max over the row/column. The reults are stored in the private datamembers - * gridPrintingRows and gridPrintingColumns. gridPrintingSize will contain the size of all graphs together - * afterwards. */ - void gridPrintingCalc(); - - /** \brief plot the grid */ - void plotSystemGrid(JKQTPEnhancedPainter& painter); - /** \brief plot the x coordinate axis (incl. labels) */ - void plotSystemXAxis(JKQTPEnhancedPainter& painter); - /** \brief plot the x coordinate axis (incl. labels) */ - void plotSystemYAxis(JKQTPEnhancedPainter& painter); - /** \brief plot the graphs */ - void plotGraphs(JKQTPEnhancedPainter& painter); - /** \brief plot a key */ - void plotKey(JKQTPEnhancedPainter& painter); - /** \brief plot all overlay elements */ - void plotOverlays(JKQTPEnhancedPainter& painter); - - /** \brief plot the key contents - * - * This function does not do anything and has to be overwritten in child classes if they want to plot a key. - * The implementation should draw the contents of the key, not its frame as this is done in plotKey(). - * - * \param painter draw the key on this painter - * \param x left-most coordinate of the key [pixels] - * \param y top-most coordinate of the key [pixels] - * \param width width of the key [pixels] - * \param height height of the key [pixels] - * - * So any implementation should only draw inside the rectangle [x..x+width, y..y+hieght] - */ - void plotKeyContents(JKQTPEnhancedPainter& painter, double x, double y, double width, double height); - - /** \brief returns the size of the key (as call-by-reference parameters - * - * Any implementation of key plotting has to overwrite this function and use it to return the size of the key that would be - * plotted by plotKeyContents(). This class will use the return values to plot the frame of the key and also supply them to - * plotKeyContents(). If height or width are returned 0, no key is plotted - * - * 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 QAction which triggers saving of the plot as an image */ - QAction* actSavePlot; - /** \brief QAction which triggers saving of the data used for the plot */ - QAction* actSaveData; - /** \brief QAction which triggers copying of the data to the clipboard */ - QAction* actCopyData; - /** \brief QAction which triggers copying of the image to the clipboard */ - QAction* actCopyPixelImage; - /** \brief QAction which triggers copying of the data to the clipboard in Matlab format */ - QAction* actCopyMatlab; - /** \brief QAction which triggers the saving as PDF */ - QAction* actSavePDF; -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) - /** \brief QAction which triggers the saving as PostScript */ - QAction* actSavePS; -#endif - /** \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; - /** \brief QAction which triggers the saving as CSV (data only) */ - QAction* actSaveCSV; - /** \brief QAction which triggers zoom all */ - QAction* actZoomAll; - /** \brief QAction which triggers zoom in */ - QAction* actZoomIn; - /** \brief QAction which triggers zoom out */ - QAction* actZoomOut; - /** \brief QAction to show a table with all the plot data in the datastore */ - QAction* actShowPlotData; - /** \brief this list contains additional actions, that can be registered by registerAdditionalAction(). They are shown in the context menu only and are e.g. used to display "save image data" actions. Each action may be in a category (key of map), which is displayed as a submenu of the context-menu! */ - AdditionalActionsMap lstAdditionalPlotterActions; - /** \brief the directory in which to open SaveAs ... dialogs */ - QString currentSaveDirectory; - QString currentFileFormat; - QString currentDataFileFormat; - QString currentPrinter; - - /** \brief the master plotter for x-dimension, this plotter is connected to. */ - JKQTBasePlotter *masterPlotterX; - /** \brief the master plotter for y-dimension, this plotter is connected to. */ - JKQTBasePlotter *masterPlotterY; - /** \brief synchronize plot width with masterPlotterX */ - bool masterSynchronizeWidth; - /** \brief synchronize plot height with masterPlotterY */ - bool masterSynchronizeHeight; - - - /** \brief controls, whether the signals plotUpdated() and overlaysUpdated() are emitted */ - bool emitPlotSignals; - - - void printpreview(QPrinter* p, bool setabsolutesize=false); - bool printpreviewNew(QPaintDevice* paintDevice, bool setAbsolutePaperSize=false, double printsizeX_inMM=-1.0, double printsizeY_inMM=-1.0, bool displayPreview=true); - bool exportpreview(QSizeF pageSize, bool unitIsMM=false); - - /*! \brief sets the property fontSizeMultiplier ( \copybrief fontSizeMultiplier ) to the specified \a __value. - \details Description of the parameter fontSizeMultiplier is:
    \copydoc fontSizeMultiplier
    - \see fontSizeMultiplier for more information */ - inline void setFontSizeMultiplier(double __value) - { - this->fontSizeMultiplier = __value; - } - /*! \brief sets the property lineWidthMultiplier ( \copybrief lineWidthMultiplier ) to the specified \a __value. - \details Description of the parameter lineWidthMultiplier is:
    \copydoc lineWidthMultiplier
    - \see lineWidthMultiplier for more information */ - inline void setLineWidthMultiplier(double __value) - { - this->lineWidthMultiplier = __value; - } - /*! \brief sets the property printMagnification ( \copybrief printMagnification ) to the specified \a __value. - \details Description of the parameter printMagnification is:
    \copydoc printMagnification
    - \see printMagnification for more information */ - inline void setPrintMagnification(double __value) - { - this->printMagnification = __value; - } - /*! \brief returns the property printMagnification ( \copybrief printMagnification ). - \details Description of the parameter printMagnification is:
    \copydoc printMagnification
    - \see printMagnification for more information */ - inline double getPrintMagnification() const - { - return this->printMagnification; - } - /*! \brief sets the property paintMagnification ( \copybrief paintMagnification ) to the specified \a __value. - \details Description of the parameter paintMagnification is:
    \copydoc paintMagnification
    - \see paintMagnification for more information */ - inline void setPaintMagnification(double __value) - { - this->paintMagnification = __value; - } - /*! \brief returns the property paintMagnification ( \copybrief paintMagnification ). - \details Description of the parameter paintMagnification is:
    \copydoc paintMagnification
    - \see paintMagnification for more information */ - inline double getPaintMagnification() const - { - return this->paintMagnification; - } - - QListWidget* dataColumnsListWidget; - QComboBox* dataColumnsCombobox; - QSet getDataColumnsByUser(); - QMap getDataColumnsByUserSaved; - - - private: - double printZoomFactor; - double printSizeX_Millimeter; - double printSizeY_Millimeter; - double printMagnification; - QPointer printPreview; - QPointer spinSizeX; - QPointer spinSizeY; - QPointer exportPreviewLabel; - QPointer spinMagnification; - bool printSetAbsolutePageSize; - bool printSetAbsolutePlotSize; - bool printKeepAbsoluteFontSizes; - bool printScaleToPagesize; - double printAspect; - bool printKeepAspect; - bool exportUnitInMM; - QSizeF printPageSizeMM; - bool printDoUpdate; - - - - - - - protected slots: - void updatePreviewLabel(); - void printpreviewPaintRequested(QPrinter *printer); - void printpreviewPaintRequestedNew(QPrinter *printer); - void printpreviewPaintRequestedNew(QPaintDevice *paintDevice); - void exportpreviewPaintRequested(JKQTPEnhancedPainter& painter, QSize size); - void printpreviewSetZoom(double value); - void printpreviewSetSizeX(double value); - void printpreviewSetSizeY(double value); - void printpreviewSetSizeXNew(double value); - void printpreviewSetSizeYNew(double value); - void printpreviewSetMagnification(double value); - void printpreviewSetMagnificationNew(double value); - void printpreviewSetAspectRatio(bool checked); - void printpreviewSetKeepAbsFontsize(bool checked); - void printpreviewToggleMagnification(bool checked); - void printpreviewSetLineWidthMultiplier(double value); - void printpreviewSetFontSizeMultiplier(double value); - void printpreviewUpdate(); - void getDataColumnsByUserCheckAll(); - void getDataColumnsByUserCheckNone(); - void getDataColumnsByUserSave(); - void getDataColumnsByUserComboBoxSelected(const QString& name); - void getDataColumnsByUserItemChanged(QListWidgetItem* widgetitem); - void showPlotData(); - /** \brief may be connected to zoomChangedLocally() of a different plot and synchronizes the local x-axis to the other x-axis */ - void synchronizeXAxis(double newxmin, double newxmax, double newymin, double newymax, JKQTBasePlotter* sender); - /** \brief may be connected to zoomChangedLocally() of a different plot and synchronizes the local y-axis to the other y-axis */ - void synchronizeYAxis(double newxmin, double newxmax, double newymin, double newymax, JKQTBasePlotter* sender); - /** \brief may be connected to zoomChangedLocally() of a different plot and synchronizes the local x- and y-axis to the other x- and y-axis */ - void synchronizeXYAxis(double newxmin, double newxmax, double newymin, double newymax, JKQTBasePlotter* sender); - - public slots: - - - - - /** \brief sets x/ymin and x/ymax to the supplied values and replots the graph (zoom operation!) */ - void zoom(double nxmin, double nxmax, double nymin, double nymax); - - /** \brief sets whether to plot grid lines or not */ - void setGrid(bool val); - - /** \brief save the current plot as a pixel image image (PNG ...), if filename is empty a file selection dialog is displayed */ - void saveAsPixelImage(const QString& filename=QString(""), bool displayPreview=true, const QByteArray &outputFormat=QByteArray()); - - /** \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 */ - 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 */ - void saveAsPDF(const QString& filename=QString(""), bool displayPreview=true); - - /** \brief save the current plot as a PS file, with the current widget aspect ratio, if filename is empty a file selection dialog is displayed */ - void saveAsPS(const QString& filename=QString(""), bool displayPreview=true); - - /** \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, ...) */ - void saveImage(const QString& filename=QString(""), bool displayPreview=true); - - /** \brief save the data used for the current plot. The file format is extracted from the file extension (csv, ...) - * - * The parameter \a format specifies the export format. if it is empty the format will be choosen according to the file extension, or - * if \a filename is also empty the format will be choosen according to what is selected in the file selection dialog. - * - * If \a format is \c "slk" the output will be in SYLK format, if \a format is \c "csv" or \a "dat" the output will be comma separated values - * and if \a format is \c "txt" the output will be tab separated values. - */ - void saveData(const QString& filename=QString(""), const QString& jkqtp_format=QString("")); - /** \brief copy the data used for the current plot to the clipboard - * - * copies data as tab separated data with the system-decimal point. - */ - void copyData(); - /** \brief copy the data used for the current plot to the clipboard in Matlab format - */ - void copyDataMatlab(); - /** \brief save the current plot data as a Comma Separated Values (CSV) file*/ - void saveAsCSV(const QString& filename=QString("")); - - /** \brief save the current plot data as a DIF file*/ - void saveAsDIF(const QString& filename=QString("")); - - /** \brief save the current plot data as a SYLK spreadsheet file*/ - void saveAsSYLK(const QString& filename=QString("")); - - /** \brief save the current plot data as a Matlab Script*/ - void saveAsMatlab(const QString& filename=QString("")); - - /** \brief save the current plot data as a Semicolon Separated Values (SSV) file*/ - void saveAsSemicolonSV(const QString& filename=QString("")); - - /** \brief save the current plot data as a Tabulator Separated Values (CSV) file*/ - void saveAsTabSV(const QString& filename=QString("")); - - /** \brief save the current plot data as a Semicolon Separated Values (CSV) file for german Excel, i.e. with comma as decimal separator*/ - void saveAsGerExcelCSV(const QString& filename=QString("")); - - /** \brief print the current plot, if printer is \c nullptr a printer selection dialog is displayed */ - void print(QPrinter* printer=nullptr, bool displayPreview=true); - - /** \brief this method zooms the graph so that all plotted datapoints are visible. - * - * \param zoomX if set \c true (default) zooms the x axis - * \param zoomY if set \c true (default) zooms the y axis - * \param includeX0 if this is \c true zoomToFit() will ensure that \f$ x=0 \f$ is visible in the plot (only for non-logx plots, default: false) - * \param includeY0 if this is \c true zoomToFit() will ensure that \f$ y=0 \f$ is visible in the plot (only for non-logy plots, default: false) - * \param scaleX the plot will have a width of \f$ \mbox{Xscale}\cdot\Delta x \f$ where \f$ \Delta x \f$ is the actual x-axis data range - * For logx plots we actually use this on the logarithmized data! (default: 1.05) - * \param scaleY the plot will have a height of \f$ \mbox{Yscale}\cdot\Delta < \f$ where \f$ \Delta < \f$ is the actual <-axis data range - * For log< plots we actually use this on the logarithmized data! (default: 1.05) - * - */ - void zoomToFit(bool zoomX=true, bool zoomY=true, bool includeX0=false, bool includeY0=false, double scaleX=1.05, double scaleY=1.05); - - /** \brief zooms into the graph (the same as turning the mouse wheel) by the given factor */ - void zoomIn(double factor=2.0); - /** \brief zooms out of the graph (the same as turning the mouse wheel) by the given factor */ - void zoomOut(double factor=2.0) { - zoomIn(1.0/factor); - } - - /** \brief en-/disables the maintaining of the data aspect ratio */ - void setMaintainAspectRatio(bool value) { - maintainAspectRatio=value; - redrawPlot(); - } - - /** \brief en-/disables the maintaining of the axis aspect ratio */ - void setMaintainAxisAspectRatio(bool value) { - maintainAxisAspectRatio=value; - redrawPlot(); - } - - void setUserSettigsFilename(const QString& filename, const QString& prefix); - void setUserSettigsFilename(const QString& filename); - void setUserSettigsPrefix(const QString& prefix); - QString getUserSettigsFilename() const; - QString getUserSettigsPrefix() const; - - /** \brief set all graphs invisible, except i */ - void setOnlyGraphVisible(int i); - /** \brief set all graphs invisible, except graph start, start+n, start+2*n, ... */ - void setOnlyNthGraphsVisible(int start, int n); - - /** \brief saves the plot user properties if userSettingsFilename is set, does nothing otherwise */ - void loadUserSettings(); - - /** \brief saves the plot user properties if userSettingsFilename is set, does nothing otherwise */ - void saveUserSettings() const; - public: /** \brief class constructor * * if \a datastore_internal is \c true then the constructor will create an internal datastore object. The datastore * will be managed (freed) by this class. If \a datastore_internal is \c false the class will use tha datastore provided * in \a datast as an external datastore. You can modify this later by using useInternalDatastore() and useExternalDatastore(). */ - JKQTBasePlotter(bool datastore_internal, QObject* parent=nullptr, JKQTPDatastore* datast=nullptr); + explicit JKQTBasePlotter(bool datastore_internal, QObject* parent=nullptr, JKQTPDatastore* datast=nullptr); + + JKQTBasePlotter()=delete; /** \brief class destructor */ virtual ~JKQTBasePlotter(); @@ -1048,61 +411,70 @@ class JKQTP_LIB_EXPORT JKQTBasePlotter: public QObject { void setEmittingSignalsEnabled(bool enabled); - /** \brief loads the plot properties from a QSettings object */ - void loadSettings(const QSettings& settings, const QString& group=QString("plots")); + /** \brief loads all the plot properties from a QSettings object */ + void loadSettings(const QSettings& settings, const QString& group=QString("plots/")); - /** \brief saves the plot properties into a QSettings object. + /** \brief saves the plot properties into a QSettings object. * * This method only saves those properties that differ from their default value. */ - void saveSettings(QSettings& settings, const QString& group=QString("plots")) const; + void saveSettings(QSettings& settings, const QString& group=QString("plots/")) const; + + + /** \brief current style properties for this JKQTBasePlotter + * + * \see JKQTPSetSystemDefaultBaseStyle(), JKQTPSetSystemDefaultBaseStyle(), getCurrentPlotterStyle(), \ref jkqtpplotter_styling + */ + const JKQTBasePlotterStyle& getCurrentPlotterStyle() const; + + /** \brief replace the current style properties for this JKQTBasePlotter + * + * \see JKQTPSetSystemDefaultBaseStyle(), JKQTPSetSystemDefaultBaseStyle(), getCurrentPlotterStyle(), \ref jkqtpplotter_styling + */ + void setCurrentPlotterStyle(const JKQTBasePlotterStyle& style); + /** \brief replace the current style properties for this JKQTBasePlotter with properties loaded from \a settings + * + * \param settings the QSettings object to read from + * \param group group in \a settings to read from + * + * \see JKQTPSetSystemDefaultBaseStyle(), JKQTPSetSystemDefaultBaseStyle(), getCurrentPlotterStyle(), \ref jkqtpplotter_styling + */ + void loadCurrentPlotterStyle(const QSettings& settings, const QString& group="plot/"); + /** \brief store the current style properties for this JKQTBasePlotter with properties loaded from \a settings + * + * \param settings the QSettings object to write to + * \param group group in \a settings to write to + * + * \see JKQTPSetSystemDefaultBaseStyle(), JKQTPSetSystemDefaultBaseStyle(), getCurrentPlotterStyle(), \ref jkqtpplotter_styling + */ + void saveCurrentPlotterStyle(QSettings& settings, const QString& group="plot/") const; - /** \brief loads the plot user properties from a QSettings object */ - void loadUserSettings(const QSettings& settings, const QString& group=QString("plots_user")); + /** \brief loads the plot user properties from a QSettings object */ + void loadUserSettings(const QSettings& settings, const QString& group=QString("plots_user/")); - /** \brief saves the plot user properties into a QSettings object. */ - void saveUserSettings(QSettings& settings, const QString& group=QString("plots_user")) const; - - /** \brief sets the width of the plot widget */ - void setWidth(int wid); - - /** \brief resize the plot */ - void resize(int width, int height); + /** \brief saves the plot user properties into a QSettings object. */ + void saveUserSettings(QSettings& settings, const QString& group=QString("plots_user/")) const; /** \brief gets the width of the plot widget */ - inline int getWidth() {return widgetWidth; } + int getWidth(); /** \brief gets the width of the plot widget */ - inline int getHeight() {return widgetHeight; } + int getHeight(); - /** \brief sets the width of the plot widget */ - void setHeight(int heigh); - - /** \brief sets the borders of the plot, see also getPlotBorderTop(), plotBorderBottom(), plotBorderLeft(), plotBorderRight() */ - void setBorder(int left, int right, int top, int bottom); - - /** \brief sets minimum and maximum x-value to plot */ - void setX(double xminn, double xmaxx); - - /** \brief sets minimum and maximum y-value to plot */ - void setY(double yminn, double ymaxx); - - /** \brief sets minimum and maximum x- and y-values to plot */ - void setXY(double xminn, double xmaxx, double yminn, double ymaxx); /** \brief returns the current x-axis min */ - inline double getXMin() const {return xAxis->getMin(); } + double getXMin() const; /** \brief returns the current x-axis max */ - inline double getXMax() const {return xAxis->getMax(); } + double getXMax() const; /** \brief returns the current y-axis min */ - inline double getYMin() const {return yAxis->getMin(); } + double getYMin() const; /** \brief returns the current y-axis max */ - inline double getYMax() const {return yAxis->getMax(); } + double getYMax() const; @@ -1145,47 +517,24 @@ class JKQTP_LIB_EXPORT JKQTBasePlotter: public QObject { return mm2px(mm, painter.device()->logicalDpiX()); } - /** \brief sets absolute minimum and maximum x-value to plot - * \note if the aspect ration of this does not fit into the widget, it is possible that you don't see the complete contents! - */ - void setAbsoluteX(double xminn, double xmaxx); - - /** \brief sets absolute minimum and maximum y-value to plot - * \note if the aspect ration of this does not fit into the widget, it is possible that you don't see the complete contents! - */ - void setAbsoluteY(double yminn, double ymaxx); - - /** \brief sets absolute minimum and maximum x- and y-values to plot - * \note if the aspect ration of this does not fit into the widget, it is possible that you don't see the complete contents! - */ - void setAbsoluteXY(double xminn, double xmaxx, double yminn, double ymaxx); - /** \brief returns the absolute x-axis min */ - inline double getAbsoluteXMin() const {return xAxis->getAbsoluteMin(); } + double getAbsoluteXMin() const; /** \brief returns the absolute x-axis max */ - inline double getAbsoluteXMax() const {return xAxis->getAbsoluteMax(); } + double getAbsoluteXMax() const; /** \brief returns the absolute y-axis min */ - inline double getAbsoluteYMin() const {return yAxis->getAbsoluteMin(); } + double getAbsoluteYMin() const; /** \brief returns the absolute y-axis max */ - inline double getAbsoluteYMax() const {return yAxis->getAbsoluteMax(); } + double getAbsoluteYMax() const; /** \brief add a new plotter for grid printing mode */ - inline void addGridPrintingPlotter(size_t x, size_t y, JKQTBasePlotter* plotter) { - JKQTPGridPrintingItem i; - i.x=x; - i.y=y; - i.plotter=plotter; - gridPrintingList.push_back(i); - } + void addGridPrintingPlotter(size_t x, size_t y, JKQTBasePlotter* plotter); /** \brief clear all additional plotters for grid printing mode */ - inline void clearGridPrintingPlotters() { - gridPrintingList.clear(); - } + void clearGridPrintingPlotters(); /** \brief return x-pixel coordinate from time coordinate */ inline double x2p(double x) const { @@ -1211,21 +560,55 @@ class JKQTP_LIB_EXPORT JKQTBasePlotter: public QObject { int getNextStyle(); - /** \brief represents a pen, when plotting in JKQTPlotter/JKQTBasePlotter - * \ingroup jkqtpplotterclasses_tools - */ - struct JKQTPPen { - QColor m_color; - double m_width; - Qt::PenStyle m_style; - void setWidthF(double w) { m_width=w; } - void setWidth(double w) { m_width=w; } - double width() const { return m_width; } - double widthF() const { return m_width; } - QColor color() const { return m_color; } - void setColor(const QColor& col) {m_color=col; } - Qt::PenStyle style() const { return m_style; } - void setStyle(Qt::PenStyle s) { m_style=s; } + /** \brief represents a pen, when plotting in JKQTPlotter/JKQTBasePlotter + * \ingroup jkqtpplotterclasses_tools + * + * \see getPlotStyle() + */ + class JKQTP_LIB_EXPORT JKQTPPen { + protected: + QColor m_color; + QColor m_fillColor; + QColor m_errorColor; + QColor m_errorFillColor; + double m_width; + double m_errorWidth; + double m_symbolLineWidth; + Qt::PenStyle m_style; + double m_symbolSize; + Qt::BrushStyle m_fillStyle; + Qt::BrushStyle m_errorFillStyle; + JKQTPGraphSymbols m_symbol; + + public: + JKQTPPen(); + void setSymbolSize(double w); + void setSymbolLineWidthF(double w); + void setWidthF(double w); + void setWidth(double w); + void setErrorWidth(double w); + double width() const; + double widthF() const; + double errorWidthF() const; + double symbolLineWidthF() const; + double symbolSize() const; + QColor color() const; + QColor errorColor() const; + QColor errorFillColor() const; + void setColor(const QColor& col); + Qt::PenStyle style() const; + Qt::PenStyle errorStyle() const; + void setStyle(Qt::PenStyle s); + QColor fillColor() const; + void setFillColor(const QColor& col); + void setErrorFillColor(const QColor& col); + void setErrorColor(const QColor& col); + void setFillStyle(Qt::BrushStyle s); + void setErrorFillStyle(Qt::BrushStyle s); + Qt::BrushStyle fillStyle() const; + Qt::BrushStyle errorFillStyle() const; + JKQTPGraphSymbols symbol() const; + void setSymbol(JKQTPGraphSymbols symbol); }; @@ -1236,7 +619,7 @@ class JKQTP_LIB_EXPORT JKQTBasePlotter: public QObject { \param painter JKQTPEnhancedPainter to which the plot should be drawn \param rect rectangle to plot into */ - void draw(JKQTPEnhancedPainter& painter, const QRect& rect, bool drawOverlays=true); + void draw(JKQTPEnhancedPainter& painter, const QRect& rect, bool showOverlays=true); /*! \brief draw the contained graph (including grid prints) into the given JKQTPEnhancedPainter \param painter JKQTPEnhancedPainter to which the plot should be drawn @@ -1248,19 +631,19 @@ class JKQTP_LIB_EXPORT JKQTBasePlotter: public QObject { \param painter JKQTPEnhancedPainter to which the plot should be drawn \param pos where to plot the painter (left-top corner) */ - void draw(JKQTPEnhancedPainter& painter, const QPoint& pos=QPoint(0,0), bool drawOverlays=true); + void draw(JKQTPEnhancedPainter& painter, const QPoint& pos=QPoint(0,0), bool showOverlays=true); /*! \brief draw the contained graph (including grid prints) into the given JKQTPEnhancedPainter \param painter JKQTPEnhancedPainter to which the plot should be drawn \param rect rectangle to plot into */ - void drawNonGrid(JKQTPEnhancedPainter& painter, const QRect& rect, bool drawOverlays=true); + void drawNonGrid(JKQTPEnhancedPainter& painter, const QRect& rect, bool showOverlays=true); /*! \brief draw the contained graph (including grid prints) into the given JKQTPEnhancedPainter \param painter JKQTPEnhancedPainter to which the plot should be drawn \param pos where to plot the painter (left-top corner) */ - void drawNonGrid(JKQTPEnhancedPainter& painter, const QPoint& pos=QPoint(0,0), bool drawOverlays=true); + void drawNonGrid(JKQTPEnhancedPainter& painter, const QPoint& pos=QPoint(0,0), bool showOverlays=true); void drawNonGridOverlays(JKQTPEnhancedPainter &painter, const QPoint& pos=QPoint(0,0)); /** \brief emit plotUpdated() */ @@ -1271,570 +654,111 @@ class JKQTP_LIB_EXPORT JKQTBasePlotter: public QObject { /** \brief returns, whether the signals plotUpdated() and overlaysUpdated() are emitted */ bool isEmittingPlotSignalsEnabled() const; - /*! \brief returns the property plotBorderTop ( \copybrief plotBorderTop ). \details Description of the parameter plotBorderTop is:
    \copydoc plotBorderTop
    . \see plotBorderTop for more information */ - inline int getPlotBorderTop() const { return this->plotBorderTop; } - /*! \brief returns the property plotBorderLeft ( \copybrief plotBorderLeft ). \details Description of the parameter plotBorderLeft is:
    \copydoc plotBorderLeft
    . \see plotBorderLeft for more information */ - inline int getPlotBorderLeft() const { return this->plotBorderLeft; } - /*! \brief returns the property plotBorderBottom ( \copybrief plotBorderBottom ). \details Description of the parameter plotBorderBottom is:
    \copydoc plotBorderBottom
    . \see plotBorderBottom for more information */ - inline int getPlotBorderBottom() const { return this->plotBorderBottom; } - /*! \brief returns the property plotBorderRight ( \copybrief plotBorderRight ). \details Description of the parameter plotBorderRight is:
    \copydoc plotBorderRight
    . \see plotBorderRight for more information */ - inline int getPlotBorderRight() const { return this->plotBorderRight; } + /** \copydoc JKQTBasePlotterStyle::plotBorderTop */ + int getPlotBorderTop() const; + /** \copydoc JKQTBasePlotterStyle::plotBorderLeft */ + int getPlotBorderLeft() const; + /** \copydoc JKQTBasePlotterStyle::plotBorderBottom */ + int getPlotBorderBottom() const; + /** \copydoc JKQTBasePlotterStyle::plotBorderRight */ + int getPlotBorderRight() const; - /*! \brief returns the property maintainAspectRatio ( \copybrief maintainAspectRatio ). \details Description of the parameter maintainAspectRatio is:
    \copydoc maintainAspectRatio
    . \see maintainAspectRatio for more information */ - inline bool doesMaintainAspectRatio() const { return this->maintainAspectRatio; } - /*! \brief sets the property aspectRatio ( \copybrief aspectRatio ) to the specified \a __value. - \details Description of the parameter aspectRatio is:
    \copydoc aspectRatio
    - \see aspectRatio for more information */ - inline void setAspectRatio(double __value) - { - if (this->aspectRatio != __value) { - this->aspectRatio = __value; - redrawPlot(); - } - } - /*! \brief returns the property aspectRatio ( \copybrief aspectRatio ). - \details Description of the parameter aspectRatio is:
    \copydoc aspectRatio
    - \see aspectRatio for more information */ - inline double getAspectRatio() const - { - return this->aspectRatio; - } + /** \brief returns whether the maintaining of the data aspect ratio is enabled or disabled */ + bool doesMaintainAspectRatio() const; + /** \brief returns the data aspect ratio, enforced with setMaintainApsectRatio(true) */ + double getAspectRatio() const; - /*! \brief returns the property maintainAxisAspectRatio ( \copybrief maintainAxisAspectRatio ). \details Description of the parameter maintainAxisAspectRatio is:
    \copydoc maintainAxisAspectRatio
    . \see maintainAxisAspectRatio for more information */ - inline bool doesMaintainAxisAspectRatio() const { return this->maintainAxisAspectRatio; } - /*! \brief sets the property axisAspectRatio ( \copybrief axisAspectRatio ) to the specified \a __value. - \details Description of the parameter axisAspectRatio is:
    \copydoc axisAspectRatio
    - \see axisAspectRatio for more information */ - inline void setAxisAspectRatio(double __value) - { - if (this->axisAspectRatio != __value) { - this->axisAspectRatio = __value; - redrawPlot(); - } - } - /*! \brief returns the property axisAspectRatio ( \copybrief axisAspectRatio ). - \details Description of the parameter axisAspectRatio is:
    \copydoc axisAspectRatio
    - \see axisAspectRatio for more information */ - inline double getAxisAspectRatio() const - { - return this->axisAspectRatio; - } + /** \brief returns whether the maintaining of the axis aspect ratio is enabled or disabled */ + bool doesMaintainAxisAspectRatio() const; + /** \brief returns the axis aspect ratio, enforced with setMaintainAxisApsectRatio(true) */ + double getAxisAspectRatio() const; + /** \copydoc JKQTBasePlotterStyle::useAntiAliasingForSystem */ + bool isUsingAntiAliasingForSystem() const; + /** \copydoc JKQTBasePlotterStyle::useAntiAliasingForGraphs */ + bool isUsingAntiAliasingForGraphs() const; + /** \copydoc JKQTBasePlotterStyle::useAntiAliasingForText */ + bool isUsingAntiAliasingForText() const; + /** \copydoc JKQTBasePlotterStyle:defaultGraphWidth: */ + double getGraphWidth() const; + /** \copydoc JKQTBasePlotterStyle::widgetBackgroundColor */ + QColor getBackgroundColor() const; + /** \copydoc JKQTBasePlotterStyle::exportBackgroundColor */ + QColor getExportBackgroundColor() const; + /** \copydoc JKQTBasePlotterStyle::plotBackgroundColor */ + QColor getPlotBackgroundColor() const; + /*! \copydoc JKQTPKeyStyle::fontSize */ + double getKeyFontSize() const; + /*! \copydoc JKQTPKeyStyle::itemWidth */ + double getKeyItemWidth() const; + /*! \copydoc JKQTPKeyStyle::itemHeight */ + double getKeyItemHeight() const; + /*! \copydoc JKQTPKeyStyle::ySeparation */ + double getKeyYSeparation() const; + /*! \copydoc JKQTPKeyStyle::sampleLineLength */ + double getKeyLineLength() const; + /*! \copydoc JKQTPKeyStyle::xMargin */ + double getKeyXMargin() const; + /*! \copydoc JKQTPKeyStyle::yMargin */ + double getKeyYMargin() const; + /*! \copydoc JKQTPKeyStyle::xSeparation */ + double getKeyXSeparation() const; + /*! \copydoc JKQTPKeyStyle::xOffset */ + double getKeyXOffset() const; + /*! \copydoc JKQTPKeyStyle::yOffset */ + double getKeyYOffset() const; + /*! \copydoc JKQTPKeyStyle::visible */ + bool getShowKey() const; + /*! \copydoc JKQTPKeyStyle::frameVisible */ + bool getShowKeyFrame() const; + /*! \copydoc JKQTPKeyStyle::frameColor */ + QColor getKeyFrameColor() const; + /*! \copydoc JKQTPKeyStyle::backgroundColor */ + QColor getKeyBackgroundColor() const; + /*! \copydoc JKQTPKeyStyle::textColor */ + QColor getKeyTextColor() const; + /*! \copydoc JKQTPKeyStyle::frameWidth */ + double getKeyFrameWidth() const; + /*! \copydoc JKQTPKeyStyle::frameRounding */ + double getKeyFrameRounding() const; + /*! \copydoc JKQTPKeyStyle::autosize */ + bool getKeyAutosize() const; + /*! \copydoc JKQTPKeyStyle::position */ + JKQTPKeyPosition getKeyPosition() const; + /*! \copydoc JKQTPKeyStyle::layout */ + JKQTPKeyLayout getKeyLayout() const; + /*! \copydoc JKQTBasePlotterStyle::defaultTextColor */ + QColor getDefaultTextColor() const; + /*! \copydoc JKQTBasePlotterStyle::defaultFontSize */ + double getDefaultTextSize() const; + /*! \copydoc JKQTBasePlotterStyle::defaultFontName */ + QString getDefaultTextFontName() const; + /** \brief if set \c true (default: \c false ) the JKQTBasePlotter draws colored rectangles to indicate the different regions in the plot (border, axes, ...) + * + * \see JKQTBasePlotterStyle::debugShowRegionBoxes, enableDebugShowRegionBoxes() + */ + bool isDebugShowRegionBoxesEnabled() const; + /*! \copydoc JKQTBasePlotterStyle::plotFrameVisible */ + bool isPlotFrameVisible() const; + /*! \copydoc JKQTBasePlotterStyle::plotFrameColor */ + QColor getPlotFrameColor() const; + /*! \copydoc JKQTBasePlotterStyle::plotFrameWidth */ + double getPlotFrameWidth() const; + /*! \copydoc JKQTBasePlotterStyle::plotFrameRounding */ + double getPlotFrameRounding() const; - /*! \brief sets the property useAntiAliasingForSystem ( \copybrief useAntiAliasingForSystem ) to the specified \a __value. - \details Description of the parameter useAntiAliasingForSystem is:
    \copydoc useAntiAliasingForSystem
    - \see useAntiAliasingForSystem for more information */ - inline void setUseAntiAliasingForSystem(bool __value) - { - if (this->useAntiAliasingForSystem != __value) { - this->useAntiAliasingForSystem = __value; - redrawPlot(); - } - } - /*! \brief returns the property useAntiAliasingForSystem ( \copybrief useAntiAliasingForSystem ). - \details Description of the parameter useAntiAliasingForSystem is:
    \copydoc useAntiAliasingForSystem
    - \see useAntiAliasingForSystem for more information */ - inline bool isUsingAntiAliasingForSystem() const - { - return this->useAntiAliasingForSystem; - } - /*! \brief sets the property useAntiAliasingForGraphs ( \copybrief useAntiAliasingForGraphs ) to the specified \a __value. - \details Description of the parameter useAntiAliasingForGraphs is:
    \copydoc useAntiAliasingForGraphs
    - \see useAntiAliasingForGraphs for more information */ - inline void setUseAntiAliasingForGraphs(bool __value) - { - if (this->useAntiAliasingForGraphs != __value) { - this->useAntiAliasingForGraphs = __value; - redrawPlot(); - } - } - /*! \brief returns the property useAntiAliasingForGraphs ( \copybrief useAntiAliasingForGraphs ). - \details Description of the parameter useAntiAliasingForGraphs is:
    \copydoc useAntiAliasingForGraphs
    - \see useAntiAliasingForGraphs for more information */ - inline bool isUsingAntiAliasingForGraphs() const - { - return this->useAntiAliasingForGraphs; - } - /*! \brief sets the property useAntiAliasingForText ( \copybrief useAntiAliasingForText ) to the specified \a __value. - \details Description of the parameter useAntiAliasingForText is:
    \copydoc useAntiAliasingForText
    - \see useAntiAliasingForText for more information */ - inline void setUseAntiAliasingForText(bool __value) - { - if (this->useAntiAliasingForText != __value) { - this->useAntiAliasingForText = __value; - redrawPlot(); - } - } - /*! \brief returns the property useAntiAliasingForText ( \copybrief useAntiAliasingForText ). - \details Description of the parameter useAntiAliasingForText is:
    \copydoc useAntiAliasingForText
    - \see useAntiAliasingForText for more information */ - inline bool isUsingAntiAliasingForText() const - { - return this->useAntiAliasingForText; - } - - /*! \brief sets the property graphColor ( \copybrief graphColor ) to the specified \a __value. - \details Description of the parameter graphColor is:
    \copydoc graphColor
    - \see graphColor for more information */ - inline void setGraphColor(const QColor & __value) - { - if (this->graphColor != __value) { - this->graphColor = __value; - redrawPlot(); - } - } - /*! \brief returns the property graphColor ( \copybrief graphColor ). - \details Description of the parameter graphColor is:
    \copydoc graphColor
    - \see graphColor for more information */ - inline QColor getGraphColor() const - { - return this->graphColor; - } - /*! \brief sets the property graphWidth ( \copybrief graphWidth ) to the specified \a __value. - \details Description of the parameter graphWidth is:
    \copydoc graphWidth
    - \see graphWidth for more information */ - inline void setGraphWidth(double __value) - { - if (this->graphWidth != __value) { - this->graphWidth = __value; - redrawPlot(); - } - } - /*! \brief returns the property graphWidth ( \copybrief graphWidth ). - \details Description of the parameter graphWidth is:
    \copydoc graphWidth
    - \see graphWidth for more information */ - inline double getGraphWidth() const - { - return this->graphWidth; - } - - /*! \brief sets the property backgroundColor ( \copybrief backgroundColor ) to the specified \a __value. - \details Description of the parameter backgroundColor is:
    \copydoc backgroundColor
    - \see backgroundColor for more information */ - inline void setBackgroundColor(const QColor & __value) - { - if (this->backgroundColor != __value) { - this->backgroundColor = __value; - redrawPlot(); - } - } - /*! \brief returns the property backgroundColor ( \copybrief backgroundColor ). - \details Description of the parameter backgroundColor is:
    \copydoc backgroundColor
    - \see backgroundColor for more information */ - inline QColor getBackgroundColor() const - { - return this->backgroundColor; - } - /*! \brief sets the property exportBackgroundColor ( \copybrief exportBackgroundColor ) to the specified \a __value. - \details Description of the parameter exportBackgroundColor is:
    \copydoc exportBackgroundColor
    - \see exportBackgroundColor for more information */ - inline void setExportBackgroundColor(const QColor & __value) - { - if (this->exportBackgroundColor != __value) { - this->exportBackgroundColor = __value; - redrawPlot(); - } - } - /*! \brief returns the property exportBackgroundColor ( \copybrief exportBackgroundColor ). - \details Description of the parameter exportBackgroundColor is:
    \copydoc exportBackgroundColor
    - \see exportBackgroundColor for more information */ - inline QColor getExportBackgroundColor() const - { - return this->exportBackgroundColor; - } - /*! \brief sets the property plotBackgroundColor ( \copybrief plotBackgroundColor ) to the specified \a __value. - \details Description of the parameter plotBackgroundColor is:
    \copydoc plotBackgroundColor
    - \see plotBackgroundColor for more information */ - inline void setPlotBackgroundColor(const QColor & __value) - { - if (this->plotBackgroundColor != __value) { - this->plotBackgroundColor = __value; - redrawPlot(); - } - } - /*! \brief returns the property plotBackgroundColor ( \copybrief plotBackgroundColor ). - \details Description of the parameter plotBackgroundColor is:
    \copydoc plotBackgroundColor
    - \see plotBackgroundColor for more information */ - inline QColor getPlotBackgroundColor() const - { - return this->plotBackgroundColor; - } - - /*! \brief sets the property keyFont ( \copybrief keyFont ) to the specified \a __value. - \details Description of the parameter keyFont is:
    \copydoc keyFont
    - \see keyFont for more information */ - inline void setKeyFont(const QString & __value) - { - if (this->keyFont != __value) { - this->keyFont = __value; - redrawPlot(); - } - } - /*! \brief returns the property keyFont ( \copybrief keyFont ). - \details Description of the parameter keyFont is:
    \copydoc keyFont
    - \see keyFont for more information */ - inline QString getKeyFont() const - { - return this->keyFont; - } - /*! \brief sets the property keyFontSize ( \copybrief keyFontSize ) to the specified \a __value. - \details Description of the parameter keyFontSize is:
    \copydoc keyFontSize
    - \see keyFontSize for more information */ - inline void setKeyFontSize(double __value) - { - if (this->keyFontSize != __value) { - this->keyFontSize = __value; - redrawPlot(); - } - } - /*! \brief returns the property keyFontSize ( \copybrief keyFontSize ). - \details Description of the parameter keyFontSize is:
    \copydoc keyFontSize
    - \see keyFontSize for more information */ - inline double getKeyFontSize() const - { - return this->keyFontSize; - } - /*! \brief sets the property key_item_width ( \copybrief key_item_width ) to the specified \a __value. - \details Description of the parameter key_item_width is:
    \copydoc key_item_width
    - \see key_item_width for more information */ - inline void setKeyItemWidth(double __value) - { - if (this->key_item_width != __value) { - this->key_item_width = __value; - redrawPlot(); - } - } - /*! \brief returns the property key_item_width ( \copybrief key_item_width ). - \details Description of the parameter key_item_width is:
    \copydoc key_item_width
    - \see key_item_width for more information */ - inline double getKeyItemWidth() const - { - return this->key_item_width; - } - /*! \brief sets the property key_item_height ( \copybrief key_item_height ) to the specified \a __value. - \details Description of the parameter key_item_height is:
    \copydoc key_item_height
    - \see key_item_height for more information */ - inline void setKeyItemHeight(double __value) - { - if (this->key_item_height != __value) { - this->key_item_height = __value; - redrawPlot(); - } - } - /*! \brief returns the property key_item_height ( \copybrief key_item_height ). - \details Description of the parameter key_item_height is:
    \copydoc key_item_height
    - \see key_item_height for more information */ - inline double getKeyItemHeight() const - { - return this->key_item_height; - } - /*! \brief sets the property keyYSeparation ( \copybrief keyYSeparation ) to the specified \a __value. - \details Description of the parameter keyYSeparation is:
    \copydoc keyYSeparation
    - \see keyYSeparation for more information */ - inline void setKeyYSeparation(double __value) - { - if (this->keyYSeparation != __value) { - this->keyYSeparation = __value; - redrawPlot(); - } - } - /*! \brief returns the property keyYSeparation ( \copybrief keyYSeparation ). - \details Description of the parameter keyYSeparation is:
    \copydoc keyYSeparation
    - \see keyYSeparation for more information */ - inline double getKeyYSeparation() const - { - return this->keyYSeparation; - } - /*! \brief sets the property key_line_length ( \copybrief key_line_length ) to the specified \a __value. - \details Description of the parameter key_line_length is:
    \copydoc key_line_length
    - \see key_line_length for more information */ - inline void setKeyLineLength(double __value) - { - if (this->key_line_length != __value) { - this->key_line_length = __value; - redrawPlot(); - } - } - /*! \brief returns the property key_line_length ( \copybrief key_line_length ). - \details Description of the parameter key_line_length is:
    \copydoc key_line_length
    - \see key_line_length for more information */ - inline double getKeyLineLength() const - { - return this->key_line_length; - } - /*! \brief sets the property keyXMargin ( \copybrief keyXMargin ) to the specified \a __value. - \details Description of the parameter keyXMargin is:
    \copydoc keyXMargin
    - \see keyXMargin for more information */ - inline void setKeyXMargin(double __value) - { - if (this->keyXMargin != __value) { - this->keyXMargin = __value; - redrawPlot(); - } - } - /*! \brief returns the property keyXMargin ( \copybrief keyXMargin ). - \details Description of the parameter keyXMargin is:
    \copydoc keyXMargin
    - \see keyXMargin for more information */ - inline double getKeyXMargin() const - { - return this->keyXMargin; - } - /*! \brief sets the property keyYMargin ( \copybrief keyYMargin ) to the specified \a __value. - \details Description of the parameter keyYMargin is:
    \copydoc keyYMargin
    - \see keyYMargin for more information */ - inline void setKeyYMargin(double __value) - { - if (this->keyYMargin != __value) { - this->keyYMargin = __value; - redrawPlot(); - } - } - /*! \brief returns the property keyYMargin ( \copybrief keyYMargin ). - \details Description of the parameter keyYMargin is:
    \copydoc keyYMargin
    - \see keyYMargin for more information */ - inline double getKeyYMargin() const - { - return this->keyYMargin; - } - /*! \brief sets the property keyXSeparation ( \copybrief keyXSeparation ) to the specified \a __value. - \details Description of the parameter keyXSeparation is:
    \copydoc keyXSeparation
    - \see keyXSeparation for more information */ - inline void setKeyXSeparation(double __value) - { - if (this->keyXSeparation != __value) { - this->keyXSeparation = __value; - redrawPlot(); - } - } - /*! \brief returns the property keyXSeparation ( \copybrief keyXSeparation ). - \details Description of the parameter keyXSeparation is:
    \copydoc keyXSeparation
    - \see keyXSeparation for more information */ - inline double getKeyXSeparation() const - { - return this->keyXSeparation; - } - - /*! \brief sets the property keyXOffset ( \copybrief keyXOffset ) to the specified \a __value. - \details Description of the parameter keyXOffset is:
    \copydoc keyXOffset
    - \see keyXOffset for more information */ - inline void setKeyXOffset(double __value) - { - if (this->keyXOffset != __value) { - this->keyXOffset = __value; - redrawPlot(); - } - } - /*! \brief returns the property keyXOffset ( \copybrief keyXOffset ). - \details Description of the parameter keyXOffset is:
    \copydoc keyXOffset
    - \see keyXOffset for more information */ - inline double getKeyXOffset() const - { - return this->keyXOffset; - } - /*! \brief sets the property keyYOffset ( \copybrief keyYOffset ) to the specified \a __value. - \details Description of the parameter keyYOffset is:
    \copydoc keyYOffset
    - \see keyYOffset for more information */ - inline void setKeyYOffset(double __value) - { - if (this->keyYOffset != __value) { - this->keyYOffset = __value; - redrawPlot(); - } - } - /*! \brief returns the property keyYOffset ( \copybrief keyYOffset ). - \details Description of the parameter keyYOffset is:
    \copydoc keyYOffset
    - \see keyYOffset for more information */ - inline double getKeyYOffset() const - { - return this->keyYOffset; - } - /*! \brief sets the property showKey ( \copybrief showKey ) to the specified \a __value. - \details Description of the parameter showKey is:
    \copydoc showKey
    - \see showKey for more information */ - inline void setShowKey(bool __value) - { - if (this->showKey != __value) { - this->showKey = __value; - redrawPlot(); - } - } - /*! \brief returns the property showKey ( \copybrief showKey ). - \details Description of the parameter showKey is:
    \copydoc showKey
    - \see showKey for more information */ - inline bool getShowKey() const - { - return this->showKey; - } - /*! \brief sets the property showKeyFrame ( \copybrief showKeyFrame ) to the specified \a __value. - \details Description of the parameter showKeyFrame is:
    \copydoc showKeyFrame
    - \see showKeyFrame for more information */ - inline void setShowKeyFrame(bool __value) - { - if (this->showKeyFrame != __value) { - this->showKeyFrame = __value; - redrawPlot(); - } - } - /*! \brief returns the property showKeyFrame ( \copybrief showKeyFrame ). - \details Description of the parameter showKeyFrame is:
    \copydoc showKeyFrame
    - \see showKeyFrame for more information */ - inline bool getShowKeyFrame() const - { - return this->showKeyFrame; - } - /*! \brief sets the property keyFrameColor ( \copybrief keyFrameColor ) to the specified \a __value. - \details Description of the parameter keyFrameColor is:
    \copydoc keyFrameColor
    - \see keyFrameColor for more information */ - inline void setKeyFrameColor(const QColor & __value) - { - if (this->keyFrameColor != __value) { - this->keyFrameColor = __value; - redrawPlot(); - } - } - /*! \brief returns the property keyFrameColor ( \copybrief keyFrameColor ). - \details Description of the parameter keyFrameColor is:
    \copydoc keyFrameColor
    - \see keyFrameColor for more information */ - inline QColor getKeyFrameColor() const - { - return this->keyFrameColor; - } - /*! \brief sets the property keyBackgroundColor ( \copybrief keyBackgroundColor ) to the specified \a __value. - \details Description of the parameter keyBackgroundColor is:
    \copydoc keyBackgroundColor
    - \see keyBackgroundColor for more information */ - inline void setKeyBackgroundColor(const QColor & __value) - { - if (this->keyBackgroundColor != __value) { - this->keyBackgroundColor = __value; - redrawPlot(); - } - } - /*! \brief returns the property keyBackgroundColor ( \copybrief keyBackgroundColor ). - \details Description of the parameter keyBackgroundColor is:
    \copydoc keyBackgroundColor
    - \see keyBackgroundColor for more information */ - inline QColor getKeyBackgroundColor() const - { - return this->keyBackgroundColor; - } - /*! \brief sets the property keyFrameWidth ( \copybrief keyFrameWidth ) to the specified \a __value. - \details Description of the parameter keyFrameWidth is:
    \copydoc keyFrameWidth
    - \see keyFrameWidth for more information */ - inline void setKeyFrameWidth(double __value) - { - if (this->keyFrameWidth != __value) { - this->keyFrameWidth = __value; - redrawPlot(); - } - } - /*! \brief returns the property keyFrameWidth ( \copybrief keyFrameWidth ). - \details Description of the parameter keyFrameWidth is:
    \copydoc keyFrameWidth
    - \see keyFrameWidth for more information */ - inline double getKeyFrameWidth() const - { - return this->keyFrameWidth; - } - /*! \brief sets the property keyAutosize ( \copybrief keyAutosize ) to the specified \a __value. - \details Description of the parameter keyAutosize is:
    \copydoc keyAutosize
    - \see keyAutosize for more information */ - inline void setKeyAutosize(bool __value) - { - if (this->keyAutosize != __value) { - this->keyAutosize = __value; - redrawPlot(); - } - } - /*! \brief returns the property keyAutosize ( \copybrief keyAutosize ). - \details Description of the parameter keyAutosize is:
    \copydoc keyAutosize
    - \see keyAutosize for more information */ - inline bool getKeyAutosize() const - { - return this->keyAutosize; - } - /*! \brief sets the property keyPosition ( \copybrief keyPosition ) to the specified \a __value. - \details Description of the parameter keyPosition is:
    \copydoc keyPosition
    - \see keyPosition for more information */ - inline void setKeyPosition(const JKQTPKeyPosition & __value) - { - if (this->keyPosition != __value) { - this->keyPosition = __value; - redrawPlot(); - } - } - /*! \brief returns the property keyPosition ( \copybrief keyPosition ). - \details Description of the parameter keyPosition is:
    \copydoc keyPosition
    - \see keyPosition for more information */ - inline JKQTPKeyPosition getKeyPosition() const - { - return this->keyPosition; - } - /*! \brief sets the property keyLayout ( \copybrief keyLayout ) to the specified \a __value. - \details Description of the parameter keyLayout is:
    \copydoc keyLayout
    - \see keyLayout for more information */ - inline void setKeyLayout(const JKQTPKeyLayout & __value) - { - if (this->keyLayout != __value) { - this->keyLayout = __value; - redrawPlot(); - } - } - /*! \brief returns the property keyLayout ( \copybrief keyLayout ). - \details Description of the parameter keyLayout is:
    \copydoc keyLayout
    - \see keyLayout for more information */ - inline JKQTPKeyLayout getKeyLayout() const - { - return this->keyLayout; - } - - /*! \brief sets the property plotLabelFontSize ( \copybrief plotLabelFontSize ) to the specified \a __value. - \details Description of the parameter plotLabelFontSize is:
    \copydoc plotLabelFontSize
    - \see plotLabelFontSize for more information */ - inline void setPlotLabelFontSize(double __value) - { - if (this->plotLabelFontSize != __value) { - this->plotLabelFontSize = __value; - redrawPlot(); - } - } /*! \brief returns the property plotLabelFontSize ( \copybrief plotLabelFontSize ). \details Description of the parameter plotLabelFontSize is:
    \copydoc plotLabelFontSize
    \see plotLabelFontSize for more information */ - inline double getPlotLabelFontSize() const - { - return this->plotLabelFontSize; - } - /*! \brief sets the property plotLabelFontname ( \copybrief plotLabelFontname ) to the specified \a __value. - \details Description of the parameter plotLabelFontname is:
    \copydoc plotLabelFontname
    - \see plotLabelFontname for more information */ - inline void setPlotLabelFontname(const QString & __value) - { - if (this->plotLabelFontname != __value) { - this->plotLabelFontname = __value; - redrawPlot(); - } - } - /*! \brief returns the property plotLabelFontname ( \copybrief plotLabelFontname ). - \details Description of the parameter plotLabelFontname is:
    \copydoc plotLabelFontname
    - \see plotLabelFontname for more information */ - inline QString getPlotLabelFontname() const - { - return this->plotLabelFontname; - } - /*! \brief sets the property plotLabel ( \copybrief plotLabel ) to the specified \a __value. - \details Description of the parameter plotLabel is:
    \copydoc plotLabel
    - \see plotLabel for more information */ - inline void setPlotLabel(const QString & __value) - { - if (this->plotLabel != __value) { - this->plotLabel = __value; - redrawPlot(); - } - } + double getPlotLabelFontSize() const; + /*! \brief returns the property plotLabelFontName ( \copybrief plotLabelFontName ). + \details Description of the parameter plotLabelFontName is:
    \copydoc plotLabelFontName
    + \see plotLabelFontName for more information */ + QString getplotLabelFontName() const; + /*! \brief returns the property plotLabel ( \copybrief plotLabel ). \details Description of the parameter plotLabel is:
    \copydoc plotLabel
    \see plotLabel for more information */ - inline QString getPlotLabel() const - { - return this->plotLabel; - } + QString getPlotLabel() const; /*! \brief sets the property gridPrinting ( \copybrief gridPrinting ) to the specified \a __value. \details Description of the parameter gridPrinting is:
    \copydoc gridPrinting
    @@ -1868,180 +792,108 @@ class JKQTP_LIB_EXPORT JKQTBasePlotter: public QObject { void setGridPrintingCurrentPos(size_t x, size_t y); + /** \brief returns the current directory in which to open SaveAs ... dialogs */ + QString getCurrentSaveDirectory() const; + /** \brief return the last file format to use in SaveAs ... dialogs */ + QString getCurrentFileFormat() const; + /** \brief returns the decimal separator used when exporting data to text files */ + QString getCSVdecimalSeparator() const; + /** \brief set the string used to introduce comments in text output when exporting data */ + QString getCSVcommentInitializer() const; - /*! \brief sets the property currentSaveDirectory ( \copybrief currentSaveDirectory ) to the specified \a __value. - \details Description of the parameter currentSaveDirectory is:
    \copydoc currentSaveDirectory
    - \see currentSaveDirectory for more information */ - inline void setCurrentSaveDirectory(const QString & __value) - { - this->currentSaveDirectory = __value; - } - /*! \brief returns the property currentSaveDirectory ( \copybrief currentSaveDirectory ). - \details Description of the parameter currentSaveDirectory is:
    \copydoc currentSaveDirectory
    - \see currentSaveDirectory for more information */ - inline QString getCurrentSaveDirectory() const - { - return this->currentSaveDirectory; - } - /*! \brief sets the property currentFileFormat ( \copybrief currentFileFormat ) to the specified \a __value. - \details Description of the parameter currentFileFormat is:
    \copydoc currentFileFormat
    - \see currentFileFormat for more information */ - inline void setCurrentFileFormat(const QString & __value) - { - this->currentFileFormat = __value; - } - /*! \brief returns the property currentFileFormat ( \copybrief currentFileFormat ). - \details Description of the parameter currentFileFormat is:
    \copydoc currentFileFormat
    - \see currentFileFormat for more information */ - inline QString getCurrentFileFormat() const - { - return this->currentFileFormat; - } - /*! \brief sets the property CSVdecimalSeparator ( \copybrief CSVdecimalSeparator ) to the specified \a __value. - \details Description of the parameter CSVdecimalSeparator is:
    \copydoc CSVdecimalSeparator
    - \see CSVdecimalSeparator for more information */ - inline void setCSVdecimalSeparator(const QString & __value) - { - this->CSVdecimalSeparator = __value; - } - /*! \brief returns the property CSVdecimalSeparator ( \copybrief CSVdecimalSeparator ). - \details Description of the parameter CSVdecimalSeparator is:
    \copydoc CSVdecimalSeparator
    - \see CSVdecimalSeparator for more information */ - inline QString getCSVdecimalSeparator() const - { - return this->CSVdecimalSeparator; - } - /*! \brief sets the property CSVcommentInitializer ( \copybrief CSVcommentInitializer ) to the specified \a __value. - \details Description of the parameter CSVcommentInitializer is:
    \copydoc CSVcommentInitializer
    - \see CSVcommentInitializer for more information */ - inline void setCSVcommentInitializer(const QString & __value) - { - this->CSVcommentInitializer = __value; - } - /*! \brief returns the property CSVcommentInitializer ( \copybrief CSVcommentInitializer ). - \details Description of the parameter CSVcommentInitializer is:
    \copydoc CSVcommentInitializer
    - \see CSVcommentInitializer for more information */ - inline QString getCSVcommentInitializer() const - { - return this->CSVcommentInitializer; - } - - /*! \brief returns the property iplotBorderTop ( \copybrief iplotBorderTop ). \details Description of the parameter iplotBorderTop is:
    \copydoc iplotBorderTop
    . \see iplotBorderTop for more information */ - inline double getInternalPlotBorderTop() const { return this->iplotBorderTop; } - /*! \brief returns the property iplotBorderLeft ( \copybrief iplotBorderLeft ). \details Description of the parameter iplotBorderLeft is:
    \copydoc iplotBorderLeft
    . \see iplotBorderLeft for more information */ - inline double getInternalPlotBorderLeft() const { return this->iplotBorderLeft; } - /*! \brief returns the property iplotBorderBottom ( \copybrief iplotBorderBottom ). \details Description of the parameter iplotBorderBottom is:
    \copydoc iplotBorderBottom
    . \see iplotBorderBottom for more information */ - inline double getInternalPlotBorderBottom() const { return this->iplotBorderBottom; } - /*! \brief returns the property iplotBorderRight ( \copybrief iplotBorderRight ). \details Description of the parameter iplotBorderRight is:
    \copydoc iplotBorderRight
    . \see iplotBorderRight for more information */ - inline double getInternalPlotBorderRight() const { return this->iplotBorderRight; } + /*! \brief returns the property internalPlotBorderTop ( \copybrief internalPlotBorderTop ). \details Description of the parameter internalPlotBorderTop is:
    \copydoc internalPlotBorderTop
    . \see internalPlotBorderTop for more information */ + inline double getInternalPlotBorderTop() const { return this->internalPlotBorderTop; } + /*! \brief returns the property internalPlotBorderLeft ( \copybrief internalPlotBorderLeft ). \details Description of the parameter internalPlotBorderLeft is:
    \copydoc internalPlotBorderLeft
    . \see internalPlotBorderLeft for more information */ + inline double getInternalPlotBorderLeft() const { return this->internalPlotBorderLeft; } + /*! \brief returns the property internalPlotBorderBottom ( \copybrief internalPlotBorderBottom ). \details Description of the parameter internalPlotBorderBottom is:
    \copydoc internalPlotBorderBottom
    . \see internalPlotBorderBottom for more information */ + inline double getInternalPlotBorderBottom() const { return this->internalPlotBorderBottom; } + /*! \brief returns the property internalPlotBorderRight ( \copybrief internalPlotBorderRight ). \details Description of the parameter internalPlotBorderRight is:
    \copydoc internalPlotBorderRight
    . \see internalPlotBorderRight for more information */ + inline double getInternalPlotBorderRight() const { return this->internalPlotBorderRight; } /*! \brief returns the property plotWidth ( \copybrief plotWidth ). \details Description of the parameter plotWidth is:
    \copydoc plotWidth
    . \see plotWidth for more information */ - inline int getPlotWidth() const { return this->plotWidth; } + inline int getPlotWidth() const { return this->internalPlotWidth; } /*! \brief returns the property plotHeight ( \copybrief plotHeight ). \details Description of the parameter plotHeight is:
    \copydoc plotHeight
    . \see plotHeight for more information */ - inline int getPlotHeight() const { return this->plotHeight; } + inline int getPlotHeight() const { return this->internalPlotHeight; } /** \brief returns the internal JKQTMathText, used to render text with LaTeX markup */ - inline JKQTMathText* getMathText() { return &mathText; } + JKQTMathText* getMathText(); /** \brief returns the internal JKQTMathText, used to render text with LaTeX markup */ - inline const JKQTMathText* getMathText() const { return &mathText; } + const JKQTMathText *getMathText() const; /** \brief returns the x-axis objet of the plot */ - inline JKQTPHorizontalAxis* getXAxis() { return xAxis; } + JKQTPHorizontalAxis *getXAxis(); /** \brief returns the y-axis objet of the plot */ - inline JKQTPVerticalAxis* getYAxis() { return yAxis; } + JKQTPVerticalAxis* getYAxis(); /** \brief returns the x-axis objet of the plot */ - inline const JKQTPHorizontalAxis* getXAxis() const { return xAxis; } + const JKQTPHorizontalAxis* getXAxis() const; /** \brief returns the y-axis objet of the plot */ - inline const JKQTPVerticalAxis* getYAxis() const { return yAxis; } + const JKQTPVerticalAxis *getYAxis() const; /*! \brief returns the property actSavePlot ( \copybrief actSavePlot ). \details Description of the parameter actSavePlot is:
    \copydoc actSavePlot
    . \see actSavePlot for more information */ - inline QAction* getActionSavePlot() const { return this->actSavePlot; } + QAction* getActionSavePlot() const; /*! \brief returns the property actSaveData ( \copybrief actSaveData ). \details Description of the parameter actSaveData is:
    \copydoc actSaveData
    . \see actSaveData for more information */ - inline QAction* getActionSaveData() const { return this->actSaveData; } + QAction* getActionSaveData() const; /*! \brief returns the property actCopyData ( \copybrief actCopyData ). \details Description of the parameter actCopyData is:
    \copydoc actCopyData
    . \see actCopyData for more information */ - inline QAction* getActionCopyData() const { return this->actCopyData; } + QAction* getActionCopyData() const; /*! \brief returns the property actCopyPixelImage ( \copybrief actCopyPixelImage ). \details Description of the parameter actCopyPixelImage is:
    \copydoc actCopyPixelImage
    . \see actCopyPixelImage for more information */ - inline QAction* getActionCopyPixelImage() const { return this->actCopyPixelImage; } + QAction* getActionCopyPixelImage() const; /*! \brief returns the property actCopyMatlab ( \copybrief actCopyMatlab ). \details Description of the parameter actCopyMatlab is:
    \copydoc actCopyMatlab
    . \see actCopyMatlab for more information */ - inline QAction* getActionCopyMatlab() const { return this->actCopyMatlab; } + QAction* getActionCopyMatlab() const; /*! \brief returns the property actSavePDF ( \copybrief actSavePDF ). \details Description of the parameter actSavePDF is:
    \copydoc actSavePDF
    . \see actSavePDF for more information */ - inline QAction* getActionSavePDF() const { return this->actSavePDF; } + QAction* getActionSavePDF() const; #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) - /*! \brief returns the property actSavePS ( \copybrief actSavePS ). \details Description of the parameter actSavePS is:
    \copydoc actSavePS
    . \see actSavePS for more information */ - inline QAction* getActionSavePS() const { return this->actSavePS; } + /*! \brief returns the property actSavePS ( \copybrief actSavePS ). \details Description of the parameter actSavePS is:
    \copydoc actSavePS
    . \see actSavePS for more information */ + QAction* getActionSavePS() const; #endif /*! \brief returns the property actSavePix ( \copybrief actSavePix ). \details Description of the parameter actSavePix is:
    \copydoc actSavePix
    . \see actSavePix for more information */ - inline QAction* getActionSavePix() const { return this->actSavePix; } + QAction* getActionSavePix() const; /*! \brief returns the property actSaveSVG ( \copybrief actSaveSVG ). \details Description of the parameter actSaveSVG is:
    \copydoc actSaveSVG
    . \see actSaveSVG for more information */ - inline QAction* getActionSaveSVG() const { return this->actSaveSVG; } + QAction* getActionSaveSVG() const; /*! \brief returns the property actPrint ( \copybrief actPrint ). \details Description of the parameter actPrint is:
    \copydoc actPrint
    . \see actPrint for more information */ - inline QAction* getActionPrint() const { return this->actPrint; } + QAction* getActionPrint() const; /*! \brief returns the property actSaveCSV ( \copybrief actSaveCSV ). \details Description of the parameter actSaveCSV is:
    \copydoc actSaveCSV
    . \see actSaveCSV for more information */ - inline QAction* getActionSaveCSV() const { return this->actSaveCSV; } + QAction* getActionSaveCSV() const; /*! \brief returns the property actZoomAll ( \copybrief actZoomAll ). \details Description of the parameter actZoomAll is:
    \copydoc actZoomAll
    . \see actZoomAll for more information */ - inline QAction* getActionZoomAll() const { return this->actZoomAll; } + QAction* getActionZoomAll() const; /*! \brief returns the property actZoomIn ( \copybrief actZoomIn ). \details Description of the parameter actZoomIn is:
    \copydoc actZoomIn
    . \see actZoomIn for more information */ - inline QAction* getActionZoomIn() const { return this->actZoomIn; } + QAction* getActionZoomIn() const; /*! \brief returns the property actZoomOut ( \copybrief actZoomOut ). \details Description of the parameter actZoomOut is:
    \copydoc actZoomOut
    . \see actZoomOut for more information */ - inline QAction* getActionZoomOut() const { return this->actZoomOut; } + QAction *getActionZoomOut() const; /*! \brief returns the property actShowPlotData ( \copybrief actShowPlotData ). \details Description of the parameter actShowPlotData is:
    \copydoc actShowPlotData
    . \see actShowPlotData for more information */ - inline QAction* getActionShowPlotData() const { return this->actShowPlotData; } + QAction *getActionShowPlotData() const; /*! \brief returns the property lstAdditionalPlotterActions ( \copybrief lstAdditionalPlotterActions ). \details Description of the parameter lstAdditionalPlotterActions is:
    \copydoc lstAdditionalPlotterActions
    . \see lstAdditionalPlotterActions for more information */ - inline AdditionalActionsMap getLstAdditionalPlotterActions() const { return this->lstAdditionalPlotterActions; } + AdditionalActionsMap getLstAdditionalPlotterActions() const; /** \brief this function registers additional actions to lstAdditionalPlotterActions, which are displayed in the context-menu */ void registerAdditionalAction(const QString& key, QAction* act); + /** \brief this function deregisters an additional action, previously added with registerAdditionalAction() + * + * \see registerAdditionalAction() + */ void deregisterAdditionalAction(QAction* act); /*! \brief returns the property masterSynchronizeWidth ( \copybrief masterSynchronizeWidth ). \details Description of the parameter masterSynchronizeWidth is:
    \copydoc masterSynchronizeWidth
    . \see masterSynchronizeWidth for more information */ - inline bool getMasterSynchronizeWidth() const { return this->masterSynchronizeWidth; } + bool getMasterSynchronizeWidth() const; /*! \brief returns the property masterSynchronizeHeight ( \copybrief masterSynchronizeHeight ). \details Description of the parameter masterSynchronizeHeight is:
    \copydoc masterSynchronizeHeight
    . \see masterSynchronizeHeight for more information */ - inline bool getMasterSynchronizeHeight() const { return this->masterSynchronizeHeight; } - /*! \brief sets the property default_backgroundColor ( \copybrief default_backgroundColor ) to the specified \a __value. - \details Description of the parameter default_backgroundColor is:
    \copydoc default_backgroundColor
    - \see default_backgroundColor for more information */ - inline void setDefaultBackgroundColor(const QColor & __value) - { - this->default_backgroundColor = __value; - } - /*! \brief sets the property default_plotBackgroundColor ( \copybrief default_plotBackgroundColor ) to the specified \a __value. - \details Description of the parameter default_plotBackgroundColor is:
    \copydoc default_plotBackgroundColor
    - \see default_plotBackgroundColor for more information */ - inline void setDefaultPlotBackgroundColor(const QColor & __value) - { - this->default_plotBackgroundColor = __value; - } - + bool getMasterSynchronizeHeight() const; /*! \brief sets the property fontSizePrintMultiplier ( \copybrief fontSizePrintMultiplier ) to the specified \a __value. \details Description of the parameter fontSizePrintMultiplier is:
    \copydoc fontSizePrintMultiplier
    \see fontSizePrintMultiplier for more information */ - inline void setFontSizePrintMultiplier(double __value) - { - this->fontSizePrintMultiplier = __value; - } + void setFontSizePrintMultiplier(double __value); /*! \brief returns the property fontSizePrintMultiplier ( \copybrief fontSizePrintMultiplier ). \details Description of the parameter fontSizePrintMultiplier is:
    \copydoc fontSizePrintMultiplier
    \see fontSizePrintMultiplier for more information */ - inline double getFontSizePrintMultiplier() const - { - return this->fontSizePrintMultiplier; - } + double getFontSizePrintMultiplier() const; /*! \brief sets the property lineWidthPrintMultiplier ( \copybrief lineWidthPrintMultiplier ) to the specified \a __value. \details Description of the parameter lineWidthPrintMultiplier is:
    \copydoc lineWidthPrintMultiplier
    \see lineWidthPrintMultiplier for more information */ - inline void setLineWidthPrintMultiplier(double __value) - { - this->lineWidthPrintMultiplier = __value; - } + void setLineWidthPrintMultiplier(double __value); /*! \brief returns the property lineWidthPrintMultiplier ( \copybrief lineWidthPrintMultiplier ). \details Description of the parameter lineWidthPrintMultiplier is:
    \copydoc lineWidthPrintMultiplier
    \see lineWidthPrintMultiplier for more information */ - inline double getLineWidthPrintMultiplier() const - { - return this->lineWidthPrintMultiplier; - } + double getLineWidthPrintMultiplier() const; /*! \brief returns the property fontSizeMultiplier ( \copybrief fontSizeMultiplier ). \details Description of the parameter fontSizeMultiplier is:
    \copydoc fontSizeMultiplier
    . \see fontSizeMultiplier for more information */ - inline double getFontSizeMultiplier() const { return this->fontSizeMultiplier; } + double getFontSizeMultiplier() const; /*! \brief returns the property lineWidthMultiplier ( \copybrief lineWidthMultiplier ). \details Description of the parameter lineWidthMultiplier is:
    \copydoc lineWidthMultiplier
    . \see lineWidthMultiplier for more information */ - inline double getLineWidthMultiplier() const { return this->lineWidthMultiplier; } + double getLineWidthMultiplier() const; /** \brief returns description of i'th graph */ @@ -2062,8 +914,17 @@ class JKQTP_LIB_EXPORT JKQTBasePlotter: public QObject { */ void clearGraphs(bool deleteGraphs=true); + /** \brief set all graphs in the plotter invisible + * + * \see setAllGraphsVisible(), setGraphVisible(), JKQTPPlotElement::setVisible() */ void setAllGraphsInvisible(); + /** \brief set all graphs in the plotter visible + * + * \see setAllGraphsInvisible(), setGraphVisible(), JKQTPPlotElement::setVisible() */ void setAllGraphsVisible(); + /** \brief switch visibility of the \a i -th graph to \a visible + * + * \see setAllGraphsInvisible(), setAllGraphsVisible(), JKQTPPlotElement::setVisible() */ void setGraphVisible(int i, bool visible=true); /** \brief add a new graph, returns it's position in the graphs list, if the graph is already in the plot, this returns the index in the list */ @@ -2077,11 +938,19 @@ class JKQTP_LIB_EXPORT JKQTBasePlotter: public QObject { /** \brief move the given graph to the top, or add it, if it is not yet contained */ size_t moveGraphBottom(JKQTPPlotElement* gr); - /** \brief add a new graphs from a QVector */ + /** \brief add a new graphs from a QVector, QList, std::vector ... or any standard-iterateable container with JKQTPPlotElement*-items + * + * \tparam TJKQTPGraphContainer a container type with default C++-sytle iterator interface + * (i.e. methods \c begin() and \c end() and an iterator, which may be + * moved to the next element with the operator \c ++ . + * \param gr Container of type TJKQTPGraphContainer, which contains the graphs \b Note: The JKQTPlotter takes ownership of graphs in \a gr . + * \param[out] graphIDsOut optional output parameter, the vector will contain the IDs of each graph added to theis plot + */ template - inline void addGraphs(const TJKQTPGraphContainer& gr) { + inline void addGraphs(const TJKQTPGraphContainer& gr, QVector* graphIDsOut=nullptr) { for (auto it=gr.begin(); it!=gr.end(); ++it) { - addGraph(*it); + const size_t g=addGraph(*it); + if (graphIDsOut) graphIDsOut->push_back(g); } } @@ -2232,10 +1101,11 @@ class JKQTP_LIB_EXPORT JKQTBasePlotter: public QObject { void getGraphsYMinMax(double& miny, double& maxy, double& smallestGreaterZero); + /** \brief denotes, which axes to synchronize in synchronizeToMaster() */ enum SynchronizationDirection { - sdXAxis, - sdYAxis, - sdXYAxes + sdXAxis, /**< \brief x-axis only */ + sdYAxis, /**< \brief y-axis only */ + sdXYAxes /**< \brief x- and y-axis */ }; /*! \brief synchronize the plot borders (and zooming) with a given plotter (master --> slave/this) @@ -2321,51 +1191,32 @@ class JKQTP_LIB_EXPORT JKQTBasePlotter: public QObject { /** \brief add a new overlay elements from a QList */ void addOverlayElements(const QList& gr); - QVector getBoundingLinesX1Y1(QRectF *rect=nullptr) const; - - signals: - /** \brief signal: emitted whenever the user selects a new x-y zoom range (by mouse) */ - void zoomChangedLocally(double newxmin, double newxmax, double newymin, double newymax, JKQTBasePlotter* sender); - - /** \brief emitted when the plot has to be updated */ - void plotUpdated(); - - /** \brief emitted when the overlay elements have to be updated */ - void overlaysUpdated(); - - /** \brief emitted when the plot scaling had to be recalculated */ - void plotScalingRecalculated(); - - /** \brief emitted before the plot scaling has been recalculated */ - void beforePlotScalingRecalculate(); - - public: - - /** \brief set a global preset/default value for the userSettigsFilename and userSettigsPrefix properties of JKQTBasePlotter + /** \brief save the current plot data as a Comma Separated Values (CSV) file * - * These presets are application global and will be used ONLY on initialization of a JKQTBasePlotter. You can overwrite them - * on a local-basis for each JKQTBasePrinter separately. The changed values from this function call will only take effect for - * newly created plotters AFTER the function call! + * \param filename the file to save to, if \a filename is empty, a file open dialog will be shown + * \param decimalSeparator decimal separator for outpu + * \param commentInitializer line-start for comment lines */ - static void setDefaultJKQTBasePrinterUserSettings(QString userSettigsFilename, const QString& userSettigsPrefix); + void saveAsCSV(const QString& filename, const QString& decimalSeparator, const QString& commentInitializer); + + /** \brief save the current plot data as a Semicolon Separated Values (SSV) file + * + * \param filename the file to save to, if \a filename is empty, a file open dialog will be shown + * \param decimalSeparator decimal separator for outpu + * \param commentInitializer line-start for comment lines + */ + void saveAsSemicolonSV(const QString& filename, const QString& decimalSeparator, const QString& commentInitializer); /** \brief save the current plot data as a Tabulator Separated Values (CSV) file + * + * \param filename the file to save to, if \a filename is empty, a file open dialog will be shown + * \param decimalSeparator decimal separator for outpu + * \param commentInitializer line-start for comment lines + */ + void saveAsTabSV(const QString& filename, const QString& decimalSeparator, const QString& commentInitializer); - /** \brief register a user-defined QPaintDevice (with factory JKQTPPaintDeviceAdapter) as a plugin to JKQTBasePlotter/JKQTPlotter, - * which will use it to export graphics */ - static void registerPaintDeviceAdapter(JKQTPPaintDeviceAdapter* adapter); - /** \brief de-register a JKQTPPaintDeviceAdapter from JKQTBasePlotter/JKQTPlotter */ - static void deregisterPaintDeviceAdapter(JKQTPPaintDeviceAdapter* adapter); - - - - - /** \brief register a JKQTPSaveDataAdapter with JKQTPlotter/JKQTBasePlotter that can be used to export data from the internal datastore into a file */ - static bool registerSaveDataAdapter(JKQTPSaveDataAdapter* adapter); - /** \brief de-register a JKQTPSaveDataAdapter from JKQTPlotter/JKQTBasePlotter */ - static bool deregisterSaveDataAdapter(JKQTPSaveDataAdapter* adapter); /** \brief internal tool class for text sizes - * \ingroup jkqtpplotterclasses_tools + * \ingroup jkqtpplotterclasses_tools * \internal */ struct JKQTP_LIB_EXPORT textSizeData { explicit textSizeData(); @@ -2384,15 +1235,998 @@ class JKQTP_LIB_EXPORT JKQTBasePlotter: public QObject { bool operator==(const textSizeKey& other) const; }; + /** \brief calculates a textSizeData for the given string \a text if it would be drawn on \a painter with font \a fm + * \internal + */ textSizeData getTextSizeDetail(const QFont &fm, const QString& text, QPainter& painter); + /** \brief calculates a textSizeData for the given string \a text if it would be drawn on \a painter with font \a fontName + * \internal + */ textSizeData getTextSizeDetail(const QString& fontName, double fontSize, const QString& text, QPainter &painter); + /** \brief calculates a text-size details for the given string \a text if it would be drawn on \a painter with font \a fontName and font size \a fontSize + * \internal + */ void getTextSizeDetail(const QString& fontName, double fontSize, const QString& text, QPainter &painter, double& width, double& ascent, double& descent, double& strikeoutPos); + /** \brief calculates a text-size details for the given string \a text if it would be drawn on \a painter with font \a fm + * \internal + */ void getTextSizeDetail(const QFont& fm, const QString& text, QPainter &painter, double& width, double& ascent, double& descent, double& strikeoutPos); + /** \brief calculates a size of the given string \a text if it would be drawn on \a painter with font \a fm + * \internal + */ QSizeF getTextSizeSize(const QFont &fm, const QString& text, QPainter& painter); + /** \brief calculates a size of the given string \a text if it would be drawn on \a painter with font \a fontName and font size \a fontSize + * \internal + */ QSizeF getTextSizeSize(const QString& fontName, double fontSize, const QString& text, QPainter &painter); + + + signals: + /** \brief signal: emitted whenever the user selects a new x-y zoom range (by mouse) */ + void zoomChangedLocally(double newxmin, double newxmax, double newymin, double newymax, JKQTBasePlotter* sender); + + /** \brief emitted when the plot has to be updated */ + void plotUpdated(); + + /** \brief emitted when the overlay elements have to be updated */ + void overlaysUpdated(); + + /** \brief emitted when the plot scaling had to be recalculated */ + void plotScalingRecalculated(); + + /** \brief emitted before the plot scaling has been recalculated */ + void beforePlotScalingRecalculate(); + + + public slots: + + + /** \brief sets the width of the plot widget + * + * \image html plot_widget_orientation.png + * + * \see setWidgetSize(), \ref jkqtplotter_base_plotsize + */ + void setWidgetWidth(int wid); + + /** \brief resize the plot + * + * \image html plot_widget_orientation.png + * + * \see \ref jkqtplotter_base_plotsize + */ + void setWidgetSize(int width, int height); + + /** \brief sets the width of the plot widget + * + * \image html plot_widget_orientation.png + * + * \see setWidgetSize(), \ref jkqtplotter_base_plotsize + */ + void setWidgetHeight(int heigh); + + /** \brief sets the borders of the plot + * + * \image html plot_widget_orientation.png + * + * \see \ref jkqtplotter_base_plotsize + */ + void setPlotBorder(int left, int right, int top, int bottom); + + /** \brief sets the left border of the plot + * + * \image html plot_widget_orientation.png + * + * \see \ref jkqtplotter_base_plotsize + */ + void setPlotBorderLeft(int left); + + /** \brief sets the right border of the plot + * + * \image html plot_widget_orientation.png + * + * \see \ref jkqtplotter_base_plotsize + */ + void setPlotBorderRight(int right); + + /** \brief sets the top border of the plot + * + * \image html plot_widget_orientation.png + * + * \see \ref jkqtplotter_base_plotsize + */ + void setPlotBorderTop(int top); + + /** \brief sets the bottom border of the plot + * + * \image html plot_widget_orientation.png + * + * \see \ref jkqtplotter_base_plotsize + */ + void setPlotBorderBottom(int bottom); + + /** \brief sets the x-range of the plot (minimum and maximum x-value on the x-axis) + * + * \param xminn absolute minimum of x-axis + * \param xmaxx absolute maximum of x-axis + * + * \note You cannot expand the x-range outside the absolute x-range set e.g. by setAbsoluteX()! + * Also the range will be limited to possible values (e.g. to positive values if you use + * logarithmic axes). + * + * Uppon setting, this function emits the signal zoomChangedLocally(), if emitting signals + * is activated at the moment (e.g. using setEmittingSignalsEnabled() ). + * + * \see setY(), setXY(), zoomToFit(), setAbsoluteXY(), JKQTPlotter::setY() + */ + void setX(double xminn, double xmaxx); + + /** \brief sets the y-range of the plot (minimum and maximum y-value on the y-axis) + * + * \param yminn absolute minimum of y-axis + * \param ymaxx absolute maximum of y-axis + * + * \note You cannot expand the y-range outside the absolute y-range set e.g. by setAbsoluteY()! + * Also the range will be limited to possible values (e.g. to positive values if you use + * logarithmic axes). + * + * Uppon setting, this function emits the signal zoomChangedLocally(), if emitting signals + * is activated at the moment (e.g. using setEmittingSignalsEnabled() ). + * + * \see setX(), setXY(), zoomToFit(), setAbsoluteXY(), JKQTPlotter::setX() + */ + void setY(double yminn, double ymaxx); + + /** \brief sets the x- and y-range of the plot (minimum and maximum values on the x-/y-axis) + * + * \param xminn absolute minimum of x-axis + * \param xmaxx absolute maximum of x-axis + * \param yminn absolute minimum of y-axis + * \param ymaxx absolute maximum of y-axis + * + * \note You cannot expand the ranges outside the absolute ranges set e.g. by setAbsoluteXY()! + * Also the range will be limited to possible values (e.g. to positive values if you use + * logarithmic axes). + * + * Uppon setting, this function emits the signal zoomChangedLocally(), if emitting signals + * is activated at the moment (e.g. using setEmittingSignalsEnabled() ). + * + * \see setX(), setX(), zoomToFit(), setAbsoluteXY(), JKQTPlotter::setXY() + */ + void setXY(double xminn, double xmaxx, double yminn, double ymaxx); + + /** \brief sets absolutely limiting x-range of the plot + * + * \param xminn absolute minimum of x-axis + * \param xmaxx absolute maximum of x-axis + * + * \note if the aspect ratio of this does not fit into the widget, it is possible that you don't see the complete contents! + * + * \see setAbsoluteXY(), setAbsoluteY(), JKQTPlotter::setAbsoluteX() + */ + void setAbsoluteX(double xminn, double xmaxx); + + /** \brief sets absolute minimum and maximum y-value to plot + * + * \param yminn absolute minimum of y-axis + * \param ymaxx absolute maximum of y-axis + * + * \note if the aspect ratio of this does not fit into the widget, it is possible that you don't see the complete contents! + * + * \see setAbsoluteXY(), setAbsoluteX(), JKQTPlotter::setAbsoluteY() + */ + void setAbsoluteY(double yminn, double ymaxx); + + /** \brief sets absolutely limiting x- and y-range of the plot + * + * The user (or programmer) cannot zoom to a viewport that is larger than the range given to this function. + * + * \param xminn absolute minimum of x-axis + * \param xmaxx absolute maximum of x-axis + * \param yminn absolute minimum of y-axis + * \param ymaxx absolute maximum of y-axis + * + * \note if the aspect ratio of this does not fit into the widget, it is possible that you don't see the complete contents! + * + * \see setAbsoluteX(), setAbsoluteY(), zoomToFit(), JKQTPlotter::setAbsoluteXY() + */ + void setAbsoluteXY(double xminn, double xmaxx, double yminn, double ymaxx); + + + /** \brief sets x/ymin and x/ymax to the supplied values and replots the graph (zoom operation!) */ + void zoom(double nxmin, double nxmax, double nymin, double nymax); + + /** \brief sets whether to plot grid lines or not */ + void setGrid(bool val); + + /** \brief save the current plot as a pixel image image (PNG ...), if filename is empty a file selection dialog is displayed */ + void saveAsPixelImage(const QString& filename=QString(""), bool displayPreview=true, const QByteArray &outputFormat=QByteArray()); + + /** \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 */ + 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 */ + void saveAsPDF(const QString& filename=QString(""), bool displayPreview=true); + + /** \brief save the current plot as a PS file, with the current widget aspect ratio, if filename is empty a file selection dialog is displayed */ + void saveAsPS(const QString& filename=QString(""), bool displayPreview=true); + + /** \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, ...) */ + void saveImage(const QString& filename=QString(""), bool displayPreview=true); + + /** \brief save the data used for the current plot. The file format is extracted from the file extension (csv, ...) + * + * The parameter \a format specifies the export format. if it is empty the format will be choosen according to the file extension, or + * if \a filename is also empty the format will be choosen according to what is selected in the file selection dialog. + * + * If \a format is \c "slk" the output will be in SYLK format, if \a format is \c "csv" or \a "dat" the output will be comma separated values + * and if \a format is \c "txt" the output will be tab separated values. + */ + void saveData(const QString& filename=QString(""), const QString& jkqtp_format=QString("")); + /** \brief copy the data used for the current plot to the clipboard + * + * copies data as tab separated data with the system-decimal point. + */ + void copyData(); + /** \brief copy the data used for the current plot to the clipboard in Matlab format + */ + void copyDataMatlab(); + /** \brief save the current plot data as a Comma Separated Values (CSV) file + * + * \param filename the file to save to, if \a filename is empty, a file open dialog will be shown + * + * \note this function uses CSVdecimalSeparator as decimal separator and CSVcommentInitializer to initialize content lines + */ + void saveAsCSV(const QString& filename=QString("")); + + /** \brief save the current plot data as a Semicolon Separated Values (SSV) file + * + * \param filename the file to save to, if \a filename is empty, a file open dialog will be shown + * + * \note this function uses CSVdecimalSeparator as decimal separator and CSVcommentInitializer to initialize content lines + */ + void saveAsSemicolonSV(const QString& filename=QString("")); + + /** \brief save the current plot data as a Tabulator Separated Values (CSV) file + * + * \param filename the file to save to, if \a filename is empty, a file open dialog will be shown + * + * \note this function uses CSVdecimalSeparator as decimal separator and CSVcommentInitializer to initialize content lines + */ + void saveAsTabSV(const QString& filename=QString("")); + + /** \brief save the current plot data as a DIF file + * + * \param filename the file to save to, if \a filename is empty, a file open dialog will be shown + */ + void saveAsDIF(const QString& filename=QString("")); + + /** \brief save the current plot data as a SYLK spreadsheet file + * + * \param filename the file to save to, if \a filename is empty, a file open dialog will be shown + */ + void saveAsSYLK(const QString& filename=QString("")); + + /** \brief save the current plot data as a Matlab Script + * + * \param filename the file to save to, if \a filename is empty, a file open dialog will be shown + */ + void saveAsMatlab(const QString& filename=QString("")); + + /** \brief save the current plot data as a Semicolon Separated Values (CSV) file for german Excel, i.e. with comma as decimal separator + * + * \param filename the file to save to, if \a filename is empty, a file open dialog will be shown + */ + void saveAsGerExcelCSV(const QString& filename=QString("")); + + /** \brief print the current plot, if printer is \c nullptr a printer selection dialog is displayed */ + void print(QPrinter* printer=nullptr, bool displayPreview=true); + + /** \brief this method zooms the graph so that all plotted datapoints are visible. + * + * \param zoomX if set \c true (default) zooms the x axis + * \param zoomY if set \c true (default) zooms the y axis + * \param includeX0 if this is \c true zoomToFit() will ensure that \f$ x=0 \f$ is visible in the plot (only for non-logx plots, default: false) + * \param includeY0 if this is \c true zoomToFit() will ensure that \f$ y=0 \f$ is visible in the plot (only for non-logy plots, default: false) + * \param scaleX the plot will have a width of \f$ \mbox{Xscale}\cdot\Delta x \f$ where \f$ \Delta x \f$ is the actual x-axis data range + * For logx plots we actually use this on the logarithmized data! (default: 1.05) + * \param scaleY the plot will have a height of \f$ \mbox{Yscale}\cdot\Delta < \f$ where \f$ \Delta < \f$ is the actual <-axis data range + * For log< plots we actually use this on the logarithmized data! (default: 1.05) + * + */ + void zoomToFit(bool zoomX=true, bool zoomY=true, bool includeX0=false, bool includeY0=false, double scaleX=1.05, double scaleY=1.05); + + /** \brief zooms into the graph (the same as turning the mouse wheel) by the given factor */ + void zoomIn(double factor=2.0); + /** \brief zooms out of the graph (the same as turning the mouse wheel) by the given factor */ + void zoomOut(double factor=2.0); + + /** \brief en-/disables the maintaining of the data aspect ratio */ + void setMaintainAspectRatio(bool value); + + /** \brief en-/disables the maintaining of the axis aspect ratio */ + void setMaintainAxisAspectRatio(bool value); + + /** \brief set filename and prefix, used by loadUserSettings() and saveUserSettings() + * + * \see loadUserSettings(), saveUserSettings(), setUserSettigsPrefix(), getUserSettigsFilename(), getUserSettigsPrefix() + */ + void setUserSettigsFilename(const QString& filename, const QString& prefix); + /** \brief set filename, used by loadUserSettings() and saveUserSettings() + * + * \see loadUserSettings(), saveUserSettings(), setUserSettigsPrefix(), getUserSettigsFilename(), getUserSettigsPrefix() + */ + void setUserSettigsFilename(const QString& filename); + /** \brief set prefix, used by loadUserSettings() and saveUserSettings() + * + * \see loadUserSettings(), saveUserSettings(), setUserSettigsPrefix(), getUserSettigsFilename(), getUserSettigsPrefix() + */ + void setUserSettigsPrefix(const QString& prefix); + /** \brief return the filename, used by loadUserSettings() and saveUserSettings() + * + * \see loadUserSettings(), saveUserSettings(), setUserSettigsPrefix(), getUserSettigsFilename(), getUserSettigsPrefix() + */ + QString getUserSettigsFilename() const; + /** \brief return the prefix, used by loadUserSettings() and saveUserSettings() + * + * \see loadUserSettings(), saveUserSettings(), setUserSettigsPrefix(), getUserSettigsFilename(), getUserSettigsPrefix() + */ + QString getUserSettigsPrefix() const; + + /** \brief loads the plot user properties from the file sepcified by setUserSettigsFilename() and the prefix specified by setUserSettigsPrefix() + * + * \see saveUserSettings(), setUserSettigsPrefix(), getUserSettigsFilename(), getUserSettigsPrefix() + */ + void loadUserSettings(); + + /** \brief saves the plot user properties to the file sepcified by setUserSettigsFilename() and the prefix specified by setUserSettigsPrefix() + * + * \see loadUserSettings(), setUserSettigsPrefix(), getUserSettigsFilename(), getUserSettigsPrefix() + */ + void saveUserSettings() const; + + /** \brief set all graphs invisible, except i */ + void setOnlyGraphVisible(int i); + + /** \brief set all graphs invisible, except graph start, start+n, start+2*n, ... */ + void setOnlyNthGraphsVisible(int start, int n); + + /** \brief sets the data aspect ratio, enforced with setMaintainApsectRatio(true) */ + void setAspectRatio(double __value); + /** \brief sets the axis aspect ratio, enforced with setMaintainAxisApsectRatio(true) */ + void setAxisAspectRatio(double __value); + /*! \copydoc JKQTBasePlotterStyle::useAntiAliasingForSystem */ + void setUseAntiAliasingForSystem(bool __value); + /*! \copydoc JKQTBasePlotterStyle::useAntiAliasingForGraphs */ + void setUseAntiAliasingForGraphs(bool __value); + /*! \copydoc JKQTBasePlotterStyle::useAntiAliasingForText */ + void setUseAntiAliasingForText(bool __value); + /*! \copydoc JKQTBasePlotterStyle::defaultGraphWidth */ + void setGraphWidth(double __value); + /*! \copydoc JKQTBasePlotterStyle::widgetBackgroundColor */ + void setBackgroundColor(const QColor & __value); + /*! \copydoc JKQTBasePlotterStyle::exportBackgroundColor */ + void setExportBackgroundColor(const QColor & __value); + /*! \copydoc JKQTBasePlotterStyle::plotBackgroundColor */ + void setPlotBackgroundColor(const QColor & __value); + /*! \copydoc JKQTPKeyStyle::textColor */ + void setKeyTextColor(const QColor & __value); + + + /*! \copydoc JKQTBasePlotterStyle::plotFrameWidth */ + void setPlotFrameWidth(double __value); + /*! \copydoc JKQTBasePlotterStyle::plotFrameRounding */ + void setPlotFrameRounding(double __value); + /*! \copydoc JKQTBasePlotterStyle::plotFrameColor */ + void setPlotFrameColor(QColor col); + /*! \copydoc JKQTBasePlotterStyle::plotFrameVisible */ + void setPlotFrameVisible(bool enabled); + + + /*! \copydoc JKQTPKeyStyle::fontSize */ + void setKeyFontSize(double __value); + /*! \copydoc JKQTPKeyStyle::itemWidth */ + void setKeyItemWidth(double __value); + /*! \copydoc JKQTPKeyStyle::itemHeight */ + void setKeyItemHeight(double __value); + /*! \copydoc JKQTPKeyStyle::ySeparation */ + void setKeyYSeparation(double __value); + /*! \copydoc JKQTPKeyStyle::sampleLineLength */ + void setKeyLineLength(double __value); + /*! \copydoc JKQTPKeyStyle::xMargin */ + void setKeyXMargin(double __value); + /*! \copydoc JKQTPKeyStyle::yMargin */ + void setKeyYMargin(double __value); + /*! \copydoc JKQTPKeyStyle::xSeparation */ + void setKeyXSeparation(double __value); + /*! \copydoc JKQTPKeyStyle::yOffset */ + void setKeyXOffset(double __value); + /*! \copydoc JKQTPKeyStyle::xOffset */ + void setKeyYOffset(double __value); + /*! \copydoc JKQTPKeyStyle::visible */ + void setShowKey(bool __value); + /*! \copydoc JKQTPKeyStyle::frameVisible */ + void setShowKeyFrame(bool __value); + /*! \copydoc JKQTPKeyStyle::frameColor */ + void setKeyFrameColor(const QColor & __value); + /*! \copydoc JKQTPKeyStyle::backgroundColor */ + void setKeyBackgroundColor(const QColor & __value); + /*! \copydoc JKQTPKeyStyle::frameWidth */ + void setKeyFrameWidth(double __value); + /*! \copydoc JKQTPKeyStyle::frameRounding */ + void setKeyFrameRounding(double __value); + /*! \copydoc JKQTPKeyStyle::autosize */ + void setKeyAutosize(bool __value); + /*! \copydoc JKQTPKeyStyle::position */ + void setKeyPosition(const JKQTPKeyPosition & __value); + /*! \copydoc JKQTPKeyStyle::layout */ + void setKeyLayout(const JKQTPKeyLayout & __value); + /*! \copydoc JKQTBasePlotterStyle::plotLabelFontSize */ + void setPlotLabelFontSize(double __value); + /*! \copydoc JKQTBasePlotterStyle::plotLabelFontName */ + void setplotLabelFontName(const QString & __value); + /** \brief set the plot label text */ + void setPlotLabel(const QString & __value); + /*! \copydoc JKQTBasePlotterStyle::defaultTextColor */ + void setDefaultTextColor(QColor __value) ; + /*! \copydoc JKQTBasePlotterStyle::defaultFontSize */ + void setDefaultTextSize(float __value) ; + /*! \copydoc JKQTBasePlotterStyle::defaultFontName */ + void setDefaultTextFontName(const QString& __value) ; + /** \brief sets the current directory in which to open SaveAs ... dialogs */ + void setCurrentSaveDirectory(const QString & __value); + /** \brief set the file format to use in SaveAs ... dialogs */ + void setCurrentFileFormat(const QString & __value); + /** \brief set the decimal separator used when exporting data to text files */ + void setCSVdecimalSeparator(const QString & __value); + /** \brief set the string used to introduce comments in text output when exporting data */ + void setCSVcommentInitializer(const QString & __value); + + /** \brief if set \c true (default: \c false ) the JKQTBasePlotter draws colored rectangles to indicate the different regions in the plot (border, axes, ...) + * + * \see JKQTBasePlotterStyle::debugShowRegionBoxes, isDebugShowRegionBoxesEnabled() + */ + void enableDebugShowRegionBoxes(bool enabled=true); protected: - static QHash tbrh; + /** \brief this is a cache for JKQTBasePlotter::textSizeData calculated with JKQTBasePlotter::getTextSizeDetail() */ + static QHash s_TextSizeDataCache; + + + + + + + + /** \brief paints the plot onto the given JKQTPEnhancedPainter object */ + void drawPlot(JKQTPEnhancedPainter& painter, bool showOverlays=true); + /** \brief simply calls paintPlot() if grid printing mode is deactivated and prints the graph grid otherwise + * \a pageRect is used to determine the size of the page to draw on. If this does not coincide with + * the widget extents this function calculates a scaling factor so the graphs fit onto the page. This + * is especially usefull when printing! + */ + void gridPaint(JKQTPEnhancedPainter& painter, QSizeF pageRect, bool showOverlays=true, bool scaleIfTooLarge=true, bool scaleIfTooSmall=true); + void gridPaintOverlays(JKQTPEnhancedPainter& painter, QSizeF pageRect); + + /** \brief This method goes through all registered plotters and calculates the width of every column and + * height of every row as the max over the row/column. The reults are stored in the private datamembers + * gridPrintingRows and gridPrintingColumns. gridPrintingSize will contain the size of all graphs together + * afterwards. */ + void gridPrintingCalc(); + + /** \brief plot the grid */ + void drawSystemGrid(JKQTPEnhancedPainter& painter); + /** \brief plot the x coordinate axis (incl. labels) */ + void drawSystemXAxis(JKQTPEnhancedPainter& painter); + /** \brief plot the x coordinate axis (incl. labels) */ + void drawSystemYAxis(JKQTPEnhancedPainter& painter); + /** \brief plot the graphs */ + void drawGraphs(JKQTPEnhancedPainter& painter); + /** \brief plot a key */ + void drawKey(JKQTPEnhancedPainter& painter); + /** \brief plot all overlay elements, also sets the render hints in \a painter */ + void drawOverlaysWithHints(JKQTPEnhancedPainter& painter); + + /** \brief plot the key contents + * + * This function does not do anything and has to be overwritten in child classes if they want to plot a key. + * The implementation should draw the contents of the key, not its frame as this is done in plotKey(). + * + * \param painter draw the key on this painter + * \param x left-most coordinate of the key [pixels] + * \param y top-most coordinate of the key [pixels] + * \param width width of the key [pixels] + * \param height height of the key [pixels] + * + * So any implementation should only draw inside the rectangle [x..x+width, y..y+hieght] + */ + void drawKeyContents(JKQTPEnhancedPainter& painter, double x, double y, double width, double height); + + /** \brief returns the size of the key (as call-by-reference parameters + * + * Any implementation of key plotting has to overwrite this function and use it to return the size of the key that would be + * plotted by plotKeyContents(). This class will use the return values to plot the frame of the key and also supply them to + * plotKeyContents(). If height or width are returned 0, no key is plotted + * + * 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); + + /** \brief show the export preview window for a given page size \a pageSize, either in pixels (\a unitIsMM \c ==false ) or in millimeters (\a unitIsMM \c ==true ) */ + bool exportpreview(QSizeF pageSize, bool unitIsMM=false); + + /*! \brief sets the property fontSizeMultiplier ( \copybrief fontSizeMultiplier ) to the specified \a __value. + \details Description of the parameter fontSizeMultiplier is:
    \copydoc fontSizeMultiplier
    + \see fontSizeMultiplier for more information */ + void setFontSizeMultiplier(double __value); + /*! \brief sets the property lineWidthMultiplier ( \copybrief lineWidthMultiplier ) to the specified \a __value. + \details Description of the parameter lineWidthMultiplier is:
    \copydoc lineWidthMultiplier
    + \see lineWidthMultiplier for more information */ + void setLineWidthMultiplier(double __value); + /*! \brief sets the property printMagnification ( \copybrief printMagnification ) to the specified \a __value. + \details Description of the parameter printMagnification is:
    \copydoc printMagnification
    + \see printMagnification for more information */ + void setPrintMagnification(double __value); + /*! \brief returns the property printMagnification ( \copybrief printMagnification ). + \details Description of the parameter printMagnification is:
    \copydoc printMagnification
    + \see printMagnification for more information */ + double getPrintMagnification() const; + /*! \brief sets the property paintMagnification ( \copybrief paintMagnification ) to the specified \a __value. + \details Description of the parameter paintMagnification is:
    \copydoc paintMagnification
    + \see paintMagnification for more information */ + void setPaintMagnification(double __value); + /*! \brief returns the property paintMagnification ( \copybrief paintMagnification ). + \details Description of the parameter paintMagnification is:
    \copydoc paintMagnification
    + \see paintMagnification for more information */ + double getPaintMagnification() const; + + + protected slots: + /** \brief internal function for print/export preview + * \internal + */ + void updatePreviewLabel(); + /** \brief internal function for print preview + * \internal + */ + void printpreviewPaintRequested(QPrinter *printer); + /** \brief internal function for print preview + * \internal + */ + void printpreviewPaintRequestedNew(QPrinter *printer); + /** \brief internal function for print preview + * \internal + */ + void printpreviewPaintRequestedNew(QPaintDevice *paintDevice); + /** \brief internal function for export preview + * \internal + */ + void exportpreviewPaintRequested(JKQTPEnhancedPainter& painter, QSize size); + /** \brief internal function for print preview + * \internal + */ + void printpreviewSetZoom(double value); + /** \brief internal function for print preview + * \internal + */ + void printpreviewSetSizeX(double value); + /** \brief internal function for print preview + * \internal + */ + void printpreviewSetSizeY(double value); + /** \brief internal function for print preview + * \internal + */ + void printpreviewSetSizeXNew(double value); + /** \brief internal function for print preview + * \internal + */ + void printpreviewSetSizeYNew(double value); + /** \brief internal function for print preview + * \internal + */ + void printpreviewSetMagnification(double value); + /** \brief internal function for print preview + * \internal + */ + void printpreviewSetMagnificationNew(double value); + /** \brief internal function for print preview + * \internal + */ + void printpreviewSetAspectRatio(bool checked); + /** \brief internal function for print preview + * \internal + */ + void printpreviewSetKeepAbsFontsize(bool checked); + /** \brief internal function for print preview + * \internal + */ + void printpreviewToggleMagnification(bool checked); + /** \brief internal function for print preview + * \internal + */ + void printpreviewSetLineWidthMultiplier(double value); + /** \brief internal function for print preview + * \internal + */ + void printpreviewSetFontSizeMultiplier(double value); + /** \brief internal function for print preview + * \internal + */ + void printpreviewUpdate(); + /** \brief internal function for getDataColumnsByUser() + * \internal + */ + void getDataColumnsByUserCheckAll(); + /** \brief internal function for getDataColumnsByUser() + * \internal + */ + void getDataColumnsByUserCheckNone(); + /** \brief internal function for getDataColumnsByUser() + * \internal + */ + void getDataColumnsByUserSave(); + /** \brief internal function for getDataColumnsByUser() + * \internal + */ + void getDataColumnsByUserComboBoxSelected(const QString& name); + /** \brief internal function for getDataColumnsByUser() + * \internal + */ + void getDataColumnsByUserItemChanged(QListWidgetItem* widgetitem); + /** \brief internal function for getDataColumnsByUser() + * \internal + */ + void showPlotData(); + /** \brief may be connected to zoomChangedLocally() of a different plot and synchronizes the local x-axis to the other x-axis */ + void synchronizeXAxis(double newxmin, double newxmax, double newymin, double newymax, JKQTBasePlotter* sender); + /** \brief may be connected to zoomChangedLocally() of a different plot and synchronizes the local y-axis to the other y-axis */ + void synchronizeYAxis(double newxmin, double newxmax, double newymin, double newymax, JKQTBasePlotter* sender); + /** \brief may be connected to zoomChangedLocally() of a different plot and synchronizes the local x- and y-axis to the other x- and y-axis */ + void synchronizeXYAxis(double newxmin, double newxmax, double newymin, double newymax, JKQTBasePlotter* sender); + + protected: + /** \brief current style properties for this JKQTBasePlotter instance + * + * \see JKQTPSetSystemDefaultBaseStyle(), JKQTPSetSystemDefaultBaseStyle(), getCurrentPlotterStyle(), \ref jkqtpplotter_styling + */ + JKQTBasePlotterStyle plotterStyle; + + /** \brief copy sub-properties of plotterStyle to sub-objects that require it (axes, axes in graphs ...) and emit a plot update */ + void propagateStyle(); + + /** \brief used to plot LaTeX markup */ + JKQTMathText mathText; + + /** \brief model representing all Plots in this plotter and showing their visible/invisible state */ + JKQTPGraphsModel* m_plotsModel; + + /** \brief object used for the x-axis */ + JKQTPHorizontalAxis* xAxis; + /** \brief object used for the y-axis */ + JKQTPVerticalAxis* yAxis; + + /** \brief filename for the ini file in which to save the user settings + * \see jkqtplotter_base_userprops + */ + QString userSettigsFilename; + /** \brief prefix for the ini file in which to save the user settings + * \see jkqtplotter_base_userprops + */ + QString userSettigsPrefix; + + + /** \brief indicates whether the \ref JKQTBASEPLOTTER_SYNCMULTIPLOT_GRIDPRINT "grid printing" is activated + * + * \see \ref JKQTBASEPLOTTER_SYNCMULTIPLOT_GRIDPRINT + */ + bool gridPrinting; + /** \brief x position of the current graph in \ref JKQTBASEPLOTTER_SYNCMULTIPLOT_GRIDPRINT "grid printing" + * + * \see \ref JKQTBASEPLOTTER_SYNCMULTIPLOT_GRIDPRINT + */ + size_t gridPrintingCurrentX; + /** \brief y position of the current graph in \ref JKQTBASEPLOTTER_SYNCMULTIPLOT_GRIDPRINT "grid printing" + * + * \see \ref JKQTBASEPLOTTER_SYNCMULTIPLOT_GRIDPRINT + */ + size_t gridPrintingCurrentY; + /** \brief list that manages all the additional graphs for \ref JKQTBASEPLOTTER_SYNCMULTIPLOT_GRIDPRINT "grid printing" mode */ + QList gridPrintingList; + /** \brief this list contains all the rows of the current \ref JKQTBASEPLOTTER_SYNCMULTIPLOT_GRIDPRINT "grid printing" and stores its heights */ + QList gridPrintingRows; + /** \brief this list contains all the columns of the current \ref JKQTBASEPLOTTER_SYNCMULTIPLOT_GRIDPRINT "grid printing" and stores its widths */ + QList gridPrintingColumns; + /** \brief size of all plots in \ref JKQTBASEPLOTTER_SYNCMULTIPLOT_GRIDPRINT "grid printing" mode, filled by gridPrintingCalc() */ + QSizeF gridPrintingSize; + + /** \brief this is an internal property that is used by the export/print system to control the "magnification". Usually this is 1.0 + * but if set !=1.0, it is used to scale the widgetWidth and widgetHeight before painting! */ + double paintMagnification; + + /** \brief an object which manages all data columns for this plotter class */ + JKQTPDatastore* datastore; + /** \brief indicates whether the datastore is managed (allocated/freed) internally or externally */ + bool datastoreInternal; + + + /** \brief width of the plot widget + * + * \image html plot_widget_orientation.png + * + * \see setWidgetSize(), \ref jkqtplotter_base_plotsize + */ + int widgetWidth; + + /** \brief height of the plot widget + * + * \image html plot_widget_orientation.png + * + * \see setWidgetSize(), \ref jkqtplotter_base_plotsize + */ + int widgetHeight; + + + + /** \brief calculated value: free space between widget top border and plot top border, as used to plot the graph + * \internal + * + * \note This property is an intermediate storage for calculated values. Do not change directly! + */ + double internalPlotBorderTop; + /** \brief calculated value: free space between widget top border and top border of the key/legend + * \internal + * + * \note This property is an intermediate storage for calculated values. Do not change directly! + */ + double internalPlotKeyBorderTop; + /** \brief calculated value: height of the plot title (or 0 if no title) + * \internal + * + * \note This property is an intermediate storage for calculated values. Do not change directly! + */ + double internalTitleHeight; + + /** \brief calculated value: free space between widget top border and plot top border, as used to plot the graph + * \internal + * + * \note This property is an intermediate storage for calculated values. Do not change directly! + */ + double internalPlotBorderLeft; + /** \brief calculated value: free space between widget left border and left border of the key/legend + * \internal + * + * \note This property is an intermediate storage for calculated values. Do not change directly! + */ + double internalPlotKeyBorderLeft; + + /** \brief calculated value: free space between widget top border and plot top border, as used to plot the graph + * \internal + * + * \note This property is an intermediate storage for calculated values. Do not change directly! + */ + double internalPlotBorderBottom; + /** \brief calculated value: free space between widget bottom border and bottom border of the key/legend + * \internal + * + * \note This property is an intermediate storage for calculated values. Do not change directly! + */ + double internalPlotKeyBorderBottom; + + /** \brief calculated value: free space between widget top border and plot top border, as used to plot the graph + * \internal + * + * \note This property is an intermediate storage for calculated values. Do not change directly! + */ + double internalPlotBorderRight; + /** \brief calculated value: free space between widget right border and right border of the key/legend + * \internal + * + * \note This property is an intermediate storage for calculated values. Do not change directly! + */ + double internalPlotKeyBorderRight; + + + + /** \brief calculated value: free space between widget top border and (plot+drawOutside) top border (including coordinate axes) + * \internal + * + * \image html plot_widget_orientation.png + * + * \note This property is an intermediate storage for calculated values. Do not change directly! + */ + double internalPlotBorderTop_notIncludingOutsidePlotSections; + /** \brief calculated value: free space between widget left border and (plot+drawOutside) left border (including coordinate axes) + * \internal + * + * \image html plot_widget_orientation.png + * + * \note This property is an intermediate storage for calculated values. Do not change directly! + */ + double internalPlotBorderLeft_notIncludingOutsidePlotSections; + /** \brief calculated value: free space between widget right border and (plot+drawOutside) right border (including coordinate axes) + * \internal + * + * \image html plot_widget_orientation.png + * + * \note This property is an intermediate storage for calculated values. Do not change directly! + */ + double internalPlotBorderBottom_notIncludingOutsidePlotSections; + /** \brief calculated value: free space between widget bottom border and (plot+drawOutside) bottom border (including coordinate axes) + * \internal + * + * \image html plot_widget_orientation.png + * + * \note This property is an intermediate storage for calculated values. Do not change directly! + */ + double internalPlotBorderRight_notIncludingOutsidePlotSections; + + /** \brief calculated value: plot width in pixel inside the widget (calculated by calcPlotScaling() from plotBorderLeft, plotBorderRight and widgetWidth) + * + * \image html plot_widget_orientation.png + * + * \see \ref jkqtplotter_base_plotsize + */ + int internalPlotWidth; + /** \brief calculated value: plot height in pixel inside the widget (calculated by calcPlotScaling() from plotBorderTop, plotBorderBottom and widgetHeight) + * + * \image html plot_widget_orientation.png + * + * \see \ref jkqtplotter_base_plotsize + */ + int internalPlotHeight; + + /** \brief indicates whether the widget should maintain an aspect ratio of plotwidth and plotheight */ + bool maintainAspectRatio; + /** \brief the aspect ratio of plotwidth and plotheight to maintain, if \c maintainAspectRatio==true */ + double aspectRatio; + + /** \brief indicates whether the axes should maintain an aspect ratio */ + bool maintainAxisAspectRatio; + /** \brief the aspect ratio of axis widths to maintain, if \c maintainAxisAspectRatio==true */ + double axisAspectRatio; + + + /** \brief the plot label text */ + QString plotLabel; + + + /** \brief calculate the scaling and offset values from axis min/max values */ + void calcPlotScaling(JKQTPEnhancedPainter& painter); + + /** \brief set the standard settings (colors, line widths ...) */ + void initSettings(); + + + /** \brief specifies whether this class emits signals, like zoomChangedLocally() or beforePlotScalingRecaluclate() */ + bool emitSignals; + + /** \brief multiplier which is used for font sizes when the plot is exported/printed */ + double fontSizePrintMultiplier; + + /** \brief multiplier which is used for linewidths when the plot is exported/printed */ + double lineWidthPrintMultiplier; + + /** \brief multiplier for the font size */ + double fontSizeMultiplier; + /** \brief multiplier or the line widths */ + double lineWidthMultiplier; + + /** \brief internal: used to store a list of all currently used plot styles */ + QList usedStyles; + + + /** \brief a vector that contains all graphs to be plottet in the system */ + QList graphs; + + + QList overlays; + + + + + + /** \brief indicates whether to use clipping (hack for printing, see print() ) */ + bool useClipping; + + + + + /** \brief QAction which triggers saving of the plot as an image */ + QAction* actSavePlot; + /** \brief QAction which triggers saving of the data used for the plot */ + QAction* actSaveData; + /** \brief QAction which triggers copying of the data to the clipboard */ + QAction* actCopyData; + /** \brief QAction which triggers copying of the image to the clipboard */ + QAction* actCopyPixelImage; + /** \brief QAction which triggers copying of the data to the clipboard in Matlab format */ + QAction* actCopyMatlab; + /** \brief QAction which triggers the saving as PDF */ + QAction* actSavePDF; +#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) + /** \brief QAction which triggers the saving as PostScript */ + QAction* actSavePS; +#endif + /** \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; + /** \brief QAction which triggers the saving as CSV (data only) */ + QAction* actSaveCSV; + /** \brief QAction which triggers zoom all */ + QAction* actZoomAll; + /** \brief QAction which triggers zoom in */ + QAction* actZoomIn; + /** \brief QAction which triggers zoom out */ + QAction* actZoomOut; + /** \brief QAction to show a table with all the plot data in the datastore */ + QAction* actShowPlotData; + /** \brief this list contains additional actions, that can be registered by registerAdditionalAction(). They are shown in the context menu only and are e.g. used to display "save image data" actions. Each action may be in a category (key of map), which is displayed as a submenu of the context-menu! */ + AdditionalActionsMap lstAdditionalPlotterActions; + /** \brief the current directory in which to open SaveAs ... dialogs */ + QString currentSaveDirectory; + /** \brief the current file format to use in SaveAs ... dialogs */ + QString currentFileFormat; + /** \brief the current file format to use in SaveDataAs ... dialogs */ + QString currentDataFileFormat; + /** \brief the currently selected printer */ + QString currentPrinter; + + /** \brief the master plotter for x-dimension, this plotter is connected to. */ + JKQTBasePlotter *masterPlotterX; + /** \brief the master plotter for y-dimension, this plotter is connected to. */ + JKQTBasePlotter *masterPlotterY; + /** \brief synchronize plot width with masterPlotterX */ + bool masterSynchronizeWidth; + /** \brief synchronize plot height with masterPlotterY */ + bool masterSynchronizeHeight; + + + /** \brief controls, whether the signals plotUpdated() and overlaysUpdated() are emitted */ + bool emitPlotSignals; + + + + + + QListWidget* dataColumnsListWidget; + QComboBox* dataColumnsCombobox; + QSet getDataColumnsByUser(); + QMap getDataColumnsByUserSaved; + + + private: + double printZoomFactor; + double printSizeX_Millimeter; + double printSizeY_Millimeter; + double printMagnification; + QPointer printPreview; + QPointer spinSizeX; + QPointer spinSizeY; + QPointer exportPreviewLabel; + QPointer spinMagnification; + bool printSetAbsolutePageSize; + bool printSetAbsolutePlotSize; + bool printKeepAbsoluteFontSizes; + bool printScaleToPagesize; + double printAspect; + bool printKeepAspect; + bool exportUnitInMM; + QSizeF printPageSizeMM; + bool printDoUpdate; + + + + }; diff --git a/lib/jkqtplotter/jkqtpbaseplotterstyle.cpp b/lib/jkqtplotter/jkqtpbaseplotterstyle.cpp new file mode 100644 index 0000000000..4b011eb4f6 --- /dev/null +++ b/lib/jkqtplotter/jkqtpbaseplotterstyle.cpp @@ -0,0 +1,235 @@ +#include "jkqtpbaseplotterstyle.h" +#include +#include +#include "jkqtplottertools/jkqtptools.h" + +JKQTBasePlotterStyle::JKQTBasePlotterStyle(): + debugShowRegionBoxes(false), + debugRegionLineWidth(3), + CSVdecimalSeparator("."), + CSVcommentInitializer("# "), + plotBorderTop(5), + plotBorderLeft(5), + plotBorderBottom(5), + plotBorderRight(5), + defaultGraphWidth(2), + defaultGraphSymbolSize(10), + defaultGraphSymbolLineWidth(1), + widgetBackgroundColor(QApplication::palette().color(QPalette::Window)), + exportBackgroundColor(QColor("white")), + plotBackgroundColor(QColor("white")), + plotFrameColor(QColor("black")), + plotFrameWidth(2), + plotFrameRounding(0), + plotFrameVisible(false), + plotLabelFontName(QApplication::font().family()+"+XITS"), + plotLabelFontSize(12), + useAntiAliasingForSystem(true), + useAntiAliasingForGraphs(true), + useAntiAliasingForText(true), + defaultTextColor(QColor("black")), + defaultFontSize(8), + defaultFontName(QApplication::font().family()+"+XITS"), + defaultPalette(JKQTPMathImageMATLAB), + graphFillColorDerivationMode(JKQTPFFCMLighterColor), + graphErrorColorDerivationMode(JKQTPFFCMDarkerColor), + graphErrorFillColorDerivationMode(JKQTPFFCMEvenLighterColor), + keyStyle(*this), + xAxisStyle(*this), + yAxisStyle(*this), + rightColorbarAxisStyle(*this), + topColorbarAxisStyle(*this) +{ + /* + keyStyle=JKQTPKeyStyle(*this); + xAxisStyle=JKQTPCoordinateAxisStyle(*this); + yAxisStyle=JKQTPCoordinateAxisStyle(*this); + rightColorbarAxisStyle=JKQTPCoordinateAxisStyle(*this); + topColorbarAxisStyle=JKQTPCoordinateAxisStyle(*this); + */ + + defaultGraphColors<(i)); + defaultGraphFillStyles<=0) { + defaultGraphColors.push_back(jkqtp_String2QColor(settings.value(group+"default_graph_styles/color"+QString::number(id), jkqtp_QColor2String(QColor("red"))).toString())); + } + + id=readID(k, group+"default_graph_styles/line_style"); + if (id>=0) { + defaultGraphPenStyles.push_back(jkqtp_String2QPenStyle(settings.value(group+"default_graph_styles/line_style"+QString::number(id), jkqtp_QPenStyle2String(Qt::SolidLine)).toString())); + } + + id=readID(k, group+"default_graph_styles/symbol"); + if (id>=0) { + defaultGraphSymbols.push_back(String2JKQTPGraphSymbols(settings.value(group+"default_graph_styles/symbol"+QString::number(id), JKQTPGraphSymbols2String(JKQTPCross)).toString())); + } + id=readID(k, group+"default_graph_styles/fill_style"); + if (id>=0) { + defaultGraphFillStyles.push_back(jkqtp_String2QBrushStyle(settings.value(group+"default_graph_styles/fill_style"+QString::number(id), jkqtp_QBrushStyle2String(Qt::SolidPattern)).toString())); + } + } + if (defaultGraphColors.size()==0) { + for (int i=defaultGraphColors.size(); i, ) + + + + This software is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License 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 for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ + +#ifndef JKQTBASEPLOTTERSTYLE_H +#define JKQTBASEPLOTTERSTYLE_H + +#include "jkqtplottertools/jkqtptools.h" +#include "jkqtplotter/jkqtpcoordinateaxesstyle.h" +#include "jkqtplotter/jkqtpkeystyle.h" +#include "jkqtplottertools/jkqtpimagetools.h" +#include "jkqtplottertools/jkqtp_imexport.h" +#include +#include +#include +#include +#include +#include +#include + + +/** \brief Support Class for JKQTBasePlotter, which summarizes all proeprties that define the visual styling of a JKQTBasePlotter + * \ingroup jkqtpplotter_styling + * + * \see JKQTBasePlotter, \ref jkqtpplotter_styling + */ +class JKQTP_LIB_EXPORT JKQTBasePlotterStyle { + Q_GADGET + public: + JKQTBasePlotterStyle(); + + + + /** \brief loads the plot properties from a QSettings object + * + * \param settings QSettings-object to read from + * \param group Group in the QSettings-object to read from + * \param defaultStyle If a setting cannot be found in \a settings, default values are taken from this object + * By default, this is a default-constructed object + */ + void loadSettings(const QSettings &settings, const QString& group=QString("plots/"), const JKQTBasePlotterStyle &defaultStyle=JKQTBasePlotterStyle()); + + /** \brief saves the plot properties into a QSettings object. + * + * \param settings QSettings-object to save to + * \param group Group in the QSettings-object to save to + */ + void saveSettings(QSettings& settings, const QString& group=QString("plots/")) const; + + /** \brief if set \c true (default: \c false ) the JKQTBasePlotter draws colored rectangles to indicate the different regions in the plot (border, axes, ...) */ + bool debugShowRegionBoxes; + /** \brief width of the lines that are drawn, when debugShowRegionBoxes \c ==true [in pixels] */ + double debugRegionLineWidth; + + + /** \brief the decimal separator used when exporting data to text files */ + QString CSVdecimalSeparator; + /** \brief this string is used to introduce comments in text output when exporting data */ + QString CSVcommentInitializer; + /** \brief free space between widget top border and plot top border, this property may be set by the user and is possibly altered + * by the key positioning algorithm. The altered value is written to internalPlotBorderTop + * + * \image html plot_widget_orientation.png + * + * \see JKQTBasePlotter::setBorder(), \ref jkqtplotter_base_plotsize + */ + int plotBorderTop; + /** \brief free space between widget left border and plot left border, this property may be set by the user and is possibly altered + * by the key positioning algorithm. The altered value is written to internalPlotBorderLeft + * + * \image html plot_widget_orientation.png + * + * \see JKQTBasePlotter::setBorder(), \ref jkqtplotter_base_plotsize + */ + int plotBorderLeft; + /** \brief free space between widget bottom border and plot bottom border, this property may be set by the user and is possibly altered + * by the key positioning algorithm. The altered value is written to internalPlotBorderBottom + * + * \image html plot_widget_orientation.png + * + * \see JKQTBasePlotter::setBorder(), \ref jkqtplotter_base_plotsize + */ + int plotBorderBottom; + /** \brief free space between widget right border and plot right border, this property may be set by the user and is possibly altered + * by the key positioning algorithm. The altered value is written to internalPlotBorderRight + * + * \image html plot_widget_orientation.png + * + * \see JKQTBasePlotter::setBorder(), \ref jkqtplotter_base_plotsize + */ + int plotBorderRight; + /** \brief width (in pt) of lines used for newly added graphs */ + double defaultGraphWidth; + /** \brief size (in pt) of symbols used for newly added graphs */ + double defaultGraphSymbolSize; + /** \brief with (in pt) of symbol lines used for newly added graphs */ + double defaultGraphSymbolLineWidth; + /** \brief color of the background of the plot (widget area) when drawing (to the screen) */ + QColor widgetBackgroundColor; + /** \brief color of the background of the plot (widget area) when exporting*/ + QColor exportBackgroundColor; + /** \brief color of the plot's background (i.e. of the area within the coordinate axes rectangle) */ + QColor plotBackgroundColor; + /** \brief if \c plotFrameVisible==true, JKQTBasePlotter will draw a rectangle/frame around the plot in this color */ + QColor plotFrameColor; + /** \brief if \c plotFrameVisible==true, JKQTBasePlotter will draw a rectangle/frame around the plot in this width [pt] */ + double plotFrameWidth; + /** \brief if \c plotFrameVisible==true, JKQTBasePlotter will draw a rectangle/frame around the plot, rounding the corners with this redius (<=0 -> no rounded rectangle) [pt] */ + double plotFrameRounding; + /** \brief if \c true, JKQTBasePlotter will draw a rectangle/frame around the plot */ + bool plotFrameVisible; + /** \brief the plot label font name */ + QString plotLabelFontName; + /** \brief the plot label font size [pt] */ + double plotLabelFontSize; + /** \brief specifies whether to use antialiasing for plotting the coordinate system */ + bool useAntiAliasingForSystem; + /** \brief specifies whether to use antialiasing for plotting the graphs + * + * \note You can set this property \c false to increase plotting speed of complex plots (with many graphs inside). You can reach a + * roughly three-fold speed improvement! + */ + bool useAntiAliasingForGraphs; + /** \brief specifies whether to use antialiasing when drawing any text + * \note You can set this property \c false to increase plotting speed of complex plots (with many graphs inside). You can reach a + * roughly three-fold speed improvement! + */ + bool useAntiAliasingForText; + /** \brief default text color in the plot */ + QColor defaultTextColor; + /** \brief default font size in the plot [pt] */ + double defaultFontSize; + /** \brief default font name in the plot */ + QString defaultFontName; + /** \brief color palette used by default for new graphs */ + JKQTPMathImageColorPalette defaultPalette; + /** \brief defines how to derive a fill color for a new graph */ + JKQTPColorDerivationMode graphFillColorDerivationMode; + /** \brief defines how to derive an error color for a new graph */ + JKQTPColorDerivationMode graphErrorColorDerivationMode; + /** \brief defines how to derive an error fill color from the error color for a new graph */ + JKQTPColorDerivationMode graphErrorFillColorDerivationMode; + + + /** \brief colors used to automatically collor different graphs differently */ + QVector defaultGraphColors; + /** \brief Qt::PenStyle used to automatically style different graphs differently */ + QVector defaultGraphPenStyles; + /** \brief JKQTPGraphSymbols used to automatically assign to different graphs */ + QVector defaultGraphSymbols; + /** \brief Qt::BrushStyle used to automatically style different graphs differently */ + QVector defaultGraphFillStyles; + + + /** \brief style of the plot key/legend */ + JKQTPKeyStyle keyStyle; + /** \brief style of the x-axis of the main coordinate system */ + JKQTPCoordinateAxisStyle xAxisStyle; + /** \brief style of the y-axis of the main coordinate system */ + JKQTPCoordinateAxisStyle yAxisStyle; + /** \brief style of the coordinate axes used to display colorbars in the right */ + JKQTPCoordinateAxisStyle rightColorbarAxisStyle; + /** \brief style of the coordinate axes used to display colorbars at the top */ + JKQTPCoordinateAxisStyle topColorbarAxisStyle; + + +}; + +/** \brief returns the system-wide default JKQTPlotterStyle + * \ingroup jkqtpplotter_styling + * + * \see JKQTPGetSystemDefaultStyle(), JKQTPSetSystemDefaultStyle(), JKQTPSetSystemDefaultBaseStyle(), \ref jkqtpplotter_styling + */ +JKQTP_LIB_EXPORT JKQTBasePlotterStyle& JKQTPGetSystemDefaultBaseStyle(); + +/** \brief replaces the system-wide default JKQTPlotterStyle with the given \a newStyle + * \ingroup jkqtpplotter_styling + * + * \see JKQTPGetSystemDefaultStyle(), JKQTPSetSystemDefaultStyle(), JKQTPGetSystemDefaultBaseStyle(), \ref jkqtpplotter_styling + */ +JKQTP_LIB_EXPORT void JKQTPSetSystemDefaultBaseStyle(JKQTBasePlotterStyle& newStyle); + +#endif // JKQTBASEPLOTTERSTYLE_H diff --git a/lib/jkqtplotter/jkqtpcoordinateaxes.cpp b/lib/jkqtplotter/jkqtpcoordinateaxes.cpp new file mode 100644 index 0000000000..86ca151623 --- /dev/null +++ b/lib/jkqtplotter/jkqtpcoordinateaxes.cpp @@ -0,0 +1,2257 @@ +/* + Copyright (c) 2008-2019 Jan W. Krieger () + + + + 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 . +*/ + +#include "jkqtplotter/jkqtpcoordinateaxes.h" +#include "jkqtplotter/jkqtpbaseplotter.h" +#include "jkqtplottertools/jkqtpdrawingtools.h" +#include +#include +#include +#include + + +//#undef SHOW_JKQTPLOTTER_DEBUG +//#define SHOW_JKQTPLOTTER_DEBUG + +JKQTPCoordinateAxis::JKQTPCoordinateAxis(JKQTBasePlotter* parent): + QObject(parent) +{ + this->parent=parent; + + axisPrefix=""; + scaleSign=1; + doUpdateScaling=true; + + axismin=-10; + axismax=10; + axisabsoultemin=-DBL_MAX/100.0; + axisabsoultemax=DBL_MAX/100.0; + axisMinWidth=-1; + + width=20; + + scale=0; + offset=0; + inverted=false; + + tickSpacing=0; + tickSpacingLog=10; + tickStart=0; + + autoAxisSpacing=true; + logAxis=false; + logAxisBase=10; + userTickSpacing=1; + userLogTickSpacing=10; + + axisLabel=""; + + + paramsChanged=true; +} + +JKQTPCoordinateAxis::~JKQTPCoordinateAxis() = default; + +void JKQTPCoordinateAxis::setParent(JKQTBasePlotter* parent) { + this->parent=parent; + QObject::setParent(parent); +} + +void JKQTPCoordinateAxis::redrawPlot() { + //if (paramsChanged) { + calcPlotScaling(); + parent->redrawPlot(); + //} +} + +JKQTMathText* JKQTPCoordinateAxis::getParentMathText() { + return parent->getMathText(); +} + +void JKQTPCoordinateAxis::clearAxisTickLabels() { + tickLabels.clear(); + redrawPlot(); +} + +void JKQTPCoordinateAxis::addAxisTickLabel(double x, const QString& label) { + tickLabels.append(qMakePair(x, label)); + redrawPlot(); +} + +void JKQTPCoordinateAxis::addAxisTickLabels(const QVector &x, const QStringList &label) { + for (int i=0; i &x, const QString *label) { + for (int i=0; i0 && res[res.size()-1]=='0') { + res=res.left(res.size()-1); + } + if (res.size()>0 && res[res.size()-1]==loc.decimalPoint()) res=res.left(res.size()-1); + } + return res; + }; break; + case JKQTPCALTexponent: { + return QString(jkqtp_floattolatexstr(data, past_comma, remove_trail0, belowIsZero, pow(10, -past_comma), pow(10, past_comma+1)).c_str()); + }; break; + case JKQTPCALTexponentCharacter: { + return QString(jkqtp_floattounitstr(data, past_comma, remove_trail0).c_str()); + }; break; + case JKQTPCALTdate: { + QDateTime dt; + dt.setMSecsSinceEpoch(uint64_t(data)); + return dt.toString(axisStyle.tickDateFormat); + }; break; + case JKQTPCALTtime: { + QDateTime dt; + dt.setMSecsSinceEpoch(uint64_t(data)); + return dt.toString(axisStyle.tickTimeFormat); + }; break; + case JKQTPCALTdatetime: { + QDateTime dt; + dt.setMSecsSinceEpoch(uint64_t(data)); + return dt.toString(axisStyle.tickDateTimeFormat); + }; break; + default: + return QString(); + break; + } + + /* + axisStyle.tickTimeFormat + axisStyle.tickDateFormat + axisStyle.tickDateTimeFormat + **/ + + return QString(); +} + +QString JKQTPCoordinateAxis::floattolabel(double data, int past_comma) { + bool remove_trail0=true; + QLocale loc=QLocale::system(); + loc.setNumberOptions(QLocale::OmitGroupSeparator); + if (axisStyle.labelType==JKQTPCALTdefault) { + QString res=loc.toString(data, 'f', past_comma);//QString::number(data, 'f', past_comma); + if (remove_trail0 && res.contains(QLocale::system().decimalPoint())) { + while (res.size()>0 && res[res.size()-1]=='0') { + res=res.left(res.size()-1); + } + if (res.size()>0 && res[res.size()-1]==loc.decimalPoint()) res=res.left(res.size()-1); + } + return res; + } else if (axisStyle.labelType==JKQTPCALTexponent) return QString(jkqtp_floattolatexstr(data, past_comma, remove_trail0, 1e-300, pow(10, -past_comma), pow(10, past_comma+1)).c_str()); + else if (axisStyle.labelType==JKQTPCALTexponentCharacter) return QString(jkqtp_floattounitstr(data, past_comma, remove_trail0).c_str()); + return ""; +} + +int JKQTPCoordinateAxis::calcLinearUnitDigits() { + if (!axisStyle.autoLabelDigits) return axisStyle.labelDigits; + int unitdigits=-1; + double minval=tickStart; + bool equals=true; + /*for (int i=0; i<20; i++) { + equals=equals || (floattolabel((minval+static_cast(i)*tickSpacing), unitdigits)== floattolabel((minval+static_cast(i+1)*tickSpacing), unitdigits)); + }*/ + while ((unitdigits<20) && equals) { + unitdigits++; + equals=false; + for (int i=-10; i<10; i++) { + QString l1=floattolabel((minval+static_cast(i)*tickSpacing), unitdigits+2); + QString l2=floattolabel((minval+static_cast(i+1.0)*tickSpacing), unitdigits+2); + //qDebug()<<"unitdigits="<axismax) { + std::swap(axismin, axismax); + } else if (axismax==axismin) { + axismax=axismin+1.0; + } + if (isLogAxis()) { + + if (axismin<0) { + if (axismax>0) axismin=axismax/(logAxisBase*logAxisBase); + else axismin=1e-5; + } + if (axismax<=axismin) axismax=axismin*logAxisBase*logAxisBase; + //if (axismax<0) axismax=pow(10.0, ceil(log10(axismax-axismin)+1.0)); + + + if (axismin<=0) axismin=1e-5; + if (axismax<=0) axismax=axismin+pow(10.0, static_cast(log10(axismin))); + if (axismax(log10(axismin))); + } + } + + if (axismin>axismax) { + std::swap(axismin, axismax); + } else if (axismax==axismin) { + axismax=axismin+1.0; + } + + // this is the x- and y-range spanned by the plot + width=fabs(axismax-axismin); + //qDebug()<<"calcPlotScaling():\n"; + //qDebug()<<" width="<objectName()<<": inverted = "<objectName()<<": plotOffset = "<objectName()<<": plotWidth = "<0) { + offset=plotOffset-log(axismin)/log(logAxisBase)*scale; + } else { + offset=plotOffset+log(axismax)/log(logAxisBase)*scale; + } + } else { + scale=getParentPlotWidth()/width; + if (scaleSign>0) { + offset=plotOffset-axismin*scale; + } else { + offset=plotOffset+axismax*scale; + } + + } +#ifdef SHOW_JKQTPLOTTER_DEBUG + //qDebug()<objectName()<<": offset = "<objectName()<<": scale = "<objectName()<<": scaleSign = "<paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::loadCurrentAxisStyle(const QSettings &settings, const QString &group) +{ + axisStyle.loadSettings(settings, group); + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::saveCurrentAxisStyle(QSettings &settings, const QString &group) const +{ + axisStyle.saveSettings(settings, group); +} + +void JKQTPCoordinateAxis::setRange(double aamin, double aamax) { + double oldamin=axismin; + double oldamax=axismax; + double amin=aamin; + double amax=aamax; + if (axisMinWidth>0 && fabs(amax-amin)axisabsoultemax) axismax=axisabsoultemax; + + if (axismin>axismax) { + axismin=amax; + axismax=amin; + } + if (isLogAxis()) { + if (axismin<=0) axismin=1e-306; + if (axismax<=0) axismax=1e-306; + if (fabs(axismin-axismax)<1e-306) { + axismax=10; + axismin=0.1; + } + } + + if (axisMinWidth>0 && fabs(axismax-axismin)tickSpacing = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setAxisMinWidth(double __value) { + this->axisMinWidth = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setAutoAxisSpacing(bool __value) { + this->autoAxisSpacing = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setMinorTickLabelsEnabled(bool __value) { + this->axisStyle.minorTickLabelsEnabled = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setLogAxis(bool __value) +{ + this->logAxis = __value; + this->paramsChanged=true; + if (this->isLogAxis()) { + if (axismin<0) axismin=pow(10.0, floor(log(axismax-axismin)/log(10.0)-1.0)); + if (axismax<0) axismax=pow(10.0, floor(log(axismax-axismin)/log(10.0)+1.0)); + } + redrawPlot(); +} + +void JKQTPCoordinateAxis::setLogAxisBase(double __value) { + this->logAxisBase = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setUserTickSpacing(double __value) { + this->userTickSpacing = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setUserLogTickSpacing(double __value) { + this->userLogTickSpacing = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setLabelType(JKQTPCALabelType __value) { + this->axisStyle.labelType = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setTickMode(JKQTPLabelTickMode __value) +{ + this->axisStyle.tickMode = __value; + this->paramsChanged=true; + setLogAxis(this->logAxis); +} + +void JKQTPCoordinateAxis::setTickMode(int __value) { + setTickMode(JKQTPLabelTickMode(__value)); +} + +void JKQTPCoordinateAxis::setAxisLabel(const QString& __value) { + this->axisLabel = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setLabelPosition(JKQTPLabelPosition __value) { + this->axisStyle.labelPosition = __value; + this->paramsChanged=true; + redrawPlot(); +} + + +void JKQTPCoordinateAxis::setLabelFontSize(double __value) { + this->axisStyle.labelFontSize = __value; + this->paramsChanged=true; + redrawPlot(); +} + + +void JKQTPCoordinateAxis::setTickTimeFormat(const QString& __value) { + this->axisStyle.tickTimeFormat = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setTickDateFormat(const QString& __value) { + this->axisStyle.tickDateFormat = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setTickDateTimeFormat(const QString& __value) { + this->axisStyle.tickDateTimeFormat = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setTickLabelFontSize(double __value) { + this->axisStyle.tickLabelFontSize = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setMinorTickLabelFontSize(double __value) { + this->axisStyle.minorTickLabelFontSize = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setMinorTickLabelFullNumber(bool __value) { + this->axisStyle.minorTickLabelFullNumber = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setMinTicks(unsigned int __value) { + this->axisStyle.minTicks = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setMinorTicks(unsigned int __value) { + this->axisStyle.minorTicks = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setMinorTicks(int __value) { + this->axisStyle.minorTicks = qMax(int(0), __value); + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setTickOutsideLength(double __value) { + this->axisStyle.tickOutsideLength = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setMinorTickOutsideLength(double __value) { + this->axisStyle.minorTickOutsideLength = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setTickInsideLength(double __value) { + this->axisStyle.tickInsideLength = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setMinorTickInsideLength(double __value) { + this->axisStyle.minorTickInsideLength = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setAxisColor(const QColor& __value) { + this->axisStyle.axisColor = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setShowZeroAxis(bool __value) { + this->axisStyle.showZeroAxis = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setInverted(bool __value) { + this->inverted = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setGridColor(const QColor& __value) { + this->axisStyle.gridColor = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setMinorGridColor(const QColor& __value) { + this->axisStyle.minorGridColor = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setGridWidth(double __value) { + this->axisStyle.gridWidth = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setGridStyle(Qt::PenStyle __value) { + this->axisStyle.gridStyle = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setMinorGridWidth(double __value) { + this->axisStyle.minorGridWidth = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setMinorGridStyle(Qt::PenStyle __value) { + this->axisStyle.minorGridStyle = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setDrawMode1(JKQTPCADrawMode __value) { + this->axisStyle.drawMode1 = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setDrawMode2(JKQTPCADrawMode __value) { + this->axisStyle.drawMode2 = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setMinorTickWidth(double __value) { + this->axisStyle.minorTickWidth = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setTickWidth(double __value) { + this->axisStyle.tickWidth = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setLineWidth(double __value) { + this->axisStyle.lineWidth = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setLineWidthZeroAxis(double __value) { + this->axisStyle.lineWidthZeroAxis = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setTickLabelDistance(double __value) { + this->axisStyle.tickLabelDistance = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setLabelDistance(double __value) { + this->axisStyle.labelDistance = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setLabelDigits(int __value) { + this->axisStyle.labelDigits = __value; + this->paramsChanged=true; + this->axisStyle.autoLabelDigits=false; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setDrawGrid(bool __value) { + this->axisStyle.drawGrid = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setDrawMinorGrid(bool __value) { + this->axisStyle.drawMinorGrid = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPCoordinateAxis::setTickLabelAngle(double __value) { + this->axisStyle.tickLabelAngle = __value; + this->paramsChanged=true; + redrawPlot(); +} + + +void JKQTPCoordinateAxis::setAbsoluteRange(double amin, double amax) { + axisabsoultemin=amin; + axisabsoultemax=amax; + + if (axisabsoultemin>axisabsoultemax) { + axisabsoultemin=amax; + axisabsoultemax=amin; + } + + if (axisabsoultemin==axisabsoultemax) { + axisabsoultemax=axisabsoultemin+1; + } + setRange(axismin, axismax); + /*paramsChanged=true; + calcPlotScaling(); + redrawPlot();*/ +} + +double JKQTPCoordinateAxis::getNextLabelDistance(double x) { + if (axisStyle.tickMode==JKQTPLTMLinOrPower) { + if (logAxis) { + return x*tickSpacingLog; + } else { + return tickSpacing; + } + } else if (axisStyle.tickMode==JKQTPLTMLin) { + return tickSpacing; + } else if (axisStyle.tickMode==JKQTPLTMPower) { + return x*tickSpacingLog; + } + return 0; +} + +bool JKQTPCoordinateAxis::getNextLabel(double& x, QString& label, bool init) { + //qDebug()<<"start JKQTPCoordinateAxis::getNextLabel("<=axismin && x<=axismax) { + label=floattolabel(x); + } + return (x<=axismax); + } else { + if (init) { + if (tickLabels.size()>0) { + x=tickLabels[0].first; + label=tickLabels[0].second; + } + return (tickLabels.size()>0); + } else { + for (int i=0; i=axismin && x<=axismax) { + label=tickLabels[i+1].second; + x=tickLabels[i+1].first; + return true; + } else { + return false; + } + } + } + } + } + return false; +} + +QSizeF JKQTPCoordinateAxis::getMaxTickLabelSize(JKQTPEnhancedPainter& painter, double* ascent, double* descent) { + double w=0, h=0, a=0; + calcPlotScaling(); + + double x=tickStart; + QString label=""; + getNextLabel(x, label, true); + QFont f; + f.setFamily(getParent()->getCurrentPlotterStyle().defaultFontName); + f.setPointSizeF(this->axisStyle.tickLabelFontSize*parent->getFontSizeMultiplier()); + QFontMetricsF fm(f); + bool first=true; + int cnt=0; + while (getNextLabel(x, label, first) && cnt<50) { + double width, ascent, descent, strikeoutPos; + parent->getTextSizeDetail(f, label, painter, width, ascent, descent, strikeoutPos); + if (width>w) w=width; + if (ascent+descent>h) h=ascent+descent; + if (ascent>a) a=ascent; + first=false; + cnt++; + } + //qDebug()<<"getMaxTickLabelSize() = ["<getCurrentPlotterStyle().yAxisStyle; + } else { + axisStyle=JKQTPGetSystemDefaultBaseStyle().yAxisStyle; + } +} + +double JKQTPVerticalAxis::getParentPlotWidth() const { + return parent->getPlotHeight(); +} + +double JKQTPVerticalAxis::getParentPlotOffset() const { + return parent->getInternalPlotBorderTop(); +} + +QSizeF JKQTPVerticalAxis::getSize1(JKQTPEnhancedPainter& painter) { + if (axisStyle.drawMode1==JKQTPCADMnone) return QSize(0,0); + double ptwidth=axisStyle.axisLineOffset; + double labwidth=0; + if (JKQTPCADrawModeHasTicks(axisStyle.drawMode1)) ptwidth+=axisStyle.tickOutsideLength; + if (JKQTPCADrawModeHasTickLabels(axisStyle.drawMode1)) { + ptwidth+=axisStyle.tickLabelDistance; + // find out the maximum width over all visible plot labels + labwidth+=getMaxTickLabelSize(painter).width(); + } + if (JKQTPCADrawModeHasTickLabels(axisStyle.drawMode1)) { + ptwidth+=axisStyle.labelDistance; + // find out size of axis label + labwidth+=parent->getTextSizeSize(getParent()->getCurrentPlotterStyle().defaultFontName, axisStyle.labelFontSize*parent->getFontSizeMultiplier(), axisLabel, painter).height(); + } + + return QSizeF(parent->pt2px(painter, ptwidth)+labwidth, getParentPlotWidth()); +} + +QSizeF JKQTPVerticalAxis::getSize2(JKQTPEnhancedPainter& painter) { + if (axisStyle.drawMode2==JKQTPCADMnone) return QSize(0,0); + double ptwidth=axisStyle.axisLineOffset; + double labwidth=0; + if (JKQTPCADrawModeHasTicks(axisStyle.drawMode2)) ptwidth+=axisStyle.tickOutsideLength; + if (JKQTPCADrawModeHasTickLabels(axisStyle.drawMode2)) { + ptwidth+=axisStyle.tickLabelDistance; + // find out the maximum width over all visible plot labels + labwidth+=getMaxTickLabelSize(painter).width(); + } + if (JKQTPCADrawModeHasTickLabels(axisStyle.drawMode2)) { + ptwidth+=axisStyle.labelDistance; + // find out size of axis label + labwidth+=parent->getTextSizeSize(getParent()->getCurrentPlotterStyle().defaultFontName, axisStyle.labelFontSize*parent->getFontSizeMultiplier(), axisLabel, painter).height(); + } + + return QSizeF(parent->pt2px(painter, ptwidth)+labwidth, getParentPlotWidth()); +} + + +double JKQTPVerticalAxis::getParentOtheraxisOffset() const { + return parent->x2p(parent->getXMin()); +} + + +double JKQTPVerticalAxis::getParentOtheraxisWidth() const { + return fabs(parent->x2p(parent->getXMax())-parent->x2p(parent->getXMin())); +} + +bool JKQTPVerticalAxis::getParentOtheraxisInverted() const +{ + return parent->getXAxis()->getInverted(); +} + +void JKQTPVerticalAxis::drawGrids(JKQTPEnhancedPainter& painter) { + //qDebug()<<" start JKQTPVerticalAxis::drawGrids("; + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + QPen pg=painter.pen(); + pg.setColor(axisStyle.gridColor); + pg.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, axisStyle.gridWidth*parent->getLineWidthMultiplier()))); + pg.setStyle(axisStyle.gridStyle); + QPen pmg=painter.pen(); + pmg.setColor(axisStyle.minorGridColor); + pmg.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH,parent->pt2px(painter, axisStyle.minorGridWidth*parent->getLineWidthMultiplier()))); + pmg.setStyle(axisStyle.minorGridStyle); + //double top=x2p(axismax); + //double bottom=x2p(axismin); + double left=0; + double right=0; + if (getParentOtheraxisInverted()) { + left=getParentOtheraxisOffset()-getParentOtheraxisWidth();//; + right=getParentOtheraxisOffset();//; + } else { + left=getParentOtheraxisOffset();//; + right=getParentOtheraxisOffset()+getParentOtheraxisWidth();//; + } + + double x=tickStart; + QString label=""; + bool first=true; + // loop through all labels, as they are at the major ticks, do not draw more than 200 labels (prevent hang ups) + int cnt=0; + QVector lines_pg; + QVector lines_pmg; + while (getNextLabel(x, label, first) && (cnt<200)) { + double w=getNextLabelDistance(x); + double mtdist=w/static_cast(axisStyle.minorTicks+1); + + double xx=x2p(x); + //qDebug()<<" tick @ x="<axismin) && (fabs(left-right)>0)) { + QLineF l(left, xx, right, xx); + if (l.length()>0) lines_pg.append(l);//painter.drawLine(l); + } + //qDebug()<<" 2"; + //painter.setPen(pmg); + //qDebug()<<" 3"; + if ((tickLabels.size()<=0) && axisStyle.drawMinorGrid && (axisStyle.minorTicks>0) && (fabs(right-left)>0)) { + //qDebug()<<" 3.1"; + double mx=x+mtdist; + //qDebug()<<" 3.2"; + for (int i=0; i(axisStyle.minorTicks); i++) { + //qDebug()<<" 3.2.1"; + double mxx=x2p(mx); + //qDebug()<<" 3.2.2"; + if ((mxaxismin) && (fabs(right-left)>0)) { + QLineF l(left, mxx, right, mxx); + if (l.length()>0) lines_pmg.append(l);//painter.drawLine(l); + } + //qDebug()<<" 3.2.3"; + mx=mx+mtdist; + //qDebug()<<" 3.2.4"; + } + } + first=false; + cnt++; + } + painter.setPen(pg); + painter.drawLines(lines_pg); + painter.setPen(pmg); + painter.drawLines(lines_pmg); + + //qDebug()<<" end JKQTPVerticalAxis::drawGrids("; +} + +void JKQTPVerticalAxis::drawTickLabel1(JKQTPEnhancedPainter &painter, double xx, double yy, const QString& label, double fontSize) +{ + getParentMathText()->setFontSize(fontSize*parent->getFontSizeMultiplier()); + getParentMathText()->setFontRomanOrSpecial(getParent()->getCurrentPlotterStyle().defaultFontName); + getParentMathText()->setFontColor(axisStyle.axisColor); + + getParentMathText()->parse(label); + double width, ascent, descent, strikeoutPos; + getParentMathText()->getSizeDetail(painter, width, ascent, descent, strikeoutPos); + if (JKQTPCADrawModeHasTickLabels(axisStyle.drawMode1)) { + double lx=xx-parent->pt2px(painter, axisStyle.minorTickOutsideLength+axisStyle.tickLabelDistance)-width; + if (axisStyle.tickLabelAngle==90) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.translate(lx+width-1.25*strikeoutPos, yy-width/2.0); + painter.rotate(axisStyle.tickLabelAngle); + getParentMathText()->draw(painter, 0,0); + + } else if (axisStyle.tickLabelAngle==-90) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.translate(lx+width-0.25*strikeoutPos, yy+width/2.0); + painter.rotate(axisStyle.tickLabelAngle); + getParentMathText()->draw(painter, 0,0); + + } else if (axisStyle.tickLabelAngle!=0) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + if (axisStyle.tickLabelAngle>0) { + painter.translate(lx-strikeoutPos+(width)*(1.0-cos(fabs(axisStyle.tickLabelAngle)/180.0*M_PI)), yy+strikeoutPos-width*sin(fabs(axisStyle.tickLabelAngle)/180.0*M_PI)); + painter.rotate(axisStyle.tickLabelAngle); + } else { + painter.translate(lx+strikeoutPos+(width-strikeoutPos)*(1.0-cos(fabs(axisStyle.tickLabelAngle)/180.0*M_PI)), yy+strikeoutPos+width*sin(fabs(axisStyle.tickLabelAngle)/180.0*M_PI)); + painter.rotate(axisStyle.tickLabelAngle); + } + getParentMathText()->draw(painter, 0,0); + + } else { + getParentMathText()->draw(painter, lx, yy+strikeoutPos); + } + } +} + +void JKQTPVerticalAxis::drawTickLabel2(JKQTPEnhancedPainter &painter, double xx, double yy, const QString &label, double fontSize) +{ + getParentMathText()->setFontSize(fontSize*parent->getFontSizeMultiplier()); + getParentMathText()->setFontRomanOrSpecial(getParent()->getCurrentPlotterStyle().defaultFontName); + getParentMathText()->setFontColor(axisStyle.axisColor); + + getParentMathText()->parse(label); + double width, ascent, descent, strikeoutPos; + getParentMathText()->getSizeDetail(painter, width, ascent, descent, strikeoutPos); + + if (JKQTPCADrawModeHasTickLabels(axisStyle.drawMode2)) { + double lx=xx+parent->pt2px(painter, axisStyle.tickOutsideLength+axisStyle.tickLabelDistance); + if (axisStyle.tickLabelAngle==90) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.translate(lx+descent, yy-width/2.0); + painter.rotate(axisStyle.tickLabelAngle); + getParentMathText()->draw(painter, 0,0); + + } else if (axisStyle.tickLabelAngle==-90) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.translate(lx+ascent, yy+width/2.0); + painter.rotate(axisStyle.tickLabelAngle); + getParentMathText()->draw(painter, 0,0); + + } else if (axisStyle.tickLabelAngle!=0) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + double shiftx=0; + if (axisStyle.tickLabelAngle>0) { + shiftx=strikeoutPos*sin(fabs(axisStyle.tickLabelAngle)/180.0*M_PI); + } else { + + } + painter.translate(lx+shiftx, yy+strikeoutPos); + painter.rotate(-axisStyle.tickLabelAngle); + getParentMathText()->draw(painter, 0,0); + + } else { + getParentMathText()->draw(painter, lx, yy+strikeoutPos); + } + } +} + +void JKQTPVerticalAxis::drawAxes(JKQTPEnhancedPainter& painter) { +#ifdef JKQTBP_AUTOTIMER + JKQTPAutoOutputTimer jkaat(QString("JKQTPEnhancedPainter[%1]::drawAxes()").arg(objectName())); +#endif + + // make shure all parameters are calculated correctly + calcPlotScaling(); + + // determine pixel coordinates of important positions + double top=x2p(axismax); + double bottom=x2p(axismin); + double left=0; + double right=0; + if (inverted) { + qSwap(top, bottom); + } + if (getParentOtheraxisInverted()) { + left=getParentOtheraxisOffset()-getParentOtheraxisWidth();//; + right=getParentOtheraxisOffset();//; + } else { + left=getParentOtheraxisOffset();//; + right=getParentOtheraxisOffset()+getParentOtheraxisWidth();//; + } + // move axes outside plot rectangle, if required + left-=parent->pt2px(painter, axisStyle.axisLineOffset); + right+=parent->pt2px(painter, axisStyle.axisLineOffset); + //qDebug()<<"JKQTPVerticalAxis:"; + //qDebug()<<" left="<pt2px(painter, axisStyle.lineWidth*parent->getLineWidthMultiplier()))); + pmain.setStyle(Qt::SolidLine); + + QPen ptick=pmain; + ptick.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, axisStyle.tickWidth*parent->getLineWidthMultiplier()))); + + QPen pmtick=ptick; + pmtick.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, axisStyle.minorTickWidth*parent->getLineWidthMultiplier()))); + + getParentMathText()->setFontSize(this->axisStyle.tickLabelFontSize*parent->getFontSizeMultiplier()); + getParentMathText()->setFontRomanOrSpecial(getParent()->getCurrentPlotterStyle().defaultFontName); + getParentMathText()->setFontColor(axisStyle.axisColor); + + painter.setPen(pmain); + + // plot thick axis at y==0 + if (axisStyle.showZeroAxis && (0>axismin) && (0pt2px(painter, axisStyle.lineWidthZeroAxis*parent->getLineWidthMultiplier()))); + pmain1.setColor(axisStyle.colorZeroAxis); + pmain1.setStyle(axisStyle.styleZeroAxis); + painter.setPen(pmain1); + QLineF l(left-parent->pt2px(painter, axisStyle.tickOutsideLength), x2p(0), right+parent->pt2px(painter, axisStyle.tickOutsideLength), x2p(0)); + painter.drawLine(l); + + painter.setPen(pmain); + } + + // draw thick axis lines, left and/or right + if ( JKQTPCADrawModeHasLine(axisStyle.drawMode1)) { + QLineF l(left, x2p(axismin), left, x2p(axismax)); + painter.drawLine(l); + } + if (JKQTPCADrawModeHasLine(axisStyle.drawMode2)) { + QLineF l(right, x2p(axismin), right, x2p(axismax)); + painter.drawLine(l); + } + + // plot minor and major ticks + tick labels + QSizeF labelMax=getMaxTickLabelSize(painter); + double x=tickStart; + QString label=""; + bool first=true; + // loop through all labels, as they are at the major ticks + int cnt=0; + + QVector lines_ptick, lines_ptick2; + QVector lines_pmtick, lines_pmtick2; + + { + #ifdef JKQTBP_AUTOTIMER + JKQTPAutoOutputTimer jkaat(QString("JKQTPEnhancedPainter[%1]::drawAxes(): calcLabels").arg(objectName())); + #endif + while (getNextLabel(x, label, first) && cnt<200) { + double mtdist=getNextLabelDistance(x)/static_cast(axisStyle.minorTicks+1); + + double xleft=-1000000; + double xx=x2p(x); + //qDebug()<<" tick @ x="< "<=axismin) { + QLineF l(xleft=left-parent->pt2px(painter, axisStyle.minorTickOutsideLength), mxx, left+parent->pt2px(painter, axisStyle.minorTickInsideLength), mxx); + if (l.length()>0) lines_pmtick.append(l);//painter.drawLine(l); + double val= mx/pow(logAxisBase,floor(log(mx)/log(logAxisBase))); + + if (axisStyle.minorTickLabelsEnabled&&JKQTPCADrawModeHasTickLabels(axisStyle.drawMode1)) { + if (axisStyle.minorTickLabelFullNumber) val=mx; + QString minorlabel=floattolabel(val); + drawTickLabel1(painter, left, mxx, minorlabel, axisStyle.minorTickLabelFontSize); + //drawTickLabel2(painter, right, xx, minorlabel, axisStyle.minorTickLabelFontSize); + } + } + mx=mx+mtdist; + + } + } + } + if (JKQTPCADrawModeHasTicks(axisStyle.drawMode2)||JKQTPCADrawModeHasTickLabels(axisStyle.drawMode2)) { + //painter.setPen(ptick); + if (x<=axismax && x>=axismin) { + QLineF l(right-parent->pt2px(painter, axisStyle.tickInsideLength), xx, right+parent->pt2px(painter, axisStyle.tickOutsideLength), xx); + if (l.length()>0) lines_ptick2.append(l);//painter.drawLine(l); + } + //painter.setPen(pmtick); + if ((tickLabels.size()<=0) && (axisStyle.minorTicks>0)) { + double mx=x+mtdist; + int minTickCnt=axisStyle.minorTicks; + if (isLogAxis()) { + if (mtdist>x) { + mx=mtdist; + } else { + minTickCnt--; + mx=2.0*mtdist; + } + + } + for (int i=0; i=axismin) { + QLineF l(right-parent->pt2px(painter, axisStyle.minorTickInsideLength), mxx, xleft=(right+parent->pt2px(painter, axisStyle.minorTickOutsideLength)), mxx); + if (l.length()>0) lines_pmtick2.append(l);//painter.drawLine(l); + double val= mx/pow(logAxisBase,floor(log(mx)/log(logAxisBase))); + + if (axisStyle.minorTickLabelsEnabled) { + if (axisStyle.minorTickLabelFullNumber&&JKQTPCADrawModeHasTickLabels(axisStyle.drawMode2)) val=mx; + QString minorlabel=floattolabel(val); + //drawTickLabel1(painter, left, xx, minorlabel, axisStyle.minorTickLabelFontSize); + drawTickLabel2(painter, xleft, mxx, minorlabel, axisStyle.minorTickLabelFontSize); + } + } + mx=mx+mtdist; + } + } + } + + if ((label!="") && (x<=axismax && x>=axismin)) { + + + if (JKQTPCADrawModeHasTickLabels(axisStyle.drawMode1)) drawTickLabel1(painter, left, xx, label, this->axisStyle.tickLabelFontSize); + if (JKQTPCADrawModeHasTickLabels(axisStyle.drawMode2)) drawTickLabel2(painter, right, xx, label, this->axisStyle.tickLabelFontSize); + + } + first=false; + cnt++; + } + } + { + #ifdef JKQTBP_AUTOTIMER + JKQTPAutoOutputTimer jkaat(QString("JKQTPEnhancedPainter[%1]::drawAxes(): drawLines").arg(objectName())); + #endif + painter.setPen(ptick); + painter.drawLines(lines_ptick); + painter.drawLines(lines_ptick2); + painter.setPen(pmtick); + painter.drawLines(lines_pmtick); + painter.drawLines(lines_pmtick2); + } + + // plot axis label + if (!axisLabel.isEmpty() && JKQTPCADrawModeHasAxisLabel(axisStyle.drawMode1)) { + #ifdef JKQTBP_AUTOTIMER + JKQTPAutoOutputTimer jkaat(QString("JKQTPEnhancedPainter[%1]::drawAxes(): axisLabel1").arg(objectName())); + #endif + getParentMathText()->setFontSize(axisStyle.labelFontSize*parent->getFontSizeMultiplier()); + getParentMathText()->setFontRomanOrSpecial(getParent()->getCurrentPlotterStyle().defaultFontName); + getParentMathText()->parse(axisLabel); + double width, ascent, descent, strikeoutPos; + getParentMathText()->getSizeDetail(painter, width, ascent, descent, strikeoutPos); + + + QRectF rect(0,0, getParentPlotWidth(), ascent+descent);//plotBorderLeft-30); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.translate(QPointF(left-parent->pt2px(painter, axisStyle.tickOutsideLength+axisStyle.tickLabelDistance+axisStyle.labelDistance)-descent-labelMax.width()-labelMax.height(), bottom)); + painter.rotate(-90); + //JKQTPEnhancedPainter::RenderHints h=painter.renderHints(); + //painter.drawRect(rect); + //painter.drawEllipse(-4, -4, 8, 8); + switch(axisStyle.labelPosition) { + case JKQTPLabelMax: + getParentMathText()->draw(painter, Qt::AlignBottom|Qt::AlignRight, rect); + break; + case JKQTPLabelMin: + getParentMathText()->draw(painter, Qt::AlignBottom|Qt::AlignLeft, rect); + break; + case JKQTPLabelCenter: + getParentMathText()->draw(painter, Qt::AlignBottom|Qt::AlignHCenter, rect); + break; + } + if (getParent()->getCurrentPlotterStyle().debugShowRegionBoxes) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + QPen p("magenta"); + QColor col=p.color(); col.setAlphaF(0.8); p.setColor(col); + p.setWidthF(getParent()->getCurrentPlotterStyle().debugRegionLineWidth/2.0); + painter.setPen(p); + painter.setBrush(QBrush(QColor(Qt::transparent))); + painter.drawRect(rect); + + } + painter.resetTransform(); + + } + if (!axisLabel.isEmpty() && JKQTPCADrawModeHasAxisLabel(axisStyle.drawMode2)) { + #ifdef JKQTBP_AUTOTIMER + JKQTPAutoOutputTimer jkaat(QString("JKQTPEnhancedPainter[%1]::drawAxes(): axisLabel2").arg(objectName())); + #endif + getParentMathText()->setFontSize(axisStyle.labelFontSize*parent->getFontSizeMultiplier()); + getParentMathText()->setFontRomanOrSpecial(getParent()->getCurrentPlotterStyle().defaultFontName); + getParentMathText()->parse(axisLabel); + + + QRectF rect(0,0, getParentPlotWidth(), getParentMathText()->getSize(painter).height());//plotBorderLeft-30); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.translate(QPointF(right+parent->pt2px(painter, axisStyle.tickOutsideLength+axisStyle.tickLabelDistance+axisStyle.labelDistance)+labelMax.width(), bottom)); + painter.rotate(-90); + //JKQTPEnhancedPainter::RenderHints h=painter.renderHints(); + //painter.drawRect(rect); + //painter.drawEllipse(-4, -4, 8, 8); + switch(axisStyle.labelPosition) { + case JKQTPLabelMax: + getParentMathText()->draw(painter, Qt::AlignBottom|Qt::AlignRight, rect); + break; + case JKQTPLabelMin: + getParentMathText()->draw(painter, Qt::AlignBottom|Qt::AlignLeft, rect); + break; + case JKQTPLabelCenter: + getParentMathText()->draw(painter, Qt::AlignBottom|Qt::AlignHCenter, rect); + break; + } + if (getParent()->getCurrentPlotterStyle().debugShowRegionBoxes) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + QPen p("magenta"); + QColor col=p.color(); col.setAlphaF(0.8); p.setColor(col); + p.setWidthF(getParent()->getCurrentPlotterStyle().debugRegionLineWidth/2.0); + painter.setPen(p); + painter.setBrush(QBrush(QColor(Qt::transparent))); + painter.drawRect(rect); + + } + //painter.resetTransform(); + + } + + + if (getParent()->getCurrentPlotterStyle().debugShowRegionBoxes) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + QPen p("cyan"); + p.setWidthF(getParent()->getCurrentPlotterStyle().debugRegionLineWidth); + QColor col=p.color(); col.setAlphaF(0.8); p.setColor(col); + painter.setPen(p); + painter.setBrush(QBrush(QColor(Qt::transparent))); + QSizeF s1, s2; + s1=getSize1(painter); + s2=getSize2(painter); + painter.drawRect(QRectF(QPointF(left-s1.width(), top), s1)); + painter.drawRect(QRectF(QPointF(right, top), s2)); + + } + + //qDebug()<<" end JKQTPVerticalAxis::drawAxes("; +} + + + + + + + + + +JKQTPVerticalIndependentAxis::JKQTPVerticalIndependentAxis(double axisOffset, double axisWidth, double otherAxisOffset, double otherAxisWidth, JKQTBasePlotter* parent): + JKQTPVerticalAxis(parent) +{ + this->axisOffset=axisOffset; + this->axisWidth=axisWidth; + this->otherAxisOffset=otherAxisOffset; + this->otherAxisWidth=otherAxisWidth; + this->otherAxisInverted=false; + if (parent) { + axisStyle=parent->getCurrentPlotterStyle().rightColorbarAxisStyle; + } else { + axisStyle=JKQTPGetSystemDefaultBaseStyle().rightColorbarAxisStyle; + } + +} + +void JKQTPVerticalIndependentAxis::setAxisOffset(double __value) { + this->axisOffset = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPVerticalIndependentAxis::setAxisWidth(double __value) { + this->axisWidth = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPVerticalIndependentAxis::setOtherAxisOffset(double __value) { + this->otherAxisOffset = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPVerticalIndependentAxis::setOtherAxisWidth(double __value) { + this->otherAxisWidth = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPVerticalIndependentAxis::setOtherAxisInverted(bool __value) { + this->otherAxisInverted = __value; + this->paramsChanged=true; + redrawPlot(); +} + +double JKQTPVerticalIndependentAxis::getParentPlotWidth() const { return axisWidth; } + +double JKQTPVerticalIndependentAxis::getParentPlotOffset() const { return axisOffset; } + +double JKQTPVerticalIndependentAxis::getParentOtheraxisWidth() const { return otherAxisWidth; } + +bool JKQTPVerticalIndependentAxis::getParentOtheraxisInverted() const { return otherAxisInverted; } + +double JKQTPVerticalIndependentAxis::getParentOtheraxisOffset() const { return otherAxisOffset; } + + + + + + + + + + +JKQTPHorizontalAxis::JKQTPHorizontalAxis(JKQTBasePlotter* parent): + JKQTPCoordinateAxis(parent) +{ + //axisPrefix="xaxis_"; + scaleSign=1; + if (parent) { + axisStyle=parent->getCurrentPlotterStyle().xAxisStyle; + } else { + axisStyle=JKQTPGetSystemDefaultBaseStyle().xAxisStyle; + } + +} + +double JKQTPHorizontalAxis::getParentPlotWidth() const { + return parent->getPlotWidth(); +} + +double JKQTPHorizontalAxis::getParentPlotOffset() const { + return parent->getInternalPlotBorderLeft(); +} + +QSizeF JKQTPHorizontalAxis::getSize1(JKQTPEnhancedPainter& painter) { + if (axisStyle.drawMode1==JKQTPCADMnone) return QSize(0,0); + double ptwidth=axisStyle.axisLineOffset; + double labwidth=0; + if (JKQTPCADrawModeHasTicks(axisStyle.drawMode1)) ptwidth+=axisStyle.tickOutsideLength; + if (JKQTPCADrawModeHasTickLabels(axisStyle.drawMode1)) { + ptwidth+=axisStyle.tickLabelDistance; + // find out the maximum width over all visible plot labels + labwidth+=getMaxTickLabelSize(painter).height(); + } + if (JKQTPCADrawModeHasTickLabels(axisStyle.drawMode1)) { + ptwidth+=axisStyle.labelDistance; + // find out size of axis label + labwidth+=parent->getTextSizeSize(getParent()->getCurrentPlotterStyle().defaultFontName, axisStyle.labelFontSize*parent->getFontSizeMultiplier(), axisLabel, painter).width(); + } + + return QSizeF(getParentPlotWidth(), parent->pt2px(painter, ptwidth)+labwidth); +} + +QSizeF JKQTPHorizontalAxis::getSize2(JKQTPEnhancedPainter& painter) { + if (axisStyle.drawMode2==JKQTPCADMnone) return QSize(0,0); + double ptwidth=axisStyle.axisLineOffset; + double labwidth=0; + if (JKQTPCADrawModeHasTicks(axisStyle.drawMode2)) ptwidth+=axisStyle.tickOutsideLength; + if (JKQTPCADrawModeHasTickLabels(axisStyle.drawMode2)) { + ptwidth+=axisStyle.tickLabelDistance; + // find out the maximum width over all visible plot labels + labwidth+=getMaxTickLabelSize(painter).height(); + } + if (JKQTPCADrawModeHasTickLabels(axisStyle.drawMode2)) { + ptwidth+=axisStyle.labelDistance; + // find out size of axis label + labwidth+=parent->getTextSizeSize(getParent()->getCurrentPlotterStyle().defaultFontName, axisStyle.labelFontSize*parent->getFontSizeMultiplier(), axisLabel, painter).width(); + } + + return QSizeF(getParentPlotWidth(), parent->pt2px(painter, ptwidth)+labwidth); +} + + +double JKQTPHorizontalAxis::getParentOtheraxisOffset() const { + return parent->y2p(parent->getYMax()); +} + + +double JKQTPHorizontalAxis::getParentOtheraxisWidth() const { + return fabs(parent->y2p(parent->getYMax())-parent->y2p(parent->getYMin())); +} + +bool JKQTPHorizontalAxis::getParentOtheraxisInverted() const +{ + return parent->getYAxis()->getInverted(); +} + +void JKQTPHorizontalAxis::drawGrids(JKQTPEnhancedPainter& painter) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + //double right=x2p(axismax); + //double left=x2p(axismin); + double bottom=0; + double top=0; + if (getParentOtheraxisInverted()) { + top=getParentOtheraxisOffset()-getParentOtheraxisWidth();//; + bottom=getParentOtheraxisOffset();//; + } else { + top=getParentOtheraxisOffset();//; + bottom=getParentOtheraxisOffset()+getParentOtheraxisWidth();//; + } + QPen pg=painter.pen(); + pg.setColor(axisStyle.gridColor); + pg.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, axisStyle.gridWidth*parent->getFontSizeMultiplier()))); + pg.setStyle(axisStyle.gridStyle); + QPen pmg=painter.pen(); + pmg.setColor(axisStyle.minorGridColor); + pmg.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, axisStyle.minorGridWidth*parent->getLineWidthMultiplier()))); + pmg.setStyle(axisStyle.minorGridStyle); + + double x=tickStart; + QString label=""; + bool first=true; + // loop through all labels, as they are at the major ticks + int cnt=0; + QVector lines_pg; + QVector lines_pmg; + + while (getNextLabel(x, label, first) && cnt<200) { + double mtdist=getNextLabelDistance(x)/static_cast(axisStyle.minorTicks+1); + + double xx=x2p(x); + //qDebug()<<" tick @ x="<pt2px(painter, axisStyle.axisLineOffset); + bottom+=parent->pt2px(painter, axisStyle.axisLineOffset); + + //qDebug()<<" left="<pt2px(painter, axisStyle.lineWidth*parent->getLineWidthMultiplier()))); + pmain.setStyle(Qt::SolidLine); + + QPen ptick=pmain; + ptick.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, axisStyle.tickWidth*parent->getLineWidthMultiplier()))); + + QPen pmtick=ptick; + pmtick.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, axisStyle.minorTickWidth*parent->getLineWidthMultiplier()))); + + getParentMathText()->setFontSize(this->axisStyle.tickLabelFontSize*parent->getFontSizeMultiplier()); + getParentMathText()->setFontRomanOrSpecial(getParent()->getCurrentPlotterStyle().defaultFontName); + getParentMathText()->setFontColor(axisStyle.axisColor); + + painter.setPen(pmain); + + // plot thick axis at y==0 + if (axisStyle.showZeroAxis && (0>axismin) && (0pt2px(painter, axisStyle.lineWidthZeroAxis*parent->getLineWidthMultiplier()))); + pmain1.setColor(axisStyle.colorZeroAxis); + pmain1.setStyle(axisStyle.styleZeroAxis); + painter.setPen(pmain1); + QLineF l(x2p(0), bottom+parent->pt2px(painter, axisStyle.tickOutsideLength), x2p(0), top-parent->pt2px(painter, axisStyle.tickOutsideLength)); + painter.drawLine(l); + painter.setPen(pmain); + } + + // draw thick axis lines, left and/or right + if (JKQTPCADrawModeHasLine(axisStyle.drawMode1)) { + QLineF l(x2p(axismin), bottom, x2p(axismax), bottom); + painter.drawLine(l); + } + if (JKQTPCADrawModeHasLine(axisStyle.drawMode2)) { + QLineF l(x2p(axismin), top, x2p(axismax), top); + painter.drawLine(l); + } + + // plot minor and major ticks + tick labels + double ascentMax, descentMax; + QSizeF labelMax=getMaxTickLabelSize(painter, &ascentMax, &descentMax); + double x=tickStart; + QString label=""; + bool first=true; + // loop through all labels, as they are at the major ticks + int cnt=0; + QVector lines_ptick, lines_ptick2; + QVector lines_pmtick, lines_pmtick2; + + + { + #ifdef JKQTBP_AUTOTIMER + JKQTPAutoOutputTimer jkaat(QString("JKQTPHorizontalAxis[%1]::drawAxes(): calcLabels").arg(objectName())); + #endif + + while (getNextLabel(x, label, first) && cnt<200) { + double mtdist=getNextLabelDistance(x)/static_cast(axisStyle.minorTicks+1); + + double xleft=-1000000; + double xx=x2p(x); + //qDebug()<<" tick @ x="<=axismin)) { + + + if (JKQTPCADrawModeHasTickLabels(axisStyle.drawMode1)) drawTickLabel1(painter, xx, bottom, label, this->axisStyle.tickLabelFontSize, ascentMax, descentMax); + if (JKQTPCADrawModeHasTickLabels(axisStyle.drawMode2)) drawTickLabel2(painter, xx, top, label, this->axisStyle.tickLabelFontSize, ascentMax, descentMax); + + } + first=false; + cnt++; + } + } + { + #ifdef JKQTBP_AUTOTIMER + JKQTPAutoOutputTimer jkaat(QString("JKQTPHorizontalAxis[%1]::drawAxes(): drawLines").arg(objectName())); + #endif + + painter.setPen(ptick); + painter.drawLines(lines_ptick); + painter.drawLines(lines_ptick2); + painter.setPen(pmtick); + painter.drawLines(lines_pmtick); + painter.drawLines(lines_pmtick2); + } + + // plot axis label + if (!axisLabel.isEmpty() && JKQTPCADrawModeHasAxisLabel(axisStyle.drawMode1)) { + #ifdef JKQTBP_AUTOTIMER + JKQTPAutoOutputTimer jkaat(QString("JKQTPHorizontalAxis[%1]::drawAxes(): axisLabel1").arg(objectName())); + #endif + getParentMathText()->setFontSize(axisStyle.labelFontSize*parent->getFontSizeMultiplier()); + getParentMathText()->setFontRomanOrSpecial(getParent()->getCurrentPlotterStyle().defaultFontName); + getParentMathText()->parse(axisLabel); + double width, ascent, descent, strikeoutPos; + getParentMathText()->getSizeDetail(painter, width, ascent, descent, strikeoutPos); + + + QRectF rect(0,0, getParentPlotWidth(), ascent+descent);//plotBorderLeft-30); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.translate(QPointF(left, bottom+parent->pt2px(painter, axisStyle.tickOutsideLength+axisStyle.tickLabelDistance+axisStyle.labelDistance)+labelMax.height())); + //JKQTPEnhancedPainter::RenderHints h=painter.renderHints(); + //painter.drawRect(rect); + //painter.drawEllipse(-4, -4, 8, 8); + switch(axisStyle.labelPosition) { + case JKQTPLabelMax: + getParentMathText()->draw(painter, Qt::AlignBottom|Qt::AlignRight, rect); + break; + case JKQTPLabelMin: + getParentMathText()->draw(painter, Qt::AlignBottom|Qt::AlignLeft, rect); + break; + case JKQTPLabelCenter: + getParentMathText()->draw(painter, Qt::AlignBottom|Qt::AlignHCenter, rect); + break; + } + if (getParent()->getCurrentPlotterStyle().debugShowRegionBoxes) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + QPen p("magenta"); + QColor col=p.color(); col.setAlphaF(0.8); p.setColor(col); + p.setWidthF(getParent()->getCurrentPlotterStyle().debugRegionLineWidth/2.0); + painter.setPen(p); + painter.setBrush(QBrush(QColor(Qt::transparent))); + painter.drawRect(rect); + + } + //painter.resetTransform(); + + } + if (!axisLabel.isEmpty() && JKQTPCADrawModeHasAxisLabel(axisStyle.drawMode2)) { + #ifdef JKQTBP_AUTOTIMER + JKQTPAutoOutputTimer jkaat(QString("JKQTPHorizontalAxis[%1]::drawAxes(): axisLabel2").arg(objectName())); + #endif + getParentMathText()->setFontSize(axisStyle.labelFontSize*parent->getFontSizeMultiplier()); + getParentMathText()->setFontRomanOrSpecial(getParent()->getCurrentPlotterStyle().defaultFontName); + getParentMathText()->parse(axisLabel); + + + QRectF rect(0,0, getParentPlotWidth(), getParentMathText()->getSize(painter).height());//plotBorderLeft-30); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.translate(QPointF(left, top-parent->pt2px(painter, axisStyle.tickOutsideLength+axisStyle.tickLabelDistance+axisStyle.labelDistance)-labelMax.height()-rect.height())); + //JKQTPEnhancedPainter::RenderHints h=painter.renderHints(); + //painter.drawRect(rect); + //painter.drawEllipse(-4, -4, 8, 8); + switch(axisStyle.labelPosition) { + case JKQTPLabelMax: + getParentMathText()->draw(painter, Qt::AlignBottom|Qt::AlignRight, rect); + break; + case JKQTPLabelMin: + getParentMathText()->draw(painter, Qt::AlignBottom|Qt::AlignLeft, rect); + break; + case JKQTPLabelCenter: + getParentMathText()->draw(painter, Qt::AlignBottom|Qt::AlignHCenter, rect); + break; + } + if (getParent()->getCurrentPlotterStyle().debugShowRegionBoxes) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + QPen p("magenta"); + QColor col=p.color(); col.setAlphaF(0.8); p.setColor(col); + p.setWidthF(getParent()->getCurrentPlotterStyle().debugRegionLineWidth/2.0); + painter.setPen(p); + painter.setBrush(QBrush(QColor(Qt::transparent))); + painter.drawRect(rect); + + } + //painter.resetTransform(); + + } + + if (getParent()->getCurrentPlotterStyle().debugShowRegionBoxes) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + QPen p("cyan"); + QColor col=p.color(); col.setAlphaF(0.8); p.setColor(col); + p.setWidthF(getParent()->getCurrentPlotterStyle().debugRegionLineWidth); + painter.setPen(p); + painter.setBrush(QBrush(QColor(Qt::transparent))); + QSizeF s1,s2; + s1=getSize1(painter); + s2=getSize2(painter); + painter.drawRect(QRectF(QPointF(left, bottom), s1)); + painter.drawRect(QRectF(QPointF(left, top-s2.height()), s2)); + + } +} + + + + + + + + +JKQTPHorizontalIndependentAxis::JKQTPHorizontalIndependentAxis(double axisOffset, double axisWidth, double otherAxisOffset, double otherAxisWidth, JKQTBasePlotter* parent): + JKQTPHorizontalAxis(parent) +{ + this->axisOffset=axisOffset; + this->axisWidth=axisWidth; + this->otherAxisOffset=otherAxisOffset; + this->otherAxisWidth=otherAxisWidth; + this->otherAxisInverted=false; + if (parent) { + axisStyle=parent->getCurrentPlotterStyle().topColorbarAxisStyle; + } else { + axisStyle=JKQTPGetSystemDefaultBaseStyle().topColorbarAxisStyle; + } + +} + +void JKQTPHorizontalIndependentAxis::setAxisOffset(double __value) { + this->axisOffset = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPHorizontalIndependentAxis::setAxisWidth(double __value) { + this->axisWidth = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPHorizontalIndependentAxis::setOtherAxisOffset(double __value) { + this->otherAxisOffset = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPHorizontalIndependentAxis::setOtherAxisWidth(double __value) { + this->otherAxisWidth = __value; + this->paramsChanged=true; + redrawPlot(); +} + +void JKQTPHorizontalIndependentAxis::setOtherAxisInverted(bool __value) { + this->otherAxisInverted = __value; + this->paramsChanged=true; + redrawPlot(); +} + +double JKQTPHorizontalIndependentAxis::getParentPlotWidth() const { return axisWidth; } + +double JKQTPHorizontalIndependentAxis::getParentPlotOffset() const { return axisOffset; } + +double JKQTPHorizontalIndependentAxis::getParentOtheraxisWidth() const { return otherAxisWidth; } + +bool JKQTPHorizontalIndependentAxis::getParentOtheraxisInverted() const { return otherAxisInverted; } + +double JKQTPHorizontalIndependentAxis::getParentOtheraxisOffset() const { return otherAxisOffset; } + + diff --git a/lib/jkqtplotter/jkqtpcoordinateaxes.h b/lib/jkqtplotter/jkqtpcoordinateaxes.h new file mode 100644 index 0000000000..084bf75ed6 --- /dev/null +++ b/lib/jkqtplotter/jkqtpcoordinateaxes.h @@ -0,0 +1,981 @@ +/* + Copyright (c) 2008-2019 Jan W. Krieger () + + + + 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 . +*/ + + + + +#ifndef JKQTPCOORDINATEAXES_H +#define JKQTPCOORDINATEAXES_H + + +#include +#include +#include +#include +#include "jkqtplottertools/jkqtptools.h" +#include "jkqtmathtext/jkqtmathtext.h" +#include "jkqtplottertools/jkqtp_imexport.h" +#include "jkqtplotter/jkqtpcoordinateaxesstyle.h" + +// forward declarations +class JKQTBasePlotter; + +/*! \brief this virtual class is the base for any type of coordinate axis, to be drawn by JKQTBasePlotter. + \ingroup jkqtpbaseplotter_elements + + This class implements all the functionality needed for a coordinate axis: + - transform world to screen coordinates and vice versa + - draw the axis (implemented by child classes!) with these elements: axis lines, JKQTPCoordinateAxisStyle::ticks, tick labels, axis label, x/y=0 axis + - measure the axes in screen coordinates + - load and save the settings to an ini file + . + + Most of the actual draw and measure functions have to be implemented in descendents of this class (namely + JKQTPHorizontalAxis and JKQTPVerticalAxis, as they are specific to whether the axis is drawn horizontally or + vertically. + + Each axis is split up into several parts, as depicted in this image: + + \image html jkqtpcoordinateaxis1.png + + Which parts to actually draw is set by the diverse properties. + + + \section jkqtplotter_base_systems_baseelements Coordinate Systems and Transformations + The plot itself is positioned inside the widget (see \ref jkqtplotter_base_plotsize for details). + You simply supply the widget dimensions and the border + widths between the plot and the widget. The Object then calculates the size of the plot: + + \image html plot_widget_orientation.png + + The plot shows the parameter range xmin ... xmax and ymin ... ymax. Note that if you plot logarithmic plots + you may only plot positive (>0) values. Any other value may lead to an error or unpredictable behaviour. + + From these parameters the object calculates the scaling laws for plotting pints to the screen. The next paragraphs + show all calculations for x- and y-coordinates, ahough this class only implements a generic form. The actual calculation + is also influenced by the parameters set in the child classes! + + -# width = xmax - xmin + -# height = ymax - ymin + -# plotWidth = widgetWidth - plotBorderLeft - plotBorderRight + -# plotHeight = widgetHeight - plotBorderTop - plotBorderBottom + -# xPlotOffset = plotBorderLeft + -# yPlotOffset = plotBorderTop + . + These parameters are common to all scaling laws. The next image explains these formulas: + + \image html plot_coordinates.png + + The actual scaling laws \f$ (x_p(x), y_p(y)) \f$ may be derived from these equations: + \f[ x_p(\mbox{xmin})=\mbox{xPlotOffset},\ \ \ \ \ x_p(\mbox{xmax})=\mbox{xPlotOffset}+\mbox{plotWidth} \f] + \f[ y_p(\mbox{ymax})=\mbox{yPlotOffset},\ \ \ \ \ y_p(\mbox{ymin})=\mbox{yPlotOffset}+\mbox{plotHeight} \f] + Here \f$ (x_p, y_p) \f$ denotes a point in pixel coordinates (green coordinate system) and \f$ (x,y) \f$ denotes a point in the + plotting coordinate system. + + If you assume a linear scaling law. \f[ x_p(x)=\mbox{xoffset}+x\cdot\mbox{xscale} \ \ \ \ \ \ \ \ \ y_p(y)=\mbox{yoffset}-y\cdot\mbox{yscale} \f] + you can derive: + \f[ \mbox{xscale}=\frac{\mbox{plotWidth}}{\mbox{xwidth}},\ \ \ \ \ \ \mbox{xoffset}=\mbox{xPlotOffset}-\mbox{xmin}\cdot\mbox{xscale} \f] + \f[ \mbox{yscale}=\frac{\mbox{plotHeight}}{\mbox{ywidth}},\ \ \ \ \ \ \mbox{yoffset}=\mbox{yPlotOffset}+\mbox{ymax}\cdot\mbox{yscale} \f] + + If you have a logarithmic axis (i.e. we plot \f$ \log_b(x) \f$ insetad of \f$ x \f$ for a given base \f$ b \f$ ) we get the same + formulas, but with \f$ x \f$ exchanged by \f$ \log_b(x) \f$. If we use the equation \f$ \log_b(x)=\log(x)/\log(b) \f$ we finally get + the scaling laws: + \f[ x_p(x)=\mbox{xoffset}+\frac{\log(x)}{\log(\mbox{logXAxisBase})}\cdot\mbox{xscale} \ \ \ \ \ \ \ \ \ y_p(y)=\mbox{yoffset}-\frac{\log(y)}{\log(\mbox{logYAxisBase})}\cdot\mbox{yscale} \f] + From these we can calculate their parameters with the same defining equations as above: + \f[ \mbox{xscale}=\frac{\mbox{plotWidth}\cdot\log(\mbox{logXAxisBase})}{\log(\mbox{xmax})-\log(\mbox{xmin})},\ \ \ \ \ \ \mbox{xoffset}=\mbox{xPlotOffset}-\frac{\log(\mbox{xmin})}{\log(\mbox{logXAxisBase})}\cdot\mbox{xscale} \f] + \f[ \mbox{yscale}=\frac{\mbox{plotHeight}\cdot\log(\mbox{logYAxisBase})}{\log(\mbox{ymax})-\log(\mbox{ymin})},\ \ \ \ \ \ \mbox{yoffset}=\mbox{yPlotOffset}+\frac{\log(\mbox{ymax})}{\log(\mbox{logYAxisBase})}\cdot\mbox{yscale} \f] + + The object implements the above coordinate transformations in the (inline) method x2p(). The inverse transformations + are implemented in p2x(). They can be used to show the system coordinates of the current mouse position. + + + \section jkqtplotter_base_grids_baseelemenets Axis JKQTPCoordinateAxisStyle::Ticks and Grids + + This section explains how this component draws the JKQTPCoordinateAxisStyle::ticks on coordinate axes and the grids that may be drawn below + the plots. In principle both - grids and axes - are drawn the same way, i.e. with the same step widths. There are + two types of JKQTPCoordinateAxisStyle::ticks and grids: The major and the minor JKQTPCoordinateAxisStyle::ticks/grids. The major JKQTPCoordinateAxisStyle::ticks also show a label that denotes the + value they represent. Between two major JKQTPCoordinateAxisStyle::ticks the axis shows \a JKQTPCoordinateAxisStyle::minorTicks small JKQTPCoordinateAxisStyle::ticks that are not + accompanied by a label. The next image shows an example of an axis: + + \image html plot_axis_ticksandlabels.png + + For the labels this class also uses an algorithm that extimates the number of valid digits (after the comma) that are + needed so that two adjacent labels do not show the same text, so if you plot the range 1.10 .. 1.15 The algorithm will + show at least two valid digits, as with one digit the labels would be 1.1, 1.1, 1.1, 1.1, 1.1, 1.1. With two digits they + are 1.10, 1.11, 1.12, 1.13, 1.14, 1.15. The class may also use a method that can write \c 1m instead of \c 0.001 and \c 1k + instead of \c 1000 (the algorithm supports the "exponent letters" f, p, n, u, m, k, M, G, T, P. The latter option may + (de)activated by using showXExponentCharacter and showYExponentCharacter. + + For grids applies the same. There are two grids that are drawn in different styles (often the major grid is drawn + thicker and darker than the minor grid). + + The minor JKQTPCoordinateAxisStyle::ticks and grid lines are generated automatically, depending in the setting of \a JKQTPCoordinateAxisStyle::minorTicks. + These properties give the number of minor JKQTPCoordinateAxisStyle::ticks between two major JKQTPCoordinateAxisStyle::ticks, so if the major JKQTPCoordinateAxisStyle::ticks are at 1,2,3,... and you + want minor JKQTPCoordinateAxisStyle::ticks at 1.1, 1.2, 1.3,... then you will have to set \c JKQTPCoordinateAxisStyle::minorTicks=9 as there are nine JKQTPCoordinateAxisStyle::ticks between two major + JKQTPCoordinateAxisStyle::ticks. So the minor tick spacing is calculated as: \f[ \Delta\mbox{MinorTicks}=\frac{\Delta\mbox{ticks}}{\mbox{minorTicks}+1} \f] + + The same applies for logarithmic axes. If the major JKQTPCoordinateAxisStyle::ticks are at 1,10,100,... and you set \c JKQTPCoordinateAxisStyle::minorTicks=9 the program will + generate 9 equally spaced minor JKQTPCoordinateAxisStyle::ticks in between, so you have minor JKQTPCoordinateAxisStyle::ticks at 2,3,4,...,11,12,13,... This results in a standard + logarithmic axis. If you set \c JKQTPCoordinateAxisStyle::minorTicks=1 then you will get minor JKQTPCoordinateAxisStyle::ticks at 5,15,150,... + + \image html plot_logaxis_ticksandlabels.png + + The major tick-tick distances of linear axes may be calculated automatically in a way that the axis shows at least a given + number of JKQTPCoordinateAxisStyle::ticks \c JKQTPCoordinateAxisStyle::minTicks. The algorithm takes that tick spacing that will give a number of JKQTPCoordinateAxisStyle::ticks per axis + nearest but \c ">=" to the given \c JKQTPCoordinateAxisStyle::minTicks. The Algorithm is described in detail with the function + calcLinearTickSpacing(). To activate this automatic tick spacing you have to set autoAxisSpacing=true. + */ +class JKQTP_LIB_EXPORT JKQTPCoordinateAxis: public QObject { + Q_OBJECT + protected: + public: + + /** \brief class constructor */ + explicit JKQTPCoordinateAxis(JKQTBasePlotter* parent); + /** \brief class destructor */ + virtual ~JKQTPCoordinateAxis(); + virtual void setParent(JKQTBasePlotter* parent); + /** \brief loads the plot properties from a QSettings object */ + virtual void loadSettings(const QSettings &settings, const QString& group=QString("plots/axes/")); + + /** \brief saves the plot properties into a QSettings object. + * + * This method only saves those properties that differ from their default value. + */ + virtual void saveSettings(QSettings& settings, const QString& group=QString("plots/axes/")) const; + + + /** \brief return x-pixel coordinate from time coordinate */ + inline double x2p(double x) const { + double r=0; + if (logAxis) { + if (x<=0) r= offset+scaleSign*log(axismin)/log(logAxisBase)*scale; + else r= offset+scaleSign*log(x)/log(logAxisBase)*scale; + } else { + r= offset+scaleSign*x*scale; + } + if (inverted) { + return 2.0*getParentPlotOffset()+getParentPlotWidth()-r;//getParentPlotOffset()+getParentPlotWidth()-(r-getParentPlotOffset()); + } else { + return r; + } + } + + /** \brief return time coordinate coordinate from x-pixel */ + inline double p2x(double x) const { + double xx=x; + if (inverted) { + xx=2.0*getParentPlotOffset()+getParentPlotWidth()-x; + } + xx=xx-offset; + if (logAxis) { + return exp(log(logAxisBase)*(xx)/(scaleSign*scale)); + } else { + return xx/(scaleSign*scale); + } + } + + + /** \brief clear axis tick labels. This switches back to automatic labels mode for the axis. */ + void clearAxisTickLabels(); + + /** \brief add a new tick label to the axis */ + void addAxisTickLabel(double x, const QString& label); + + + /** \brief add a new tick label to the axis */ + void addAxisTickLabels(const QVector& x, const QStringList& label); + /** \brief add a new tick label to the axis */ + void addAxisTickLabels(const double* x, const QStringList& label); + /** \brief add a new tick label to the axis */ + void addAxisTickLabels(const QVector& x, const QString* label); + /** \brief add a new tick label to the axis */ + void addAxisTickLabels(const double* x, const QString* label, int items); + + /** \brief returns the size of the left/bottom axis in pt */ + virtual QSizeF getSize1(JKQTPEnhancedPainter& painter)=0; + + /** \brief returns the size of the right/top axis in pt */ + virtual QSizeF getSize2(JKQTPEnhancedPainter& painter)=0; + + /** \brief draw axes */ + virtual void drawAxes(JKQTPEnhancedPainter& painter)=0; + + /** \brief draw grids */ + virtual void drawGrids(JKQTPEnhancedPainter& painter)=0; + + + /*! \copydoc tickSpacing + \see tickSpacing */ + inline double getTickSpacing() const { return this->tickSpacing; } + /*! \copydoc JKQTPCoordinateAxisStyle::labelDigits + \see JKQTPCoordinateAxisStyle::labelDigits */ + inline int getLabelDigits() const { return this->axisStyle.labelDigits; } + /*! \copydoc autoAxisSpacing + \see autoAxisSpacing */ + inline bool getAutoAxisSpacing() const { return this->autoAxisSpacing; } + /*! \copydoc JKQTPCoordinateAxisStyle::minorTickLabelsEnabled + \see JKQTPCoordinateAxisStyle::minorTickLabelsEnabled */ + inline bool getMinorTickLabelsEnabled() const { return this->axisStyle.minorTickLabelsEnabled; } + /*! \copydoc logAxis + \see logAxis */ + inline bool getLogAxis() const { return this->logAxis; } + /*! \copydoc inverted + \see inverted */ + inline bool getInverted() const { return this->inverted; } + /*! \copydoc logAxisBase + \see logAxisBase */ + inline double getLogAxisBase() const { return this->logAxisBase; } + /*! \copydoc userTickSpacing + \see userTickSpacing */ + inline double getUserTickSpacing() const { return this->userTickSpacing; } + /*! \copydoc userLogTickSpacing + \see userLogTickSpacing */ + inline double getUserLogTickSpacing() const { return this->userLogTickSpacing; } + /*! \copydoc JKQTPCoordinateAxisStyle::labelType + \see JKQTPCoordinateAxisStyle::labelType */ + inline JKQTPCALabelType getLabelType() const { return this->axisStyle.labelType; } + /*! \copydoc axisLabel + \see axisLabel */ + inline QString getAxisLabel() const { return this->axisLabel; } + /*! \copydoc JKQTPCoordinateAxisStyle::labelPosition + \see JKQTPCoordinateAxisStyle::labelPosition */ + inline JKQTPLabelPosition getLabelPosition() const { return this->axisStyle.labelPosition; } + /*! \copydoc JKQTPCoordinateAxisStyle::labelFontSize + \see JKQTPCoordinateAxisStyle::labelFontSize */ + inline double getLabelFontSize() const { return this->axisStyle.labelFontSize; } + /*! \copydoc JKQTPCoordinateAxisStyle::tickLabelFontSize + \see JKQTPCoordinateAxisStyle::tickLabelFontSize */ + inline double getTickLabelFontSize() const { return this->axisStyle.tickLabelFontSize; } + /*! \copydoc JKQTPCoordinateAxisStyle::minorTickLabelFontSize + \see JKQTPCoordinateAxisStyle::minorTickLabelFontSize */ + inline double getMinorTickLabelFontSize() const { return this->axisStyle.minorTickLabelFontSize; } + /*! \copydoc JKQTPCoordinateAxisStyle::minorTickLabelFullNumber + \see JKQTPCoordinateAxisStyle::minorTickLabelFullNumber */ + inline bool getMinorTickLabelFullNumber() const { return this->axisStyle.minorTickLabelFullNumber; } + /*! \copydoc JKQTPCoordinateAxisStyle::tickLabelAngle + \see JKQTPCoordinateAxisStyle::tickLabelAngle */ + inline double getTickLabelAngle() const { return this->axisStyle.tickLabelAngle; } + /*! \copydoc JKQTPCoordinateAxisStyle::minTicks + \see JKQTPCoordinateAxisStyle::minTicks */ + inline unsigned int getMinTicks() const { return this->axisStyle.minTicks; } + /*! \copydoc JKQTPCoordinateAxisStyle::minorTicks + \see JKQTPCoordinateAxisStyle::minorTicks */ + inline unsigned int getMinorTicks() const { return this->axisStyle.minorTicks; } + /*! \copydoc JKQTPCoordinateAxisStyle::tickOutsideLength + \see JKQTPCoordinateAxisStyle::tickOutsideLength */ + inline double getTickOutsideLength() const { return this->axisStyle.tickOutsideLength; } + /*! \copydoc JKQTPCoordinateAxisStyle::minorTickOutsideLength + \see JKQTPCoordinateAxisStyle::minorTickOutsideLength */ + inline double getMinorTickOutsideLength() const { return this->axisStyle.minorTickOutsideLength; } + /*! \copydoc JKQTPCoordinateAxisStyle::axisColor + \see JKQTPCoordinateAxisStyle::axisColor */ + inline QColor getAxisColor() const { return this->axisStyle.axisColor; } + /*! \copydoc JKQTPCoordinateAxisStyle::showZeroAxis + \see JKQTPCoordinateAxisStyle::showZeroAxis */ + inline bool getShowZeroAxis() const { return this->axisStyle.showZeroAxis; } + /*! \copydoc JKQTPCoordinateAxisStyle::gridColor + \see JKQTPCoordinateAxisStyle::gridColor */ + inline QColor getGridColor() const { return this->axisStyle.gridColor; } + /*! \copydoc JKQTPCoordinateAxisStyle::minorGridColor + \see JKQTPCoordinateAxisStyle::minorGridColor */ + inline QColor getMinorGridColor() const { return this->axisStyle.minorGridColor; } + /*! \copydoc JKQTPCoordinateAxisStyle::gridWidth + \see JKQTPCoordinateAxisStyle::gridWidth */ + inline double getGridWidth() const { return this->axisStyle.gridWidth; } + /*! \copydoc JKQTPCoordinateAxisStyle::gridStyle + \see JKQTPCoordinateAxisStyle::gridStyle */ + inline Qt::PenStyle getGridStyle() const { return this->axisStyle.gridStyle; } + /*! \copydoc JKQTPCoordinateAxisStyle::minorGridWidth + \see JKQTPCoordinateAxisStyle::minorGridWidth */ + inline double getMinorGridWidth() const { return this->axisStyle.minorGridWidth; } + /*! \copydoc JKQTPCoordinateAxisStyle::minorGridStyle + \see JKQTPCoordinateAxisStyle::minorGridStyle */ + inline Qt::PenStyle getMinorGridStyle() const { return this->axisStyle.minorGridStyle; } + /*! \copydoc JKQTPCoordinateAxisStyle::tickTimeFormat + \see JKQTPCoordinateAxisStyle::tickTimeFormat */ + inline QString getTickTimeFormat() const { return this->axisStyle.tickTimeFormat; } + /*! \copydoc JKQTPCoordinateAxisStyle::tickDateFormat + \see JKQTPCoordinateAxisStyle::tickDateFormat */ + inline QString getTickDateFormat() const { return this->axisStyle.tickDateFormat; } + /*! \copydoc JKQTPCoordinateAxisStyle::tickDateTimeFormat + \see JKQTPCoordinateAxisStyle::tickDateTimeFormat */ + inline QString getTickDateTimeFormat() const { return this->axisStyle.tickDateTimeFormat; } + /*! \copydoc JKQTPCoordinateAxisStyle::tickMode + \see JKQTPCoordinateAxisStyle::tickMode */ + inline JKQTPLabelTickMode getTickMode() const { return this->axisStyle.tickMode; } + + /*! \copydoc JKQTPCoordinateAxisStyle::drawMode1 + \see JKQTPCoordinateAxisStyle::drawMode1 */ + inline JKQTPCADrawMode getDrawMode1() const { return this->axisStyle.drawMode1; } + /*! \copydoc JKQTPCoordinateAxisStyle::drawMode2 + \see JKQTPCoordinateAxisStyle::drawMode2 */ + inline JKQTPCADrawMode getDrawMode2() const { return this->axisStyle.drawMode2; } + /*! \copydoc JKQTPCoordinateAxisStyle::minorTickWidth + \see JKQTPCoordinateAxisStyle::minorTickWidth */ + inline double getMinorTickWidth() const { return this->axisStyle.minorTickWidth; } + /*! \copydoc JKQTPCoordinateAxisStyle::tickWidth + \see JKQTPCoordinateAxisStyle::tickWidth */ + inline double getTickWidth() const { return this->axisStyle.tickWidth; } + /*! \copydoc JKQTPCoordinateAxisStyle::lineWidth + \see JKQTPCoordinateAxisStyle::lineWidth */ + inline double getLineWidth() const { return this->axisStyle.lineWidth; } + /*! \copydoc JKQTPCoordinateAxisStyle::lineWidthZeroAxis + \see JKQTPCoordinateAxisStyle::lineWidthZeroAxis */ + inline double getLineWidthZeroAxis() const { return this->axisStyle.lineWidthZeroAxis; } + /*! \copydoc JKQTPCoordinateAxisStyle::tickLabelDistance + \see JKQTPCoordinateAxisStyle::tickLabelDistance */ + inline double getTickLabelDistance() const { return this->axisStyle.tickLabelDistance; } + /*! \copydoc JKQTPCoordinateAxisStyle::labelDistance + \see JKQTPCoordinateAxisStyle::labelDistance */ + inline double getLabelDistance() const { return this->axisStyle.labelDistance; } + /*! \copydoc JKQTPCoordinateAxisStyle::drawGrid + \see JKQTPCoordinateAxisStyle::drawGrid */ + inline bool getDrawGrid() const { return this->axisStyle.drawGrid; } + /*! \copydoc JKQTPCoordinateAxisStyle::drawMinorGrid + \see JKQTPCoordinateAxisStyle::drawMinorGrid */ + inline bool getDrawMinorGrid() const { return this->axisStyle.drawMinorGrid; } + /*! \copydoc JKQTPCoordinateAxisStyle::autoLabelDigits + \see JKQTPCoordinateAxisStyle::autoLabelDigits */ + inline void setAutoLabelDigits(bool __value) + { + this->axisStyle.autoLabelDigits = __value; + } + /*! \copydoc JKQTPCoordinateAxisStyle::autoLabelDigits + \see JKQTPCoordinateAxisStyle::autoLabelDigits */ + inline bool getAutoLabelDigits() const + { + return this->axisStyle.autoLabelDigits; + } + /*! \copydoc parent + \see parent */ + inline const JKQTBasePlotter* getParent() const { return this->parent; } + /*! \brief returns the property parent ( \copybrief parent ). \details Description of the parameter parent is:
    \copydoc parent
    . \see parent for more information */ + inline JKQTBasePlotter* getParent() { return this->parent; } + /*! \brief sets the property doUpdateScaling ( \copybrief doUpdateScaling ) to the specified \a __value. + \details Description of the parameter doUpdateScaling is:
    \copydoc doUpdateScaling
    + \see doUpdateScaling for more information */ + inline void setDoUpdateScaling(bool __value) + { + this->doUpdateScaling = __value; + } + /*! \brief returns the property doUpdateScaling ( \copybrief doUpdateScaling ). + \details Description of the parameter doUpdateScaling is:
    \copydoc doUpdateScaling
    + \see doUpdateScaling for more information */ + inline bool getDoUpdateScaling() const + { + return this->doUpdateScaling; + } + + + /** \brief returns the current min */ + inline double getMin() const {return axismin; } + + /** \brief returns the current max */ + inline double getMax() const {return axismax; } + + /** \brief returns the current absolute min */ + inline double getAbsoluteMin() const {return axisabsoultemin; } + + /** \brief returns the current absolute max */ + inline double getAbsoluteMax() const {return axisabsoultemax; } + /** \brief calculate the scaling and offset values from axis min/max values + * + * This is only executed when \c paramChanged==true, as otherwise the data has to be still + * correct. recalculating may be forced by caling calcPlotScaing(true); + */ + void calcPlotScaling(bool force=false); + + /** \brief returns whether this axis uses logarithmic scaling */ + bool isLogAxis() const; + + + /** \brief current style properties for this JKQTBasePlotter + * + * \see JKQTPSetSystemDefaultBaseStyle(), JKQTPSetSystemDefaultBaseStyle(), setCurrentAxisStyle(), getCurrentAxisStyle(), \ref jkqtpplotter_styling + */ + const JKQTPCoordinateAxisStyle &getCurrentAxisStyle() const; + + /** \brief replace the current style properties for this JKQTBasePlotter + * + * \see JKQTPSetSystemDefaultBaseStyle(), JKQTPSetSystemDefaultBaseStyle(), setCurrentAxisStyle(), getCurrentAxisStyle(), \ref jkqtpplotter_styling + */ + void setCurrentAxisStyle(const JKQTPCoordinateAxisStyle& style); + /** \brief replace the current style properties for this JKQTBasePlotter with properties loaded from \a settings + * + * \param settings the QSettings object to read from + * \param group group in \a settings to read from + * + * \see JKQTPCoordinateAxisStyle getCurrentAxisStyle(), \ref jkqtpplotter_styling + */ + void loadCurrentAxisStyle(const QSettings& settings, const QString& group="plot/axes/"); + /** \brief store the current style properties for this JKQTBasePlotter with properties loaded from \a settings + * + * \param settings the QSettings object to write to + * \param group group in \a settings to write to + * + * \see JKQTPSetSystemDefaultBaseStyle(), JKQTPSetSystemDefaultBaseStyle(), setCurrentAxisStyle(), getCurrentAxisStyle(), \ref jkqtpplotter_styling + */ + void saveCurrentAxisStyle(QSettings& settings, const QString& group="plot/axes/") const; + + + public slots: + /** \brief set range of plot axis */ + void setRange(double amin, double amax); + /** \brief set absolute range of plot axis */ + void setAbsoluteRange(double aamin, double aamax); + /** \brief do not use an absolute range of plot axis */ + void setNoAbsoluteRange(); + + /*! \copydoc tickSpacing + \see tickSpacing */ + void setTickSpacing(double __value); + + /*! \copydoc axisMinWidth + \see axisMinWidth */ + void setAxisMinWidth(double __value); + + /*! \copydoc autoAxisSpacing + \see autoAxisSpacing */ + void setAutoAxisSpacing(bool __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::minorTickLabelsEnabled + \see JKQTPCoordinateAxisStyle::minorTickLabelsEnabled */ + void setMinorTickLabelsEnabled(bool __value); + + /*! \copydoc logAxis + \see logAxis */ + void setLogAxis(bool __value) ; + + /*! \copydoc logAxisBase + \see logAxisBase */ + void setLogAxisBase (double __value); + + /*! \copydoc userTickSpacing + \see userTickSpacing */ + void setUserTickSpacing (double __value); + + /*! \copydoc userLogTickSpacing + \see userLogTickSpacing */ + void setUserLogTickSpacing (double __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::labelType + \see JKQTPCoordinateAxisStyle::labelType */ + void setLabelType (JKQTPCALabelType __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::tickMode + \see JKQTPCoordinateAxisStyle::tickMode */ + void setTickMode (JKQTPLabelTickMode __value); + /*! \copydoc JKQTPCoordinateAxisStyle::tickMode + \see JKQTPCoordinateAxisStyle::tickMode */ + void setTickMode (int __value); + + /*! \copydoc axisLabel + \see axisLabel */ + void setAxisLabel (const QString& __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::labelPosition + \see JKQTPCoordinateAxisStyle::labelPosition */ + void setLabelPosition (JKQTPLabelPosition __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::labelFontSize + \see JKQTPCoordinateAxisStyle::labelFontSize */ + void setLabelFontSize (double __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::tickTimeFormat + \see JKQTPCoordinateAxisStyle::tickTimeFormat */ + void setTickTimeFormat (const QString& __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::tickDateFormat + \see JKQTPCoordinateAxisStyle::tickDateFormat */ + void setTickDateFormat (const QString& __value); + + + /*! \copydoc JKQTPCoordinateAxisStyle::tickDateTimeFormat + \see JKQTPCoordinateAxisStyle::tickDateTimeFormat */ + void setTickDateTimeFormat (const QString& __value); + + + /*! \copydoc JKQTPCoordinateAxisStyle::tickLabelFontSize + \see JKQTPCoordinateAxisStyle::tickLabelFontSize */ + void setTickLabelFontSize (double __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::minorTickLabelFontSize + \see JKQTPCoordinateAxisStyle::minorTickLabelFontSize */ + void setMinorTickLabelFontSize (double __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::minorTickLabelFullNumber + \see JKQTPCoordinateAxisStyle::minorTickLabelFullNumber */ + void setMinorTickLabelFullNumber (bool __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::minTicks + \see JKQTPCoordinateAxisStyle::minTicks */ + void setMinTicks(unsigned int __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::minorTicks + \see JKQTPCoordinateAxisStyle::minorTicks */ + void setMinorTicks (unsigned int __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::minorTicks + \see JKQTPCoordinateAxisStyle::minorTicks */ + void setMinorTicks (int __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::tickOutsideLength + \see JKQTPCoordinateAxisStyle::tickOutsideLength */ + void setTickOutsideLength(double __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::minorTickOutsideLength + \see JKQTPCoordinateAxisStyle::minorTickOutsideLength */ + void setMinorTickOutsideLength (double __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::tickInsideLength + \see JKQTPCoordinateAxisStyle::tickInsideLength */ + void setTickInsideLength(double __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::minorTickInsideLength + \see JKQTPCoordinateAxisStyle::minorTickInsideLength */ + void setMinorTickInsideLength (double __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::axisColor + \see JKQTPCoordinateAxisStyle::axisColor */ + void setAxisColor (const QColor& __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::showZeroAxis + \see JKQTPCoordinateAxisStyle::showZeroAxis */ + void setShowZeroAxis(bool __value); + + /*! \copydoc inverted + \see inverted */ + void setInverted(bool __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::gridColor + \see JKQTPCoordinateAxisStyle::gridColor */ + void setGridColor(const QColor& __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::minorGridColor + \see JKQTPCoordinateAxisStyle::minorGridColor */ + void setMinorGridColor(const QColor& __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::gridWidth + \see JKQTPCoordinateAxisStyle::gridWidth */ + void setGridWidth (double __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::gridStyle + \see JKQTPCoordinateAxisStyle::gridStyle */ + void setGridStyle(Qt::PenStyle __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::minorGridWidth + \see JKQTPCoordinateAxisStyle::minorGridWidth */ + void setMinorGridWidth(double __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::minorGridStyle + \see JKQTPCoordinateAxisStyle::minorGridStyle */ + void setMinorGridStyle (Qt::PenStyle __value); + + + /*! \copydoc JKQTPCoordinateAxisStyle::drawMode1 + \see JKQTPCoordinateAxisStyle::drawMode1 */ + void setDrawMode1 (JKQTPCADrawMode __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::drawMode2 + \see JKQTPCoordinateAxisStyle::drawMode2 */ + void setDrawMode2(JKQTPCADrawMode __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::minorTickWidth + \see JKQTPCoordinateAxisStyle::minorTickWidth */ + void setMinorTickWidth(double __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::tickWidth + \see JKQTPCoordinateAxisStyle::tickWidth */ + void setTickWidth (double __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::lineWidth + \see JKQTPCoordinateAxisStyle::lineWidth */ + void setLineWidth (double __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::lineWidthZeroAxis + \see JKQTPCoordinateAxisStyle::lineWidthZeroAxis */ + void setLineWidthZeroAxis (double __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::tickLabelDistance + \see JKQTPCoordinateAxisStyle::tickLabelDistance */ + void setTickLabelDistance(double __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::labelDistance + \see JKQTPCoordinateAxisStyle::labelDistance */ + void setLabelDistance(double __value); + /*! \copydoc JKQTPCoordinateAxisStyle::labelDigits + \see JKQTPCoordinateAxisStyle::labelDigits */ + void setLabelDigits(int __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::drawGrid + \see JKQTPCoordinateAxisStyle::drawGrid */ + void setDrawGrid(bool __value); + + /*! \copydoc JKQTPCoordinateAxisStyle::drawMinorGrid + \see JKQTPCoordinateAxisStyle::drawMinorGrid */ + void setDrawMinorGrid(bool __value); + + + /*! \copydoc JKQTPCoordinateAxisStyle::tickLabelAngle + \see JKQTPCoordinateAxisStyle::tickLabelAngle */ + void setTickLabelAngle(double __value); + + protected: + /** \brief indicates whether one of the parameters has changed sinse the last recalculation of tickSpacing ... */ + bool paramsChanged; + bool doUpdateScaling; + + /** \brief simply calls the redrawPlot method of the parent plotter class */ + void redrawPlot(); + /** \brief a list of tick labels. + * + * If this list contains items, this class will NOT plot a standard x-axis, + * but only mark the positions in this list. Every item is a x-position together with + * the label to be plotted there. The label may contain LaTeX markup. + */ + QVector > tickLabels; + /** \brief width of the plot in the direction of the axis */ + virtual double getParentPlotWidth() const=0; + /** \brief offset of the plot in the direction of the axis */ + virtual double getParentPlotOffset() const=0; + /** \brief width of other (perpendicular) axis (needed for grids) */ + virtual double getParentOtheraxisWidth() const=0; + /** \brief is other (perpendicular) axis inverted (needed for grids) */ + virtual bool getParentOtheraxisInverted() const=0; + /** \brief pixel offset of (perpendicular) other axis (needed for grids) */ + virtual double getParentOtheraxisOffset() const=0; + /** \brief retun parents JKQTMathText* object */ + virtual JKQTMathText* getParentMathText(); + + + /** \brief convert a float to a tick label string */ + QString floattolabel(double data); + + /** \brief convert a float to a tick label string with a given precision */ + QString floattolabel(double data, int past_comma); + /** \brief parent plotter class */ + JKQTBasePlotter* parent; + /** \brief current view: minimum of time axis */ + double axismin; + /** \brief current view: maximum of time axis */ + double axismax; + + /** \brief absoulte minimum of axis (axismin/axismax xan not be set below this) */ + double axisabsoultemin; + /** \brief absoulte maximum of axis (axismin/axismax xan not be set above this) */ + double axisabsoultemax; + + + /** \brief current style properties for this coordinate axis instance + * + * \see JKQTBasePlotterStyle, JKQTPSetSystemDefaultBaseStyle(), JKQTPSetSystemDefaultBaseStyle(), setCurrentAxisStyle(), getCurrentAxisStyle(), \ref jkqtpplotter_styling + */ + JKQTPCoordinateAxisStyle axisStyle; + + /** \brief absolute minimum range width, feature switched off when <0 */ + double axisMinWidth; + + /** \brief calculated property: width of plot on time axis (calculated by calcPlotScaling() ) + * + * \see calcPlotScaling(), calcTickSpacing() + */ + double width; + + /** \brief calculated property: time axis scaling factor (calculated by calcPlotScaling() ) + * + * \see calcPlotScaling(), calcTickSpacing() + */ + double scale; + /** \brief calculated property: time axis offset (calculated by calcPlotScaling() ) + * + * \see calcPlotScaling(), calcTickSpacing() + */ + double offset; + /** \brief indicates whether the axis is to be inverted or not */ + bool inverted; + + /** \brief calculated property: x position of the first tick (calculated by calcPlotScaling() ). Given in system coordinates, not pixel coordinates. + * + * \see calcPlotScaling(), calcTickSpacing() + */ + double tickStart; + + /** \brief calculated property: indicates whether the object should use automatic tick spacing for the x axis (calculated by calcPlotScaling() ) + * + * \see calcPlotScaling(), calcTickSpacing() + */ + bool autoAxisSpacing; + + /** \brief indicates whether the y axis has a logarithmic scale */ + bool logAxis; + /** \brief the base for a logarithmic x axis */ + double logAxisBase; + /** \brief if autoXAxisSpacing is \c false then this value is used for xTickSpacing. So this is the property which + * is editable by use of public access methods. + */ + double userTickSpacing; + /** \brief if autoXAxisSpacing is \c false then this value is used for xTickSpacing. So this is the property which + * is editable by use of public access methods. + */ + double userLogTickSpacing; + + /** \brief calculated property: axis tick spacing (calculated by calcPlotScaling() and calcTickSpacing() ) for logarithmic/linear axes. + * + * \see calcPlotScaling(), calcTickSpacing() + */ + double tickSpacing; + /** \brief calculated property: axis tick spacing for logarithmic JKQTPCoordinateAxisStyle::ticks (calculated by calcPlotScaling() and calcTickSpacing() ) axes. + * + * \see calcPlotScaling() + */ + double tickSpacingLog; + + + /** \brief axis label of the axis */ + QString axisLabel; + + + /** \brief calculates the tick spacing for a linear axis that spans \a awidth and that should + * show at least \a JKQTPCoordinateAxisStyle::minTicks JKQTPCoordinateAxisStyle::ticks. + * + * The algorithm used in here works as follows: + * + * There is only a limited subset of allowed tick distances. These distances are 1 (resulting in 10 JKQTPCoordinateAxisStyle::ticks per decade, i.e. 0,1,2,3,4,...), + * 2 (5 JKQTPCoordinateAxisStyle::ticks/decade, i.e. 0,2,4,...), 2.5 (4 JKQTPCoordinateAxisStyle::ticks/decade, i.e. 0,2.5,5,...) and 5 (2 JKQTPCoordinateAxisStyle::ticks/decade, i.e. 0,5,10,15,...). So the + * axis is divided into decades that each is divided into JKQTPCoordinateAxisStyle::ticks, as defined above. With these preconditions the algorithm tries + * to find a tick increment \f$ \Delta\mbox{tick} \f$ which is one of the above distances multiplied by a power \f$ \rho \f$ of 10. + * This increment is determined in a way, that the axis contains at least \a JKQTPCoordinateAxisStyle::minTicks JKQTPCoordinateAxisStyle::ticks: + * \f[ \Delta\mbox{tick}=f\cdot 10^\rho,\ \ \ \ \ f\in\{1, 2, 2.5, 5\} \f] + * + * -# The algorithm starts by finding a start exponent \f$ \rho_s=\left\lfloor\log_{10}(\mbox{awidth})\right\rfloor+3 \f$. This + * is a good (over)estimate for the biggest possible power \f$ \rho \f$. + * -# now we set \f$ \rho=\rho_0 \f$ and \f$ f=10 \f$. + * -# now the algorithm cycles through all possible factors \f$ f\in\{1, 2, 2.5, 5, 10\} \f$ (starting from 10) and calculates + * \f$ \Delta\mbox{tick}=f\cdot 10^\rho \f$. Then it checks whether \f$ \mbox{tickcount}=\mbox{round}\left(\frac{\mbox{awidth}}{\Delta\mbox{tick}}\right) \f$ + * is smaller than \a JKQTPCoordinateAxisStyle::minTicks (if yes the algorithm reached its end and \f$ \Delta\mbox{tick} \f$ can be used. + * -# if \f$ f=1 \f$ is reached and checked \c false, then the algorithm decreases the exponent \f$ \rho \leftarrow \rho-1 \f$ and returns to step 3. + * + */ + double calcLinearTickSpacing(); + /** \brief same as calcLinearTickSpacing(), but for logarithmic scaling + * + * \see calcLinearTickSpacing() + * */ + double calcLogTickSpacing(); + + /** \brief Calculate the number of digits needed for the labels of an axis that starts at + * \a minval and where the tick spacing is \a tickSpacing. + * + * This method determines how many digits to output for the labels on a coordinate axis. + * This is done by testing different digit numbers and comparing subsequent labels. If two labels + * are equal, then we need more valid digits to distinguish them. + */ + int calcLinearUnitDigits(); + + + + /** \brief axis prefix for storage of parameters */ + QString axisPrefix; + /** \brief this is used by x2p() and p2x() to determine the sign */ + double scaleSign; + + /** \brief calculates the next label from the given parameters. + * + * \return \c true on success and \c false if there is no more label + * \param x \b before \b call: the position of the label for which the text should be returned (or JKQTPCoordinateAxisStyle::tickStart for first call), + * \b after \b call: position of the next label (given in world coordinates!) + * \param label \b after \b call: text of the (input) tick label This is an empty string, if the label is not visible! + * \param init call this function with \c init=true to obtain the first label (at JKQTPCoordinateAxisStyle::tickStart) + */ + bool getNextLabel(double& x, QString& label, bool init=false); + + /** \brief returns the distance from the current tick position (x before call) to the next tick position */ + double getNextLabelDistance(double x); + + /** \brief calculates the maximum width and height (returned as QSize) of all tick labels. + * Ascent and descent may also be returned in the two additional pointer arguments- */ + QSizeF getMaxTickLabelSize(JKQTPEnhancedPainter& painter, double* ascent=nullptr, double* descent=nullptr); +}; + + + + + +/*! \brief implements a vertical axis, based on JKQTPCoordinateAxis (for most of documentation: see JKQTPCoordinateAxis). + \ingroup jkqtpbaseplotter_elements + + */ +class JKQTP_LIB_EXPORT JKQTPVerticalAxis: public JKQTPCoordinateAxis { + Q_OBJECT + protected: + public: + /** \brief class constructor */ + JKQTPVerticalAxis(JKQTBasePlotter* parent); + + /** \brief returns the size of the left/bottom axis in pt */ + virtual QSizeF getSize1(JKQTPEnhancedPainter& painter) override; + + /** \brief returns the size of the right/top axis in pt */ + virtual QSizeF getSize2(JKQTPEnhancedPainter& painter) override; + + /** \brief draw axes */ + virtual void drawAxes(JKQTPEnhancedPainter& painter) override; + + /** \brief draw grids */ + virtual void drawGrids(JKQTPEnhancedPainter& painter) override; + + + protected: + /** \brief width of the plot in the direction of the axis */ + virtual double getParentPlotWidth() const override; + /** \brief offset of the plot in the direction of the axis */ + virtual double getParentPlotOffset() const override; + /** \brief pixel of other (perpendicular) axis (needed for grids) */ + virtual double getParentOtheraxisWidth() const override; + virtual bool getParentOtheraxisInverted() const override; + /** \brief pixel offset of (perpendicular) other axis (needed for grids) */ + virtual double getParentOtheraxisOffset() const override; + + virtual void drawTickLabel1(JKQTPEnhancedPainter& painter, double xx, double yy, const QString &label, double fontSize) ; + virtual void drawTickLabel2(JKQTPEnhancedPainter& painter, double xx, double yy, const QString &label, double fontSize) ; +}; + + +/*! \brief implements a position-indipendent vertical axis, based on JKQTPCoordinateAxis (for most of documentation: see JKQTPCoordinateAxis). + \ingroup jkqtpbaseplotter_elements + + This axis may be draw at a user-supplied position (used e.g. for color bar axes) + */ +class JKQTP_LIB_EXPORT JKQTPVerticalIndependentAxis: public JKQTPVerticalAxis { + Q_OBJECT + protected: + public: + /** \brief class constructor */ + JKQTPVerticalIndependentAxis(double axisOffset, double axisWidth, double otherAxisOffset, double otherAxisWidth, JKQTBasePlotter* parent); + /** \brief set the axis offset */ + virtual void setAxisOffset(double __value) ; + /** \brief set the axis width */ + virtual void setAxisWidth(double __value) ; + /** \brief set the other axis offset */ + virtual void setOtherAxisOffset(double __value) ; + /** \brief set the other axis width */ + virtual void setOtherAxisWidth(double __value) ; + /** \brief set the other axis width */ + virtual void setOtherAxisInverted(bool __value) ; + protected: + /** \brief width of the plot in the direction of the axis */ + virtual double getParentPlotWidth() const override; + /** \brief offset of the plot in the direction of the axis */ + virtual double getParentPlotOffset() const override; + /** \brief pixel of other (perpendicular) axis (needed for grids) */ + virtual double getParentOtheraxisWidth() const override; + virtual bool getParentOtheraxisInverted() const override; + /** \brief pixel offset of (perpendicular) other axis (needed for grids) */ + virtual double getParentOtheraxisOffset() const override; + + double axisOffset; + double axisWidth; + double otherAxisWidth; + double otherAxisOffset; + bool otherAxisInverted; +}; + + + +/*! \brief implements a horizontal axis, based on JKQTPCoordinateAxis (for most of documentation: see JKQTPCoordinateAxis). + \ingroup jkqtpbaseplotter_elements + + */ +class JKQTP_LIB_EXPORT JKQTPHorizontalAxis: public JKQTPCoordinateAxis { + Q_OBJECT + protected: + public: + /** \brief class constructor */ + JKQTPHorizontalAxis(JKQTBasePlotter* parent); + + /** \brief returns the size of the left/bottom axis in pt */ + virtual QSizeF getSize1(JKQTPEnhancedPainter& painter) override; + + /** \brief returns the size of the right/top axis in pt */ + virtual QSizeF getSize2(JKQTPEnhancedPainter& painter) override; + + /** \brief draw axes */ + virtual void drawAxes(JKQTPEnhancedPainter& painter) override; + + /** \brief draw grids */ + virtual void drawGrids(JKQTPEnhancedPainter& painter) override; + + protected: + /** \brief width of the plot in the direction of the axis */ + virtual double getParentPlotWidth() const override; + /** \brief offset of the plot in the direction of the axis */ + virtual double getParentPlotOffset() const override; + /** \brief pixel of other (perpendicular) axis (needed for grids) */ + virtual double getParentOtheraxisWidth() const override; + virtual bool getParentOtheraxisInverted() const override; + /** \brief pixel offset of (perpendicular) other axis (needed for grids) */ + virtual double getParentOtheraxisOffset() const override; + + + virtual void drawTickLabel1(JKQTPEnhancedPainter& painter, double xx, double yy, const QString &label, double fontSize, double ascentMax, double descentMax) ; + virtual void drawTickLabel2(JKQTPEnhancedPainter& painter, double xx, double yy, const QString &label, double fontSize, double ascentMax, double descentMax) ; + +}; + + +/*! \brief implements a position-indipendent horizontal axis, based on JKQTPCoordinateAxis (for most of documentation: see JKQTPCoordinateAxis). + \ingroup jkqtpbaseplotter_elements + + This axis may be draw at a user-supplied position (used e.g. for color bar axes) + */ +class JKQTP_LIB_EXPORT JKQTPHorizontalIndependentAxis: public JKQTPHorizontalAxis { + Q_OBJECT + protected: + public: + /** \brief class constructor */ + JKQTPHorizontalIndependentAxis(double axisOffset, double axisWidth, double otherAxisOffset, double otherAxisWidth, JKQTBasePlotter* parent); + /** \brief se the axis offset */ + virtual void setAxisOffset(double __value); + /** \brief se the axis width */ + virtual void setAxisWidth(double __value); + /** \brief set the other axis offset */ + virtual void setOtherAxisOffset(double __value); + /** \brief set the other axis width */ + virtual void setOtherAxisWidth(double __value); + virtual void setOtherAxisInverted(bool __value); + protected: + /** \brief width of the plot in the direction of the axis */ + virtual double getParentPlotWidth() const override; + /** \brief offset of the plot in the direction of the axis */ + virtual double getParentPlotOffset() const override; + /** \brief pixel of other (perpendicular) axis (needed for grids) */ + virtual double getParentOtheraxisWidth() const override; + virtual bool getParentOtheraxisInverted() const override; + /** \brief pixel offset of (perpendicular) other axis (needed for grids) */ + virtual double getParentOtheraxisOffset() const override; + + double axisOffset; + double axisWidth; + double otherAxisWidth; + double otherAxisOffset; + bool otherAxisInverted; +}; + +#endif // JKQTPCOORDINATEAXES_H diff --git a/lib/jkqtplotter/jkqtpcoordinateaxesstyle.cpp b/lib/jkqtplotter/jkqtpcoordinateaxesstyle.cpp new file mode 100644 index 0000000000..e7a77dd8d4 --- /dev/null +++ b/lib/jkqtplotter/jkqtpcoordinateaxesstyle.cpp @@ -0,0 +1,142 @@ +#include "jkqtpcoordinateaxesstyle.h" +#include "jkqtpbaseplotterstyle.h" +#include + +JKQTPCoordinateAxisStyle::JKQTPCoordinateAxisStyle(): + labelDigits(3), + autoLabelDigits(true), + minorTickLabelsEnabled(false), + labelType(JKQTPCALTexponent), + tickMode(JKQTPLTMLinOrPower), + labelPosition(JKQTPLabelCenter), + labelFontSize(10), + tickLabelFontSize(10), + minorTickLabelFontSize(8), + showZeroAxis(true), + minorTickLabelFullNumber(true), + drawMode1(JKQTPCADMcomplete), + drawMode2(JKQTPCADMLineTicks), + minorTickWidth(1), + tickWidth(1.5), + lineWidth(1.5), + lineWidthZeroAxis(1.5), + tickTimeFormat(QLocale().timeFormat(QLocale::NarrowFormat)), + tickDateFormat(QLocale().dateFormat(QLocale::NarrowFormat)), + tickDateTimeFormat(QLocale().dateTimeFormat(QLocale::NarrowFormat)), + minTicks(5), + minorTicks(1), + tickOutsideLength(3), + minorTickOutsideLength(1.5), + tickInsideLength(3), + minorTickInsideLength(1.5), + axisColor(QColor("black")), + tickLabelDistance(3), + labelDistance(5), + tickLabelAngle(0), + drawGrid(true), + gridColor(QColor("gray")), + gridWidth(0.75), + gridStyle(Qt::DashLine), + drawMinorGrid(false), + minorGridColor(QColor("gray")), + minorGridWidth(0.5), + minorGridStyle(Qt::DotLine), + colorZeroAxis(QColor("black")), + styleZeroAxis(Qt::SolidLine), + axisLineOffset(0) +{ + +} + +JKQTPCoordinateAxisStyle::JKQTPCoordinateAxisStyle(const JKQTBasePlotterStyle &baseStyle): + JKQTPCoordinateAxisStyle() +{ + labelFontSize=baseStyle.defaultFontSize; + tickLabelFontSize=baseStyle.defaultFontSize; + minorTickLabelFontSize=baseStyle.defaultFontSize*0.8; + +} + +void JKQTPCoordinateAxisStyle::loadSettings(const QSettings &settings, const QString &group, const JKQTPCoordinateAxisStyle &defaultStyle) +{ + showZeroAxis = settings.value(group+"zero_line/enabled", defaultStyle.showZeroAxis).toBool(); + minorTickLabelsEnabled = settings.value(group+"minor_tick/labels_enabled", defaultStyle.minorTickLabelsEnabled).toBool(); + minorTickWidth = settings.value(group+"minor_tick/width", defaultStyle.minorTickWidth).toDouble(); + tickWidth = settings.value(group+"ticks/width", defaultStyle.tickWidth).toDouble(); + lineWidth = settings.value(group+"line_width", defaultStyle.lineWidth).toDouble(); + lineWidthZeroAxis = settings.value(group+"zero_line/line_width", defaultStyle.lineWidthZeroAxis).toDouble(); + labelFontSize = settings.value(group+"axis_label/font_size", defaultStyle.labelFontSize).toDouble(); + tickLabelFontSize = settings.value(group+"ticks/label_font_size", defaultStyle.tickLabelFontSize).toDouble(); + minorTickLabelFontSize = settings.value(group+"minor_tick/label_font_size", defaultStyle.minorTickLabelFontSize).toDouble(); + minorTickLabelFullNumber = settings.value(group+"minor_tick/label_full_number", defaultStyle.minorTickLabelFullNumber).toBool(); + tickTimeFormat = settings.value(group+"ticks/time_format", defaultStyle.tickTimeFormat).toString(); + tickDateFormat = settings.value(group+"ticks/date_format", defaultStyle.tickDateFormat).toString(); + tickDateTimeFormat = settings.value(group+"ticks/datetime_format", defaultStyle.tickDateTimeFormat).toString(); + minTicks = settings.value(group+"min_ticks", defaultStyle.minTicks).toUInt(); + minorTicks = settings.value(group+"minor_tick/count", defaultStyle.minorTicks).toUInt(); + tickOutsideLength = settings.value(group+"ticks/outside_length", defaultStyle.tickOutsideLength).toDouble(); + minorTickOutsideLength = settings.value(group+"minor_tick/outside_length", defaultStyle.minorTickOutsideLength).toDouble(); + tickInsideLength = settings.value(group+"ticks/inside_length", defaultStyle.tickInsideLength).toDouble(); + minorTickInsideLength = settings.value(group+"minor_tick/inside_length", defaultStyle.minorTickInsideLength).toDouble(); + tickLabelDistance = settings.value(group+"ticks/label_distance", defaultStyle.tickLabelDistance).toDouble(); + labelDistance = settings.value(group+"axis_label/distance", defaultStyle.labelDistance).toDouble(); + gridWidth = settings.value(group+"grid/width", defaultStyle.gridWidth).toDouble(); + minorGridWidth = settings.value(group+"minor_grid/width", defaultStyle.minorGridWidth).toDouble(); + drawGrid = settings.value(group+"grid/enabled", defaultStyle.drawGrid).toBool(); + drawMinorGrid = settings.value(group+"minor_grid/enabled", defaultStyle.drawMinorGrid).toBool(); + labelPosition=String2JKQTPLabelPosition(settings.value(group+"axis_label/position", JKQTPLabelPosition2String(labelPosition)).toString()); + labelType=String2JKQTPCALabelType(settings.value(group+"axis_label/type", JKQTPCALabelType2String(labelType)).toString()); + axisColor=jkqtp_String2QColor(settings.value(group+"color", jkqtp_QColor2String(axisColor)).toString()); + gridColor=jkqtp_String2QColor(settings.value(group+"grid/color", jkqtp_QColor2String(gridColor)).toString()); + minorGridColor=jkqtp_String2QColor(settings.value(group+"minor_grid/color", jkqtp_QColor2String(minorGridColor)).toString()); + gridStyle=jkqtp_String2QPenStyle(settings.value(group+"grid/style", jkqtp_QPenStyle2String(gridStyle)).toString()); + minorGridStyle=jkqtp_String2QPenStyle(settings.value(group+"minor_grid/style", jkqtp_QPenStyle2String(minorGridStyle)).toString()); + drawMode1=String2JKQTPCADrawMode(settings.value(group+"draw_mode1", JKQTPCADrawMode2String(drawMode1)).toString()); + drawMode2=String2JKQTPCADrawMode(settings.value(group+"draw_mode2", JKQTPCADrawMode2String(drawMode2)).toString()); + tickMode=String2JKQTPLabelTickMode(settings.value(group+"ticks/mode", JKQTPLabelTickMode2String(tickMode)).toString()); + colorZeroAxis=jkqtp_String2QColor(settings.value(group+"zero_line/color", jkqtp_QColor2String(colorZeroAxis)).toString()); + styleZeroAxis=jkqtp_String2QPenStyle(settings.value(group+"zero_line/style", jkqtp_QPenStyle2String(styleZeroAxis)).toString()); + axisLineOffset = settings.value(group+"axis_lines_offset", defaultStyle.axisLineOffset).toDouble(); +} + +void JKQTPCoordinateAxisStyle::saveSettings(QSettings &settings, const QString &group) const +{ + settings.setValue(group+"color", jkqtp_QColor2String(axisColor)); + settings.setValue(group+"draw_mode1", JKQTPCADrawMode2String(drawMode1)); + settings.setValue(group+"draw_mode2", JKQTPCADrawMode2String(drawMode2)); + settings.setValue(group+"line_width", lineWidth); + settings.setValue(group+"axis_lines_offset", axisLineOffset); + settings.setValue(group+"min_ticks", minTicks); + settings.setValue(group+"grid/enabled", drawGrid); + settings.setValue(group+"grid/color", jkqtp_QColor2String(gridColor)); + settings.setValue(group+"grid/width", gridWidth); + settings.setValue(group+"grid/style", jkqtp_QPenStyle2String(gridStyle)); + settings.setValue(group+"axis_label/distance", labelDistance); + settings.setValue(group+"axis_label/font_size", labelFontSize); + settings.setValue(group+"axis_label/position", JKQTPLabelPosition2String(labelPosition)); + settings.setValue(group+"axis_label/type", JKQTPCALabelType2String(labelType)); + settings.setValue(group+"minor_grid/enabled", drawMinorGrid); + settings.setValue(group+"minor_grid/color", jkqtp_QColor2String(minorGridColor)); + settings.setValue(group+"minor_grid/style", jkqtp_QPenStyle2String(minorGridStyle)); + settings.setValue(group+"minor_grid/width", minorGridWidth); + settings.setValue(group+"minor_tick/labels_enabled", minorTickLabelsEnabled); + settings.setValue(group+"minor_tick/inside_length", minorTickInsideLength); + settings.setValue(group+"minor_tick/label_font_size", minorTickLabelFontSize); + settings.setValue(group+"minor_tick/label_full_number", minorTickLabelFullNumber); + settings.setValue(group+"minor_tick/outside_length", minorTickOutsideLength); + settings.setValue(group+"minor_tick/width", minorTickWidth); + settings.setValue(group+"minor_tick/count", minorTicks); + settings.setValue(group+"ticks/date_format", tickDateFormat); + settings.setValue(group+"ticks/datetime_format", tickDateTimeFormat); + settings.setValue(group+"ticks/inside_length", tickInsideLength); + settings.setValue(group+"ticks/label_distance", tickLabelDistance); + settings.setValue(group+"ticks/label_font_size", tickLabelFontSize); + settings.setValue(group+"ticks/mode", JKQTPLabelTickMode2String(tickMode)); + settings.setValue(group+"ticks/outside_length", tickOutsideLength); + settings.setValue(group+"ticks/time_format", tickTimeFormat); + settings.setValue(group+"ticks/width", tickWidth); + settings.setValue(group+"zero_line/enabled", showZeroAxis); + settings.setValue(group+"zero_line/line_width", lineWidthZeroAxis); + settings.setValue(group+"zero_line/color", jkqtp_QColor2String(colorZeroAxis)); + settings.setValue(group+"zero_line/style", jkqtp_QPenStyle2String(styleZeroAxis)); +} diff --git a/lib/jkqtplotter/jkqtpcoordinateaxesstyle.h b/lib/jkqtplotter/jkqtpcoordinateaxesstyle.h new file mode 100644 index 0000000000..272fae16c2 --- /dev/null +++ b/lib/jkqtplotter/jkqtpcoordinateaxesstyle.h @@ -0,0 +1,158 @@ +/* + Copyright (c) 2008-2019 Jan W. Krieger (, ) + + + + This software is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License 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 for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ + +#ifndef JKQTPCOORDINATEAXESSTYLE_H +#define JKQTPCOORDINATEAXESSTYLE_H + +#include +#include +#include +#include "jkqtplottertools/jkqtptools.h" +#include "jkqtplottertools/jkqtp_imexport.h" + +class JKQTBasePlotterStyle; // forward + +/** \brief Support Class for JKQTPCoordinateAxis, which summarizes all proeprties that define the visual styling of a JKQTPCoordinateAxis + * \ingroup jkqtpplotter_styling + * + * \see JKQTPCoordinateAxis, \ref jkqtpplotter_styling + * + */ +class JKQTP_LIB_EXPORT JKQTPCoordinateAxisStyle { + Q_GADGET + public: + JKQTPCoordinateAxisStyle(); + + JKQTPCoordinateAxisStyle(const JKQTBasePlotterStyle& baseStyle); + + + /** \brief loads the plot properties from a QSettings object + * + * \param settings QSettings-object to read from + * \param group Group in the QSettings-object to read from + * \param defaultStyle If a setting cannot be found in \a settings, default values are taken from this object + * By default, this is a default-constructed object + */ + void loadSettings(const QSettings &settings, const QString& group=QString("axis/"), const JKQTPCoordinateAxisStyle &defaultStyle=JKQTPCoordinateAxisStyle()); + + /** \brief saves the plot properties into a QSettings object. + * + * \param settings QSettings-object to save to + * \param group Group in the QSettings-object to save to + */ + void saveSettings(QSettings& settings, const QString& group=QString("axis/")) const; + + /** \brief digits used for tick labels */ + int labelDigits; + /** \brief when \c true, the digits of the labels are calculated automatically */ + bool autoLabelDigits; + /** \brief if \c true, the plotter displays minor axis labels as number between 1 and 10 in some cases */ + bool minorTickLabelsEnabled; + /** \brief indicates how to draw the labels */ + JKQTPCALabelType labelType; + + /** \brief mode of the major ticks */ + JKQTPLabelTickMode tickMode; + + /** \brief position of the axis label */ + JKQTPLabelPosition labelPosition; + /** \brief fontsize of the axis labels */ + double labelFontSize; + /** \brief fontsize of the axis tick labels */ + double tickLabelFontSize; + /** \brief fontsize of the minor axis tick labels */ + double minorTickLabelFontSize; + /** \brief indicates whether to draw a thick axis line at x=0 (zero axis) */ + bool showZeroAxis; + /** \brief indicates whether the minor tick labels should be full numbers, or just a number between 0..10 */ + bool minorTickLabelFullNumber; + + + /** \brief draw mode of the main (left/bottom) axis */ + JKQTPCADrawMode drawMode1; + /** \brief draw mode of the secondary (right/top) axis */ + JKQTPCADrawMode drawMode2; + /** \brief line width of minor ticks in pt */ + double minorTickWidth; + /** \brief line width of ticks in pt */ + double tickWidth; + /** \brief line width of axis in pt */ + double lineWidth; + /** \brief line width of 0-line in pt */ + double lineWidthZeroAxis; + + + /** \brief format string for time tick labels, see see QDateTime::toString() documentation for details on format strings */ + QString tickTimeFormat; + /** \brief format string for date tick labels, see see QDateTime::toString() documentation for details on format strings */ + QString tickDateFormat; + /** \brief format string for datetime tick labels, see see QDateTime::toString() documentation for details on format strings */ + QString tickDateTimeFormat; + + + + /** \brief minimum number of axis ticks */ + unsigned int minTicks; + /** \brief number of minor grid lines per axis tick interval + * + * \image html docu_logaxis_set_minorticks.png + **/ + unsigned int minorTicks; + /** \brief length of an axis tick outside the plot border in pt */ + double tickOutsideLength; + /** \brief length of a minor axis tick outside the plot border in pt */ + double minorTickOutsideLength; + /** \brief length of an axis tick inside the plot border in pt */ + double tickInsideLength; + /** \brief length of a minor axis tick inside the plot border in pt */ + double minorTickInsideLength; + /** \brief color of the axis (labels, ticks, axis itself ...) */ + QColor axisColor; + /** \brief distance between tick end and label start in pt */ + double tickLabelDistance; + /** \brief distance between tick label and axis label in pt */ + double labelDistance; + /** \brief rotation angle of tick labels [-180..180], i.e. given in degrees, default is 0 (horizontal) */ + double tickLabelAngle; + + /** \brief indicates whether to draw the major grid lines */ + bool drawGrid; + /** \brief color of the grid*/ + QColor gridColor; + /** \brief width of the grid lines (in pixel) */ + double gridWidth; + /** \brief line stye of the grid lines */ + Qt::PenStyle gridStyle; + /** \brief indicates whether to draw the minor grid lines */ + bool drawMinorGrid; + /** \brief color of the minor grid lines */ + QColor minorGridColor; + /** \brief width of the minor grid lines (in pixel) */ + double minorGridWidth; + /** \brief line stye of the minor grid lines */ + Qt::PenStyle minorGridStyle; + /** \brief color of 0-line */ + QColor colorZeroAxis; + /** \brief pen style of 0-line */ + Qt::PenStyle styleZeroAxis; + /** \brief if non-zero, the line of the coordinate axis is moved outside by this amount [pt] */ + double axisLineOffset; +}; + +#endif // JKQTPCOORDINATEAXESSTYLE_H diff --git a/lib/jkqtplotter/jkqtpdatastorage.cpp b/lib/jkqtplotter/jkqtpdatastorage.cpp index 349b5fb528..3dd932b6f6 100644 --- a/lib/jkqtplotter/jkqtpdatastorage.cpp +++ b/lib/jkqtplotter/jkqtpdatastorage.cpp @@ -5,7 +5,7 @@ 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 of the License, or + 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, diff --git a/lib/jkqtplotter/jkqtpdatastorage.h b/lib/jkqtplotter/jkqtpdatastorage.h index f2b1afccd6..6b05ac71a2 100644 --- a/lib/jkqtplotter/jkqtpdatastorage.h +++ b/lib/jkqtplotter/jkqtpdatastorage.h @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -77,9 +77,9 @@ class JKQTPDatastoreModel; // forward declaration \endverbatim */ enum JKQTPDatastoreItemFormat { - JKQTPSingleColumn, /*!< \brief a 1D vector of doubles. (default option) */ - JKQTPMatrixColumn, /*!< \brief a 1D vector of double that represents a number of columns. The data is store column after column. */ - JKQTPMatrixRow /*!< \brief a 1D vector of double that represents a number of rows (C standard representation of matrices). The data is stored row after row.*/ + JKQTPSingleColumn, /*!< \brief a 1D vector of doubles. (default option) */ + JKQTPMatrixColumn, /*!< \brief a 1D vector of double that represents a number of columns. The data is store column after column. */ + JKQTPMatrixRow /*!< \brief a 1D vector of double that represents a number of rows (C standard representation of matrices). The data is stored row after row.*/ }; /** \brief This class manages chunks of memory that are used for column data in JKQTBasePlotter descendents @@ -833,7 +833,7 @@ class JKQTP_LIB_EXPORT JKQTPDatastoreItem { }; -/** \brief QAbstractTableModel descendent that allows to view data in a JKQTPDatastore +/** \brief QAbstractTableModel descendent that allows to view data in a JKQTPDatastore * \ingroup jkqtpdatastorage * * \see JKQTPDatastore diff --git a/lib/jkqtplotter/jkqtpelementsoverlay.cpp b/lib/jkqtplotter/jkqtpelementsoverlay.cpp index 4605f41029..955891f6ee 100644 --- a/lib/jkqtplotter/jkqtpelementsoverlay.cpp +++ b/lib/jkqtplotter/jkqtpelementsoverlay.cpp @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -22,6 +22,7 @@ #include "jkqtplotter/jkqtpelementsoverlay.h" #include "jkqtplotter/jkqtpbaseplotter.h" #include "jkqtplottertools/jkqtptools.h" +#include "jkqtplottertools/jkqtpdrawingtools.h" #include #include @@ -35,7 +36,7 @@ JKQTPOverlayElement::JKQTPOverlayElement(JKQTBasePlotter *parent) : fillStyle=Qt::SolidPattern; lineWidth=1.0; text=""; - fontName=QFont().family(); + fontName=QFont().family()+"+XITS"; fontSize=QFont().pointSizeF(); visible=true; } @@ -92,7 +93,7 @@ QBrush JKQTPOverlayElement::getBrush(JKQTPEnhancedPainter& /*painter*/) const { QPen JKQTPOverlayElement::getPen(JKQTPEnhancedPainter& painter) const { QPen p; p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth))); p.setStyle(lineStyle); return p; } @@ -136,7 +137,7 @@ void JKQTPOverlayVerticalLine::draw(JKQTPEnhancedPainter &painter) { QPointF p1=transform(position, ymin); QPointF p2=transform(position, ymax); QPointF p3=p2-QPointF(0, (p2.y()-p1.y())*0.1); - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.setPen(getPen(painter)); painter.drawLine(p1, p2); @@ -146,14 +147,12 @@ void JKQTPOverlayVerticalLine::draw(JKQTPEnhancedPainter &painter) { JKQTMathText* mt=parent->getMathText(); mt->setFontSize(fontSize); mt->setFontColor(color); -#ifdef USE_XITS_FONTS - mt->useXITS(); -#endif + mt->setFontRomanOrSpecial(fontName); mt->parse(text); mt->draw(painter, p3.x(), p3.y()); } - painter.restore(); + } JKQTPOverlayTwoCoordOverlay::JKQTPOverlayTwoCoordOverlay(double pos, double pos2, JKQTBasePlotter *parent): @@ -190,7 +189,7 @@ void JKQTPOverlayVerticalRange::draw(JKQTPEnhancedPainter &painter) { QPointF p21=transform(position2, ymin); QPointF p22=transform(position2, ymax); //QPointF p23=p2-QPointF(0, (p2.y()-p1.y())*0.1); - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); if (fillColor!=QColor(Qt::transparent)) { if (inverted) { painter.fillRect(QRectF(transform(xmin, ymin), p2), getBrush(painter)); @@ -208,14 +207,12 @@ void JKQTPOverlayVerticalRange::draw(JKQTPEnhancedPainter &painter) { JKQTMathText* mt=parent->getMathText(); mt->setFontSize(fontSize); mt->setFontColor(color); -#ifdef USE_XITS_FONTS - mt->useXITS(); -#endif + mt->setFontRomanOrSpecial(fontName); mt->parse(text); mt->draw(painter, p3.x(), p3.y()); } - painter.restore(); + } JKQTPOverlayTwoPositionOverlay::JKQTPOverlayTwoPositionOverlay(double x1, double y1, double x2, double y2, JKQTBasePlotter *parent): @@ -252,7 +249,7 @@ void JKQTPOverlayLine::draw(JKQTPEnhancedPainter &painter) { - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.setPen(getPen(painter)); if (infinite) { double alpha=(p2.y()-p1.y())/(p2.x()-p1.x()); @@ -270,7 +267,7 @@ void JKQTPOverlayLine::draw(JKQTPEnhancedPainter &painter) { - painter.restore(); + } @@ -287,10 +284,10 @@ void JKQTPOverlayRectangle::draw(JKQTPEnhancedPainter &painter) QPointF p2=transform(x2, y2); QRectF rect(qMin(p1.x(), p2.x()), qMin(p1.y(), p2.y()), fabs(p1.x()-p2.x()), fabs(p1.y()-p2.y())); - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.setPen(getPen(painter)); painter.setBrush(getBrush(painter)); //painter.fillRect(rect); painter.drawRect(rect); - painter.restore(); + } diff --git a/lib/jkqtplotter/jkqtpelementsoverlay.h b/lib/jkqtplotter/jkqtpelementsoverlay.h index 04978e2d57..e34c721220 100644 --- a/lib/jkqtplotter/jkqtpelementsoverlay.h +++ b/lib/jkqtplotter/jkqtpelementsoverlay.h @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -51,128 +51,110 @@ class JKQTP_LIB_EXPORT JKQTPOverlayElement : public QObject { /** \brief sets the parent painter class */ virtual void setParent(JKQTBasePlotter* parent); - /*! \brief sets the property color ( \copybrief color ) to the specified \a __value. - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual void setColor(const QColor & __value) { this->color = __value; } - /*! \brief returns the property color ( \copybrief color ). - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual QColor getColor() const { return this->color; } - /*! \brief sets the property fillColor ( \copybrief fillColor ) to the specified \a __value. - \details Description of the parameter fillColor is:
    \copydoc fillColor
    - \see fillColor for more information */ + /*! \copydoc fillColor + \see see fillColor for details */ inline virtual void setFillColor(const QColor & __value) { this->fillColor = __value; } - /*! \brief returns the property fillColor ( \copybrief fillColor ). - \details Description of the parameter fillColor is:
    \copydoc fillColor
    - \see fillColor for more information */ + /*! \copydoc fillColor + \see see fillColor for details */ inline virtual QColor getFillColor() const { return this->fillColor; } - /*! \brief sets the property lineStyle ( \copybrief lineStyle ) to the specified \a __value. - \details Description of the parameter lineStyle is:
    \copydoc lineStyle
    - \see lineStyle for more information */ + /*! \copydoc lineStyle + \see see lineStyle for details */ inline virtual void setLineStyle(const Qt::PenStyle & __value) { this->lineStyle = __value; } - /*! \brief returns the property lineStyle ( \copybrief lineStyle ). - \details Description of the parameter lineStyle is:
    \copydoc lineStyle
    - \see lineStyle for more information */ + /*! \copydoc lineStyle + \see see lineStyle for details */ inline virtual Qt::PenStyle getLineStyle() const { return this->lineStyle; } - /*! \brief sets the property fillStyle ( \copybrief fillStyle ) to the specified \a __value. - \details Description of the parameter fillStyle is:
    \copydoc fillStyle
    - \see fillStyle for more information */ + /*! \copydoc fillStyle + \see see fillStyle for details */ inline virtual void setFillStyle(const Qt::BrushStyle & __value) { this->fillStyle = __value; } - /*! \brief returns the property fillStyle ( \copybrief fillStyle ). - \details Description of the parameter fillStyle is:
    \copydoc fillStyle
    - \see fillStyle for more information */ + /*! \copydoc fillStyle + \see see fillStyle for details */ inline virtual Qt::BrushStyle getFillStyle() const { return this->fillStyle; } - /*! \brief sets the property lineWidth ( \copybrief lineWidth ) to the specified \a __value. - \details Description of the parameter lineWidth is:
    \copydoc lineWidth
    - \see lineWidth for more information */ + /*! \copydoc lineWidth + \see see lineWidth for details */ inline virtual void setLineWidth(double __value) { this->lineWidth = __value; } - /*! \brief returns the property lineWidth ( \copybrief lineWidth ). - \details Description of the parameter lineWidth is:
    \copydoc lineWidth
    - \see lineWidth for more information */ + /*! \copydoc lineWidth + \see see lineWidth for details */ inline virtual double getLineWidth() const { return this->lineWidth; } - /*! \brief sets the property text ( \copybrief text ) to the specified \a __value. - \details Description of the parameter text is:
    \copydoc text
    - \see text for more information */ + /*! \copydoc text + \see see text for details */ inline virtual void setText(const QString & __value) { this->text = __value; } - /*! \brief returns the property text ( \copybrief text ). - \details Description of the parameter text is:
    \copydoc text
    - \see text for more information */ + /*! \copydoc text + \see see text for details */ inline virtual QString getText() const { return this->text; } - /*! \brief sets the property fontName ( \copybrief fontName ) to the specified \a __value. - \details Description of the parameter fontName is:
    \copydoc fontName
    - \see fontName for more information */ + /*! \copydoc fontName + \see see fontName for details */ inline virtual void setFontName(const QString & __value) { this->fontName = __value; } - /*! \brief returns the property fontName ( \copybrief fontName ). - \details Description of the parameter fontName is:
    \copydoc fontName
    - \see fontName for more information */ + /*! \copydoc fontName + \see see fontName for details */ inline virtual QString getFontName() const { return this->fontName; } - /*! \brief sets the property fontSize ( \copybrief fontSize ) to the specified \a __value. - \details Description of the parameter fontSize is:
    \copydoc fontSize
    - \see fontSize for more information */ + /*! \copydoc fontSize + \see see fontSize for details */ inline virtual void setFontSize(double __value) { this->fontSize = __value; } - /*! \brief returns the property fontSize ( \copybrief fontSize ). - \details Description of the parameter fontSize is:
    \copydoc fontSize
    - \see fontSize for more information */ + /*! \copydoc fontSize + \see see fontSize for details */ inline virtual double getFontSize() const { return this->fontSize; } - /*! \brief sets the property visible ( \copybrief visible ) to the specified \a __value. - \details Description of the parameter visible is:
    \copydoc visible
    - \see visible for more information */ + /*! \copydoc visible + \see see visible for details */ inline virtual void setVisible(bool __value) { this->visible = __value; } - /*! \brief returns the property visible ( \copybrief visible ). - \details Description of the parameter visible is:
    \copydoc visible
    - \see visible for more information */ + /*! \copydoc visible + \see see visible for details */ inline virtual bool isVisible() const { return this->visible; @@ -239,58 +221,50 @@ class JKQTP_LIB_EXPORT JKQTPOverlayTwoPositionOverlay : public JKQTPOverlayEleme public: explicit JKQTPOverlayTwoPositionOverlay(double x1, double y1, double x2, double y2, JKQTBasePlotter *parent = 0); - /*! \brief sets the property x1 ( \copybrief x1 ) to the specified \a __value. - \details Description of the parameter x1 is:
    \copydoc x1
    - \see x1 for more information */ + /*! \copydoc x1 + \see see x1 for details */ inline virtual void setX1(double __value) { this->x1 = __value; } - /*! \brief returns the property x1 ( \copybrief x1 ). - \details Description of the parameter x1 is:
    \copydoc x1
    - \see x1 for more information */ + /*! \copydoc x1 + \see see x1 for details */ inline virtual double getX1() const { return this->x1; } - /*! \brief sets the property x2 ( \copybrief x2 ) to the specified \a __value. - \details Description of the parameter x2 is:
    \copydoc x2
    - \see x2 for more information */ + /*! \copydoc x2 + \see see x2 for details */ inline virtual void setX2(double __value) { this->x2 = __value; } - /*! \brief returns the property x2 ( \copybrief x2 ). - \details Description of the parameter x2 is:
    \copydoc x2
    - \see x2 for more information */ + /*! \copydoc x2 + \see see x2 for details */ inline virtual double getX2() const { return this->x2; } - /*! \brief sets the property y1 ( \copybrief y1 ) to the specified \a __value. - \details Description of the parameter y1 is:
    \copydoc y1
    - \see y1 for more information */ + /*! \copydoc y1 + \see see y1 for details */ inline virtual void setY1(double __value) { this->y1 = __value; } - /*! \brief returns the property y1 ( \copybrief y1 ). - \details Description of the parameter y1 is:
    \copydoc y1
    - \see y1 for more information */ + /*! \copydoc y1 + \see see y1 for details */ inline virtual double getY1() const { return this->y1; } - /*! \brief sets the property y2 ( \copybrief y2 ) to the specified \a __value. - \details Description of the parameter y2 is:
    \copydoc y2
    - \see y2 for more information */ + /*! \copydoc y2 + \see see y2 for details */ inline virtual void setY2(double __value) { this->y2 = __value; } - /*! \brief returns the property y2 ( \copybrief y2 ). - \details Description of the parameter y2 is:
    \copydoc y2
    - \see y2 for more information */ + /*! \copydoc y2 + \see see y2 for details */ inline virtual double getY2() const { return this->y2; @@ -312,16 +286,14 @@ class JKQTP_LIB_EXPORT JKQTPOverlayOneCoordOverlay : public JKQTPOverlayElement public: explicit JKQTPOverlayOneCoordOverlay(double pos, JKQTBasePlotter *parent = 0); - /*! \brief sets the property position ( \copybrief position ) to the specified \a __value. - \details Description of the parameter position is:
    \copydoc position
    - \see position for more information */ + /*! \copydoc position + \see see position for details */ inline virtual void setPosition(double __value) { this->position = __value; } - /*! \brief returns the property position ( \copybrief position ). - \details Description of the parameter position is:
    \copydoc position
    - \see position for more information */ + /*! \copydoc position + \see see position for details */ inline virtual double getPosition() const { return this->position; @@ -340,16 +312,14 @@ class JKQTP_LIB_EXPORT JKQTPOverlayTwoCoordOverlay : public JKQTPOverlayOneCoord public: explicit JKQTPOverlayTwoCoordOverlay(double pos, double pos2, JKQTBasePlotter *parent = 0); - /*! \brief sets the property position2 ( \copybrief position2 ) to the specified \a __value. - \details Description of the parameter position2 is:
    \copydoc position2
    - \see position2 for more information */ + /*! \copydoc position2 + \see see position2 for details */ inline virtual void setPosition2(double __value) { this->position2 = __value; } - /*! \brief returns the property position2 ( \copybrief position2 ). - \details Description of the parameter position2 is:
    \copydoc position2
    - \see position2 for more information */ + /*! \copydoc position2 + \see see position2 for details */ inline virtual double getPosition2() const { return this->position2; @@ -392,16 +362,14 @@ class JKQTP_LIB_EXPORT JKQTPOverlayVerticalRange : public JKQTPOverlayTwoCoordOv /** \brief plots the graph to the plotter object specified as parent */ virtual void draw(JKQTPEnhancedPainter& painter); - /*! \brief sets the property inverted ( \copybrief inverted ) to the specified \a __value. - \details Description of the parameter inverted is:
    \copydoc inverted
    - \see inverted for more information */ + /*! \copydoc inverted + \see see inverted for details */ inline virtual void setInverted(bool __value) { this->inverted = __value; } - /*! \brief returns the property inverted ( \copybrief inverted ). - \details Description of the parameter inverted is:
    \copydoc inverted
    - \see inverted for more information */ + /*! \copydoc inverted + \see see inverted for details */ inline virtual bool getInverted() const { return this->inverted; @@ -423,16 +391,14 @@ class JKQTP_LIB_EXPORT JKQTPOverlayLine : public JKQTPOverlayTwoPositionOverlay /** \brief plots the graph to the plotter object specified as parent */ virtual void draw(JKQTPEnhancedPainter& painter); - /*! \brief sets the property infinite ( \copybrief infinite ) to the specified \a __value. - \details Description of the parameter infinite is:
    \copydoc infinite
    - \see infinite for more information */ + /*! \copydoc infinite + \see see infinite for details */ inline virtual void setInfinite(bool __value) { this->infinite = __value; } - /*! \brief returns the property infinite ( \copybrief infinite ). - \details Description of the parameter infinite is:
    \copydoc infinite
    - \see infinite for more information */ + /*! \copydoc infinite + \see see infinite for details */ inline virtual bool getInfinite() const { return this->infinite; diff --git a/lib/jkqtplotter/jkqtpgraphs.cpp b/lib/jkqtplotter/jkqtpgraphs.cpp index 07e7b0195a..caab661056 100644 --- a/lib/jkqtplotter/jkqtpgraphs.cpp +++ b/lib/jkqtplotter/jkqtpgraphs.cpp @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -60,9 +60,13 @@ JKQTPXYLineGraph::JKQTPXYLineGraph(JKQTPlotter* parent): parentPlotStyle=parent->getNextStyle(); //std::cout<<"got style settings from parent: "<getPlotStyle(parentPlotStyle).color(); + fillColor=parent->getPlotStyle(parentPlotStyle).fillColor(); style=parent->getPlotStyle(parentPlotStyle).style(); + lineWidth=parent->getPlotStyle(parentPlotStyle).widthF(); + symbolSize=parent->getPlotStyle(parentPlotStyle).symbolSize(); + symbolWidth=parent->getPlotStyle(parentPlotStyle).symbolLineWidthF(); + symbol=parent->getPlotStyle(parentPlotStyle).symbol(); } - fillColor=color; } JKQTPXYLineGraph::JKQTPXYLineGraph(JKQTBasePlotter* parent): @@ -84,9 +88,13 @@ JKQTPXYLineGraph::JKQTPXYLineGraph(JKQTBasePlotter* parent): parentPlotStyle=parent->getNextStyle(); //std::cout<<"got style settings from parent: "<getPlotStyle(parentPlotStyle).color(); + fillColor=parent->getPlotStyle(parentPlotStyle).fillColor(); style=parent->getPlotStyle(parentPlotStyle).style(); + lineWidth=parent->getPlotStyle(parentPlotStyle).widthF(); + symbolSize=parent->getPlotStyle(parentPlotStyle).symbolSize(); + symbolWidth=parent->getPlotStyle(parentPlotStyle).symbolLineWidthF(); + symbol=parent->getPlotStyle(parentPlotStyle).symbol(); } - fillColor=color; } void JKQTPXYLineGraph::draw(JKQTPEnhancedPainter& painter) { @@ -100,90 +108,90 @@ void JKQTPXYLineGraph::draw(JKQTPEnhancedPainter& painter) { //qDebug()<<"JKQTPXYLineGraph::draw();"; drawErrorsBefore(painter); + { + //qDebug()<<"JKQTPXYLineGraph::draw(): "<<1; + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + //qDebug()<<"JKQTPXYLineGraph::draw(): "<<2; - //qDebug()<<"JKQTPXYLineGraph::draw(): "<<1; - painter.save(); - //qDebug()<<"JKQTPXYLineGraph::draw(): "<<2; - - QPen p=painter.pen(); - p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); - p.setStyle(style); - p.setJoinStyle(Qt::RoundJoin); - p.setCapStyle(Qt::RoundCap); + QPen p=painter.pen(); + p.setColor(color); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); + p.setStyle(style); + p.setJoinStyle(Qt::RoundJoin); + p.setCapStyle(Qt::RoundCap); - QPen penSelection=p; penSelection.setStyle(Qt::SolidLine); - QColor selcol=penSelection.color(); selcol.setAlphaF(0.5); penSelection.setColor(selcol); - if (selectionLineColor!=Qt::transparent) { - penSelection.setColor(selectionLineColor); - } - penSelection.setWidthF(penSelection.widthF()*3.0); - - - int imax=qMin(datastore->getColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(yColumn)).getRows()); - int imin=0; - - if (imaxpt2px(painter, symbolSize*1.5), parent->pt2px(painter, symbolWidth*parent->getLineWidthMultiplier()), penSelection.color(), penSelection.color()); - } - JKQTPPlotSymbol(painter, x, y, symbol, parent->pt2px(painter, symbolSize), parent->pt2px(painter, symbolWidth*parent->getLineWidthMultiplier()), symbColor, symbFillColor); - /*if (drawLine && first) { - double xl1=xold; - double yl1=yold; - double xl2=x; - double yl2=y; - lines.append(QLineF(xl1, yl1, xl2, yl2)); - }*/ - if (drawLine) { - linesP<pt2px(painter, symbolSize*1.5), parent->pt2px(painter, symbolWidth*parent->getLineWidthMultiplier()), penSelection.color(), penSelection.color()); + } + JKQTPPlotSymbol(painter, x, y, symbol, parent->pt2px(painter, symbolSize), parent->pt2px(painter, symbolWidth*parent->getLineWidthMultiplier()), symbColor, symbFillColor); + /*if (drawLine && first) { + double xl1=xold; + double yl1=yold; + double xl2=x; + double yl2=y; + lines.append(QLineF(xl1, yl1, xl2, yl2)); + }*/ + if (drawLine) { + linesP<pt2px(painter, this->lineWidth*parent->getLineWidthMultiplier()); if (lineWidth>0.5*maxSize) lineWidth=0.5*maxSize; - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); QPen p=painter.pen(); p.setColor(getKeyLabelColor()); p.setStyle(style); @@ -208,7 +216,7 @@ void JKQTPXYLineGraph::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect double y=rect.top()+rect.height()/2.0; if (drawLine) painter.drawLine(QLineF(rect.left(), y, rect.right(), y)); JKQTPPlotSymbol(painter, rect.left()+rect.width()/2.0, rect.top()+rect.height()/2.0, symbol, symbolSize, symbolWidth, getKeyLabelColor(), fillColor); - painter.restore(); + } QColor JKQTPXYLineGraph::getKeyLabelColor() { @@ -217,12 +225,17 @@ QColor JKQTPXYLineGraph::getKeyLabelColor() { JKQTPXYLineErrorGraph::JKQTPXYLineErrorGraph(JKQTBasePlotter *parent): - JKQTPXYLineGraph(parent), JKQTPXYGraphErrors() -{ setErrorColorFromGraphColor(color); } + JKQTPXYLineGraph(parent), JKQTPXYGraphErrors(color, parent) +{ + setErrorColorFromGraphColor(color); + if (parentPlotStyle>=0) setErrorStyleFromPen(parent->getPlotStyle(parentPlotStyle)); +} JKQTPXYLineErrorGraph::JKQTPXYLineErrorGraph(JKQTPlotter *parent): - JKQTPXYLineGraph(parent), JKQTPXYGraphErrors() -{ setErrorColorFromGraphColor(color); } + JKQTPXYLineErrorGraph(parent->getPlotter()) +{ + +} bool JKQTPXYLineErrorGraph::getXMinMax(double &minx, double &maxx, double &smallestGreaterZero) { if (xErrorColumn<0 || xErrorStyle==JKQTPNoError) { @@ -351,8 +364,9 @@ JKQTPStepHorizontalGraph::JKQTPStepHorizontalGraph(JKQTBasePlotter* parent): parentPlotStyle=parent->getNextStyle(); //std::cout<<"got style settings from parent: "<getPlotStyle(parentPlotStyle).color(); - fillColor=color.lighter(); + fillColor=parent->getPlotStyle(parentPlotStyle).fillColor(); style=parent->getPlotStyle(parentPlotStyle).style(); + lineWidth=parent->getPlotStyle(parentPlotStyle).widthF(); } } @@ -374,14 +388,15 @@ JKQTPStepHorizontalGraph::JKQTPStepHorizontalGraph(JKQTPlotter* parent): parentPlotStyle=parent->getNextStyle(); //std::cout<<"got style settings from parent: "<getPlotStyle(parentPlotStyle).color(); - fillColor=color.lighter(); + fillColor=parent->getPlotStyle(parentPlotStyle).fillColor(); style=parent->getPlotStyle(parentPlotStyle).style(); + lineWidth=parent->getPlotStyle(parentPlotStyle).widthF(); } } void JKQTPStepHorizontalGraph::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) { - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); QPen p=painter.pen(); QPen np(Qt::NoPen); p.setColor(color); @@ -397,7 +412,7 @@ void JKQTPStepHorizontalGraph::drawKeyMarker(JKQTPEnhancedPainter& painter, QRec painter.setBrush(b); if (fillCurve) painter.drawRect(rect); if (!fillCurve & drawLine) painter.drawLine(QLineF(rect.left(), y, rect.right(), y)); - painter.restore(); + } QColor JKQTPStepHorizontalGraph::getKeyLabelColor() { @@ -417,7 +432,7 @@ void JKQTPStepHorizontalGraph::draw(JKQTPEnhancedPainter& painter) { QPen p=painter.pen(); p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); p.setStyle(style); p.setJoinStyle(Qt::RoundJoin); p.setJoinStyle(Qt::RoundJoin); @@ -509,7 +524,7 @@ void JKQTPStepHorizontalGraph::draw(JKQTPEnhancedPainter& painter) { pf.lineTo(xold, y0); pf.closeSubpath(); } - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); if (fillCurve) { painter.fillPath(pf, b); @@ -520,7 +535,7 @@ void JKQTPStepHorizontalGraph::draw(JKQTPEnhancedPainter& painter) { painter.setPen(p); painter.drawPath(pl); } - painter.restore(); + drawErrorsAfter(painter); } @@ -558,7 +573,7 @@ void JKQTPStepVerticalGraph::draw(JKQTPEnhancedPainter& painter) { QPen p=painter.pen(); p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); p.setStyle(style); p.setJoinStyle(Qt::RoundJoin); p.setCapStyle(Qt::RoundCap); @@ -642,7 +657,7 @@ void JKQTPStepVerticalGraph::draw(JKQTPEnhancedPainter& painter) { } pf.lineTo(x0, yold); pf.closeSubpath(); - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); if (drawLine) { painter.setPen(p); painter.drawPath(pl); @@ -651,7 +666,7 @@ void JKQTPStepVerticalGraph::draw(JKQTPEnhancedPainter& painter) { painter.setPen(np); painter.drawPath(pf); - painter.restore(); + drawErrorsAfter(painter); } @@ -691,8 +706,10 @@ JKQTPHorizontalRange::JKQTPHorizontalRange(JKQTBasePlotter* parent): if (parent) { // get style settings from parent object parentPlotStyle=parent->getNextStyle(); centerColor=parent->getPlotStyle(parentPlotStyle).color(); + fillColor=parent->getPlotStyle(parentPlotStyle).fillColor(); + style=parent->getPlotStyle(parentPlotStyle).style(); + lineWidth=parent->getPlotStyle(parentPlotStyle).widthF(); color=centerColor.darker(); - fillColor=centerColor.lighter(); } fillColor.setAlphaF(0.5); @@ -725,10 +742,11 @@ JKQTPHorizontalRange::JKQTPHorizontalRange(JKQTPlotter* parent): if (parent) { // get style settings from parent object - parentPlotStyle=parent->getNextStyle(); centerColor=parent->getPlotStyle(parentPlotStyle).color(); + fillColor=parent->getPlotStyle(parentPlotStyle).fillColor(); + style=parent->getPlotStyle(parentPlotStyle).style(); + lineWidth=parent->getPlotStyle(parentPlotStyle).widthF(); color=centerColor.darker(); - fillColor=centerColor.lighter(); } fillColor.setAlphaF(0.5); @@ -754,13 +772,13 @@ void JKQTPHorizontalRange::draw(JKQTPEnhancedPainter& painter) { if (!unlimitedSizeMax) ma=transformX(sizeMax); //std::cout<<"hor: rangeMin="< "< "<pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); QBrush nb(Qt::NoBrush); QBrush b=painter.brush(); b.setColor(fillColor); @@ -798,15 +816,15 @@ void JKQTPHorizontalRange::draw(JKQTPEnhancedPainter& painter) { QPen p=painter.pen(); p.setColor(centerColor); p.setStyle(centerStyle); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, centerLineWidth*parent->getLineWidthMultiplier()))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, centerLineWidth*parent->getLineWidthMultiplier()))); painter.setPen(p); painter.drawLine(QLineF(mi, c, ma, c)); } - painter.restore(); + } void JKQTPHorizontalRange::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) { - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); QPen p=painter.pen(); QPen np(Qt::NoPen); p.setColor(color); @@ -836,7 +854,7 @@ void JKQTPHorizontalRange::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& int y=rect.top()+rect.height()/2.0; painter.drawLine(rect.left(), y, rect.right(), y); } - painter.restore(); + } bool JKQTPHorizontalRange::getXMinMax(double &minx, double &maxx, double &smallestGreaterZero) @@ -897,13 +915,13 @@ void JKQTPVerticalRange::draw(JKQTPEnhancedPainter& painter) { double sma=transformX(parent->getXAxis()->getMax()); if (!unlimitedSizeMin) mi=transformY(sizeMin); if (!unlimitedSizeMax) ma=transformY(sizeMax); - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); if (plotRange && (cmi!=cma) && JKQTPIsOKFloat(mi) && JKQTPIsOKFloat(ma)) { QPen p=painter.pen(); QPen np(Qt::NoPen); p.setColor(color); p.setStyle(style); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); QBrush nb(Qt::NoBrush); QBrush b=painter.brush(); b.setColor(fillColor); @@ -937,15 +955,15 @@ void JKQTPVerticalRange::draw(JKQTPEnhancedPainter& painter) { QPen p=painter.pen(); p.setColor(centerColor); p.setStyle(centerStyle); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, centerLineWidth*parent->getLineWidthMultiplier()))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, centerLineWidth*parent->getLineWidthMultiplier()))); painter.setPen(p); painter.drawLine(QLineF(c, mi, c, ma)); } - painter.restore(); + } void JKQTPVerticalRange::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) { - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); QPen p=painter.pen(); QPen np(Qt::NoPen); p.setColor(color); @@ -974,7 +992,7 @@ void JKQTPVerticalRange::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& re int y=rect.left()+rect.width()/2.0; painter.drawLine(y, rect.top(), y, rect.bottom()); } - painter.restore(); + } bool JKQTPVerticalRange::getXMinMax(double &minx, double &maxx, double &smallestGreaterZero) @@ -996,7 +1014,7 @@ bool JKQTPVerticalRange::getYMinMax(double &miny, double &maxy, double &smallest QPen JKQTPXYLineGraph::getLinePen(JKQTPEnhancedPainter& painter) const { QPen p; p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH,parent->pt2px(painter, parent->getLineWidthMultiplier()*lineWidth))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH,parent->pt2px(painter, parent->getLineWidthMultiplier()*lineWidth))); p.setStyle(style); p.setJoinStyle(Qt::RoundJoin); p.setCapStyle(Qt::RoundCap); @@ -1006,7 +1024,7 @@ QPen JKQTPXYLineGraph::getLinePen(JKQTPEnhancedPainter& painter) const { QPen JKQTPXYLineGraph::getSymbolPen(JKQTPEnhancedPainter& painter) const { QPen p; p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH,parent->pt2px(painter, parent->getLineWidthMultiplier()*symbolWidth))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH,parent->pt2px(painter, parent->getLineWidthMultiplier()*symbolWidth))); p.setStyle(style); p.setJoinStyle(Qt::RoundJoin); p.setCapStyle(Qt::RoundCap); @@ -1030,7 +1048,7 @@ QBrush JKQTPStepHorizontalGraph::getBrush(JKQTPEnhancedPainter& /*painter*/) con QPen JKQTPStepHorizontalGraph::getLinePen(JKQTPEnhancedPainter& painter) const { QPen p; p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH,parent->pt2px(painter, parent->getLineWidthMultiplier()*lineWidth))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH,parent->pt2px(painter, parent->getLineWidthMultiplier()*lineWidth))); p.setStyle(style); p.setJoinStyle(Qt::RoundJoin); p.setCapStyle(Qt::RoundCap); @@ -1048,7 +1066,7 @@ QBrush JKQTPHorizontalRange::getBrush(JKQTPEnhancedPainter& /*painter*/ ) const QPen JKQTPHorizontalRange::getLinePen(JKQTPEnhancedPainter& painter) const { QPen p; p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH,parent->pt2px(painter, parent->getLineWidthMultiplier()*lineWidth))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH,parent->pt2px(painter, parent->getLineWidthMultiplier()*lineWidth))); p.setStyle(style); p.setJoinStyle(Qt::RoundJoin); p.setCapStyle(Qt::RoundCap); @@ -1073,25 +1091,16 @@ JKQTPXYParametrizedScatterGraph::JKQTPXYParametrizedScatterGraph(JKQTBasePlotter gridDeltaX=1; gridDeltaY=1; gridSymbolFractionSize=0.9; + symbolFillDerivationMode=JKQTPFFCMLighterColor; + if (parent) { + symbolFillDerivationMode=parent->getCurrentPlotterStyle().graphFillColorDerivationMode; + } } JKQTPXYParametrizedScatterGraph::JKQTPXYParametrizedScatterGraph(JKQTPlotter *parent): - JKQTPXYLineGraph(parent), - JKQTPColorPaletteTools(parent->getPlotter()) + JKQTPXYParametrizedScatterGraph(parent->getPlotter()) { - sizeColumn=-1; - colorColumn=-1; - symbolColumn=-1; - linewidthColumn=-1; - palette=JKQTPMathImageMATLAB; - colorColumnContainsRGB=false; - symbol=JKQTPFilledCircle; - drawLine=false; - gridModeForSymbolSize=false; - gridDeltaX=1; - gridDeltaY=1; - gridSymbolFractionSize=0.9; } void JKQTPXYParametrizedScatterGraph::draw(JKQTPEnhancedPainter &painter) @@ -1107,11 +1116,11 @@ void JKQTPXYParametrizedScatterGraph::draw(JKQTPEnhancedPainter &painter) drawErrorsBefore(painter); - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); QPen p=painter.pen(); p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); p.setStyle(style); p.setJoinStyle(Qt::RoundJoin); p.setJoinStyle(Qt::RoundJoin); @@ -1148,61 +1157,64 @@ void JKQTPXYParametrizedScatterGraph::draw(JKQTPEnhancedPainter &painter) intSortData(); double specSymbSize=0; bool hasSpecSymbSize=false; - painter.save(); - for (int iii=imin; iiiget(static_cast(xColumn),static_cast(i)); - double yv=datastore->get(static_cast(yColumn),static_cast(i)); - double x=transformX(xv); - double y=transformY(yv); - if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv) && JKQTPIsOKFloat(x) && JKQTPIsOKFloat(y)) { - double symbSize= parent->pt2px(painter, getLocalSymbolSize(i)); - double lineW= parent->pt2px(painter, getLocalLineWidth(i)); + { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + for (int iii=imin; iiiget(static_cast(xColumn),static_cast(i)); + double yv=datastore->get(static_cast(yColumn),static_cast(i)); + double x=transformX(xv); + double y=transformY(yv); + if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv) && JKQTPIsOKFloat(x) && JKQTPIsOKFloat(y)) { + double symbSize= parent->pt2px(painter, getLocalSymbolSize(i)); + double lineW= parent->pt2px(painter, getLocalLineWidth(i)); - if (gridModeForSymbolSize) { - if (!hasSpecSymbSize) { - double sSX= fabs(transformX( xv+gridDeltaX*gridSymbolFractionSize/2.0)-transformX( xv-gridDeltaX*gridSymbolFractionSize/2.0)); - double sSY= fabs(transformY( yv+gridDeltaY*gridSymbolFractionSize/2.0)-transformY( yv-gridDeltaY*gridSymbolFractionSize/2.0)); - hasSpecSymbSize=true; - specSymbSize=qMin(sSX,sSY); + if (gridModeForSymbolSize) { + if (!hasSpecSymbSize) { + double sSX= fabs(transformX( xv+gridDeltaX*gridSymbolFractionSize/2.0)-transformX( xv-gridDeltaX*gridSymbolFractionSize/2.0)); + double sSY= fabs(transformY( yv+gridDeltaY*gridSymbolFractionSize/2.0)-transformY( yv-gridDeltaY*gridSymbolFractionSize/2.0)); + hasSpecSymbSize=true; + specSymbSize=qMin(sSX,sSY); + } + symbSize=specSymbSize; } - symbSize=specSymbSize; - } - QColor symbColor=getLocalColor(i); - QColor symbFillColor=symbColor.lighter(); - //qDebug()<=0) linecolss<=0) linecolss<pt2px(painter, symbolWidth*parent->getLineWidthMultiplier()), penSelection.color(), penSelection.color()); + } else { + JKQTPPlotSymbol(painter, x, y, getLocalSymbolType(i), symbSize, parent->pt2px(painter, symbolWidth*parent->getLineWidthMultiplier()), symbColor, symbFillColor); + } + + + xold=x; + yold=y; + first=true; } - - if (drawSelectionLine && symbol!=JKQTPNoSymbol && symbolColumn<0) { - JKQTPPlotSymbol(painter, x, y, JKQTPFilledCircle,symbSize, parent->pt2px(painter, symbolWidth*parent->getLineWidthMultiplier()), penSelection.color(), penSelection.color()); - } else { - JKQTPPlotSymbol(painter, x, y, getLocalSymbolType(i), symbSize, parent->pt2px(painter, symbolWidth*parent->getLineWidthMultiplier()), symbColor, symbFillColor); - } - - - xold=x; - yold=y; - first=true; } } - painter.restore(); + + if (lines.size()>0) { - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); if (drawSelectionLine) { QPen pp=penSelection; if (colorColumn>=0) { @@ -1230,9 +1242,9 @@ void JKQTPXYParametrizedScatterGraph::draw(JKQTPEnhancedPainter &painter) painter.setPen(pp); painter.drawPolyline(linesP); } - painter.restore(); + } - painter.restore(); + drawErrorsAfter(painter); } @@ -1280,7 +1292,7 @@ void JKQTPXYParametrizedScatterGraph::drawKeyMarker(JKQTPEnhancedPainter &painte double lineWidth=parent->pt2px(painter, this->lineWidth*0.7*parent->getLineWidthMultiplier()); if (lineWidth>0.1*maxSize) lineWidth=0.1*maxSize; - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); QPen p=painter.pen(); p.setColor(color1); p.setStyle(style); @@ -1290,10 +1302,10 @@ void JKQTPXYParametrizedScatterGraph::drawKeyMarker(JKQTPEnhancedPainter &painte double y1=rect.top()+symbolSize1/2.0; double x2=rect.right()-symbolSize2/2.0; double y2=rect.bottom()-symbolSize2/2.0; - JKQTPPlotSymbol(painter, x1, y1, symbol1, symbolSize1, symbolWidth, color1, color1.lighter()); - JKQTPPlotSymbol(painter, x2, y2, symbol2, symbolSize2, symbolWidth, color2, color2.lighter()); + JKQTPPlotSymbol(painter, x1, y1, symbol1, symbolSize1, symbolWidth, color1, JKQTPGetDerivedColor(symbolFillDerivationMode, color1)); + JKQTPPlotSymbol(painter, x2, y2, symbol2, symbolSize2, symbolWidth, color2, JKQTPGetDerivedColor(symbolFillDerivationMode, color2)); if (drawLine) painter.drawLine(x1,y1, x2,y2); - painter.restore(); + } QColor JKQTPXYParametrizedScatterGraph::getKeyLabelColor() @@ -1435,12 +1447,17 @@ JKQTPGraphSymbols JKQTPXYParametrizedScatterGraph::getLocalSymbolType(int i) JKQTPXYParametrizedErrorScatterGraph::JKQTPXYParametrizedErrorScatterGraph(JKQTBasePlotter *parent): - JKQTPXYParametrizedScatterGraph(parent), JKQTPXYGraphErrors() -{ setErrorColorFromGraphColor(color); } + JKQTPXYParametrizedScatterGraph(parent), JKQTPXYGraphErrors(color, parent) +{ + setErrorColorFromGraphColor(color); + if (parentPlotStyle>=0) setErrorStyleFromPen(parent->getPlotStyle(parentPlotStyle)); +} JKQTPXYParametrizedErrorScatterGraph::JKQTPXYParametrizedErrorScatterGraph(JKQTPlotter *parent): - JKQTPXYParametrizedScatterGraph(parent), JKQTPXYGraphErrors() -{ setErrorColorFromGraphColor(color); } + JKQTPXYParametrizedErrorScatterGraph(parent->getPlotter()) +{ + +} bool JKQTPXYParametrizedErrorScatterGraph::getXMinMax(double &minx, double &maxx, double &smallestGreaterZero) { diff --git a/lib/jkqtplotter/jkqtpgraphs.h b/lib/jkqtplotter/jkqtpgraphs.h index 9b2955f4f3..8bd92e5462 100644 --- a/lib/jkqtplotter/jkqtpgraphs.h +++ b/lib/jkqtplotter/jkqtpgraphs.h @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -26,6 +26,7 @@ #include "jkqtplottertools/jkqtpdrawingtools.h" #include "jkqtplotter/jkqtpgraphsbase.h" #include "jkqtplottertools/jkqtpenhancedpainter.h" +#include "jkqtplotter/jkqtpgraphsbaseerrors.h" #ifndef jkqtpgraphs_H #define jkqtpgraphs_H @@ -62,142 +63,122 @@ class JKQTP_LIB_EXPORT JKQTPXYLineGraph: public JKQTPXYGraph { /** \brief returns the color to be used for the key label */ virtual QColor getKeyLabelColor() override; - /*! \brief sets the property color ( \copybrief color ) to the specified \a __value. - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual void setColor(const QColor & __value) { this->color = __value; } - /*! \brief returns the property color ( \copybrief color ). - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual QColor getColor() const { return this->color; } - /*! \brief sets the property fillColor ( \copybrief fillColor ) to the specified \a __value. - \details Description of the parameter fillColor is:
    \copydoc fillColor
    - \see fillColor for more information */ + /*! \copydoc fillColor + \see see fillColor for details */ inline virtual void setFillColor(const QColor & __value) { this->fillColor = __value; } - /*! \brief returns the property fillColor ( \copybrief fillColor ). - \details Description of the parameter fillColor is:
    \copydoc fillColor
    - \see fillColor for more information */ + /*! \copydoc fillColor + \see see fillColor for details */ inline virtual QColor getFillColor() const { return this->fillColor; } - /*! \brief sets the property style ( \copybrief style ) to the specified \a __value. - \details Description of the parameter style is:
    \copydoc style
    - \see style for more information */ + /*! \copydoc style + \see see style for details */ inline virtual void setStyle(const Qt::PenStyle & __value) { this->style = __value; } - /*! \brief returns the property style ( \copybrief style ). - \details Description of the parameter style is:
    \copydoc style
    - \see style for more information */ + /*! \copydoc style + \see see style for details */ inline virtual Qt::PenStyle getStyle() const { return this->style; } - /*! \brief sets the property lineWidth ( \copybrief lineWidth ) to the specified \a __value. - \details Description of the parameter lineWidth is:
    \copydoc lineWidth
    - \see lineWidth for more information */ + /*! \copydoc lineWidth + \see see lineWidth for details */ inline virtual void setLineWidth(double __value) { this->lineWidth = __value; } - /*! \brief returns the property lineWidth ( \copybrief lineWidth ). - \details Description of the parameter lineWidth is:
    \copydoc lineWidth
    - \see lineWidth for more information */ + /*! \copydoc lineWidth + \see see lineWidth for details */ inline virtual double getLineWidth() const { return this->lineWidth; } - /*! \brief sets the property symbol ( \copybrief symbol ) to the specified \a __value. - \details Description of the parameter symbol is:
    \copydoc symbol
    - \see symbol for more information */ + /*! \copydoc symbol + \see see symbol for details */ inline virtual void setSymbol(const JKQTPGraphSymbols & __value) { this->symbol = __value; } - /*! \brief returns the property symbol ( \copybrief symbol ). - \details Description of the parameter symbol is:
    \copydoc symbol
    - \see symbol for more information */ + /*! \copydoc symbol + \see see symbol for details */ inline virtual JKQTPGraphSymbols getSymbol() const { return this->symbol; } - /*! \brief sets the property symbolWidth ( \copybrief symbolWidth ) to the specified \a __value. - \details Description of the parameter symbolWidth is:
    \copydoc symbolWidth
    - \see symbolWidth for more information */ + /*! \copydoc symbolWidth + \see see symbolWidth for details */ inline virtual void setSymbolWidth(double __value) { this->symbolWidth = __value; } - /*! \brief returns the property symbolWidth ( \copybrief symbolWidth ). - \details Description of the parameter symbolWidth is:
    \copydoc symbolWidth
    - \see symbolWidth for more information */ + /*! \copydoc symbolWidth + \see see symbolWidth for details */ inline virtual double getSymbolWidth() const { return this->symbolWidth; } - /*! \brief sets the property symbolSize ( \copybrief symbolSize ) to the specified \a __value. - \details Description of the parameter symbolSize is:
    \copydoc symbolSize
    - \see symbolSize for more information */ + /*! \copydoc symbolSize + \see see symbolSize for details */ inline virtual void setSymbolSize(double __value) { this->symbolSize = __value; } - /*! \brief returns the property symbolSize ( \copybrief symbolSize ). - \details Description of the parameter symbolSize is:
    \copydoc symbolSize
    - \see symbolSize for more information */ + /*! \copydoc symbolSize + \see see symbolSize for details */ inline virtual double getSymbolSize() const { return this->symbolSize; } - /*! \brief sets the property drawLine ( \copybrief drawLine ) to the specified \a __value. - \details Description of the parameter drawLine is:
    \copydoc drawLine
    - \see drawLine for more information */ + /*! \copydoc drawLine + \see see drawLine for details */ inline virtual void setDrawLine(bool __value) { this->drawLine = __value; } - /*! \brief returns the property drawLine ( \copybrief drawLine ). - \details Description of the parameter drawLine is:
    \copydoc drawLine
    - \see drawLine for more information */ + /*! \copydoc drawLine + \see see drawLine for details */ inline virtual bool getDrawLine() const { return this->drawLine; } - /*! \brief sets the property drawSelectionLine ( \copybrief drawSelectionLine ) to the specified \a __value. - \details Description of the parameter drawSelectionLine is:
    \copydoc drawSelectionLine
    - \see drawSelectionLine for more information */ + /*! \copydoc drawSelectionLine + \see see drawSelectionLine for details */ inline virtual void setDrawSelectionLine(bool __value) { this->drawSelectionLine = __value; } - /*! \brief returns the property drawSelectionLine ( \copybrief drawSelectionLine ). - \details Description of the parameter drawSelectionLine is:
    \copydoc drawSelectionLine
    - \see drawSelectionLine for more information */ + /*! \copydoc drawSelectionLine + \see see drawSelectionLine for details */ inline virtual bool getDrawSelectionLine() const { return this->drawSelectionLine; } - /*! \brief sets the property selectionLineColor ( \copybrief selectionLineColor ) to the specified \a __value. - \details Description of the parameter selectionLineColor is:
    \copydoc selectionLineColor
    - \see selectionLineColor for more information */ + /*! \copydoc selectionLineColor + \see see selectionLineColor for details */ inline virtual void setSelectionLineColor(const QColor & __value) { this->selectionLineColor = __value; } - /*! \brief returns the property selectionLineColor ( \copybrief selectionLineColor ). - \details Description of the parameter selectionLineColor is:
    \copydoc selectionLineColor
    - \see selectionLineColor for more information */ + /*! \copydoc selectionLineColor + \see see selectionLineColor for details */ inline virtual QColor getSelectionLineColor() const { return this->selectionLineColor; @@ -273,148 +254,142 @@ class JKQTP_LIB_EXPORT JKQTPXYParametrizedScatterGraph: public JKQTPXYLineGraph, /** \brief returns the color to be used for the key label */ virtual QColor getKeyLabelColor() override; - /*! \brief sets the property sizeColumn ( \copybrief sizeColumn ) to the specified \a __value. - \details Description of the parameter sizeColumn is:
    \copydoc sizeColumn
    - \see sizeColumn for more information */ + /*! \copydoc sizeColumn + \see see sizeColumn for details */ inline virtual void setSizeColumn(int __value) { this->sizeColumn = __value; } - /*! \brief returns the property sizeColumn ( \copybrief sizeColumn ). - \details Description of the parameter sizeColumn is:
    \copydoc sizeColumn
    - \see sizeColumn for more information */ + /*! \copydoc sizeColumn + \see see sizeColumn for details */ inline virtual int getSizeColumn() const { return this->sizeColumn; } /*! \brief sets the property sizeColumn ( \copybrief sizeColumn ) to the specified \a __value, where __value is static_cast'ed from size_t to int. \details Description of the parameter sizeColumn is:
    \copydoc sizeColumn
    - \see sizeColumn for more information */ + \see sizeColumn for more information */ inline virtual void setSizeColumn (size_t __value) { this->sizeColumn = static_cast(__value); } - /*! \brief sets the property colorColumn ( \copybrief colorColumn ) to the specified \a __value. - \details Description of the parameter colorColumn is:
    \copydoc colorColumn
    - \see colorColumn for more information */ + /*! \copydoc colorColumn + \see see colorColumn for details */ inline virtual void setColorColumn(int __value) { this->colorColumn = __value; } - /*! \brief returns the property colorColumn ( \copybrief colorColumn ). - \details Description of the parameter colorColumn is:
    \copydoc colorColumn
    - \see colorColumn for more information */ + /*! \copydoc colorColumn + \see see colorColumn for details */ inline virtual int getColorColumn() const { return this->colorColumn; } /*! \brief sets the property colorColumn ( \copybrief colorColumn ) to the specified \a __value, where __value is static_cast'ed from size_t to int. \details Description of the parameter colorColumn is:
    \copydoc colorColumn
    - \see colorColumn for more information */ + \see colorColumn for more information */ inline virtual void setColorColumn (size_t __value) { this->colorColumn = static_cast(__value); } - /*! \brief sets the property symbolColumn ( \copybrief symbolColumn ) to the specified \a __value. - \details Description of the parameter symbolColumn is:
    \copydoc symbolColumn
    - \see symbolColumn for more information */ + /*! \copydoc symbolColumn + \see see symbolColumn for details */ inline virtual void setSymbolColumn(int __value) { this->symbolColumn = __value; } - /*! \brief returns the property symbolColumn ( \copybrief symbolColumn ). - \details Description of the parameter symbolColumn is:
    \copydoc symbolColumn
    - \see symbolColumn for more information */ + /*! \copydoc symbolColumn + \see see symbolColumn for details */ inline virtual int getSymbolColumn() const { return this->symbolColumn; } /*! \brief sets the property symbolColumn ( \copybrief symbolColumn ) to the specified \a __value, where __value is static_cast'ed from size_t to int. \details Description of the parameter symbolColumn is:
    \copydoc symbolColumn
    - \see symbolColumn for more information */ + \see symbolColumn for more information */ inline virtual void setSymbolColumn (size_t __value) { this->symbolColumn = static_cast(__value); } - /*! \brief sets the property linewidthColumn ( \copybrief linewidthColumn ) to the specified \a __value. - \details Description of the parameter linewidthColumn is:
    \copydoc linewidthColumn
    - \see linewidthColumn for more information */ + /*! \copydoc linewidthColumn + \see see linewidthColumn for details */ inline virtual void setLinewidthColumn(int __value) { this->linewidthColumn = __value; } - /*! \brief returns the property linewidthColumn ( \copybrief linewidthColumn ). - \details Description of the parameter linewidthColumn is:
    \copydoc linewidthColumn
    - \see linewidthColumn for more information */ + /*! \copydoc linewidthColumn + \see see linewidthColumn for details */ inline virtual int getLinewidthColumn() const { return this->linewidthColumn; } /*! \brief sets the property linewidthColumn ( \copybrief linewidthColumn ) to the specified \a __value, where __value is static_cast'ed from size_t to int. \details Description of the parameter linewidthColumn is:
    \copydoc linewidthColumn
    - \see linewidthColumn for more information */ + \see linewidthColumn for more information */ inline virtual void setLinewidthColumn( size_t __value) { this->linewidthColumn = static_cast(__value); } - /*! \brief sets the property colorColumnContainsRGB ( \copybrief colorColumnContainsRGB ) to the specified \a __value. - \details Description of the parameter colorColumnContainsRGB is:
    \copydoc colorColumnContainsRGB
    - \see colorColumnContainsRGB for more information */ + /*! \copydoc colorColumnContainsRGB + \see see colorColumnContainsRGB for details */ inline virtual void setColorColumnContainsRGB(bool __value) { this->colorColumnContainsRGB = __value; } - /*! \brief returns the property colorColumnContainsRGB ( \copybrief colorColumnContainsRGB ). - \details Description of the parameter colorColumnContainsRGB is:
    \copydoc colorColumnContainsRGB
    - \see colorColumnContainsRGB for more information */ + /*! \copydoc colorColumnContainsRGB + \see see colorColumnContainsRGB for details */ inline virtual bool getColorColumnContainsRGB() const { return this->colorColumnContainsRGB; } - /*! \brief sets the property gridModeForSymbolSize ( \copybrief gridModeForSymbolSize ) to the specified \a __value. - \details Description of the parameter gridModeForSymbolSize is:
    \copydoc gridModeForSymbolSize
    - \see gridModeForSymbolSize for more information */ + /*! \copydoc gridModeForSymbolSize + \see see gridModeForSymbolSize for details */ inline virtual void setGridModeForSymbolSize(bool __value) { this->gridModeForSymbolSize = __value; } - /*! \brief returns the property gridModeForSymbolSize ( \copybrief gridModeForSymbolSize ). - \details Description of the parameter gridModeForSymbolSize is:
    \copydoc gridModeForSymbolSize
    - \see gridModeForSymbolSize for more information */ + /*! \copydoc gridModeForSymbolSize + \see see gridModeForSymbolSize for details */ inline virtual bool getGridModeForSymbolSize() const { return this->gridModeForSymbolSize; } - /*! \brief sets the property gridDeltaX ( \copybrief gridDeltaX ) to the specified \a __value. - \details Description of the parameter gridDeltaX is:
    \copydoc gridDeltaX
    - \see gridDeltaX for more information */ + /*! \copydoc gridDeltaX + \see see gridDeltaX for details */ inline virtual void setGridDeltaX(double __value) { this->gridDeltaX = __value; } - /*! \brief returns the property gridDeltaX ( \copybrief gridDeltaX ). - \details Description of the parameter gridDeltaX is:
    \copydoc gridDeltaX
    - \see gridDeltaX for more information */ + /*! \copydoc gridDeltaX + \see see gridDeltaX for details */ inline virtual double getGridDeltaX() const { return this->gridDeltaX; } - /*! \brief sets the property gridDeltaY ( \copybrief gridDeltaY ) to the specified \a __value. - \details Description of the parameter gridDeltaY is:
    \copydoc gridDeltaY
    - \see gridDeltaY for more information */ + /*! \copydoc gridDeltaY + \see see gridDeltaY for details */ inline virtual void setGridDeltaY(double __value) { this->gridDeltaY = __value; } - /*! \brief returns the property gridDeltaY ( \copybrief gridDeltaY ). - \details Description of the parameter gridDeltaY is:
    \copydoc gridDeltaY
    - \see gridDeltaY for more information */ + /*! \copydoc gridDeltaY + \see see gridDeltaY for details */ inline virtual double getGridDeltaY() const { return this->gridDeltaY; } - /*! \brief sets the property gridSymbolFractionSize ( \copybrief gridSymbolFractionSize ) to the specified \a __value. - \details Description of the parameter gridSymbolFractionSize is:
    \copydoc gridSymbolFractionSize
    - \see gridSymbolFractionSize for more information */ + /*! \copydoc gridSymbolFractionSize + \see see gridSymbolFractionSize for details */ inline virtual void setGridSymbolFractionSize(double __value) { this->gridSymbolFractionSize = __value; } - /*! \brief returns the property gridSymbolFractionSize ( \copybrief gridSymbolFractionSize ). - \details Description of the parameter gridSymbolFractionSize is:
    \copydoc gridSymbolFractionSize
    - \see gridSymbolFractionSize for more information */ + /*! \copydoc gridSymbolFractionSize + \see see gridSymbolFractionSize for details */ inline virtual double getGridSymbolFractionSize() const { return this->gridSymbolFractionSize; } + /*! \copydoc symbolFillDerivationMode + \see see symbolFillDerivationMode for details */ + inline virtual JKQTPColorDerivationMode getSymbolFillDerivationMode() const + { + return this->symbolFillDerivationMode; + } + /*! \copydoc symbolFillDerivationMode + \see see symbolFillDerivationMode for details */ + inline virtual void setSymbolFillDerivationMode(JKQTPColorDerivationMode m) + { + this->symbolFillDerivationMode=m; + } virtual void setParent(JKQTBasePlotter* parent) override; @@ -475,6 +450,9 @@ class JKQTP_LIB_EXPORT JKQTPXYParametrizedScatterGraph: public JKQTPXYLineGraph, /** \brief internally used to store the range of the color column */ double intColMax; + /** \brief specifies how to derive the symbol fill color from the symbol/line color */ + JKQTPColorDerivationMode symbolFillDerivationMode; + }; @@ -579,114 +557,98 @@ class JKQTP_LIB_EXPORT JKQTPStepHorizontalGraph: public JKQTPXYGraph { /** \brief returns the color to be used for the key label */ virtual QColor getKeyLabelColor() override; - /*! \brief sets the property color ( \copybrief color ) to the specified \a __value. - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual void setColor(const QColor & __value) { this->color = __value; } - /*! \brief returns the property color ( \copybrief color ). - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual QColor getColor() const { return this->color; } - /*! \brief sets the property fillColor ( \copybrief fillColor ) to the specified \a __value. - \details Description of the parameter fillColor is:
    \copydoc fillColor
    - \see fillColor for more information */ + /*! \copydoc fillColor + \see see fillColor for details */ inline virtual void setFillColor(const QColor & __value) { this->fillColor = __value; } - /*! \brief returns the property fillColor ( \copybrief fillColor ). - \details Description of the parameter fillColor is:
    \copydoc fillColor
    - \see fillColor for more information */ + /*! \copydoc fillColor + \see see fillColor for details */ inline virtual QColor getFillColor() const { return this->fillColor; } - /*! \brief sets the property fillStyle ( \copybrief fillStyle ) to the specified \a __value. - \details Description of the parameter fillStyle is:
    \copydoc fillStyle
    - \see fillStyle for more information */ + /*! \copydoc fillStyle + \see see fillStyle for details */ inline virtual void setFillStyle(const Qt::BrushStyle & __value) { this->fillStyle = __value; } - /*! \brief returns the property fillStyle ( \copybrief fillStyle ). - \details Description of the parameter fillStyle is:
    \copydoc fillStyle
    - \see fillStyle for more information */ + /*! \copydoc fillStyle + \see see fillStyle for details */ inline virtual Qt::BrushStyle getFillStyle() const { return this->fillStyle; } - /*! \brief sets the property style ( \copybrief style ) to the specified \a __value. - \details Description of the parameter style is:
    \copydoc style
    - \see style for more information */ + /*! \copydoc style + \see see style for details */ inline virtual void setStyle(const Qt::PenStyle & __value) { this->style = __value; } - /*! \brief returns the property style ( \copybrief style ). - \details Description of the parameter style is:
    \copydoc style
    - \see style for more information */ + /*! \copydoc style + \see see style for details */ inline virtual Qt::PenStyle getStyle() const { return this->style; } - /*! \brief sets the property lineWidth ( \copybrief lineWidth ) to the specified \a __value. - \details Description of the parameter lineWidth is:
    \copydoc lineWidth
    - \see lineWidth for more information */ + /*! \copydoc lineWidth + \see see lineWidth for details */ inline virtual void setLineWidth(double __value) { this->lineWidth = __value; } - /*! \brief returns the property lineWidth ( \copybrief lineWidth ). - \details Description of the parameter lineWidth is:
    \copydoc lineWidth
    - \see lineWidth for more information */ + /*! \copydoc lineWidth + \see see lineWidth for details */ inline virtual double getLineWidth() const { return this->lineWidth; } - /*! \brief sets the property drawLine ( \copybrief drawLine ) to the specified \a __value. - \details Description of the parameter drawLine is:
    \copydoc drawLine
    - \see drawLine for more information */ + /*! \copydoc drawLine + \see see drawLine for details */ inline virtual void setDrawLine(bool __value) { this->drawLine = __value; } - /*! \brief returns the property drawLine ( \copybrief drawLine ). - \details Description of the parameter drawLine is:
    \copydoc drawLine
    - \see drawLine for more information */ + /*! \copydoc drawLine + \see see drawLine for details */ inline virtual bool getDrawLine() const { return this->drawLine; } - /*! \brief sets the property fillCurve ( \copybrief fillCurve ) to the specified \a __value. - \details Description of the parameter fillCurve is:
    \copydoc fillCurve
    - \see fillCurve for more information */ + /*! \copydoc fillCurve + \see see fillCurve for details */ inline virtual void setFillCurve(bool __value) { this->fillCurve = __value; } - /*! \brief returns the property fillCurve ( \copybrief fillCurve ). - \details Description of the parameter fillCurve is:
    \copydoc fillCurve
    - \see fillCurve for more information */ + /*! \copydoc fillCurve + \see see fillCurve for details */ inline virtual bool getFillCurve() const { return this->fillCurve; } - /*! \brief sets the property stepType ( \copybrief stepType ) to the specified \a __value. - \details Description of the parameter stepType is:
    \copydoc stepType
    - \see stepType for more information */ + /*! \copydoc stepType + \see see stepType for details */ inline virtual void setStepType(const JKQTPStepType & __value) { this->stepType = __value; } - /*! \brief returns the property stepType ( \copybrief stepType ). - \details Description of the parameter stepType is:
    \copydoc stepType
    - \see stepType for more information */ + /*! \copydoc stepType + \see see stepType for details */ inline virtual JKQTPStepType getStepType() const { return this->stepType; @@ -779,283 +741,243 @@ class JKQTP_LIB_EXPORT JKQTPHorizontalRange: public JKQTPGraph { void setDrawCenterLineOnly(); - /*! \brief sets the property color ( \copybrief color ) to the specified \a __value. - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual void setColor(const QColor & __value) { this->color = __value; } - /*! \brief returns the property color ( \copybrief color ). - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual QColor getColor() const { return this->color; } - /*! \brief sets the property fillColor ( \copybrief fillColor ) to the specified \a __value. - \details Description of the parameter fillColor is:
    \copydoc fillColor
    - \see fillColor for more information */ + /*! \copydoc fillColor + \see see fillColor for details */ inline virtual void setFillColor(const QColor & __value) { this->fillColor = __value; } - /*! \brief returns the property fillColor ( \copybrief fillColor ). - \details Description of the parameter fillColor is:
    \copydoc fillColor
    - \see fillColor for more information */ + /*! \copydoc fillColor + \see see fillColor for details */ inline virtual QColor getFillColor() const { return this->fillColor; } - /*! \brief sets the property fillStyle ( \copybrief fillStyle ) to the specified \a __value. - \details Description of the parameter fillStyle is:
    \copydoc fillStyle
    - \see fillStyle for more information */ + /*! \copydoc fillStyle + \see see fillStyle for details */ inline virtual void setFillStyle(const Qt::BrushStyle & __value) { this->fillStyle = __value; } - /*! \brief returns the property fillStyle ( \copybrief fillStyle ). - \details Description of the parameter fillStyle is:
    \copydoc fillStyle
    - \see fillStyle for more information */ + /*! \copydoc fillStyle + \see see fillStyle for details */ inline virtual Qt::BrushStyle getFillStyle() const { return this->fillStyle; } - /*! \brief sets the property style ( \copybrief style ) to the specified \a __value. - \details Description of the parameter style is:
    \copydoc style
    - \see style for more information */ + /*! \copydoc style + \see see style for details */ inline virtual void setStyle(const Qt::PenStyle & __value) { this->style = __value; } - /*! \brief returns the property style ( \copybrief style ). - \details Description of the parameter style is:
    \copydoc style
    - \see style for more information */ + /*! \copydoc style + \see see style for details */ inline virtual Qt::PenStyle getStyle() const { return this->style; } - /*! \brief sets the property lineWidth ( \copybrief lineWidth ) to the specified \a __value. - \details Description of the parameter lineWidth is:
    \copydoc lineWidth
    - \see lineWidth for more information */ + /*! \copydoc lineWidth + \see see lineWidth for details */ inline virtual void setLineWidth(double __value) { this->lineWidth = __value; } - /*! \brief returns the property lineWidth ( \copybrief lineWidth ). - \details Description of the parameter lineWidth is:
    \copydoc lineWidth
    - \see lineWidth for more information */ + /*! \copydoc lineWidth + \see see lineWidth for details */ inline virtual double getLineWidth() const { return this->lineWidth; } - /*! \brief sets the property centerColor ( \copybrief centerColor ) to the specified \a __value. - \details Description of the parameter centerColor is:
    \copydoc centerColor
    - \see centerColor for more information */ + /*! \copydoc centerColor + \see see centerColor for details */ inline virtual void setCenterColor(const QColor & __value) { this->centerColor = __value; } - /*! \brief returns the property centerColor ( \copybrief centerColor ). - \details Description of the parameter centerColor is:
    \copydoc centerColor
    - \see centerColor for more information */ + /*! \copydoc centerColor + \see see centerColor for details */ inline virtual QColor getCenterColor() const { return this->centerColor; } - /*! \brief sets the property centerStyle ( \copybrief centerStyle ) to the specified \a __value. - \details Description of the parameter centerStyle is:
    \copydoc centerStyle
    - \see centerStyle for more information */ + /*! \copydoc centerStyle + \see see centerStyle for details */ inline virtual void setCenterStyle(const Qt::PenStyle & __value) { this->centerStyle = __value; } - /*! \brief returns the property centerStyle ( \copybrief centerStyle ). - \details Description of the parameter centerStyle is:
    \copydoc centerStyle
    - \see centerStyle for more information */ + /*! \copydoc centerStyle + \see see centerStyle for details */ inline virtual Qt::PenStyle getCenterStyle() const { return this->centerStyle; } - /*! \brief sets the property centerLineWidth ( \copybrief centerLineWidth ) to the specified \a __value. - \details Description of the parameter centerLineWidth is:
    \copydoc centerLineWidth
    - \see centerLineWidth for more information */ + /*! \copydoc centerLineWidth + \see see centerLineWidth for details */ inline virtual void setCenterLineWidth(double __value) { this->centerLineWidth = __value; } - /*! \brief returns the property centerLineWidth ( \copybrief centerLineWidth ). - \details Description of the parameter centerLineWidth is:
    \copydoc centerLineWidth
    - \see centerLineWidth for more information */ + /*! \copydoc centerLineWidth + \see see centerLineWidth for details */ inline virtual double getCenterLineWidth() const { return this->centerLineWidth; } - /*! \brief sets the property rangeMin ( \copybrief rangeMin ) to the specified \a __value. - \details Description of the parameter rangeMin is:
    \copydoc rangeMin
    - \see rangeMin for more information */ + /*! \copydoc rangeMin + \see see rangeMin for details */ inline virtual void setRangeMin(double __value) { this->rangeMin = __value; } - /*! \brief returns the property rangeMin ( \copybrief rangeMin ). - \details Description of the parameter rangeMin is:
    \copydoc rangeMin
    - \see rangeMin for more information */ + /*! \copydoc rangeMin + \see see rangeMin for details */ inline virtual double getRangeMin() const { return this->rangeMin; } - /*! \brief sets the property rangeMax ( \copybrief rangeMax ) to the specified \a __value. - \details Description of the parameter rangeMax is:
    \copydoc rangeMax
    - \see rangeMax for more information */ + /*! \copydoc rangeMax + \see see rangeMax for details */ inline virtual void setRangeMax(double __value) { this->rangeMax = __value; } - /*! \brief returns the property rangeMax ( \copybrief rangeMax ). - \details Description of the parameter rangeMax is:
    \copydoc rangeMax
    - \see rangeMax for more information */ + /*! \copydoc rangeMax + \see see rangeMax for details */ inline virtual double getRangeMax() const { return this->rangeMax; } - /*! \brief sets the property sizeMin ( \copybrief sizeMin ) to the specified \a __value. - \details Description of the parameter sizeMin is:
    \copydoc sizeMin
    - \see sizeMin for more information */ + /*! \copydoc sizeMin + \see see sizeMin for details */ inline virtual void setSizeMin(double __value) { this->sizeMin = __value; } - /*! \brief returns the property sizeMin ( \copybrief sizeMin ). - \details Description of the parameter sizeMin is:
    \copydoc sizeMin
    - \see sizeMin for more information */ + /*! \copydoc sizeMin + \see see sizeMin for details */ inline virtual double getSizeMin() const { return this->sizeMin; } - /*! \brief sets the property sizeMax ( \copybrief sizeMax ) to the specified \a __value. - \details Description of the parameter sizeMax is:
    \copydoc sizeMax
    - \see sizeMax for more information */ + /*! \copydoc sizeMax + \see see sizeMax for details */ inline virtual void setSizeMax(double __value) { this->sizeMax = __value; } - /*! \brief returns the property sizeMax ( \copybrief sizeMax ). - \details Description of the parameter sizeMax is:
    \copydoc sizeMax
    - \see sizeMax for more information */ + /*! \copydoc sizeMax + \see see sizeMax for details */ inline virtual double getSizeMax() const { return this->sizeMax; } - /*! \brief sets the property unlimitedSizeMin ( \copybrief unlimitedSizeMin ) to the specified \a __value. - \details Description of the parameter unlimitedSizeMin is:
    \copydoc unlimitedSizeMin
    - \see unlimitedSizeMin for more information */ + /*! \copydoc unlimitedSizeMin + \see see unlimitedSizeMin for details */ inline virtual void setUnlimitedSizeMin(bool __value) { this->unlimitedSizeMin = __value; } - /*! \brief returns the property unlimitedSizeMin ( \copybrief unlimitedSizeMin ). - \details Description of the parameter unlimitedSizeMin is:
    \copydoc unlimitedSizeMin
    - \see unlimitedSizeMin for more information */ + /*! \copydoc unlimitedSizeMin + \see see unlimitedSizeMin for details */ inline virtual bool getUnlimitedSizeMin() const { return this->unlimitedSizeMin; } - /*! \brief sets the property unlimitedSizeMax ( \copybrief unlimitedSizeMax ) to the specified \a __value. - \details Description of the parameter unlimitedSizeMax is:
    \copydoc unlimitedSizeMax
    - \see unlimitedSizeMax for more information */ + /*! \copydoc unlimitedSizeMax + \see see unlimitedSizeMax for details */ inline virtual void setUnlimitedSizeMax(bool __value) { this->unlimitedSizeMax = __value; } - /*! \brief returns the property unlimitedSizeMax ( \copybrief unlimitedSizeMax ). - \details Description of the parameter unlimitedSizeMax is:
    \copydoc unlimitedSizeMax
    - \see unlimitedSizeMax for more information */ + /*! \copydoc unlimitedSizeMax + \see see unlimitedSizeMax for details */ inline virtual bool getUnlimitedSizeMax() const { return this->unlimitedSizeMax; } - /*! \brief sets the property rangeCenter ( \copybrief rangeCenter ) to the specified \a __value. - \details Description of the parameter rangeCenter is:
    \copydoc rangeCenter
    - \see rangeCenter for more information */ + /*! \copydoc rangeCenter + \see see rangeCenter for details */ inline virtual void setRangeCenter(double __value) { this->rangeCenter = __value; } - /*! \brief returns the property rangeCenter ( \copybrief rangeCenter ). - \details Description of the parameter rangeCenter is:
    \copydoc rangeCenter
    - \see rangeCenter for more information */ + /*! \copydoc rangeCenter + \see see rangeCenter for details */ inline virtual double getRangeCenter() const { return this->rangeCenter; } - /*! \brief sets the property plotCenterLine ( \copybrief plotCenterLine ) to the specified \a __value. - \details Description of the parameter plotCenterLine is:
    \copydoc plotCenterLine
    - \see plotCenterLine for more information */ + /*! \copydoc plotCenterLine + \see see plotCenterLine for details */ inline virtual void setPlotCenterLine(bool __value) { this->plotCenterLine = __value; } - /*! \brief returns the property plotCenterLine ( \copybrief plotCenterLine ). - \details Description of the parameter plotCenterLine is:
    \copydoc plotCenterLine
    - \see plotCenterLine for more information */ + /*! \copydoc plotCenterLine + \see see plotCenterLine for details */ inline virtual bool getPlotCenterLine() const { return this->plotCenterLine; } - /*! \brief sets the property invertedRange ( \copybrief invertedRange ) to the specified \a __value. - \details Description of the parameter invertedRange is:
    \copydoc invertedRange
    - \see invertedRange for more information */ + /*! \copydoc invertedRange + \see see invertedRange for details */ inline virtual void setInvertedRange(bool __value) { this->invertedRange = __value; } - /*! \brief returns the property invertedRange ( \copybrief invertedRange ). - \details Description of the parameter invertedRange is:
    \copydoc invertedRange
    - \see invertedRange for more information */ + /*! \copydoc invertedRange + \see see invertedRange for details */ inline virtual bool getInvertedRange() const { return this->invertedRange; } - /*! \brief sets the property plotRange ( \copybrief plotRange ) to the specified \a __value. - \details Description of the parameter plotRange is:
    \copydoc plotRange
    - \see plotRange for more information */ + /*! \copydoc plotRange + \see see plotRange for details */ inline virtual void setPlotRange(bool __value) { this->plotRange = __value; } - /*! \brief returns the property plotRange ( \copybrief plotRange ). - \details Description of the parameter plotRange is:
    \copydoc plotRange
    - \see plotRange for more information */ + /*! \copydoc plotRange + \see see plotRange for details */ inline virtual bool getPlotRange() const { return this->plotRange; } - /*! \brief sets the property fillRange ( \copybrief fillRange ) to the specified \a __value. - \details Description of the parameter fillRange is:
    \copydoc fillRange
    - \see fillRange for more information */ + /*! \copydoc fillRange + \see see fillRange for details */ inline virtual void setFillRange(bool __value) { this->fillRange = __value; } - /*! \brief returns the property fillRange ( \copybrief fillRange ). - \details Description of the parameter fillRange is:
    \copydoc fillRange
    - \see fillRange for more information */ + /*! \copydoc fillRange + \see see fillRange for details */ inline virtual bool getFillRange() const { return this->fillRange; } - /*! \brief sets the property plotRangeLines ( \copybrief plotRangeLines ) to the specified \a __value. - \details Description of the parameter plotRangeLines is:
    \copydoc plotRangeLines
    - \see plotRangeLines for more information */ + /*! \copydoc plotRangeLines + \see see plotRangeLines for details */ inline virtual void setPlotRangeLines(bool __value) { this->plotRangeLines = __value; } - /*! \brief returns the property plotRangeLines ( \copybrief plotRangeLines ). - \details Description of the parameter plotRangeLines is:
    \copydoc plotRangeLines
    - \see plotRangeLines for more information */ + /*! \copydoc plotRangeLines + \see see plotRangeLines for details */ inline virtual bool getPlotRangeLines() const { return this->plotRangeLines; diff --git a/lib/jkqtplotter/jkqtpgraphsbarchart.cpp b/lib/jkqtplotter/jkqtpgraphsbarchart.cpp index a637f3950a..28ccfcd4b3 100644 --- a/lib/jkqtplotter/jkqtpgraphsbarchart.cpp +++ b/lib/jkqtplotter/jkqtpgraphsbarchart.cpp @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -51,32 +51,22 @@ JKQTPBarVerticalGraph::JKQTPBarVerticalGraph(JKQTBasePlotter* parent): if (parent) { // get style settings from parent object parentPlotStyle=parent->getNextStyle(); - fillColor=parent->getPlotStyle(parentPlotStyle).color(); + color=parent->getPlotStyle(parentPlotStyle).color(); + fillColor=parent->getPlotStyle(parentPlotStyle).fillColor(); + fillStyle=parent->getPlotStyle(parentPlotStyle).fillStyle(); + //style=parent->getPlotStyle(parentPlotStyle).style(); + lineWidth=parent->getPlotStyle(parentPlotStyle).widthF(); } } JKQTPBarVerticalGraph::JKQTPBarVerticalGraph(JKQTPlotter* parent): - JKQTPXYGraph(parent) + JKQTPBarVerticalGraph(parent->getPlotter()) { - baseline=0.0; - color=QColor("black"); - fillColor=QColor("red"); - style=Qt::SolidLine; - lineWidth=1; - fillStyle=Qt::SolidPattern; - width=0.9; - shift=0; - - - if (parent) { // get style settings from parent object - parentPlotStyle=parent->getNextStyle(); - fillColor=parent->getPlotStyle(parentPlotStyle).color(); - } } void JKQTPBarVerticalGraph::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) { - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); QPen p=painter.pen(); QPen np(Qt::NoPen); p.setColor(color); @@ -88,7 +78,7 @@ void JKQTPBarVerticalGraph::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& painter.setPen(p); painter.setBrush(b); painter.drawRect(rect); - painter.restore(); + } QColor JKQTPBarVerticalGraph::getKeyLabelColor() { @@ -108,7 +98,7 @@ void JKQTPBarVerticalGraph::draw(JKQTPEnhancedPainter& painter) { QPen p=painter.pen(); p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); p.setStyle(style); p.setJoinStyle(Qt::RoundJoin); @@ -126,64 +116,66 @@ void JKQTPBarVerticalGraph::draw(JKQTPEnhancedPainter& painter) { } if (imin<0) imin=0; if (imax<0) imax=0; - painter.save(); -// double x0=transformX(0); -// if (parent->getXAxis()->isLogAxis()) x0=transformX(parent->getXAxis()->getMin()); - double y0=transformY(0); - if (parent->getYAxis()->isLogAxis()) y0=transformY(parent->getYAxis()->getMin()); - double delta=1; - double deltap=0; - double deltam=0; - intSortData(); - const bool hasStackPar=hasStackParent(); - for (int iii=imin; iiiget(static_cast(xColumn),static_cast(i)); - int sr=datastore->getNextLowerIndex(xColumn, i); - int lr=datastore->getNextHigherIndex(xColumn, i); - double yv=datastore->get(static_cast(yColumn),static_cast(i)); - double yv0=y0; - if (!qFuzzyIsNull(baseline)) yv0=transformY(baseline); - if (hasStackPar) { - double stackLastY=getParentStackedMax(i); - const double yvold=yv; - yv0=transformY(stackLastY)-(getLineWidth()); - yv=stackLastY+yvold; - } - if (sr<0 && lr<0) { // only one x-value - deltam=0.5; - deltap=0.5; - } else if (lr<0) { // the right-most x-value - deltap=deltam=fabs(xv-datastore->get(xColumn,sr))/2.0; - } else if (sr<0) { // the left-most x-value - deltam=deltap=fabs(datastore->get(xColumn,lr)-xv)/2.0; - } else { - deltam=fabs(xv-datastore->get(xColumn,sr))/2.0; - deltap=fabs(datastore->get(xColumn,lr)-xv)/2.0; - } - //std::cout<getXAxis()->isLogAxis()) x0=transformX(parent->getXAxis()->getMin()); + double y0=transformY(0); + if (parent->getYAxis()->isLogAxis()) y0=transformY(parent->getYAxis()->getMin()); + double delta=1; + double deltap=0; + double deltam=0; + intSortData(); + const bool hasStackPar=hasStackParent(); + for (int iii=imin; iiiget(static_cast(xColumn),static_cast(i)); + int sr=datastore->getNextLowerIndex(xColumn, i); + int lr=datastore->getNextHigherIndex(xColumn, i); + double yv=datastore->get(static_cast(yColumn),static_cast(i)); + double yv0=y0; + if (!qFuzzyIsNull(baseline)) yv0=transformY(baseline); + if (hasStackPar) { + double stackLastY=getParentStackedMax(i); + const double yvold=yv; + yv0=transformY(stackLastY)-(getLineWidth()); + yv=stackLastY+yvold; + } + if (sr<0 && lr<0) { // only one x-value + deltam=0.5; + deltap=0.5; + } else if (lr<0) { // the right-most x-value + deltap=deltam=fabs(xv-datastore->get(xColumn,sr))/2.0; + } else if (sr<0) { // the left-most x-value + deltam=deltap=fabs(datastore->get(xColumn,lr)-xv)/2.0; + } else { + deltam=fabs(xv-datastore->get(xColumn,sr))/2.0; + deltap=fabs(datastore->get(xColumn,lr)-xv)/2.0; + } + //std::cout<xx) { qSwap(x,xx); } + //qDebug()<<"delta="<pt2px(painter, parent->getLineWidthMultiplier()*lineWidth))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH,parent->pt2px(painter, parent->getLineWidthMultiplier()*lineWidth))); p.setStyle(style); p.setJoinStyle(Qt::RoundJoin); p.setCapStyle(Qt::RoundCap); @@ -590,15 +583,16 @@ void JKQTPBarVerticalGraph::setFillColor_and_darkenedColor(QColor fill, int colo } JKQTPBarHorizontalErrorGraph::JKQTPBarHorizontalErrorGraph(JKQTBasePlotter *parent): - JKQTPBarHorizontalGraph(parent), JKQTPXGraphErrors() + JKQTPBarHorizontalGraph(parent), JKQTPXGraphErrors(color, parent) { setErrorColorFromGraphColor(color); + if (parentPlotStyle>=0) setErrorStyleFromPen(parent->getPlotStyle(parentPlotStyle)); } JKQTPBarHorizontalErrorGraph::JKQTPBarHorizontalErrorGraph(JKQTPlotter *parent): - JKQTPBarHorizontalGraph(parent), JKQTPXGraphErrors() + JKQTPBarHorizontalErrorGraph(parent->getPlotter()) { - setErrorColorFromGraphColor(color); + } bool JKQTPBarHorizontalErrorGraph::usesColumn(int c) const @@ -655,15 +649,17 @@ void JKQTPBarHorizontalErrorGraph::drawErrorsAfter(JKQTPEnhancedPainter &painter } JKQTPBarVerticalErrorGraph::JKQTPBarVerticalErrorGraph(JKQTBasePlotter *parent): - JKQTPBarVerticalGraph(parent), JKQTPYGraphErrors() + JKQTPBarVerticalGraph(parent), JKQTPYGraphErrors(color, parent) { setErrorColorFromGraphColor(color); + if (parentPlotStyle>=0) setErrorStyleFromPen(parent->getPlotStyle(parentPlotStyle)); + } JKQTPBarVerticalErrorGraph::JKQTPBarVerticalErrorGraph(JKQTPlotter *parent): - JKQTPBarVerticalGraph(parent), JKQTPYGraphErrors() + JKQTPBarVerticalErrorGraph(parent->getPlotter()) { - setErrorColorFromGraphColor(color); + } bool JKQTPBarVerticalErrorGraph::usesColumn(int c) const @@ -770,7 +766,7 @@ JKQTPBarVerticalStackableGraph::JKQTPBarVerticalStackableGraph(JKQTBasePlotter * } JKQTPBarVerticalStackableGraph::JKQTPBarVerticalStackableGraph(JKQTPlotter *parent): - JKQTPBarVerticalGraph(parent), stackParent(nullptr) + JKQTPBarVerticalStackableGraph(parent->getPlotter()) { } @@ -827,7 +823,7 @@ JKQTPBarHorizontalStackableGraph::JKQTPBarHorizontalStackableGraph(JKQTBasePlott } JKQTPBarHorizontalStackableGraph::JKQTPBarHorizontalStackableGraph(JKQTPlotter *parent): - JKQTPBarHorizontalGraph(parent), stackParent(nullptr) + JKQTPBarHorizontalStackableGraph(parent->getPlotter()) { } diff --git a/lib/jkqtplotter/jkqtpgraphsbarchart.h b/lib/jkqtplotter/jkqtpgraphsbarchart.h index cbf7d24c6a..2e7280e06e 100644 --- a/lib/jkqtplotter/jkqtpgraphsbarchart.h +++ b/lib/jkqtplotter/jkqtpgraphsbarchart.h @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -24,6 +24,7 @@ #include "jkqtplottertools/jkqtp_imexport.h" #include "jkqtplottertools/jkqtpimagetools.h" #include "jkqtplotter/jkqtpgraphsbase.h" +#include "jkqtplotter/jkqtpgraphsbaseerrors.h" #ifndef jkqtpgraphsbarchart_H #define jkqtpgraphsbarchart_H @@ -93,114 +94,98 @@ class JKQTP_LIB_EXPORT JKQTPBarVerticalGraph: public JKQTPXYGraph { virtual bool isHorizontal() const; - /*! \brief sets the property color ( \copybrief color ) to the specified \a __value. - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual void setColor(const QColor & __value) { this->color = __value; } - /*! \brief returns the property color ( \copybrief color ). - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual QColor getColor() const { return this->color; } - /*! \brief sets the property fillColor ( \copybrief fillColor ) to the specified \a __value. - \details Description of the parameter fillColor is:
    \copydoc fillColor
    - \see fillColor for more information */ + /*! \copydoc fillColor + \see see fillColor for details */ inline virtual void setFillColor(const QColor & __value) { this->fillColor = __value; } - /*! \brief returns the property fillColor ( \copybrief fillColor ). - \details Description of the parameter fillColor is:
    \copydoc fillColor
    - \see fillColor for more information */ + /*! \copydoc fillColor + \see see fillColor for details */ inline virtual QColor getFillColor() const { return this->fillColor; } - /*! \brief sets the property fillStyle ( \copybrief fillStyle ) to the specified \a __value. - \details Description of the parameter fillStyle is:
    \copydoc fillStyle
    - \see fillStyle for more information */ + /*! \copydoc fillStyle + \see see fillStyle for details */ inline virtual void setFillStyle(const Qt::BrushStyle & __value) { this->fillStyle = __value; } - /*! \brief returns the property fillStyle ( \copybrief fillStyle ). - \details Description of the parameter fillStyle is:
    \copydoc fillStyle
    - \see fillStyle for more information */ + /*! \copydoc fillStyle + \see see fillStyle for details */ inline virtual Qt::BrushStyle getFillStyle() const { return this->fillStyle; } - /*! \brief sets the property style ( \copybrief style ) to the specified \a __value. - \details Description of the parameter style is:
    \copydoc style
    - \see style for more information */ + /*! \copydoc style + \see see style for details */ inline virtual void setStyle(const Qt::PenStyle & __value) { this->style = __value; } - /*! \brief returns the property style ( \copybrief style ). - \details Description of the parameter style is:
    \copydoc style
    - \see style for more information */ + /*! \copydoc style + \see see style for details */ inline virtual Qt::PenStyle getStyle() const { return this->style; } - /*! \brief sets the property lineWidth ( \copybrief lineWidth ) to the specified \a __value. - \details Description of the parameter lineWidth is:
    \copydoc lineWidth
    - \see lineWidth for more information */ + /*! \copydoc lineWidth + \see see lineWidth for details */ inline virtual void setLineWidth(double __value) { this->lineWidth = __value; } - /*! \brief returns the property lineWidth ( \copybrief lineWidth ). - \details Description of the parameter lineWidth is:
    \copydoc lineWidth
    - \see lineWidth for more information */ + /*! \copydoc lineWidth + \see see lineWidth for details */ inline virtual double getLineWidth() const { return this->lineWidth; } - /*! \brief sets the property shift ( \copybrief shift ) to the specified \a __value. - \details Description of the parameter shift is:
    \copydoc shift
    - \see shift for more information */ + /*! \copydoc shift + \see see shift for details */ inline virtual void setShift(double __value) { this->shift = __value; } - /*! \brief returns the property shift ( \copybrief shift ). - \details Description of the parameter shift is:
    \copydoc shift
    - \see shift for more information */ + /*! \copydoc shift + \see see shift for details */ inline virtual double getShift() const { return this->shift; } - /*! \brief sets the property width ( \copybrief width ) to the specified \a __value. - \details Description of the parameter width is:
    \copydoc width
    - \see width for more information */ + /*! \copydoc width + \see see width for details */ inline virtual void setWidth(double __value) { this->width = __value; } - /*! \brief returns the property width ( \copybrief width ). - \details Description of the parameter width is:
    \copydoc width
    - \see width for more information */ + /*! \copydoc width + \see see width for details */ inline virtual double getWidth() const { return this->width; } - /*! \brief sets the property baseline ( \copybrief baseline ) to the specified \a __value. - \details Description of the parameter baseline is:
    \copydoc baseline
    - \see baseline for more information */ + /*! \copydoc baseline + \see see baseline for details */ inline virtual void setBaseline(double __value) { this->baseline = __value; } - /*! \brief returns the property baseline ( \copybrief baseline ). - \details Description of the parameter baseline is:
    \copydoc baseline
    - \see baseline for more information */ + /*! \copydoc baseline + \see see baseline for details */ inline virtual double getBaseline() const { return this->baseline; diff --git a/lib/jkqtplotter/jkqtpgraphsbase.cpp b/lib/jkqtplotter/jkqtpgraphsbase.cpp index 54dfeee532..38361872f4 100644 --- a/lib/jkqtplotter/jkqtpgraphsbase.cpp +++ b/lib/jkqtplotter/jkqtpgraphsbase.cpp @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -29,6 +29,8 @@ #include "jkqtplotter/jkqtpbaseelements.h" #include "jkqtplotter/jkqtplotter.h" #include "jkqtpgraphsbase.h" + + #define SmallestGreaterZeroCompare_xvsgz() if ((xvsgz>10.0*DBL_MIN)&&((smallestGreaterZero<10.0*DBL_MIN) || (xvsgzgetPlotStyle(parentPlotStyle).color(); style=parent->getPlotStyle(parentPlotStyle).style(); + lineWidth=parent->getPlotStyle(parentPlotStyle).widthF(); } } @@ -331,6 +334,8 @@ JKQTPSingleColumnGraph::JKQTPSingleColumnGraph(int dataColumn, JKQTBasePlotter * //std::cout<<"got style settings from parent: "<getPlotStyle(parentPlotStyle).color(); style=parent->getPlotStyle(parentPlotStyle).style(); + lineWidth=parent->getPlotStyle(parentPlotStyle).widthF(); + } } @@ -361,6 +366,8 @@ JKQTPSingleColumnGraph::JKQTPSingleColumnGraph(JKQTPlotter *parent): //std::cout<<"got style settings from parent: "<getPlotStyle(parentPlotStyle).color(); style=parent->getPlotStyle(parentPlotStyle).style(); + lineWidth=parent->getPlotStyle(parentPlotStyle).widthF(); + } } @@ -381,6 +388,8 @@ JKQTPSingleColumnGraph::JKQTPSingleColumnGraph(int dataColumn, JKQTPlotter *pare //std::cout<<"got style settings from parent: "<getPlotStyle(parentPlotStyle).color(); style=parent->getPlotStyle(parentPlotStyle).style(); + lineWidth=parent->getPlotStyle(parentPlotStyle).widthF(); + } } @@ -435,7 +444,7 @@ QPen JKQTPSingleColumnGraph::getLinePen(JKQTPEnhancedPainter& painter) const { QPen p; p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH,parent->pt2px(painter, parent->getLineWidthMultiplier()*lineWidth))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH,parent->pt2px(painter, parent->getLineWidthMultiplier()*lineWidth))); p.setStyle(style); p.setJoinStyle(Qt::RoundJoin); p.setCapStyle(Qt::RoundCap); @@ -489,544 +498,6 @@ void JKQTPSingleColumnGraph::intSortData() -JKQTPGraphErrors::JKQTPGraphErrors(QColor graphColor) { - errorColor=graphColor.darker(); - errorStyle=Qt::SolidLine; - errorWidth=2; - errorFillColor=graphColor.lighter(); - errorColor.setAlphaF(0.5); - errorFillStyle=Qt::SolidPattern; - errorbarSize=7; -} - -JKQTPGraphErrors::~JKQTPGraphErrors() -= default; - - - -void JKQTPGraphErrors::intPlotXYErrorIndicators(JKQTPEnhancedPainter& painter, JKQTBasePlotter* parent, JKQTPGraph* parentGraph, int xColumn, int yColumn, int xErrorColumn, int yErrorColumn, JKQTPErrorPlotstyle xErrorStyle, JKQTPErrorPlotstyle yErrorStyle, int xErrorColumnLower, int yErrorColumnLower, bool xErrorSymmetric, bool yErrorSymmetric, double xrelshift, double yrelshift, const QVector* dataorder) { - //std::cout<<"JKQTPGraphErrors::intPlotXYErrorIndicators(p, "<getDatastore(); - if (datastore==nullptr) return; - - if ((yErrorStyle==JKQTPNoError) && (xErrorStyle==JKQTPNoError)) return; - bool visX=(xErrorStyle!=JKQTPNoError)&&(xErrorColumn>=0||xErrorColumnLower>=0)&&(xColumn>=0)&&(yColumn>=0); - bool visY=(yErrorStyle!=JKQTPNoError)&&(yErrorColumn>=0||yErrorColumnLower>=0)&&(xColumn>=0)&&(yColumn>=0); - if (!visX&&!visY) return; - //std::cout<<" JKQTPGraphErrors::intPlotXYErrorIndicators(p, "<pt2px(painter, errorWidth*parent->getLineWidthMultiplier()))); - p.setStyle(errorStyle); - p.setJoinStyle(Qt::RoundJoin); - p.setCapStyle(Qt::RoundCap); - painter.setPen(p); - - unsigned int imaxx=0, imaxy=0; - if (xColumn>=0) imaxx=datastore->getColumn(static_cast(xColumn)).getRows(); - if (yColumn>=0) imaxy=datastore->getColumn(static_cast(yColumn)).getRows(); - int imax=qMin(imaxx, imaxy); - int imin=0; - if (imaxpt2px(painter, errorbarSize); - QPolygonF polyX, polyY; - QList polyXTopPoints, polyXBottomPoints, polyYTopPoints, polyYBottomPoints; - QList errFC, errC; - bool defaultErrorColor=true; - - - /* - * double delta=1; - double deltap=0; - double deltam=0; - for (int i=imin; iget(static_cast(xColumn),static_cast(i)); - double yv=datastore->get(static_cast(yColumn),static_cast(i)); - if (imin==imax) { // only one x-value - deltam=0.5; - deltap=0.5; - } else if (i==imax-1) { // the right-most x-value - deltap=deltam=fabs(xv-datastore->get(xColumn,i-1))/2.0; - } else if (i==imin) { // the left-most x-value - deltam=deltap=fabs(datastore->get(xColumn,i+1)-xv)/2.0; - } else { - deltam=fabs(xv-datastore->get(xColumn,i-1))/2.0; - deltap=fabs(datastore->get(xColumn,i+1)-xv)/2.0; - } - delta=deltap+deltam; - **/ - - for (int iii=imin; iiivalue(iii, iii); - double xv=datastore->get(static_cast(xColumn),static_cast(i)); - double yv=datastore->get(static_cast(yColumn),static_cast(i)); - - double deltax=1; - double deltapx=0; - double deltamx=0; - if (imin==imax) { // only one x-value - deltamx=0.5; - deltapx=0.5; - } else if (i==imax-1&& i-1>=0) { // the right-most x-value - deltapx=deltamx=fabs(xv-datastore->get(xColumn,i-1))/2.0; - } else if (i==imin && i+1get(xColumn,i+1)-xv)/2.0; - } else { - if (i-1>=0) deltamx=fabs(xv-datastore->get(xColumn,i-1))/2.0; - if (i+1get(xColumn,i+1)-xv)/2.0; - } - deltax=deltapx+deltamx; - - double deltay=1; - double deltapy=0; - double deltamy=0; - if (imin==imax) { // only one y-value - deltamy=0.5; - deltapy=0.5; - } else if (i==imax-1&& i-1>=0) { // the right-most y-value - deltapy=deltamy=fabs(yv-datastore->get(yColumn,i-1))/2.0; - } else if (i==imin && i+1get(yColumn,i+1)-yv)/2.0; - } else { - if (i-1>=0) deltamy=fabs(yv-datastore->get(yColumn,i-1))/2.0; - if (i+1get(yColumn,i+1)-yv)/2.0; - } - deltay=deltapy+deltamy; - - bool plotlowerbarx=false; - bool plotupperbarx=false; - bool plotlowerbary=false; - bool plotupperbary=false; - - double xe=0; if (xErrorStyle!=JKQTPNoError && xErrorColumn>=0) { xe=datastore->get(xErrorColumn,i); plotupperbarx=true; } - double ye=0; if (yErrorStyle!=JKQTPNoError && yErrorColumn>=0) { ye=datastore->get(yErrorColumn,i); plotupperbary=true; } - double xl=0; if (xErrorSymmetric) { xl=xe; plotlowerbarx=plotupperbarx||(xl>0); } - else if (xErrorStyle!=JKQTPNoError && xErrorColumnLower>=0) { xl=datastore->get(xErrorColumnLower,i); plotlowerbarx=true; } - double yl=0; if (yErrorSymmetric) { yl=ye; plotlowerbary=plotupperbary||(yl>0); } - else if (yErrorStyle!=JKQTPNoError && yErrorColumnLower>=0) { yl=datastore->get(yErrorColumnLower,i); plotlowerbary=true; } - if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv) && JKQTPIsOKFloat(xe) && JKQTPIsOKFloat(ye) && JKQTPIsOKFloat(xl) && JKQTPIsOKFloat(yl)) { - double x=parentGraph->transformX(xv+xrelshift*deltax); bool xok=JKQTPIsOKFloat(x); - double y=parentGraph->transformY(yv+yrelshift*deltay); bool yok=JKQTPIsOKFloat(y); - QColor terrCol=errorColor; - QColor terrFillCol=errorFillColor; - defaultErrorColor = defaultErrorColor && !this->intPlotXYErrorIndicatorsGetColor(painter, parent, parentGraph, xColumn, yColumn, xErrorColumn, yErrorColumn, xErrorStyle, yErrorStyle, i, terrCol, terrFillCol); - - // x-errorpolygons - if (/*pastFirst &&*/ (xErrorStyle==JKQTPErrorPolygons || xErrorStyle==JKQTPErrorBarsPolygons || xErrorStyle==JKQTPErrorSimpleBarsPolygons)) { - //double xl1m=xmold; - //double xl1p=xpold; - //double yl1=yold; - double xl2m=parentGraph->transformX(xv+xrelshift*deltax-xl); - double xl2p=parentGraph->transformX(xv+xrelshift*deltax+xe); - double yl2=y; - /*painter.save(); - painter.setBrush(b); - painter.setPen(QPen(Qt::NoPen)); - QPolygonF poly; - poly << QPointF(xl1p, yl1) << QPointF(xl1m, yl1) << QPointF(xl2m, yl2) << QPointF(xl2p, yl2); - painter.drawConvexPolygon(poly); - painter.restore();*/ - polyXTopPoints<transformY(yv+yrelshift*deltay-yl); - double yl2p=parentGraph->transformY(yv+yrelshift*deltay+ye); - double xl2=x; - /*painter.save(); - painter.setBrush(b); - painter.setPen(QPen(Qt::NoPen)); - QPolygonF poly; - poly << QPointF(xl1, yl1m) << QPointF(xl2, yl2m) << QPointF(xl2, yl2p) << QPointF(xl1, yl1p); - painter.drawConvexPolygon(poly); - painter.restore();*/ - polyYTopPoints<=xmin && xv<=xmax && yv>=ymin && yv<=ymax) { - //x-errorbars - if ((xErrorColumn>=0 || xErrorColumnLower>=0) && (xErrorStyle==JKQTPErrorBars || xErrorStyle==JKQTPErrorBarsLines|| xErrorStyle==JKQTPErrorBarsPolygons - || xErrorStyle==JKQTPErrorSimpleBars || xErrorStyle==JKQTPErrorSimpleBarsLines|| xErrorStyle==JKQTPErrorSimpleBarsPolygons)) { - double x0=parentGraph->transformX(xv+xrelshift*deltax-xl); bool x0ok=JKQTPIsOKFloat(x0); - double x1=parentGraph->transformX(xv+xrelshift*deltax+xe); bool x1ok=JKQTPIsOKFloat(x1); - painter.save(); - QPen pp=p; - pp.setColor(terrCol); - painter.setPen(pp); - if (x0ok&&x1ok&&xok&&yok) { - painter.drawLine(QLineF(x0, y, x1, y)); - if (xErrorStyle==JKQTPErrorBars || xErrorStyle==JKQTPErrorBarsLines|| xErrorStyle==JKQTPErrorBarsPolygons) { - if (plotlowerbarx) painter.drawLine(QLineF(x0,y-ebs_px/2.0,x0,y+ebs_px/2.0)); - if (plotupperbarx) painter.drawLine(QLineF(x1,y-ebs_px/2.0,x1,y+ebs_px/2.0)); - } - } else if (x0ok&&!x1ok&&xok&&yok) { - painter.drawLine(QLineF(x0, y, x, y)); - if (xErrorStyle==JKQTPErrorBars || xErrorStyle==JKQTPErrorBarsLines|| xErrorStyle==JKQTPErrorBarsPolygons) { - if (plotlowerbarx) painter.drawLine(QLineF(x0,y-ebs_px/2.0,x0,y+ebs_px/2.0)); - } - if (x0transformX(parent->getXMax()),y)); - else painter.drawLine(QLineF(x,y,parentGraph->transformX(parent->getXMin()),y)); - } else if (!x0ok&&x1ok&&xok&&yok) { - painter.drawLine(QLineF(x1, y, x, y)); - if (xErrorStyle==JKQTPErrorBars || xErrorStyle==JKQTPErrorBarsLines|| xErrorStyle==JKQTPErrorBarsPolygons) { - if (plotupperbarx) painter.drawLine(QLineF(x1,y-ebs_px/2.0,x1,y+ebs_px/2.0)); - } - if (x1transformX(parent->getXMin()),y)); - else painter.drawLine(QLineF(x,y,parentGraph->transformX(parent->getXMax()),y)); - } - painter.restore(); - } - // y-errorbars - if ((yErrorColumn>=0 || yErrorColumnLower>=0) && (yErrorStyle==JKQTPErrorBars || yErrorStyle==JKQTPErrorBarsLines || yErrorStyle==JKQTPErrorBarsPolygons - || yErrorStyle==JKQTPErrorSimpleBars || yErrorStyle==JKQTPErrorSimpleBarsLines || yErrorStyle==JKQTPErrorSimpleBarsPolygons)) { - double y0=parentGraph->transformY(yv+yrelshift*deltay-yl); bool y0ok=JKQTPIsOKFloat(y0); - double y1=parentGraph->transformY(yv+yrelshift*deltay+ye); bool y1ok=JKQTPIsOKFloat(y1); - painter.save(); - QPen pp=p; - pp.setColor(terrCol); - painter.setPen(pp); - if (y0ok&&y1ok&&xok&&yok) { - painter.drawLine(QLineF(x, y0, x, y1)); - if (yErrorStyle==JKQTPErrorBars || yErrorStyle==JKQTPErrorBarsLines || yErrorStyle==JKQTPErrorBarsPolygons) { - if (plotlowerbary) painter.drawLine(QLineF(x-ebs_px/2.0,y0,x+ebs_px/2.0,y0)); - if (plotupperbary) painter.drawLine(QLineF(x-ebs_px/2.0,y1,x+ebs_px/2.0,y1)); - } - } else if (y0ok&&!y1ok&&xok&&yok) { // upper errorbar OK, lower errorbar NAN - painter.drawLine(QLineF(x, y0, x, y)); - if (yErrorStyle==JKQTPErrorBars || yErrorStyle==JKQTPErrorBarsLines || yErrorStyle==JKQTPErrorBarsPolygons) { - if (plotlowerbary) painter.drawLine(QLineF(x-ebs_px/2.0,y0,x+ebs_px/2.0,y0)); - } - if (y0transformY(parent->getYMin()))); - else painter.drawLine(QLineF(x,y,x,parentGraph->transformY(parent->getYMax()))); // inverted axis! - } else if (!y0ok&&y1ok&&xok&&yok) { - painter.drawLine(QLineF(x, y1, x, y)); - if (yErrorStyle==JKQTPErrorBars || yErrorStyle==JKQTPErrorBarsLines || yErrorStyle==JKQTPErrorBarsPolygons) { - if (plotupperbary) painter.drawLine(QLineF(x-ebs_px/2.0,y1,x+ebs_px/2.0,y1)); - } - if (y1transformY(parent->getYMax()))); - else painter.drawLine(QLineF(x,y,x,parentGraph->transformY(parent->getYMin()))); - } - - painter.restore(); - } - - // error boxes - if (yErrorStyle==JKQTPErrorBoxes || xErrorStyle==JKQTPErrorBoxes || yErrorStyle==JKQTPErrorEllipses || xErrorStyle==JKQTPErrorEllipses ) { - double y0=parentGraph->transformY(yv+yrelshift*deltay-yl); bool y0ok=JKQTPIsOKFloat(y0); - double y1=parentGraph->transformY(yv+yrelshift*deltay+ye); bool y1ok=JKQTPIsOKFloat(y1); - double x0=parentGraph->transformX(xv+xrelshift*deltax-xl); bool x0ok=JKQTPIsOKFloat(x0); - double x1=parentGraph->transformX(xv+xrelshift*deltax+xe); bool x1ok=JKQTPIsOKFloat(x1); - painter.save(); - QPen pp=p; - pp.setColor(terrCol); - painter.setPen(pp); - QBrush bb=b; - bb.setColor(terrFillCol); - painter.setBrush(bb); - - QRectF errRect=QRectF(QPointF(x0,y0), QPointF(x1,y1)); - if ((y0ok&&y1ok)||(x0ok&&x1ok)) { - if (yErrorStyle==JKQTPErrorEllipses || xErrorStyle==JKQTPErrorEllipses) painter.drawEllipse(errRect); - else painter.drawRect(errRect); - } - - painter.restore(); - } //} - - // x-errorlines - if (pastFirst && (xErrorStyle==JKQTPErrorLines || xErrorStyle==JKQTPErrorBarsLines || xErrorStyle==JKQTPErrorSimpleBarsLines)) { - double xl1m=xmold; - double xl1p=xpold; - double yl1=yold; - double xl2m=parentGraph->transformX(xv+xrelshift*deltax-xl); - double xl2p=parentGraph->transformX(xv+xrelshift*deltax+xe); - double yl2=y; - painter.save(); - QPen pp=p; - pp.setColor(terrCol); - painter.setPen(pp); - if (JKQTPIsOKFloat(xl1m)&&JKQTPIsOKFloat(yl1)&&JKQTPIsOKFloat(xl2m)&&JKQTPIsOKFloat(yl2)) { - painter.drawLine(QLineF(xl1m, yl1, xl2m, yl2)); - } - if (JKQTPIsOKFloat(xl1p)&&JKQTPIsOKFloat(yl1)&&JKQTPIsOKFloat(xl2p)&&JKQTPIsOKFloat(yl2)) { - painter.drawLine(QLineF(xl1p, yl1, xl2p, yl2)); - } - painter.restore(); - } - - - // y-errorlines - if (pastFirst && (yErrorStyle==JKQTPErrorLines || yErrorStyle==JKQTPErrorBarsLines || yErrorStyle==JKQTPErrorSimpleBarsLines)) { - double yl1m=ymold; - double yl1p=ypold; - double xl1=xold; - double yl2m=parentGraph->transformY(yv+yrelshift*deltay-yl); - double yl2p=parentGraph->transformY(yv+yrelshift*deltay+ye); - double xl2=x; - painter.save(); - QPen pp=p; - pp.setColor(terrCol); - painter.setPen(pp); - if (JKQTPIsOKFloat(xl1)&&JKQTPIsOKFloat(yl1m)&&JKQTPIsOKFloat(xl2)&&JKQTPIsOKFloat(yl2m)) { - painter.drawLine(QLineF(xl1, yl1m, xl2, yl2m)); - } - if (JKQTPIsOKFloat(xl1)&&JKQTPIsOKFloat(yl1p)&&JKQTPIsOKFloat(xl2)&&JKQTPIsOKFloat(yl2p)) { - painter.drawLine(QLineF(xl1, yl1p, xl2, yl2p)); - } - painter.restore(); - } - - - - pastFirst=true; - xold=x; - xmold=parentGraph->transformX(xv+xrelshift*deltax-xl); - xpold=parentGraph->transformX(xv+xrelshift*deltax+xe); - yold=y; - ymold=parentGraph->transformY(yv+yrelshift*deltay-yl); - ypold=parentGraph->transformY(yv+yrelshift*deltay+ye); - } - } - // x-errorpolygons - if ((polyXTopPoints.size()>0 || polyXBottomPoints.size()>0) && (xErrorStyle==JKQTPErrorPolygons || xErrorStyle==JKQTPErrorBarsPolygons || xErrorStyle==JKQTPErrorSimpleBarsPolygons)) { - painter.save(); - painter.setBrush(b); - painter.setPen(QPen(Qt::NoPen)); - QPolygonF poly; - //poly << QPointF(xl1p, yl1) << QPointF(xl1m, yl1) << QPointF(xl2m, yl2) << QPointF(xl2p, yl2); - for (int i=0; i=0; i--) { - poly<0 || polyYBottomPoints.size()>0) && (yErrorStyle==JKQTPErrorPolygons || yErrorStyle==JKQTPErrorBarsPolygons || yErrorStyle==JKQTPErrorSimpleBarsPolygons)) { - painter.save(); - painter.setBrush(b); - painter.setPen(QPen(Qt::NoPen)); - QPolygonF poly; - //poly << QPointF(xl1p, yl1) << QPointF(xl1m, yl1) << QPointF(xl2m, yl2) << QPointF(xl2p, yl2); - for (int i=0; i=0; i--) { - poly<xErrorColumn != __value) { - this->xErrorColumn = __value; - if (xErrorColumn>=0 && xErrorStyle==JKQTPNoError) xErrorStyle=JKQTPErrorBars; - } -} - -void JKQTPXGraphErrors::setXErrorColumnLower(int __value) { - if (this->xErrorColumnLower != __value) { - this->xErrorColumnLower = __value; - if (xErrorColumnLower>=0 && xErrorStyle==JKQTPNoError) xErrorStyle=JKQTPErrorBars; - } -} - -void JKQTPXGraphErrors::plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQTBasePlotter* parent, JKQTPGraph *parentGraph, int xColumn, int yColumn, double xrelshift, double yrelshift, const QVector* dataorder) { - intPlotXYErrorIndicators(painter, parent, parentGraph, xColumn, yColumn, xErrorColumn, -1, xErrorStyle, JKQTPNoError, xErrorColumnLower, -1, xErrorSymmetric, true, xrelshift, yrelshift, dataorder); -} - -double JKQTPXGraphErrors::getXErrorU(int i, JKQTPDatastore *ds) const -{ - if (ds && xErrorColumn>=0) { - return ds->get(xErrorColumn, i); - } - return 0.0; -} - -double JKQTPXGraphErrors::getXErrorL(int i, JKQTPDatastore *ds) const -{ - if (ds) { - if (xErrorSymmetric) { if (xErrorColumn>=0) return ds->get(xErrorColumn, i); } - else if (xErrorColumnLower>=0) return ds->get(xErrorColumnLower, i); - } - return 0.0; -} - - - - - - - -JKQTPYGraphErrors::JKQTPYGraphErrors(QColor graphColor): - JKQTPGraphErrors(graphColor) -{ - yErrorColumn=-1; - yErrorSymmetric=true; - yErrorStyle=JKQTPNoError; - yErrorColumnLower=-1; -} - -void JKQTPYGraphErrors::plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQTBasePlotter* parent, JKQTPGraph* parentGraph, int xColumn, int yColumn, double xrelshift, double yrelshift, const QVector* dataorder) { - intPlotXYErrorIndicators(painter, parent, parentGraph, xColumn, yColumn, -1, yErrorColumn, JKQTPNoError, yErrorStyle, -1, yErrorColumnLower, true, yErrorSymmetric, xrelshift, yrelshift, dataorder); -} - -double JKQTPYGraphErrors::getYErrorU(int i, JKQTPDatastore *ds) const -{ - if (ds && yErrorColumn>=0) { - return ds->get(yErrorColumn, i); - } - return 0.0; -} - -double JKQTPYGraphErrors::getYErrorL(int i, JKQTPDatastore *ds) const -{ - if (ds) { - if (yErrorSymmetric) { if (yErrorColumn>=0) return ds->get(yErrorColumn, i); } - else if (yErrorColumnLower>=0) return ds->get(yErrorColumnLower, i); - } - return 0.0; -} - - - - - - - -JKQTPXYGraphErrors::JKQTPXYGraphErrors(QColor graphColor): - JKQTPGraphErrors(graphColor) -{ - xErrorSymmetric=true; - yErrorSymmetric=true; - yErrorColumn=-1; - yErrorStyle=JKQTPNoError; - xErrorColumn=-1; - xErrorStyle=JKQTPNoError; - xErrorColumnLower=-1; - yErrorColumnLower=-1; - -} - -void JKQTPXYGraphErrors::plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQTBasePlotter* parent, JKQTPGraph* parentGraph, int xColumn, int yColumn, double xrelshift, double yrelshift, const QVector* dataorder) { - this->intPlotXYErrorIndicators(painter, parent, parentGraph, xColumn, yColumn, xErrorColumn, yErrorColumn, xErrorStyle, yErrorStyle, xErrorColumnLower, yErrorColumnLower, xErrorSymmetric, yErrorSymmetric, xrelshift, yrelshift, dataorder); -} - -double JKQTPXYGraphErrors::getXErrorU(int i, JKQTPDatastore *ds) const -{ - if (ds && xErrorColumn>=0) { - return ds->get(xErrorColumn, i); - } - return 0.0; -} - -double JKQTPXYGraphErrors::getXErrorL(int i, JKQTPDatastore *ds) const -{ - if (ds && xErrorColumn>=0) { - if (xErrorSymmetric) { if (xErrorColumn>=0) return ds->get(xErrorColumn, i); } - else if (xErrorColumnLower>=0) return ds->get(xErrorColumnLower, i); - } - return 0.0; -} - -double JKQTPXYGraphErrors::getYErrorU(int i, JKQTPDatastore *ds) const -{ - if (ds && yErrorColumn>=0) { - return ds->get(yErrorColumn, i); - } - return 0.0; -} - -double JKQTPXYGraphErrors::getYErrorL(int i, JKQTPDatastore *ds) const -{ - if (ds && yErrorColumn>=0) { - if (yErrorSymmetric) { if (yErrorColumn>=0) return ds->get(yErrorColumn, i); } - else if (yErrorColumnLower>=0) return ds->get(yErrorColumnLower, i); - } - return 0.0; -} - - - - - - - void JKQTPXYGraph::intSortData() @@ -1074,95 +545,6 @@ void JKQTPXYGraph::intSortData() } -bool JKQTPXGraphErrors::errorUsesColumn(int c) const -{ - return c==(xErrorColumn) || (c==xErrorColumnLower); -} - -bool JKQTPGraphErrors::errorUsesColumn(int /*c*/) const -{ - return false; -} - -void JKQTPGraphErrors::setErrorColorFromGraphColor(QColor graphColor) -{ - errorColor=graphColor.darker(); - errorFillColor=graphColor.lighter(); - //errorColor.setAlphaF(0.5); -} - -bool JKQTPYGraphErrors::errorUsesColumn(int c) const -{ - return (c==yErrorColumn) || (c==yErrorColumnLower); -} - -void JKQTPYGraphErrors::setYErrorColumn(int __value) { - if (this->yErrorColumn != __value) { - this->yErrorColumn = __value; - if (yErrorColumn>=0 && yErrorStyle==JKQTPNoError) yErrorStyle=JKQTPErrorBars; - } -} - -void JKQTPYGraphErrors::setYErrorColumnLower(int __value) { - if (this->yErrorColumnLower != __value) { - this->yErrorColumnLower = __value; - if (yErrorColumnLower>=0 && yErrorStyle==JKQTPNoError) yErrorStyle=JKQTPErrorBars; - } -} - -bool JKQTPXYGraphErrors::errorUsesColumn(int c) const -{ - return (c==xErrorColumn)||(c==yErrorColumn)||(c==xErrorColumnLower)||(c==yErrorColumnLower); -} - -void JKQTPXYGraphErrors::setXErrorColumn(int __value) { - if (this->xErrorColumn != __value) { - this->xErrorColumn = __value; - if (xErrorColumn>=0 && xErrorStyle==JKQTPNoError) xErrorStyle=JKQTPErrorBars; - } -} - -void JKQTPXYGraphErrors::setXErrorColumnLower(int __value) { - if (this->xErrorColumnLower != __value) { - this->xErrorColumnLower = __value; - if (xErrorColumnLower>=0 && xErrorStyle==JKQTPNoError) xErrorStyle=JKQTPErrorBars; - } \ -} - -void JKQTPXYGraphErrors::setYErrorColumn(int __value) { - if (this->yErrorColumn != __value) { - this->yErrorColumn = __value; - if (yErrorColumn>=0 && yErrorStyle==JKQTPNoError) yErrorStyle=JKQTPErrorBars; - } -} - -void JKQTPXYGraphErrors::setYErrorColumnLower(int __value) { - if (this->yErrorColumnLower != __value) { - this->yErrorColumnLower = __value; - if (yErrorColumnLower>=0 && yErrorStyle==JKQTPNoError) yErrorStyle=JKQTPErrorBars; - } -} - -void JKQTPXYGraphErrors::setXErrorColumn(size_t __value) -{ - setXErrorColumn(static_cast(__value)); -} - -void JKQTPXYGraphErrors::setXErrorColumnLower(size_t __value) -{ - setXErrorColumnLower(static_cast(__value)); -} - -void JKQTPXYGraphErrors::setYErrorColumn(size_t __value) -{ - setYErrorColumn(static_cast(__value)); -} - -void JKQTPXYGraphErrors::setYErrorColumnLower(size_t __value) -{ - setYErrorColumnLower(static_cast(__value)); -} - JKQTPPlotObject::JKQTPPlotObject(JKQTBasePlotter *parent): JKQTPPlotElement(parent) diff --git a/lib/jkqtplotter/jkqtpgraphsbase.h b/lib/jkqtplotter/jkqtpgraphsbase.h index d9b5c449a1..a5d8d18434 100644 --- a/lib/jkqtplotter/jkqtpgraphsbase.h +++ b/lib/jkqtplotter/jkqtpgraphsbase.h @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -27,8 +27,8 @@ #include "jkqtplottertools/jkqtp_imexport.h" #include "jkqtplottertools/jkqtpimagetools.h" -#ifndef jkqtpgraphsbase_H -#define jkqtpgraphsbase_H +#ifndef JKQTPGRAPHSBASE_H +#define JKQTPGRAPHSBASE_H // forward declarations class JKQTPlotter; @@ -329,52 +329,46 @@ class JKQTP_LIB_EXPORT JKQTPXYGraph: public JKQTPGraph { /** \copydoc JKQTPGraph::usesColumn() */ virtual bool usesColumn(int column) const override; - /*! \brief sets the property xColumn ( \copybrief xColumn ) to the specified \a __value. - \details Description of the parameter xColumn is:
    \copydoc xColumn
    - \see xColumn for more information */ + /*! \copydoc xColumn + \see see xColumn for details */ inline virtual void setXColumn(int __value) { this->xColumn = __value; } - /*! \brief returns the property xColumn ( \copybrief xColumn ). - \details Description of the parameter xColumn is:
    \copydoc xColumn
    - \see xColumn for more information */ + /*! \copydoc xColumn + \see see xColumn for details */ inline virtual int getXColumn() const { return this->xColumn; } /*! \brief sets the property xColumn ( \copybrief xColumn ) to the specified \a __value, where __value is static_cast'ed from size_t to int. \details Description of the parameter xColumn is:
    \copydoc xColumn
    - \see xColumn for more information */ + \see xColumn for more information */ inline virtual void setXColumn (size_t __value) { this->xColumn = static_cast(__value); } - /*! \brief sets the property yColumn ( \copybrief yColumn ) to the specified \a __value. - \details Description of the parameter yColumn is:
    \copydoc yColumn
    - \see yColumn for more information */ + /*! \copydoc yColumn + \see see yColumn for details */ inline virtual void setYColumn(int __value) { this->yColumn = __value; } - /*! \brief returns the property yColumn ( \copybrief yColumn ). - \details Description of the parameter yColumn is:
    \copydoc yColumn
    - \see yColumn for more information */ + /*! \copydoc yColumn + \see see yColumn for details */ inline virtual int getYColumn() const { return this->yColumn; } /*! \brief sets the property yColumn ( \copybrief yColumn ) to the specified \a __value, where __value is static_cast'ed from size_t to int. \details Description of the parameter yColumn is:
    \copydoc yColumn
    - \see yColumn for more information */ + \see yColumn for more information */ inline virtual void setYColumn (size_t __value) { this->yColumn = static_cast(__value); } - /*! \brief sets the property sortData ( \copybrief sortData ) to the specified \a __value. - \details Description of the parameter sortData is:
    \copydoc sortData
    - \see sortData for more information */ + /*! \copydoc sortData + \see see sortData for details */ inline virtual void setDataSortOrder(const DataSortOrder & __value) { this->sortData = __value; } - /*! \brief returns the property sortData ( \copybrief sortData ). - \details Description of the parameter sortData is:
    \copydoc sortData
    - \see sortData for more information */ + /*! \copydoc sortData + \see see sortData for details */ inline virtual DataSortOrder getDataSortOrder() const { return this->sortData; @@ -448,76 +442,66 @@ class JKQTP_LIB_EXPORT JKQTPSingleColumnGraph: public JKQTPGraph { /** \brief returns the color to be used for the key label */ virtual QColor getKeyLabelColor() override ; - /*! \brief sets the property dataColumn ( \copybrief dataColumn ) to the specified \a __value. - \details Description of the parameter dataColumn is:
    \copydoc dataColumn
    - \see dataColumn for more information */ + /*! \copydoc dataColumn + \see see dataColumn for details */ inline virtual void setDataColumn(int __value) { this->dataColumn = __value; } - /*! \brief returns the property dataColumn ( \copybrief dataColumn ). - \details Description of the parameter dataColumn is:
    \copydoc dataColumn
    - \see dataColumn for more information */ + /*! \copydoc dataColumn + \see see dataColumn for details */ inline virtual int getDataColumn() const { return this->dataColumn; } /*! \brief sets the property dataColumn ( \copybrief dataColumn ) to the specified \a __value, where __value is static_cast'ed from size_t to int. \details Description of the parameter dataColumn is:
    \copydoc dataColumn
    - \see dataColumn for more information */ + \see dataColumn for more information */ inline virtual void setDataColumn (size_t __value) { this->dataColumn = static_cast(__value); } - /*! \brief sets the property color ( \copybrief color ) to the specified \a __value. - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual void setColor(const QColor & __value) { this->color = __value; } - /*! \brief returns the property color ( \copybrief color ). - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual QColor getColor() const { return this->color; } - /*! \brief sets the property style ( \copybrief style ) to the specified \a __value. - \details Description of the parameter style is:
    \copydoc style
    - \see style for more information */ + /*! \copydoc style + \see see style for details */ inline virtual void setStyle(const Qt::PenStyle & __value) { this->style = __value; } - /*! \brief returns the property style ( \copybrief style ). - \details Description of the parameter style is:
    \copydoc style
    - \see style for more information */ + /*! \copydoc style + \see see style for details */ inline virtual Qt::PenStyle getStyle() const { return this->style; } - /*! \brief sets the property lineWidth ( \copybrief lineWidth ) to the specified \a __value. - \details Description of the parameter lineWidth is:
    \copydoc lineWidth
    - \see lineWidth for more information */ + /*! \copydoc lineWidth + \see see lineWidth for details */ inline virtual void setLineWidth(double __value) { this->lineWidth = __value; } - /*! \brief returns the property lineWidth ( \copybrief lineWidth ). - \details Description of the parameter lineWidth is:
    \copydoc lineWidth
    - \see lineWidth for more information */ + /*! \copydoc lineWidth + \see see lineWidth for details */ inline virtual double getLineWidth() const { return this->lineWidth; } - /*! \brief sets the property sortData ( \copybrief sortData ) to the specified \a __value. - \details Description of the parameter sortData is:
    \copydoc sortData
    - \see sortData for more information */ + /*! \copydoc sortData + \see see sortData for details */ inline virtual void setDataSortOrder(const DataSortOrder & __value) { this->sortData = __value; } - /*! \brief returns the property sortData ( \copybrief sortData ). - \details Description of the parameter sortData is:
    \copydoc sortData
    - \see sortData for more information */ + /*! \copydoc sortData + \see see sortData for details */ inline virtual DataSortOrder getDataSortOrder() const { return this->sortData; @@ -565,419 +549,4 @@ class JKQTP_LIB_EXPORT JKQTPSingleColumnGraph: public JKQTPGraph { - - -/*! \brief Descendents of this class add data fields for error indicators and methods to plot them to a class. - \ingroup jkqtplotter_basegraphserrors - - This class is meant to be used with multiple inheritance. I.e. if you implemented some kind of plot - you may derive an error plot class in which you will have to overwrite the JKQTPGraph::drawErrorsBefor() - or drawErrorsAfter() so it calls the plotErrorIndicators() method from this class. In addition this class - will add some public datamemebers and methods to your class that allow to specify the properties of the - error indicators (plot properties: color, width, ... and columns for the data). - - \image html jkqtplotter_simpletest_errorbarstyles.png "line-graphs with different types of error indicators" - - - \see \ref jkqtplotter_graphsgroup_classstructure_mixins - - */ -class JKQTP_LIB_EXPORT JKQTPGraphErrors { - public: - /** \brief class contructor */ - JKQTPGraphErrors(QColor graphColor=QColor("black")); - virtual ~JKQTPGraphErrors(); - - /*! \brief sets the property errorColor ( \copybrief errorColor ) to the specified \a __value. - \details Description of the parameter errorColor is:
    \copydoc errorColor
    - \see errorColor for more information */ - inline virtual void setErrorColor(const QColor & __value) - { - this->errorColor = __value; - } - /*! \brief returns the property errorColor ( \copybrief errorColor ). - \details Description of the parameter errorColor is:
    \copydoc errorColor
    - \see errorColor for more information */ - inline virtual QColor getErrorColor() const - { - return this->errorColor; - } - /*! \brief sets the property errorStyle ( \copybrief errorStyle ) to the specified \a __value. - \details Description of the parameter errorStyle is:
    \copydoc errorStyle
    - \see errorStyle for more information */ - inline virtual void setErrorStyle(const Qt::PenStyle & __value) - { - this->errorStyle = __value; - } - /*! \brief returns the property errorStyle ( \copybrief errorStyle ). - \details Description of the parameter errorStyle is:
    \copydoc errorStyle
    - \see errorStyle for more information */ - inline virtual Qt::PenStyle getErrorStyle() const - { - return this->errorStyle; - } - /*! \brief sets the property errorWidth ( \copybrief errorWidth ) to the specified \a __value. - \details Description of the parameter errorWidth is:
    \copydoc errorWidth
    - \see errorWidth for more information */ - inline virtual void setErrorWidth(double __value) - { - this->errorWidth = __value; - } - /*! \brief returns the property errorWidth ( \copybrief errorWidth ). - \details Description of the parameter errorWidth is:
    \copydoc errorWidth
    - \see errorWidth for more information */ - inline virtual double getErrorWidth() const - { - return this->errorWidth; - } - /*! \brief sets the property errorFillColor ( \copybrief errorFillColor ) to the specified \a __value. - \details Description of the parameter errorFillColor is:
    \copydoc errorFillColor
    - \see errorFillColor for more information */ - inline virtual void setErrorFillColor(const QColor & __value) - { - this->errorFillColor = __value; - } - /*! \brief returns the property errorFillColor ( \copybrief errorFillColor ). - \details Description of the parameter errorFillColor is:
    \copydoc errorFillColor
    - \see errorFillColor for more information */ - inline virtual QColor getErrorFillColor() const - { - return this->errorFillColor; - } - /*! \brief sets the property errorFillStyle ( \copybrief errorFillStyle ) to the specified \a __value. - \details Description of the parameter errorFillStyle is:
    \copydoc errorFillStyle
    - \see errorFillStyle for more information */ - inline virtual void setErrorFillStyle(const Qt::BrushStyle & __value) - { - this->errorFillStyle = __value; - } - /*! \brief returns the property errorFillStyle ( \copybrief errorFillStyle ). - \details Description of the parameter errorFillStyle is:
    \copydoc errorFillStyle
    - \see errorFillStyle for more information */ - inline virtual Qt::BrushStyle getErrorFillStyle() const - { - return this->errorFillStyle; - } - /*! \brief sets the property errorbarSize ( \copybrief errorbarSize ) to the specified \a __value. - \details Description of the parameter errorbarSize is:
    \copydoc errorbarSize
    - \see errorbarSize for more information */ - inline virtual void setErrorbarSize(double __value) - { - this->errorbarSize = __value; - } - /*! \brief returns the property errorbarSize ( \copybrief errorbarSize ). - \details Description of the parameter errorbarSize is:
    \copydoc errorbarSize
    - \see errorbarSize for more information */ - inline virtual double getErrorbarSize() const - { - return this->errorbarSize; - } - /** \brief returns true, if the error plots use the given column */ - virtual bool errorUsesColumn(int c) const; - - void setErrorColorFromGraphColor(QColor graphColor); - - protected: - /** \brief color of the error lines/bars */ - QColor errorColor; - /** \brief linestyle of the error lines/bars */ - Qt::PenStyle errorStyle; - /** \brief width (pixels) of the error lines/bars */ - double errorWidth; - /** \brief fill color for error polygons */ - QColor errorFillColor; - /** \brief fill style for error polygons */ - Qt::BrushStyle errorFillStyle; - /** \brief size of the error bar end markers [pixels] */ - double errorbarSize; - - /** \brief draw error indicators with the parameters defined in this class. The position of the datapoints is - * given by the \a xColumn and \a yColumn. It is also possible to specify a datarange. This method is called by - * the JKQTPGraph descendents */ - virtual void plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQTBasePlotter* parent, JKQTPGraph* parentGraph, int xColumn, int yColumn, double xrelshift=0, double yrelshift=0.0, const QVector* dataorder=nullptr)=0; - - /** \brief draw error indicators with the parameters defined in this class. The position of the datapoints is - * given by the \a xColumn and \a yColumn. It is also possible to specify a datarange. */ - void intPlotXYErrorIndicators(JKQTPEnhancedPainter& painter, JKQTBasePlotter* parent, JKQTPGraph* parentGraph, int xColumn, int yColumn, int xErrorColumn, int yErrorColumn, JKQTPErrorPlotstyle xErrorStyle, JKQTPErrorPlotstyle yErrorStyle, int xErrorColumnLower=-1, int yErrorColumnLower=-1, bool xErrorSymmetric=true, bool yErrorSymmetric=true, double xrelshift=0, double yrelshift=0.0, const QVector *dataorder=nullptr); - - /** \brief this function can be used to set the color of the error indicators automatically - * - * return \c true and the colors to use, if applicable, the default implementation returns false */ - virtual bool intPlotXYErrorIndicatorsGetColor(JKQTPEnhancedPainter& painter, JKQTBasePlotter* parent, JKQTPGraph* parentGraph, int xColumn, int yColumn, int xErrorColumn, int yErrorColumn, JKQTPErrorPlotstyle xErrorStyle, JKQTPErrorPlotstyle yErrorStyle, int index, QColor& errorColor, QColor& errorFillColor); - - - virtual double getXErrorU(int i, JKQTPDatastore* ds) const; - virtual double getXErrorL(int i, JKQTPDatastore* ds) const; - virtual double getYErrorU(int i, JKQTPDatastore* ds) const; - virtual double getYErrorL(int i, JKQTPDatastore* ds) const; - - //** \brief plot a single error indicator */ - //void intPlotXYErrorIndicator(JKQTPEnhancedPainter& painter, double x, double xperror, double xmerror, double y, double yperror, double ymerror, JKQTPErrorPlotstyle xErrorStyle=JKQTPNoError, JKQTPErrorPlotstyle yErrorStyle=JKQTPNoError, double lastx=0, double lastxperror=0, double lastxmerror=0, double lasty=0, double lastyperror=0, double lastymerror=0); -}; - - -/*! \brief This class adds data fields for error indicators in x direction to a JKQTPGraph descendent. - \ingroup jkqtplotter_basegraphserrors - \see JKQTPGraphErrors, \ref jkqtplotter_graphsgroup_classstructure_mixins - */ -class JKQTP_LIB_EXPORT JKQTPXGraphErrors: public JKQTPGraphErrors { - public: - /** \brief class contructor */ - JKQTPXGraphErrors(QColor graphColor=QColor("black")); - - /*! \brief sets the property xErrorSymmetric ( \copybrief xErrorSymmetric ) to the specified \a __value. - \details Description of the parameter xErrorSymmetric is:
    \copydoc xErrorSymmetric
    - \see xErrorSymmetric for more information */ - inline virtual void setXErrorSymmetric(bool __value) - { - this->xErrorSymmetric = __value; - } - /*! \brief returns the property xErrorSymmetric ( \copybrief xErrorSymmetric ). - \details Description of the parameter xErrorSymmetric is:
    \copydoc xErrorSymmetric
    - \see xErrorSymmetric for more information */ - inline virtual bool getXErrorSymmetric() const - { - return this->xErrorSymmetric; - } - /*! \brief returns the property xErrorColumnLower ( \copybrief xErrorColumnLower ). \details Description of the parameter xErrorColumnLower is:
    \copydoc xErrorColumnLower
    . \see xErrorColumnLower for more information */ - inline int getXErrorColumnLower() const { return this->xErrorColumnLower; } - /*! \brief returns the property xErrorColumn ( \copybrief xErrorColumn ). \details Description of the parameter xErrorColumn is:
    \copydoc xErrorColumn
    . \see xErrorColumn for more information */ - inline int getXErrorColumn() const { return this->xErrorColumn; } - /*! \brief sets the property xErrorStyle ( \copybrief xErrorStyle ) to the specified \a __value. - \details Description of the parameter xErrorStyle is:
    \copydoc xErrorStyle
    - \see xErrorStyle for more information */ - inline virtual void setXErrorStyle(const JKQTPErrorPlotstyle & __value) - { - this->xErrorStyle = __value; - } - /*! \brief returns the property xErrorStyle ( \copybrief xErrorStyle ). - \details Description of the parameter xErrorStyle is:
    \copydoc xErrorStyle
    - \see xErrorStyle for more information */ - inline virtual JKQTPErrorPlotstyle getXErrorStyle() const - { - return this->xErrorStyle; - } - /** \brief set the column from which to read the error values for x-error indicators */ - void setXErrorColumn(int __value); - /** \brief set the column from which to read the error values for lower x-error indicators (if not set [=-1], the xErrorColumn-values will be used for upper and lower error indicators) */ - void setXErrorColumnLower(int __value); - - /** \brief returns true, if the error plots use the given column */ - virtual bool errorUsesColumn(int c) const override; - - protected: - /** \brief the column that contains the error of the x-component of the datapoints */ - int xErrorColumn; - /** \brief the column that contains the error of the x-component of the datapoints. This is used as the lower error length, if xErrorSymmetric \c ==false. */ - int xErrorColumnLower; - /** \brief indicates whether the x-errors are symmetric (from one column only) */ - bool xErrorSymmetric; - /** \brief how to draw the errors (if available) of the x-value */ - JKQTPErrorPlotstyle xErrorStyle; - - /** \brief draw error indicators with the parameters defined in this class. The position of the datapoints is - * given by the \a xColumn and \a yColumn. It is also possible to specify a datarange. */ - virtual void plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQTBasePlotter* parent, JKQTPGraph* parentGraph, int xColumn, int yColumn, double xrelshift=0, double yrelshift=0.0, const QVector *dataorder=nullptr) override; - - virtual double getXErrorU(int i, JKQTPDatastore* ds) const override; - virtual double getXErrorL(int i, JKQTPDatastore* ds) const override; - -}; - - -/*! \brief This class adds data fields for error indicators in y direction to a class. - \ingroup jkqtplotter_basegraphserrors - \see JKQTPGraphErrors, \ref jkqtplotter_graphsgroup_classstructure_mixins - - */ -class JKQTP_LIB_EXPORT JKQTPYGraphErrors: public JKQTPGraphErrors { - public: - /** \brief class contructor */ - JKQTPYGraphErrors(QColor graphColor=QColor("black")); - - /*! \brief sets the property yErrorSymmetric ( \copybrief yErrorSymmetric ) to the specified \a __value. - \details Description of the parameter yErrorSymmetric is:
    \copydoc yErrorSymmetric
    - \see yErrorSymmetric for more information */ - inline virtual void setYErrorSymmetric(bool __value) - { - this->yErrorSymmetric = __value; - } - /*! \brief returns the property yErrorSymmetric ( \copybrief yErrorSymmetric ). - \details Description of the parameter yErrorSymmetric is:
    \copydoc yErrorSymmetric
    - \see yErrorSymmetric for more information */ - inline virtual bool getYErrorSymmetric() const - { - return this->yErrorSymmetric; - } - /*! \brief returns the property yErrorColumnLower ( \copybrief yErrorColumnLower ). \details Description of the parameter yErrorColumnLower is:
    \copydoc yErrorColumnLower
    . \see yErrorColumnLower for more information */ - inline int getYErrorColumnLower() const { return this->yErrorColumnLower; } - /*! \brief returns the property yErrorColumn ( \copybrief yErrorColumn ). \details Description of the parameter yErrorColumn is:
    \copydoc yErrorColumn
    . \see yErrorColumn for more information */ - inline int getYErrorColumn() const { return this->yErrorColumn; } - /*! \brief sets the property yErrorStyle ( \copybrief yErrorStyle ) to the specified \a __value. - \details Description of the parameter yErrorStyle is:
    \copydoc yErrorStyle
    - \see yErrorStyle for more information */ - inline virtual void setYErrorStyle(const JKQTPErrorPlotstyle & __value) - { - this->yErrorStyle = __value; - } - /*! \brief returns the property yErrorStyle ( \copybrief yErrorStyle ). - \details Description of the parameter yErrorStyle is:
    \copydoc yErrorStyle
    - \see yErrorStyle for more information */ - inline virtual JKQTPErrorPlotstyle getYErrorStyle() const - { - return this->yErrorStyle; - } - /** \copydoc JKQTPGraphErrors::errorUsesColumn() */ - virtual bool errorUsesColumn(int c) const override; - - /** \brief set the column from which to read the error values for y-error indicators */ - void setYErrorColumn(int __value); - /** \brief set the column from which to read the error values for lower y-error indicators (if not set [=-1], the xErrorColumn-values will be used for upper and lower error indicators) */ - void setYErrorColumnLower(int __value); - protected: - /** \brief the column that contains the error of the x-component of the datapoints */ - int yErrorColumn; - /** \brief how to draw the errors (if available) of the x-value */ - JKQTPErrorPlotstyle yErrorStyle; - /** \brief indicates whether the y-errors are symmetric (from one column only) */ - bool yErrorSymmetric; - /** \brief the column that contains the error of the y-component of the datapoints. This is used as the lower error length, if yErrorSymmetric \c ==false. */ - int yErrorColumnLower; - - /** \brief draw error indicators with the parameters defined in this class. The position of the datapoints is - * given by the \a xColumn and \a yColumn. It is also possible to specify a datarange. */ - virtual void plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQTBasePlotter* parent, JKQTPGraph* parentGraph, int xColumn, int yColumn, double xrelshift=0, double yrelshift=0.0, const QVector *dataorder=nullptr) override; - - virtual double getYErrorU(int i, JKQTPDatastore* ds) const override; - virtual double getYErrorL(int i, JKQTPDatastore* ds) const override; -}; - - -/*! \brief This class adds data fields for error indicators in x and y direction to a class. - \ingroup jkqtplotter_basegraphserrors - \see JKQTPGraphErrors, \ref jkqtplotter_graphsgroup_classstructure_mixins - - */ -class JKQTP_LIB_EXPORT JKQTPXYGraphErrors: public JKQTPGraphErrors { - public: - /** \brief class contructor */ - JKQTPXYGraphErrors(QColor graphColor=QColor("black")); - /*! \brief sets the property xErrorSymmetric ( \copybrief xErrorSymmetric ) to the specified \a __value. - \details Description of the parameter xErrorSymmetric is:
    \copydoc xErrorSymmetric
    - \see xErrorSymmetric for more information */ - inline virtual void setXErrorSymmetric(bool __value) - { - this->xErrorSymmetric = __value; - } - /*! \brief returns the property xErrorSymmetric ( \copybrief xErrorSymmetric ). - \details Description of the parameter xErrorSymmetric is:
    \copydoc xErrorSymmetric
    - \see xErrorSymmetric for more information */ - inline virtual bool getXErrorSymmetric() const - { - return this->xErrorSymmetric; - } - /*! \brief sets the property yErrorSymmetric ( \copybrief yErrorSymmetric ) to the specified \a __value. - \details Description of the parameter yErrorSymmetric is:
    \copydoc yErrorSymmetric
    - \see yErrorSymmetric for more information */ - inline virtual void setYErrorSymmetric(bool __value) - { - this->yErrorSymmetric = __value; - } - /*! \brief returns the property yErrorSymmetric ( \copybrief yErrorSymmetric ). - \details Description of the parameter yErrorSymmetric is:
    \copydoc yErrorSymmetric
    - \see yErrorSymmetric for more information */ - inline virtual bool getYErrorSymmetric() const - { - return this->yErrorSymmetric; - } - /*! \brief returns the property xErrorColumnLower ( \copybrief xErrorColumnLower ). \details Description of the parameter xErrorColumnLower is:
    \copydoc xErrorColumnLower
    . \see xErrorColumnLower for more information */ - inline int getXErrorColumnLower() const { return this->xErrorColumnLower; } - /*! \brief returns the property xErrorColumn ( \copybrief xErrorColumn ). \details Description of the parameter xErrorColumn is:
    \copydoc xErrorColumn
    . \see xErrorColumn for more information */ - inline int getXErrorColumn() const { return this->xErrorColumn; } - /*! \brief returns the property yErrorColumnLower ( \copybrief yErrorColumnLower ). \details Description of the parameter yErrorColumnLower is:
    \copydoc yErrorColumnLower
    . \see yErrorColumnLower for more information */ - inline int getYErrorColumnLower() const { return this->yErrorColumnLower; } - /*! \brief returns the property yErrorColumn ( \copybrief yErrorColumn ). \details Description of the parameter yErrorColumn is:
    \copydoc yErrorColumn
    . \see yErrorColumn for more information */ - inline int getYErrorColumn() const { return this->yErrorColumn; } - /*! \brief sets the property yErrorStyle ( \copybrief yErrorStyle ) to the specified \a __value. - \details Description of the parameter yErrorStyle is:
    \copydoc yErrorStyle
    - \see yErrorStyle for more information */ - inline virtual void setYErrorStyle(const JKQTPErrorPlotstyle & __value) - { - this->yErrorStyle = __value; - } - /*! \brief returns the property yErrorStyle ( \copybrief yErrorStyle ). - \details Description of the parameter yErrorStyle is:
    \copydoc yErrorStyle
    - \see yErrorStyle for more information */ - inline virtual JKQTPErrorPlotstyle getYErrorStyle() const - { - return this->yErrorStyle; - } - /*! \brief sets the property xErrorStyle ( \copybrief xErrorStyle ) to the specified \a __value. - \details Description of the parameter xErrorStyle is:
    \copydoc xErrorStyle
    - \see xErrorStyle for more information */ - inline virtual void setXErrorStyle(const JKQTPErrorPlotstyle & __value) - { - this->xErrorStyle = __value; - } - /*! \brief returns the property xErrorStyle ( \copybrief xErrorStyle ). - \details Description of the parameter xErrorStyle is:
    \copydoc xErrorStyle
    - \see xErrorStyle for more information */ - inline virtual JKQTPErrorPlotstyle getXErrorStyle() const - { - return this->xErrorStyle; - } - /** \copydoc JKQTPGraphErrors::errorUsesColumn() */ - virtual bool errorUsesColumn(int c) const override; - - /** \brief set the column from which to read the error values for x-error indicators */ - void setXErrorColumn(int __value); - /** \brief set the column from which to read the error values for lower x-error indicators (if not set [=-1], the xErrorColumn-values will be used for upper and lower error indicators) */ - void setXErrorColumnLower(int __value); - /** \brief set the column from which to read the error values for x-error indicators */ - void setYErrorColumn(int __value); - /** \brief set the column from which to read the error values for lower x-error indicators (if not set [=-1], the xErrorColumn-values will be used for upper and lower error indicators) */ - void setYErrorColumnLower(int __value); - /** \brief set the column from which to read the error values for y-error indicators */ - void setXErrorColumn(size_t __value); - /** \brief set the column from which to read the error values for lower y-error indicators (if not set [=-1], the xErrorColumn-values will be used for upper and lower error indicators) */ - void setXErrorColumnLower(size_t __value); - /** \brief set the column from which to read the error values for y-error indicators */ - void setYErrorColumn(size_t __value); - /** \brief set the column from which to read the error values for lower y-error indicators (if not set [=-1], the xErrorColumn-values will be used for upper and lower error indicators) */ - void setYErrorColumnLower(size_t __value); - - protected: - /** \brief the column that contains the error of the x-component of the datapoints */ - int yErrorColumn; - /** \brief how to draw the errors (if available) of the x-value */ - JKQTPErrorPlotstyle yErrorStyle; - /** \brief the column that contains the error of the x-component of the datapoints */ - int xErrorColumn; - /** \brief how to draw the errors (if available) of the x-value */ - JKQTPErrorPlotstyle xErrorStyle; - /** \brief indicates whether the x-errors are symmetric (from one column only) */ - bool xErrorSymmetric; - /** \brief indicates whether the y-errors are symmetric (from one column only) */ - bool yErrorSymmetric; - /** \brief the column that contains the error of the x-component of the datapoints. This is used as the lower error length, if xErrorSymmetric \c ==false. */ - int xErrorColumnLower; - /** \brief the column that contains the error of the y-component of the datapoints. This is used as the lower error length, if yErrorSymmetric \c ==false. */ - int yErrorColumnLower; - - /** \brief draw error indicators with the parameters defined in this class. The position of the datapoints is - * given by the \a xColumn and \a yColumn. It is also possible to specify a datarange. */ - virtual void plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQTBasePlotter* parent, JKQTPGraph* parentGraph, int xColumn, int yColumn, double xrelshift=0, double yrelshift=0.0, const QVector *dataorder=nullptr) override; - - virtual double getXErrorU(int i, JKQTPDatastore* ds) const override; - virtual double getXErrorL(int i, JKQTPDatastore* ds) const override; - virtual double getYErrorU(int i, JKQTPDatastore* ds) const override; - virtual double getYErrorL(int i, JKQTPDatastore* ds) const override; -}; - - - - - - - -#endif // jkqtpgraphsbase_H +#endif // JKQTPGRAPHSBASE_H diff --git a/lib/jkqtplotter/jkqtpgraphsbaseerrors.cpp b/lib/jkqtplotter/jkqtpgraphsbaseerrors.cpp new file mode 100644 index 0000000000..a2757ec243 --- /dev/null +++ b/lib/jkqtplotter/jkqtpgraphsbaseerrors.cpp @@ -0,0 +1,680 @@ +/* + Copyright (c) 2008-2019 Jan W. Krieger () + + + + 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 . +*/ + + + +#include "jkqtplotter/jkqtpgraphsbaseerrors.h" +#include "jkqtplotter/jkqtpbaseplotter.h" +#include +#include +#include +#include "jkqtplottertools/jkqtptools.h" +#include "jkqtplotter/jkqtpgraphsimage.h" +#include "jkqtplotter/jkqtpbaseelements.h" +#include "jkqtplotter/jkqtplotter.h" +#include "jkqtpgraphsbase.h" + + +#define SmallestGreaterZeroCompare_xvsgz() if ((xvsgz>10.0*DBL_MIN)&&((smallestGreaterZero<10.0*DBL_MIN) || (xvsgzgetCurrentPlotterStyle().defaultGraphSymbolLineWidth; + errorbarSize=basePlotter->getCurrentPlotterStyle().defaultGraphSymbolSize*0.75; + } +} + +void JKQTPGraphErrors::setErrorStyleFromPen(const JKQTBasePlotter::JKQTPPen &pen) +{ + errorWidth=pen.errorWidthF(); + errorColor=pen.errorColor(); + errorFillColor=pen.errorFillColor(); + errorFillStyle=pen.errorFillStyle(); + errorStyle=pen.errorStyle(); + errorbarSize=pen.symbolSize()*0.75; +} + + + +void JKQTPGraphErrors::intPlotXYErrorIndicators(JKQTPEnhancedPainter& painter, JKQTBasePlotter* parent, JKQTPGraph* parentGraph, int xColumn, int yColumn, int xErrorColumn, int yErrorColumn, JKQTPErrorPlotstyle xErrorStyle, JKQTPErrorPlotstyle yErrorStyle, int xErrorColumnLower, int yErrorColumnLower, bool xErrorSymmetric, bool yErrorSymmetric, double xrelshift, double yrelshift, const QVector* dataorder) { + //std::cout<<"JKQTPGraphErrors::intPlotXYErrorIndicators(p, "<getDatastore(); + if (datastore==nullptr) return; + + if ((yErrorStyle==JKQTPNoError) && (xErrorStyle==JKQTPNoError)) return; + bool visX=(xErrorStyle!=JKQTPNoError)&&(xErrorColumn>=0||xErrorColumnLower>=0)&&(xColumn>=0)&&(yColumn>=0); + bool visY=(yErrorStyle!=JKQTPNoError)&&(yErrorColumn>=0||yErrorColumnLower>=0)&&(xColumn>=0)&&(yColumn>=0); + if (!visX&&!visY) return; + //std::cout<<" JKQTPGraphErrors::intPlotXYErrorIndicators(p, "<pt2px(painter, errorWidth*parent->getLineWidthMultiplier()))); + p.setStyle(errorStyle); + p.setJoinStyle(Qt::RoundJoin); + p.setCapStyle(Qt::RoundCap); + painter.setPen(p); + + unsigned int imaxx=0, imaxy=0; + if (xColumn>=0) imaxx=datastore->getColumn(static_cast(xColumn)).getRows(); + if (yColumn>=0) imaxy=datastore->getColumn(static_cast(yColumn)).getRows(); + int imax=qMin(imaxx, imaxy); + int imin=0; + if (imaxpt2px(painter, errorbarSize); + QPolygonF polyX, polyY; + QList polyXTopPoints, polyXBottomPoints, polyYTopPoints, polyYBottomPoints; + QList errFC, errC; + bool defaultErrorColor=true; + + + /* + * double delta=1; + double deltap=0; + double deltam=0; + for (int i=imin; iget(static_cast(xColumn),static_cast(i)); + double yv=datastore->get(static_cast(yColumn),static_cast(i)); + if (imin==imax) { // only one x-value + deltam=0.5; + deltap=0.5; + } else if (i==imax-1) { // the right-most x-value + deltap=deltam=fabs(xv-datastore->get(xColumn,i-1))/2.0; + } else if (i==imin) { // the left-most x-value + deltam=deltap=fabs(datastore->get(xColumn,i+1)-xv)/2.0; + } else { + deltam=fabs(xv-datastore->get(xColumn,i-1))/2.0; + deltap=fabs(datastore->get(xColumn,i+1)-xv)/2.0; + } + delta=deltap+deltam; + **/ + + for (int iii=imin; iiivalue(iii, iii); + double xv=datastore->get(static_cast(xColumn),static_cast(i)); + double yv=datastore->get(static_cast(yColumn),static_cast(i)); + + double deltax=1; + double deltapx=0; + double deltamx=0; + if (imin==imax) { // only one x-value + deltamx=0.5; + deltapx=0.5; + } else if (i==imax-1&& i-1>=0) { // the right-most x-value + deltapx=deltamx=fabs(xv-datastore->get(xColumn,i-1))/2.0; + } else if (i==imin && i+1get(xColumn,i+1)-xv)/2.0; + } else { + if (i-1>=0) deltamx=fabs(xv-datastore->get(xColumn,i-1))/2.0; + if (i+1get(xColumn,i+1)-xv)/2.0; + } + deltax=deltapx+deltamx; + + double deltay=1; + double deltapy=0; + double deltamy=0; + if (imin==imax) { // only one y-value + deltamy=0.5; + deltapy=0.5; + } else if (i==imax-1&& i-1>=0) { // the right-most y-value + deltapy=deltamy=fabs(yv-datastore->get(yColumn,i-1))/2.0; + } else if (i==imin && i+1get(yColumn,i+1)-yv)/2.0; + } else { + if (i-1>=0) deltamy=fabs(yv-datastore->get(yColumn,i-1))/2.0; + if (i+1get(yColumn,i+1)-yv)/2.0; + } + deltay=deltapy+deltamy; + + bool plotlowerbarx=false; + bool plotupperbarx=false; + bool plotlowerbary=false; + bool plotupperbary=false; + + double xe=0; if (xErrorStyle!=JKQTPNoError && xErrorColumn>=0) { xe=datastore->get(xErrorColumn,i); plotupperbarx=true; } + double ye=0; if (yErrorStyle!=JKQTPNoError && yErrorColumn>=0) { ye=datastore->get(yErrorColumn,i); plotupperbary=true; } + double xl=0; if (xErrorSymmetric) { xl=xe; plotlowerbarx=plotupperbarx||(xl>0); } + else if (xErrorStyle!=JKQTPNoError && xErrorColumnLower>=0) { xl=datastore->get(xErrorColumnLower,i); plotlowerbarx=true; } + double yl=0; if (yErrorSymmetric) { yl=ye; plotlowerbary=plotupperbary||(yl>0); } + else if (yErrorStyle!=JKQTPNoError && yErrorColumnLower>=0) { yl=datastore->get(yErrorColumnLower,i); plotlowerbary=true; } + if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv) && JKQTPIsOKFloat(xe) && JKQTPIsOKFloat(ye) && JKQTPIsOKFloat(xl) && JKQTPIsOKFloat(yl)) { + double x=parentGraph->transformX(xv+xrelshift*deltax); bool xok=JKQTPIsOKFloat(x); + double y=parentGraph->transformY(yv+yrelshift*deltay); bool yok=JKQTPIsOKFloat(y); + QColor terrCol=errorColor; + QColor terrFillCol=errorFillColor; + defaultErrorColor = defaultErrorColor && !this->intPlotXYErrorIndicatorsGetColor(painter, parent, parentGraph, xColumn, yColumn, xErrorColumn, yErrorColumn, xErrorStyle, yErrorStyle, i, terrCol, terrFillCol); + + // x-errorpolygons + if (/*pastFirst &&*/ (xErrorStyle==JKQTPErrorPolygons || xErrorStyle==JKQTPErrorBarsPolygons || xErrorStyle==JKQTPErrorSimpleBarsPolygons)) { + //double xl1m=xmold; + //double xl1p=xpold; + //double yl1=yold; + double xl2m=parentGraph->transformX(xv+xrelshift*deltax-xl); + double xl2p=parentGraph->transformX(xv+xrelshift*deltax+xe); + double yl2=y; + /*painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.setBrush(b); + painter.setPen(QPen(Qt::NoPen)); + QPolygonF poly; + poly << QPointF(xl1p, yl1) << QPointF(xl1m, yl1) << QPointF(xl2m, yl2) << QPointF(xl2p, yl2); + painter.drawConvexPolygon(poly); + */ + polyXTopPoints<transformY(yv+yrelshift*deltay-yl); + double yl2p=parentGraph->transformY(yv+yrelshift*deltay+ye); + double xl2=x; + /*painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.setBrush(b); + painter.setPen(QPen(Qt::NoPen)); + QPolygonF poly; + poly << QPointF(xl1, yl1m) << QPointF(xl2, yl2m) << QPointF(xl2, yl2p) << QPointF(xl1, yl1p); + painter.drawConvexPolygon(poly); + */ + polyYTopPoints<=xmin && xv<=xmax && yv>=ymin && yv<=ymax) { + //x-errorbars + if ((xErrorColumn>=0 || xErrorColumnLower>=0) && (xErrorStyle==JKQTPErrorBars || xErrorStyle==JKQTPErrorBarsLines|| xErrorStyle==JKQTPErrorBarsPolygons + || xErrorStyle==JKQTPErrorSimpleBars || xErrorStyle==JKQTPErrorSimpleBarsLines|| xErrorStyle==JKQTPErrorSimpleBarsPolygons)) { + double x0=parentGraph->transformX(xv+xrelshift*deltax-xl); bool x0ok=JKQTPIsOKFloat(x0); + double x1=parentGraph->transformX(xv+xrelshift*deltax+xe); bool x1ok=JKQTPIsOKFloat(x1); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + QPen pp=p; + pp.setColor(terrCol); + painter.setPen(pp); + if (x0ok&&x1ok&&xok&&yok) { + painter.drawLine(QLineF(x0, y, x1, y)); + if (xErrorStyle==JKQTPErrorBars || xErrorStyle==JKQTPErrorBarsLines|| xErrorStyle==JKQTPErrorBarsPolygons) { + if (plotlowerbarx) painter.drawLine(QLineF(x0,y-ebs_px/2.0,x0,y+ebs_px/2.0)); + if (plotupperbarx) painter.drawLine(QLineF(x1,y-ebs_px/2.0,x1,y+ebs_px/2.0)); + } + } else if (x0ok&&!x1ok&&xok&&yok) { + painter.drawLine(QLineF(x0, y, x, y)); + if (xErrorStyle==JKQTPErrorBars || xErrorStyle==JKQTPErrorBarsLines|| xErrorStyle==JKQTPErrorBarsPolygons) { + if (plotlowerbarx) painter.drawLine(QLineF(x0,y-ebs_px/2.0,x0,y+ebs_px/2.0)); + } + if (x0transformX(parent->getXMax()),y)); + else painter.drawLine(QLineF(x,y,parentGraph->transformX(parent->getXMin()),y)); + } else if (!x0ok&&x1ok&&xok&&yok) { + painter.drawLine(QLineF(x1, y, x, y)); + if (xErrorStyle==JKQTPErrorBars || xErrorStyle==JKQTPErrorBarsLines|| xErrorStyle==JKQTPErrorBarsPolygons) { + if (plotupperbarx) painter.drawLine(QLineF(x1,y-ebs_px/2.0,x1,y+ebs_px/2.0)); + } + if (x1transformX(parent->getXMin()),y)); + else painter.drawLine(QLineF(x,y,parentGraph->transformX(parent->getXMax()),y)); + } + + } + // y-errorbars + if ((yErrorColumn>=0 || yErrorColumnLower>=0) && (yErrorStyle==JKQTPErrorBars || yErrorStyle==JKQTPErrorBarsLines || yErrorStyle==JKQTPErrorBarsPolygons + || yErrorStyle==JKQTPErrorSimpleBars || yErrorStyle==JKQTPErrorSimpleBarsLines || yErrorStyle==JKQTPErrorSimpleBarsPolygons)) { + double y0=parentGraph->transformY(yv+yrelshift*deltay-yl); bool y0ok=JKQTPIsOKFloat(y0); + double y1=parentGraph->transformY(yv+yrelshift*deltay+ye); bool y1ok=JKQTPIsOKFloat(y1); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + QPen pp=p; + pp.setColor(terrCol); + painter.setPen(pp); + if (y0ok&&y1ok&&xok&&yok) { + painter.drawLine(QLineF(x, y0, x, y1)); + if (yErrorStyle==JKQTPErrorBars || yErrorStyle==JKQTPErrorBarsLines || yErrorStyle==JKQTPErrorBarsPolygons) { + if (plotlowerbary) painter.drawLine(QLineF(x-ebs_px/2.0,y0,x+ebs_px/2.0,y0)); + if (plotupperbary) painter.drawLine(QLineF(x-ebs_px/2.0,y1,x+ebs_px/2.0,y1)); + } + } else if (y0ok&&!y1ok&&xok&&yok) { // upper errorbar OK, lower errorbar NAN + painter.drawLine(QLineF(x, y0, x, y)); + if (yErrorStyle==JKQTPErrorBars || yErrorStyle==JKQTPErrorBarsLines || yErrorStyle==JKQTPErrorBarsPolygons) { + if (plotlowerbary) painter.drawLine(QLineF(x-ebs_px/2.0,y0,x+ebs_px/2.0,y0)); + } + if (y0transformY(parent->getYMin()))); + else painter.drawLine(QLineF(x,y,x,parentGraph->transformY(parent->getYMax()))); // inverted axis! + } else if (!y0ok&&y1ok&&xok&&yok) { + painter.drawLine(QLineF(x, y1, x, y)); + if (yErrorStyle==JKQTPErrorBars || yErrorStyle==JKQTPErrorBarsLines || yErrorStyle==JKQTPErrorBarsPolygons) { + if (plotupperbary) painter.drawLine(QLineF(x-ebs_px/2.0,y1,x+ebs_px/2.0,y1)); + } + if (y1transformY(parent->getYMax()))); + else painter.drawLine(QLineF(x,y,x,parentGraph->transformY(parent->getYMin()))); + } + + + } + + // error boxes + if (yErrorStyle==JKQTPErrorBoxes || xErrorStyle==JKQTPErrorBoxes || yErrorStyle==JKQTPErrorEllipses || xErrorStyle==JKQTPErrorEllipses ) { + double y0=parentGraph->transformY(yv+yrelshift*deltay-yl); bool y0ok=JKQTPIsOKFloat(y0); + double y1=parentGraph->transformY(yv+yrelshift*deltay+ye); bool y1ok=JKQTPIsOKFloat(y1); + double x0=parentGraph->transformX(xv+xrelshift*deltax-xl); bool x0ok=JKQTPIsOKFloat(x0); + double x1=parentGraph->transformX(xv+xrelshift*deltax+xe); bool x1ok=JKQTPIsOKFloat(x1); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + QPen pp=p; + pp.setColor(terrCol); + painter.setPen(pp); + QBrush bb=b; + bb.setColor(terrFillCol); + painter.setBrush(bb); + + QRectF errRect=QRectF(QPointF(x0,y0), QPointF(x1,y1)); + if ((y0ok&&y1ok)||(x0ok&&x1ok)) { + if (yErrorStyle==JKQTPErrorEllipses || xErrorStyle==JKQTPErrorEllipses) painter.drawEllipse(errRect); + else painter.drawRect(errRect); + } + + + } //} + + // x-errorlines + if (pastFirst && (xErrorStyle==JKQTPErrorLines || xErrorStyle==JKQTPErrorBarsLines || xErrorStyle==JKQTPErrorSimpleBarsLines)) { + double xl1m=xmold; + double xl1p=xpold; + double yl1=yold; + double xl2m=parentGraph->transformX(xv+xrelshift*deltax-xl); + double xl2p=parentGraph->transformX(xv+xrelshift*deltax+xe); + double yl2=y; + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + QPen pp=p; + pp.setColor(terrCol); + painter.setPen(pp); + if (JKQTPIsOKFloat(xl1m)&&JKQTPIsOKFloat(yl1)&&JKQTPIsOKFloat(xl2m)&&JKQTPIsOKFloat(yl2)) { + painter.drawLine(QLineF(xl1m, yl1, xl2m, yl2)); + } + if (JKQTPIsOKFloat(xl1p)&&JKQTPIsOKFloat(yl1)&&JKQTPIsOKFloat(xl2p)&&JKQTPIsOKFloat(yl2)) { + painter.drawLine(QLineF(xl1p, yl1, xl2p, yl2)); + } + + } + + + // y-errorlines + if (pastFirst && (yErrorStyle==JKQTPErrorLines || yErrorStyle==JKQTPErrorBarsLines || yErrorStyle==JKQTPErrorSimpleBarsLines)) { + double yl1m=ymold; + double yl1p=ypold; + double xl1=xold; + double yl2m=parentGraph->transformY(yv+yrelshift*deltay-yl); + double yl2p=parentGraph->transformY(yv+yrelshift*deltay+ye); + double xl2=x; + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + QPen pp=p; + pp.setColor(terrCol); + painter.setPen(pp); + if (JKQTPIsOKFloat(xl1)&&JKQTPIsOKFloat(yl1m)&&JKQTPIsOKFloat(xl2)&&JKQTPIsOKFloat(yl2m)) { + painter.drawLine(QLineF(xl1, yl1m, xl2, yl2m)); + } + if (JKQTPIsOKFloat(xl1)&&JKQTPIsOKFloat(yl1p)&&JKQTPIsOKFloat(xl2)&&JKQTPIsOKFloat(yl2p)) { + painter.drawLine(QLineF(xl1, yl1p, xl2, yl2p)); + } + + } + + + + pastFirst=true; + xold=x; + xmold=parentGraph->transformX(xv+xrelshift*deltax-xl); + xpold=parentGraph->transformX(xv+xrelshift*deltax+xe); + yold=y; + ymold=parentGraph->transformY(yv+yrelshift*deltay-yl); + ypold=parentGraph->transformY(yv+yrelshift*deltay+ye); + } + } + // x-errorpolygons + if ((polyXTopPoints.size()>0 || polyXBottomPoints.size()>0) && (xErrorStyle==JKQTPErrorPolygons || xErrorStyle==JKQTPErrorBarsPolygons || xErrorStyle==JKQTPErrorSimpleBarsPolygons)) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.setBrush(b); + painter.setPen(QPen(Qt::NoPen)); + QPolygonF poly; + //poly << QPointF(xl1p, yl1) << QPointF(xl1m, yl1) << QPointF(xl2m, yl2) << QPointF(xl2p, yl2); + for (int i=0; i=0; i--) { + poly<0 || polyYBottomPoints.size()>0) && (yErrorStyle==JKQTPErrorPolygons || yErrorStyle==JKQTPErrorBarsPolygons || yErrorStyle==JKQTPErrorSimpleBarsPolygons)) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.setBrush(b); + painter.setPen(QPen(Qt::NoPen)); + QPolygonF poly; + //poly << QPointF(xl1p, yl1) << QPointF(xl1m, yl1) << QPointF(xl2m, yl2) << QPointF(xl2p, yl2); + for (int i=0; i=0; i--) { + poly<xErrorColumn != __value) { + this->xErrorColumn = __value; + if (xErrorColumn>=0 && xErrorStyle==JKQTPNoError) xErrorStyle=JKQTPErrorBars; + } +} + +void JKQTPXGraphErrors::setXErrorColumnLower(int __value) { + if (this->xErrorColumnLower != __value) { + this->xErrorColumnLower = __value; + if (xErrorColumnLower>=0 && xErrorStyle==JKQTPNoError) xErrorStyle=JKQTPErrorBars; + } +} + +void JKQTPXGraphErrors::plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQTBasePlotter* parent, JKQTPGraph *parentGraph, int xColumn, int yColumn, double xrelshift, double yrelshift, const QVector* dataorder) { + intPlotXYErrorIndicators(painter, parent, parentGraph, xColumn, yColumn, xErrorColumn, -1, xErrorStyle, JKQTPNoError, xErrorColumnLower, -1, xErrorSymmetric, true, xrelshift, yrelshift, dataorder); +} + +double JKQTPXGraphErrors::getXErrorU(int i, JKQTPDatastore *ds) const +{ + if (ds && xErrorColumn>=0) { + return ds->get(xErrorColumn, i); + } + return 0.0; +} + +double JKQTPXGraphErrors::getXErrorL(int i, JKQTPDatastore *ds) const +{ + if (ds) { + if (xErrorSymmetric) { if (xErrorColumn>=0) return ds->get(xErrorColumn, i); } + else if (xErrorColumnLower>=0) return ds->get(xErrorColumnLower, i); + } + return 0.0; +} + + + + + + + +JKQTPYGraphErrors::JKQTPYGraphErrors(QColor graphColor, JKQTBasePlotter *basePlotter): + JKQTPGraphErrors(graphColor, basePlotter) +{ + yErrorColumn=-1; + yErrorSymmetric=true; + yErrorStyle=JKQTPNoError; + yErrorColumnLower=-1; +} + +void JKQTPYGraphErrors::plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQTBasePlotter* parent, JKQTPGraph* parentGraph, int xColumn, int yColumn, double xrelshift, double yrelshift, const QVector* dataorder) { + intPlotXYErrorIndicators(painter, parent, parentGraph, xColumn, yColumn, -1, yErrorColumn, JKQTPNoError, yErrorStyle, -1, yErrorColumnLower, true, yErrorSymmetric, xrelshift, yrelshift, dataorder); +} + +double JKQTPYGraphErrors::getYErrorU(int i, JKQTPDatastore *ds) const +{ + if (ds && yErrorColumn>=0) { + return ds->get(yErrorColumn, i); + } + return 0.0; +} + +double JKQTPYGraphErrors::getYErrorL(int i, JKQTPDatastore *ds) const +{ + if (ds) { + if (yErrorSymmetric) { if (yErrorColumn>=0) return ds->get(yErrorColumn, i); } + else if (yErrorColumnLower>=0) return ds->get(yErrorColumnLower, i); + } + return 0.0; +} + + + + + + + +JKQTPXYGraphErrors::JKQTPXYGraphErrors(QColor graphColor, JKQTBasePlotter *basePlotter): + JKQTPGraphErrors(graphColor, basePlotter) +{ + xErrorSymmetric=true; + yErrorSymmetric=true; + yErrorColumn=-1; + yErrorStyle=JKQTPNoError; + xErrorColumn=-1; + xErrorStyle=JKQTPNoError; + xErrorColumnLower=-1; + yErrorColumnLower=-1; + +} + +void JKQTPXYGraphErrors::plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQTBasePlotter* parent, JKQTPGraph* parentGraph, int xColumn, int yColumn, double xrelshift, double yrelshift, const QVector* dataorder) { + this->intPlotXYErrorIndicators(painter, parent, parentGraph, xColumn, yColumn, xErrorColumn, yErrorColumn, xErrorStyle, yErrorStyle, xErrorColumnLower, yErrorColumnLower, xErrorSymmetric, yErrorSymmetric, xrelshift, yrelshift, dataorder); +} + +double JKQTPXYGraphErrors::getXErrorU(int i, JKQTPDatastore *ds) const +{ + if (ds && xErrorColumn>=0) { + return ds->get(xErrorColumn, i); + } + return 0.0; +} + +double JKQTPXYGraphErrors::getXErrorL(int i, JKQTPDatastore *ds) const +{ + if (ds && xErrorColumn>=0) { + if (xErrorSymmetric) { if (xErrorColumn>=0) return ds->get(xErrorColumn, i); } + else if (xErrorColumnLower>=0) return ds->get(xErrorColumnLower, i); + } + return 0.0; +} + +double JKQTPXYGraphErrors::getYErrorU(int i, JKQTPDatastore *ds) const +{ + if (ds && yErrorColumn>=0) { + return ds->get(yErrorColumn, i); + } + return 0.0; +} + +double JKQTPXYGraphErrors::getYErrorL(int i, JKQTPDatastore *ds) const +{ + if (ds && yErrorColumn>=0) { + if (yErrorSymmetric) { if (yErrorColumn>=0) return ds->get(yErrorColumn, i); } + else if (yErrorColumnLower>=0) return ds->get(yErrorColumnLower, i); + } + return 0.0; +} + + + + + + + + +bool JKQTPXGraphErrors::errorUsesColumn(int c) const +{ + return c==(xErrorColumn) || (c==xErrorColumnLower); +} + +bool JKQTPGraphErrors::errorUsesColumn(int /*c*/) const +{ + return false; +} + +void JKQTPGraphErrors::setErrorColorFromGraphColor(QColor graphColor) +{ + errorColor=graphColor.darker(); + errorFillColor=graphColor.lighter(); + //errorColor.setAlphaF(0.5); +} + +bool JKQTPYGraphErrors::errorUsesColumn(int c) const +{ + return (c==yErrorColumn) || (c==yErrorColumnLower); +} + +void JKQTPYGraphErrors::setYErrorColumn(int __value) { + if (this->yErrorColumn != __value) { + this->yErrorColumn = __value; + if (yErrorColumn>=0 && yErrorStyle==JKQTPNoError) yErrorStyle=JKQTPErrorBars; + } +} + +void JKQTPYGraphErrors::setYErrorColumnLower(int __value) { + if (this->yErrorColumnLower != __value) { + this->yErrorColumnLower = __value; + if (yErrorColumnLower>=0 && yErrorStyle==JKQTPNoError) yErrorStyle=JKQTPErrorBars; + } +} + +bool JKQTPXYGraphErrors::errorUsesColumn(int c) const +{ + return (c==xErrorColumn)||(c==yErrorColumn)||(c==xErrorColumnLower)||(c==yErrorColumnLower); +} + +void JKQTPXYGraphErrors::setXErrorColumn(int __value) { + if (this->xErrorColumn != __value) { + this->xErrorColumn = __value; + if (xErrorColumn>=0 && xErrorStyle==JKQTPNoError) xErrorStyle=JKQTPErrorBars; + } +} + +void JKQTPXYGraphErrors::setXErrorColumnLower(int __value) { + if (this->xErrorColumnLower != __value) { + this->xErrorColumnLower = __value; + if (xErrorColumnLower>=0 && xErrorStyle==JKQTPNoError) xErrorStyle=JKQTPErrorBars; + } \ +} + +void JKQTPXYGraphErrors::setYErrorColumn(int __value) { + if (this->yErrorColumn != __value) { + this->yErrorColumn = __value; + if (yErrorColumn>=0 && yErrorStyle==JKQTPNoError) yErrorStyle=JKQTPErrorBars; + } +} + +void JKQTPXYGraphErrors::setYErrorColumnLower(int __value) { + if (this->yErrorColumnLower != __value) { + this->yErrorColumnLower = __value; + if (yErrorColumnLower>=0 && yErrorStyle==JKQTPNoError) yErrorStyle=JKQTPErrorBars; + } +} + +void JKQTPXYGraphErrors::setXErrorColumn(size_t __value) +{ + setXErrorColumn(static_cast(__value)); +} + +void JKQTPXYGraphErrors::setXErrorColumnLower(size_t __value) +{ + setXErrorColumnLower(static_cast(__value)); +} + +void JKQTPXYGraphErrors::setYErrorColumn(size_t __value) +{ + setYErrorColumn(static_cast(__value)); +} + +void JKQTPXYGraphErrors::setYErrorColumnLower(size_t __value) +{ + setYErrorColumnLower(static_cast(__value)); +} + diff --git a/lib/jkqtplotter/jkqtpgraphsbaseerrors.h b/lib/jkqtplotter/jkqtpgraphsbaseerrors.h new file mode 100644 index 0000000000..ef6c79ec61 --- /dev/null +++ b/lib/jkqtplotter/jkqtpgraphsbaseerrors.h @@ -0,0 +1,423 @@ +/* + Copyright (c) 2008-2019 Jan W. Krieger () + + + + 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 . +*/ + + +#include +#include +#include +#include "jkqtplotter/jkqtpbaseelements.h" +#include "jkqtplotter/jkqtpbaseplotter.h" +#include "jkqtplotter/jkqtpgraphsbase.h" +#include "jkqtplottertools/jkqtptools.h" +#include "jkqtplottertools/jkqtp_imexport.h" +#include "jkqtplottertools/jkqtpimagetools.h" + +#ifndef JKQTPGRAPHSBASEERROR_H +#define JKQTPGRAPHSBASEERROR_H + + +/*! \brief Descendents of this class add data fields for error indicators and methods to plot them to a class. + \ingroup jkqtplotter_basegraphserrors + + This class is meant to be used with multiple inheritance. I.e. if you implemented some kind of plot + you may derive an error plot class in which you will have to overwrite the JKQTPGraph::drawErrorsBefor() + or drawErrorsAfter() so it calls the plotErrorIndicators() method from this class. In addition this class + will add some public datamemebers and methods to your class that allow to specify the properties of the + error indicators (plot properties: color, width, ... and columns for the data). + + \image html jkqtplotter_simpletest_errorbarstyles.png "line-graphs with different types of error indicators" + + + \see \ref jkqtplotter_graphsgroup_classstructure_mixins + + */ +class JKQTP_LIB_EXPORT JKQTPGraphErrors { + public: + /** \brief class contructor */ + JKQTPGraphErrors(QColor graphColor, JKQTBasePlotter* basePlotter=nullptr); + virtual ~JKQTPGraphErrors()=default; + + /** \brief derive the properties of the error indicators from \a pen */ + void setErrorStyleFromPen(const JKQTBasePlotter::JKQTPPen& pen); + + /*! \copydoc errorColor + \see see errorColor for details */ + inline virtual void setErrorColor(const QColor & __value) + { + this->errorColor = __value; + } + /*! \copydoc errorColor + \see see errorColor for details */ + inline virtual QColor getErrorColor() const + { + return this->errorColor; + } + /*! \copydoc errorStyle + \see see errorStyle for details */ + inline virtual void setErrorStyle(const Qt::PenStyle & __value) + { + this->errorStyle = __value; + } + /*! \copydoc errorStyle + \see see errorStyle for details */ + inline virtual Qt::PenStyle getErrorStyle() const + { + return this->errorStyle; + } + /*! \copydoc errorWidth + \see see errorWidth for details */ + inline virtual void setErrorWidth(double __value) + { + this->errorWidth = __value; + } + /*! \copydoc errorWidth + \see see errorWidth for details */ + inline virtual double getErrorWidth() const + { + return this->errorWidth; + } + /*! \copydoc errorFillColor + \see see errorFillColor for details */ + inline virtual void setErrorFillColor(const QColor & __value) + { + this->errorFillColor = __value; + } + /*! \copydoc errorFillColor + \see see errorFillColor for details */ + inline virtual QColor getErrorFillColor() const + { + return this->errorFillColor; + } + /*! \copydoc errorFillStyle + \see see errorFillStyle for details */ + inline virtual void setErrorFillStyle(const Qt::BrushStyle & __value) + { + this->errorFillStyle = __value; + } + /*! \copydoc errorFillStyle + \see see errorFillStyle for details */ + inline virtual Qt::BrushStyle getErrorFillStyle() const + { + return this->errorFillStyle; + } + /*! \copydoc errorbarSize + \see see errorbarSize for details */ + inline virtual void setErrorbarSize(double __value) + { + this->errorbarSize = __value; + } + /*! \copydoc errorbarSize + \see see errorbarSize for details */ + inline virtual double getErrorbarSize() const + { + return this->errorbarSize; + } + /** \brief returns true, if the error plots use the given column */ + virtual bool errorUsesColumn(int c) const; + + void setErrorColorFromGraphColor(QColor graphColor); + + protected: + /** \brief color of the error lines/bars */ + QColor errorColor; + /** \brief linestyle of the error lines/bars */ + Qt::PenStyle errorStyle; + /** \brief width (pixels) of the error lines/bars */ + double errorWidth; + /** \brief fill color for error polygons */ + QColor errorFillColor; + /** \brief fill style for error polygons */ + Qt::BrushStyle errorFillStyle; + /** \brief size of the error bar end markers [pixels] */ + double errorbarSize; + + /** \brief draw error indicators with the parameters defined in this class. The position of the datapoints is + * given by the \a xColumn and \a yColumn. It is also possible to specify a datarange. This method is called by + * the JKQTPGraph descendents */ + virtual void plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQTBasePlotter* parent, JKQTPGraph* parentGraph, int xColumn, int yColumn, double xrelshift=0, double yrelshift=0.0, const QVector* dataorder=nullptr)=0; + + /** \brief draw error indicators with the parameters defined in this class. The position of the datapoints is + * given by the \a xColumn and \a yColumn. It is also possible to specify a datarange. */ + void intPlotXYErrorIndicators(JKQTPEnhancedPainter& painter, JKQTBasePlotter* parent, JKQTPGraph* parentGraph, int xColumn, int yColumn, int xErrorColumn, int yErrorColumn, JKQTPErrorPlotstyle xErrorStyle, JKQTPErrorPlotstyle yErrorStyle, int xErrorColumnLower=-1, int yErrorColumnLower=-1, bool xErrorSymmetric=true, bool yErrorSymmetric=true, double xrelshift=0, double yrelshift=0.0, const QVector *dataorder=nullptr); + + /** \brief this function can be used to set the color of the error indicators automatically + * + * return \c true and the colors to use, if applicable, the default implementation returns false */ + virtual bool intPlotXYErrorIndicatorsGetColor(JKQTPEnhancedPainter& painter, JKQTBasePlotter* parent, JKQTPGraph* parentGraph, int xColumn, int yColumn, int xErrorColumn, int yErrorColumn, JKQTPErrorPlotstyle xErrorStyle, JKQTPErrorPlotstyle yErrorStyle, int index, QColor& errorColor, QColor& errorFillColor); + + + virtual double getXErrorU(int i, JKQTPDatastore* ds) const; + virtual double getXErrorL(int i, JKQTPDatastore* ds) const; + virtual double getYErrorU(int i, JKQTPDatastore* ds) const; + virtual double getYErrorL(int i, JKQTPDatastore* ds) const; + + //** \brief plot a single error indicator */ + //void intPlotXYErrorIndicator(JKQTPEnhancedPainter& painter, double x, double xperror, double xmerror, double y, double yperror, double ymerror, JKQTPErrorPlotstyle xErrorStyle=JKQTPNoError, JKQTPErrorPlotstyle yErrorStyle=JKQTPNoError, double lastx=0, double lastxperror=0, double lastxmerror=0, double lasty=0, double lastyperror=0, double lastymerror=0); +}; + + +/*! \brief This class adds data fields for error indicators in x direction to a JKQTPGraph descendent. + \ingroup jkqtplotter_basegraphserrors + \see JKQTPGraphErrors, \ref jkqtplotter_graphsgroup_classstructure_mixins + */ +class JKQTP_LIB_EXPORT JKQTPXGraphErrors: public JKQTPGraphErrors { + public: + /** \brief class contructor */ + JKQTPXGraphErrors(QColor graphColor, JKQTBasePlotter* basePlotter=nullptr); + + /*! \copydoc xErrorSymmetric + \see see xErrorSymmetric for details */ + inline virtual void setXErrorSymmetric(bool __value) + { + this->xErrorSymmetric = __value; + } + /*! \copydoc xErrorSymmetric + \see see xErrorSymmetric for details */ + inline virtual bool getXErrorSymmetric() const + { + return this->xErrorSymmetric; + } + /*! \brief returns the property xErrorColumnLower ( \copybrief xErrorColumnLower ). \details Description of the parameter xErrorColumnLower is:
    \copydoc xErrorColumnLower
    . \see xErrorColumnLower for more information */ + inline int getXErrorColumnLower() const { return this->xErrorColumnLower; } + /*! \brief returns the property xErrorColumn ( \copybrief xErrorColumn ). \details Description of the parameter xErrorColumn is:
    \copydoc xErrorColumn
    . \see xErrorColumn for more information */ + inline int getXErrorColumn() const { return this->xErrorColumn; } + /*! \copydoc xErrorStyle + \see see xErrorStyle for details */ + inline virtual void setXErrorStyle(const JKQTPErrorPlotstyle & __value) + { + this->xErrorStyle = __value; + } + /*! \copydoc xErrorStyle + \see see xErrorStyle for details */ + inline virtual JKQTPErrorPlotstyle getXErrorStyle() const + { + return this->xErrorStyle; + } + /** \brief set the column from which to read the error values for x-error indicators */ + void setXErrorColumn(int __value); + /** \brief set the column from which to read the error values for lower x-error indicators (if not set [=-1], the xErrorColumn-values will be used for upper and lower error indicators) */ + void setXErrorColumnLower(int __value); + + /** \brief returns true, if the error plots use the given column */ + virtual bool errorUsesColumn(int c) const override; + + protected: + /** \brief the column that contains the error of the x-component of the datapoints */ + int xErrorColumn; + /** \brief the column that contains the error of the x-component of the datapoints. This is used as the lower error length, if xErrorSymmetric \c ==false. */ + int xErrorColumnLower; + /** \brief indicates whether the x-errors are symmetric (from one column only) */ + bool xErrorSymmetric; + /** \brief how to draw the errors (if available) of the x-value */ + JKQTPErrorPlotstyle xErrorStyle; + + /** \brief draw error indicators with the parameters defined in this class. The position of the datapoints is + * given by the \a xColumn and \a yColumn. It is also possible to specify a datarange. */ + virtual void plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQTBasePlotter* parent, JKQTPGraph* parentGraph, int xColumn, int yColumn, double xrelshift=0, double yrelshift=0.0, const QVector *dataorder=nullptr) override; + + virtual double getXErrorU(int i, JKQTPDatastore* ds) const override; + virtual double getXErrorL(int i, JKQTPDatastore* ds) const override; + +}; + + +/*! \brief This class adds data fields for error indicators in y direction to a class. + \ingroup jkqtplotter_basegraphserrors + \see JKQTPGraphErrors, \ref jkqtplotter_graphsgroup_classstructure_mixins + + */ +class JKQTP_LIB_EXPORT JKQTPYGraphErrors: public JKQTPGraphErrors { + public: + /** \brief class contructor */ + JKQTPYGraphErrors(QColor graphColor, JKQTBasePlotter* basePlotter=nullptr); + + /*! \copydoc yErrorSymmetric + \see see yErrorSymmetric for details */ + inline virtual void setYErrorSymmetric(bool __value) + { + this->yErrorSymmetric = __value; + } + /*! \copydoc yErrorSymmetric + \see see yErrorSymmetric for details */ + inline virtual bool getYErrorSymmetric() const + { + return this->yErrorSymmetric; + } + /*! \brief returns the property yErrorColumnLower ( \copybrief yErrorColumnLower ). \details Description of the parameter yErrorColumnLower is:
    \copydoc yErrorColumnLower
    . \see yErrorColumnLower for more information */ + inline int getYErrorColumnLower() const { return this->yErrorColumnLower; } + /*! \brief returns the property yErrorColumn ( \copybrief yErrorColumn ). \details Description of the parameter yErrorColumn is:
    \copydoc yErrorColumn
    . \see yErrorColumn for more information */ + inline int getYErrorColumn() const { return this->yErrorColumn; } + /*! \copydoc yErrorStyle + \see see yErrorStyle for details */ + inline virtual void setYErrorStyle(const JKQTPErrorPlotstyle & __value) + { + this->yErrorStyle = __value; + } + /*! \copydoc yErrorStyle + \see see yErrorStyle for details */ + inline virtual JKQTPErrorPlotstyle getYErrorStyle() const + { + return this->yErrorStyle; + } + /** \copydoc JKQTPGraphErrors::errorUsesColumn() */ + virtual bool errorUsesColumn(int c) const override; + + /** \brief set the column from which to read the error values for y-error indicators */ + void setYErrorColumn(int __value); + /** \brief set the column from which to read the error values for lower y-error indicators (if not set [=-1], the xErrorColumn-values will be used for upper and lower error indicators) */ + void setYErrorColumnLower(int __value); + protected: + /** \brief the column that contains the error of the x-component of the datapoints */ + int yErrorColumn; + /** \brief how to draw the errors (if available) of the x-value */ + JKQTPErrorPlotstyle yErrorStyle; + /** \brief indicates whether the y-errors are symmetric (from one column only) */ + bool yErrorSymmetric; + /** \brief the column that contains the error of the y-component of the datapoints. This is used as the lower error length, if yErrorSymmetric \c ==false. */ + int yErrorColumnLower; + + /** \brief draw error indicators with the parameters defined in this class. The position of the datapoints is + * given by the \a xColumn and \a yColumn. It is also possible to specify a datarange. */ + virtual void plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQTBasePlotter* parent, JKQTPGraph* parentGraph, int xColumn, int yColumn, double xrelshift=0, double yrelshift=0.0, const QVector *dataorder=nullptr) override; + + virtual double getYErrorU(int i, JKQTPDatastore* ds) const override; + virtual double getYErrorL(int i, JKQTPDatastore* ds) const override; +}; + + +/*! \brief This class adds data fields for error indicators in x and y direction to a class. + \ingroup jkqtplotter_basegraphserrors + \see JKQTPGraphErrors, \ref jkqtplotter_graphsgroup_classstructure_mixins + + */ +class JKQTP_LIB_EXPORT JKQTPXYGraphErrors: public JKQTPGraphErrors { + public: + /** \brief class contructor */ + JKQTPXYGraphErrors(QColor graphColor, JKQTBasePlotter* basePlotter=nullptr); + /*! \copydoc xErrorSymmetric + \see see xErrorSymmetric for details */ + inline virtual void setXErrorSymmetric(bool __value) + { + this->xErrorSymmetric = __value; + } + /*! \copydoc xErrorSymmetric + \see see xErrorSymmetric for details */ + inline virtual bool getXErrorSymmetric() const + { + return this->xErrorSymmetric; + } + /*! \copydoc yErrorSymmetric + \see see yErrorSymmetric for details */ + inline virtual void setYErrorSymmetric(bool __value) + { + this->yErrorSymmetric = __value; + } + /*! \copydoc yErrorSymmetric + \see see yErrorSymmetric for details */ + inline virtual bool getYErrorSymmetric() const + { + return this->yErrorSymmetric; + } + /*! \brief returns the property xErrorColumnLower ( \copybrief xErrorColumnLower ). \details Description of the parameter xErrorColumnLower is:
    \copydoc xErrorColumnLower
    . \see xErrorColumnLower for more information */ + inline int getXErrorColumnLower() const { return this->xErrorColumnLower; } + /*! \brief returns the property xErrorColumn ( \copybrief xErrorColumn ). \details Description of the parameter xErrorColumn is:
    \copydoc xErrorColumn
    . \see xErrorColumn for more information */ + inline int getXErrorColumn() const { return this->xErrorColumn; } + /*! \brief returns the property yErrorColumnLower ( \copybrief yErrorColumnLower ). \details Description of the parameter yErrorColumnLower is:
    \copydoc yErrorColumnLower
    . \see yErrorColumnLower for more information */ + inline int getYErrorColumnLower() const { return this->yErrorColumnLower; } + /*! \brief returns the property yErrorColumn ( \copybrief yErrorColumn ). \details Description of the parameter yErrorColumn is:
    \copydoc yErrorColumn
    . \see yErrorColumn for more information */ + inline int getYErrorColumn() const { return this->yErrorColumn; } + /*! \copydoc yErrorStyle + \see see yErrorStyle for details */ + inline virtual void setYErrorStyle(const JKQTPErrorPlotstyle & __value) + { + this->yErrorStyle = __value; + } + /*! \copydoc yErrorStyle + \see see yErrorStyle for details */ + inline virtual JKQTPErrorPlotstyle getYErrorStyle() const + { + return this->yErrorStyle; + } + /*! \copydoc xErrorStyle + \see see xErrorStyle for details */ + inline virtual void setXErrorStyle(const JKQTPErrorPlotstyle & __value) + { + this->xErrorStyle = __value; + } + /*! \copydoc xErrorStyle + \see see xErrorStyle for details */ + inline virtual JKQTPErrorPlotstyle getXErrorStyle() const + { + return this->xErrorStyle; + } + /** \copydoc JKQTPGraphErrors::errorUsesColumn() */ + virtual bool errorUsesColumn(int c) const override; + + /** \brief set the column from which to read the error values for x-error indicators */ + void setXErrorColumn(int __value); + /** \brief set the column from which to read the error values for lower x-error indicators (if not set [=-1], the xErrorColumn-values will be used for upper and lower error indicators) */ + void setXErrorColumnLower(int __value); + /** \brief set the column from which to read the error values for x-error indicators */ + void setYErrorColumn(int __value); + /** \brief set the column from which to read the error values for lower x-error indicators (if not set [=-1], the xErrorColumn-values will be used for upper and lower error indicators) */ + void setYErrorColumnLower(int __value); + /** \brief set the column from which to read the error values for y-error indicators */ + void setXErrorColumn(size_t __value); + /** \brief set the column from which to read the error values for lower y-error indicators (if not set [=-1], the xErrorColumn-values will be used for upper and lower error indicators) */ + void setXErrorColumnLower(size_t __value); + /** \brief set the column from which to read the error values for y-error indicators */ + void setYErrorColumn(size_t __value); + /** \brief set the column from which to read the error values for lower y-error indicators (if not set [=-1], the xErrorColumn-values will be used for upper and lower error indicators) */ + void setYErrorColumnLower(size_t __value); + + protected: + /** \brief the column that contains the error of the x-component of the datapoints */ + int yErrorColumn; + /** \brief how to draw the errors (if available) of the x-value */ + JKQTPErrorPlotstyle yErrorStyle; + /** \brief the column that contains the error of the x-component of the datapoints */ + int xErrorColumn; + /** \brief how to draw the errors (if available) of the x-value */ + JKQTPErrorPlotstyle xErrorStyle; + /** \brief indicates whether the x-errors are symmetric (from one column only) */ + bool xErrorSymmetric; + /** \brief indicates whether the y-errors are symmetric (from one column only) */ + bool yErrorSymmetric; + /** \brief the column that contains the error of the x-component of the datapoints. This is used as the lower error length, if xErrorSymmetric \c ==false. */ + int xErrorColumnLower; + /** \brief the column that contains the error of the y-component of the datapoints. This is used as the lower error length, if yErrorSymmetric \c ==false. */ + int yErrorColumnLower; + + /** \brief draw error indicators with the parameters defined in this class. The position of the datapoints is + * given by the \a xColumn and \a yColumn. It is also possible to specify a datarange. */ + virtual void plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQTBasePlotter* parent, JKQTPGraph* parentGraph, int xColumn, int yColumn, double xrelshift=0, double yrelshift=0.0, const QVector *dataorder=nullptr) override; + + virtual double getXErrorU(int i, JKQTPDatastore* ds) const override; + virtual double getXErrorL(int i, JKQTPDatastore* ds) const override; + virtual double getYErrorU(int i, JKQTPDatastore* ds) const override; + virtual double getYErrorL(int i, JKQTPDatastore* ds) const override; +}; + + + + + + + +#endif // JKQTPGRAPHSBASEERROR_H diff --git a/lib/jkqtplotter/jkqtpgraphsboxplot.cpp b/lib/jkqtplotter/jkqtpgraphsboxplot.cpp index 1a23d08b31..7aaa47cd4a 100644 --- a/lib/jkqtplotter/jkqtpgraphsboxplot.cpp +++ b/lib/jkqtplotter/jkqtpgraphsboxplot.cpp @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -62,7 +62,11 @@ JKQTPBoxplotVerticalGraph::JKQTPBoxplotVerticalGraph(JKQTBasePlotter* parent): parentPlotStyle=parent->getNextStyle(); //std::cout<<"got style settings from parent: "<getPlotStyle(parentPlotStyle).color(); + fillColor=parent->getPlotStyle(parentPlotStyle).fillColor(); whiskerStyle=parent->getPlotStyle(parentPlotStyle).style(); + lineWidth=parent->getPlotStyle(parentPlotStyle).widthF(); + meanSymbolSize=parent->getPlotStyle(parentPlotStyle).symbolSize(); + meanSymbolWidth=parent->getPlotStyle(parentPlotStyle).symbolLineWidthF(); } } @@ -93,7 +97,11 @@ JKQTPBoxplotVerticalGraph::JKQTPBoxplotVerticalGraph(JKQTPlotter* parent): parentPlotStyle=parent->getNextStyle(); //std::cout<<"got style settings from parent: "<getPlotStyle(parentPlotStyle).color(); + fillColor=parent->getPlotStyle(parentPlotStyle).fillColor(); whiskerStyle=parent->getPlotStyle(parentPlotStyle).style(); + lineWidth=parent->getPlotStyle(parentPlotStyle).widthF(); + meanSymbolSize=parent->getPlotStyle(parentPlotStyle).symbolSize(); + meanSymbolWidth=parent->getPlotStyle(parentPlotStyle).symbolLineWidthF(); } } @@ -112,7 +120,7 @@ void JKQTPBoxplotVerticalGraph::draw(JKQTPEnhancedPainter& painter) { QPen p=painter.pen(); p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); p.setJoinStyle(Qt::RoundJoin); p.setJoinStyle(Qt::RoundJoin); p.setCapStyle(Qt::RoundCap); @@ -156,87 +164,88 @@ void JKQTPBoxplotVerticalGraph::draw(JKQTPEnhancedPainter& painter) { } } // 2. plot: - painter.save(); - for (int i=imin; iget(posColumn,i); - double p25v=datastore->get(percentile25Column,i); - double p75v=datastore->get(percentile75Column,i); - double minv=datastore->get(minColumn,i); - double maxv=datastore->get(maxColumn,i); - double medianv=datastore->get(medianColumn,i); - double mean=transformY(datastore->get(meanColumn,i)); + { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + for (int i=imin; iget(posColumn,i); + double p25v=datastore->get(percentile25Column,i); + double p75v=datastore->get(percentile75Column,i); + double minv=datastore->get(minColumn,i); + double maxv=datastore->get(maxColumn,i); + double medianv=datastore->get(medianColumn,i); + double mean=transformY(datastore->get(meanColumn,i)); - QVector lines_p, lines_pw; + QVector lines_p, lines_pw; - //std::cout<<"(xv, yv) = ( "<=0 && JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(p25v) && - JKQTPIsOKFloat(p75v) && JKQTPIsOKFloat(minv) && - JKQTPIsOKFloat(maxv) && JKQTPIsOKFloat(medianv) ) { + //std::cout<<"(xv, yv) = ( "<=0 && JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(p25v) && + JKQTPIsOKFloat(p75v) && JKQTPIsOKFloat(minv) && + JKQTPIsOKFloat(maxv) && JKQTPIsOKFloat(medianv) ) { - painter.save(); - painter.setPen(p); - painter.setBrush(b); - //std::cout<<"boxplot(med="<get(posColumn,i+1)); - else if (i-1>=0) xn=transformX(datastore->get(posColumn,i-1)); - else xn=x+1; + double xn=x+1; + if (i+1get(posColumn,i+1)); + else if (i-1>=0) xn=transformX(datastore->get(posColumn,i-1)); + else xn=x+1; - double w=((boxwidth_real>0)?boxwidth_real:(fabs(xn-x)))*boxWidth; - double minstop=p25; - double maxstop=p75; - if (percentile25Column<0 && medianColumn>=0) minstop=median; - else if (percentile25Column<0 && meanColumn>=0) minstop=mean; - else if (percentile25Column<0 && maxColumn>=0) minstop=max; - if (percentile75Column<0 && medianColumn>=0) maxstop=median; - else if (percentile75Column<0 && meanColumn>=0) maxstop=mean; - else if (percentile75Column<0 && minColumn>=0) maxstop=min; - double xma=x+w/2.0; - double xmi=x-w/2.0; - double xma4=x+w/4.0; - double xmi4=x-w/4.0; + double w=((boxwidth_real>0)?boxwidth_real:(fabs(xn-x)))*boxWidth; + double minstop=p25; + double maxstop=p75; + if (percentile25Column<0 && medianColumn>=0) minstop=median; + else if (percentile25Column<0 && meanColumn>=0) minstop=mean; + else if (percentile25Column<0 && maxColumn>=0) minstop=max; + if (percentile75Column<0 && medianColumn>=0) maxstop=median; + else if (percentile75Column<0 && meanColumn>=0) maxstop=mean; + else if (percentile75Column<0 && minColumn>=0) maxstop=min; + double xma=x+w/2.0; + double xmi=x-w/2.0; + double xma4=x+w/4.0; + double xmi4=x-w/4.0; - if (imax<=0) { - xma=transformX(xv+boxWidth/2.0); - xmi=transformX(xv-boxWidth/2.0); - xma4=transformX(xv+boxWidth/4.0); - xmi4=transformX(xv-boxWidth/4.0); + if (imax<=0) { + xma=transformX(xv+boxWidth/2.0); + xmi=transformX(xv-boxWidth/2.0); + xma4=transformX(xv+boxWidth/4.0); + xmi4=transformX(xv-boxWidth/4.0); + } + + if (minColumn>=0) { + lines_p.append(QLineF(xmi4, min, xma4, min)); + lines_pw.append(QLineF(x, min, x, minstop)); + } + if (maxColumn>=0) { + lines_p.append(QLineF(xmi4, max, xma4, max)); + lines_pw.append(QLineF(x, max, x, maxstop)); + } + + if (percentile25Column>=0 && percentile75Column>=0) painter.drawRect(QRectF(xmi, p75, fabs(xma-xmi), fabs(p75-p25))); + if (medianColumn>=0) lines_p.append(QLineF(xmi+p.widthF()/2.0, median, xma-p.widthF()/2.0, median)); + if (meanColumn>=0 && JKQTPIsOKFloat(mean)) { + JKQTPPlotSymbol(painter, x, mean, meanSymbol, parent->pt2px(painter, meanSymbolSize), parent->pt2px(painter, meanSymbolWidth*parent->getLineWidthMultiplier()), color, fillColor); + } + + + painter.setPen(p); + if (lines_p.size()>0) painter.drawLines(lines_p); + painter.setPen(pw); + if (lines_pw.size()>0) painter.drawLines(lines_pw); + + + //first=true; } - - if (minColumn>=0) { - lines_p.append(QLineF(xmi4, min, xma4, min)); - lines_pw.append(QLineF(x, min, x, minstop)); - } - if (maxColumn>=0) { - lines_p.append(QLineF(xmi4, max, xma4, max)); - lines_pw.append(QLineF(x, max, x, maxstop)); - } - - if (percentile25Column>=0 && percentile75Column>=0) painter.drawRect(QRectF(xmi, p75, fabs(xma-xmi), fabs(p75-p25))); - if (medianColumn>=0) lines_p.append(QLineF(xmi+p.widthF()/2.0, median, xma-p.widthF()/2.0, median)); - if (meanColumn>=0 && JKQTPIsOKFloat(mean)) { - JKQTPPlotSymbol(painter, x, mean, meanSymbol, parent->pt2px(painter, meanSymbolSize), parent->pt2px(painter, meanSymbolWidth*parent->getLineWidthMultiplier()), color, fillColor); - } - - - painter.setPen(p); - if (lines_p.size()>0) painter.drawLines(lines_p); - painter.setPen(pw); - if (lines_pw.size()>0) painter.drawLines(lines_pw); - painter.restore(); - - //first=true; } } - painter.restore(); drawErrorsAfter(painter); @@ -348,11 +357,11 @@ void JKQTPBoxplotVerticalGraph::setDataSortOrder(int __value) { void JKQTPBoxplotVerticalGraph::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) { - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); QPen p=painter.pen(); p.setJoinStyle(Qt::RoundJoin); p.setCapStyle(Qt::RoundCap); p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); p.setJoinStyle(Qt::RoundJoin); QPen pw=p; pw.setStyle(whiskerStyle); @@ -373,17 +382,19 @@ void JKQTPBoxplotVerticalGraph::drawKeyMarker(JKQTPEnhancedPainter& painter, QRe double p75=max+0.25*rect.height(); painter.setPen(p); - painter.save(); - painter.setBrush(b); - painter.drawRect(QRectF(xmi, p75, fabs(xma-xmi), fabs(p75-p25))); - painter.restore(); + { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.setBrush(b); + painter.drawRect(QRectF(xmi, p75, fabs(xma-xmi), fabs(p75-p25))); + } + painter.drawLine(QLineF(xmi, median, xma, median)); painter.drawLine(QLineF(x-w/4.0, max, x+w/4.0, max)); painter.drawLine(QLineF(x-w/4.0, min, x+w/4.0, min)); painter.setPen(pw); painter.drawLine(QLineF(x, max, x, p75)); painter.drawLine(QLineF(x, min, x, p25)); - painter.restore(); + } QColor JKQTPBoxplotVerticalGraph::getKeyLabelColor() { @@ -394,10 +405,10 @@ QColor JKQTPBoxplotVerticalGraph::getKeyLabelColor() { void JKQTPBoxplotHorizontalGraph::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) { - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); QPen p=painter.pen(); p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); p.setJoinStyle(Qt::RoundJoin); p.setJoinStyle(Qt::RoundJoin); p.setCapStyle(Qt::RoundCap); @@ -420,17 +431,19 @@ void JKQTPBoxplotHorizontalGraph::drawKeyMarker(JKQTPEnhancedPainter& painter, Q double p75=min+0.25*rect.width(); painter.setPen(p); - painter.save(); - painter.setBrush(b); - painter.drawRect(QRectF(p75, ymi, fabs(p75-p25), fabs(yma-ymi))); - painter.restore(); + { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.setBrush(b); + painter.drawRect(QRectF(p75, ymi, fabs(p75-p25), fabs(yma-ymi))); + } + painter.drawLine(QLineF(median, ymi, median, yma)); painter.drawLine(QLineF(max, y-w/4.0, max, y+w/4.0)); painter.drawLine(QLineF(min, y-w/4.0, min, y+w/4.0)); painter.setPen(pw); painter.drawLine(QLineF(max, y, p75, y)); painter.drawLine(QLineF(min, y, p25, y)); - painter.restore(); + } bool JKQTPBoxplotHorizontalGraph::getXMinMax(double& miny, double& maxy, double& smallestGreaterZero) { @@ -548,7 +561,7 @@ void JKQTPBoxplotHorizontalGraph::draw(JKQTPEnhancedPainter& painter) { QPen p=painter.pen(); p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); p.setJoinStyle(Qt::RoundJoin); p.setJoinStyle(Qt::RoundJoin); p.setCapStyle(Qt::RoundCap); @@ -588,94 +601,95 @@ void JKQTPBoxplotHorizontalGraph::draw(JKQTPEnhancedPainter& painter) { } } // 2. plot: - painter.save(); + { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); - //bool first=false; - for (int i=imin; iget(posColumn,i); - double p25v=datastore->get(percentile25Column,i); - double p75v=datastore->get(percentile75Column,i); - double minv=datastore->get(minColumn,i); - double maxv=datastore->get(maxColumn,i); - double medianv=datastore->get(medianColumn,i); - double mean=transformX(datastore->get(meanColumn,i)); + //bool first=false; + for (int i=imin; iget(posColumn,i); + double p25v=datastore->get(percentile25Column,i); + double p75v=datastore->get(percentile75Column,i); + double minv=datastore->get(minColumn,i); + double maxv=datastore->get(maxColumn,i); + double medianv=datastore->get(medianColumn,i); + double mean=transformX(datastore->get(meanColumn,i)); - QVector lines_p, lines_pw; - //std::cout<<"(xv, yv) = ( "<=0 && JKQTPIsOKFloat(yv) && - JKQTPIsOKFloat(p25v) && - JKQTPIsOKFloat(p75v) && - JKQTPIsOKFloat(minv) && - JKQTPIsOKFloat(maxv) && - JKQTPIsOKFloat(medianv)) { + QVector lines_p, lines_pw; + //std::cout<<"(xv, yv) = ( "<=0 && JKQTPIsOKFloat(yv) && + JKQTPIsOKFloat(p25v) && + JKQTPIsOKFloat(p75v) && + JKQTPIsOKFloat(minv) && + JKQTPIsOKFloat(maxv) && + JKQTPIsOKFloat(medianv)) { - painter.save(); - painter.setPen(p); - painter.setBrush(b); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.setPen(p); + painter.setBrush(b); - double p25=transformX(p25v); - double p75=transformX(p75v); - double min=transformX(minv); - double max=transformX(maxv); - double median=transformX(medianv); + double p25=transformX(p25v); + double p75=transformX(p75v); + double min=transformX(minv); + double max=transformX(maxv); + double median=transformX(medianv); - //std::cout<<"boxplot(med="<=0) minstop=median; - else if (percentile25Column<0 && maxColumn>=0) minstop=max; - else if (percentile25Column<0 && meanColumn>=0) minstop=mean; - if (percentile75Column<0 && medianColumn>=0) maxstop=median; - else if (percentile75Column<0 && minColumn>=0) maxstop=min; - else if (percentile75Column<0 && meanColumn>=0) maxstop=mean; + //std::cout<<"boxplot(med="<=0) minstop=median; + else if (percentile25Column<0 && maxColumn>=0) minstop=max; + else if (percentile25Column<0 && meanColumn>=0) minstop=mean; + if (percentile75Column<0 && medianColumn>=0) maxstop=median; + else if (percentile75Column<0 && minColumn>=0) maxstop=min; + else if (percentile75Column<0 && meanColumn>=0) maxstop=mean; - double yn=y+1; - if (i+1get(posColumn,i+1)); - else if (i-1>=0) yn=transformY(datastore->get(posColumn,i-1)); - else yn=y+1; - double delta=fabs(yn-y); - double w=((boxwidth_real>0)?boxwidth_real:(delta))*boxWidth; - double yma=y-w/2.0; - double ymi=y+w/2.0; - double yma4=y+w/4.0; - double ymi4=y-w/4.0; + double yn=y+1; + if (i+1get(posColumn,i+1)); + else if (i-1>=0) yn=transformY(datastore->get(posColumn,i-1)); + else yn=y+1; + double delta=fabs(yn-y); + double w=((boxwidth_real>0)?boxwidth_real:(delta))*boxWidth; + double yma=y-w/2.0; + double ymi=y+w/2.0; + double yma4=y+w/4.0; + double ymi4=y-w/4.0; - if (imax<=1) { - ymi=transformY(yv+boxWidth/2.0); - yma=transformY(yv-boxWidth/2.0); - yma4=transformY(yv+boxWidth/4.0); - ymi4=transformY(yv-boxWidth/4.0); - } - if (minColumn>=0) { - lines_p.append(QLineF(min, ymi4, min, yma4)); - lines_pw.append(QLineF(min, y, minstop, y)); - } - if (maxColumn>=0) { - lines_p.append(QLineF(max, ymi4, max, yma4)); - lines_pw.append(QLineF(max, y, maxstop, y)); - } - if (percentile25Column>=0 && percentile75Column>=0) painter.drawRect(QRectF(p25, qMin(yma,ymi), fabs(p75-p25), fabs(yma-ymi))); - if (medianColumn>=0) lines_p.append(QLineF(median, ymi-p.widthF()/2.0, median, yma+p.widthF()/2.0)); + if (imax<=1) { + ymi=transformY(yv+boxWidth/2.0); + yma=transformY(yv-boxWidth/2.0); + yma4=transformY(yv+boxWidth/4.0); + ymi4=transformY(yv-boxWidth/4.0); + } + if (minColumn>=0) { + lines_p.append(QLineF(min, ymi4, min, yma4)); + lines_pw.append(QLineF(min, y, minstop, y)); + } + if (maxColumn>=0) { + lines_p.append(QLineF(max, ymi4, max, yma4)); + lines_pw.append(QLineF(max, y, maxstop, y)); + } + if (percentile25Column>=0 && percentile75Column>=0) painter.drawRect(QRectF(p25, qMin(yma,ymi), fabs(p75-p25), fabs(yma-ymi))); + if (medianColumn>=0) lines_p.append(QLineF(median, ymi-p.widthF()/2.0, median, yma+p.widthF()/2.0)); - if (meanColumn>=0 && JKQTPIsOKFloat(mean)) { - JKQTPPlotSymbol(painter, mean, y, meanSymbol, parent->pt2px(painter, meanSymbolSize), parent->pt2px(painter, meanSymbolWidth*parent->getLineWidthMultiplier()), color, fillColor); + if (meanColumn>=0 && JKQTPIsOKFloat(mean)) { + JKQTPPlotSymbol(painter, mean, y, meanSymbol, parent->pt2px(painter, meanSymbolSize), parent->pt2px(painter, meanSymbolWidth*parent->getLineWidthMultiplier()), color, fillColor); + } + + //first=true; + painter.setPen(p); + if (lines_p.size()>0) painter.drawLines(lines_p); + painter.setPen(pw); + if (lines_pw.size()>0) painter.drawLines(lines_pw); + } - //first=true; - painter.setPen(p); - if (lines_p.size()>0) painter.drawLines(lines_p); - painter.setPen(pw); - if (lines_pw.size()>0) painter.drawLines(lines_pw); - painter.restore(); } } - painter.restore(); - drawErrorsAfter(painter); } @@ -725,7 +739,11 @@ JKQTPBoxplotVerticalElement::JKQTPBoxplotVerticalElement(JKQTBasePlotter* parent parentPlotStyle=parent->getNextStyle(); //std::cout<<"got style settings from parent: "<getPlotStyle(parentPlotStyle).color(); + fillColor=parent->getPlotStyle(parentPlotStyle).fillColor(); whiskerStyle=parent->getPlotStyle(parentPlotStyle).style(); + lineWidth=parent->getPlotStyle(parentPlotStyle).widthF(); + meanSymbolSize=parent->getPlotStyle(parentPlotStyle).symbolSize(); + meanSymbolWidth=parent->getPlotStyle(parentPlotStyle).symbolLineWidthF(); } } @@ -756,7 +774,11 @@ JKQTPBoxplotVerticalElement::JKQTPBoxplotVerticalElement(JKQTPlotter* parent): parentPlotStyle=parent->getNextStyle(); //std::cout<<"got style settings from parent: "<getPlotStyle(parentPlotStyle).color(); + fillColor=parent->getPlotStyle(parentPlotStyle).fillColor(); whiskerStyle=parent->getPlotStyle(parentPlotStyle).style(); + lineWidth=parent->getPlotStyle(parentPlotStyle).widthF(); + meanSymbolSize=parent->getPlotStyle(parentPlotStyle).symbolSize(); + meanSymbolWidth=parent->getPlotStyle(parentPlotStyle).symbolLineWidthF(); } } @@ -767,74 +789,76 @@ void JKQTPBoxplotVerticalElement::draw(JKQTPEnhancedPainter& painter) { if (parent==nullptr) return; //drawErrorsBefore(painter); + { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); - painter.save(); + QPen p=painter.pen(); + p.setColor(color); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); + p.setJoinStyle(Qt::RoundJoin); + p.setJoinStyle(Qt::RoundJoin); + p.setCapStyle(Qt::RoundCap); + QPen pw=p; + pw.setStyle(whiskerStyle); + QPen np(Qt::NoPen); - QPen p=painter.pen(); - p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); - p.setJoinStyle(Qt::RoundJoin); - p.setJoinStyle(Qt::RoundJoin); - p.setCapStyle(Qt::RoundCap); - QPen pw=p; - pw.setStyle(whiskerStyle); - QPen np(Qt::NoPen); - - QBrush b=painter.brush(); - b.setColor(fillColor); - b.setStyle(fillStyle); + QBrush b=painter.brush(); + b.setColor(fillColor); + b.setStyle(fillStyle); - double xv=pos; - double p25v=percentile25; - double p75v=percentile75; - double minv=min; - double maxv=max; - double medianv=median; + double xv=pos; + double p25v=percentile25; + double p75v=percentile75; + double minv=min; + double maxv=max; + double medianv=median; - //std::cout<<"(xv, yv) = ( "<mean); + JKQTPPlotSymbol(painter, x, mean, meanSymbol, parent->pt2px(painter, meanSymbolSize), parent->pt2px(painter, meanSymbolWidth*parent->getLineWidthMultiplier()), color, fillColor); + } - double w=boxWidth; - double xma=x+w/2.0; - double xmi=x-w/2.0; - painter.save(); - painter.setPen(p); - painter.save(); - painter.setBrush(b); - painter.drawRect(QRectF(xmi, p75, fabs(xma-xmi), fabs(p75-p25))); - painter.restore(); - if (drawMedian) { - painter.drawLine(QLineF(xmi, median, xma, median)); } - if (drawMinMax) { - painter.drawLine(QLineF(x-w/4.0, max, x+w/4.0, max)); - painter.drawLine(QLineF(x-w/4.0, min, x+w/4.0, min)); - painter.setPen(pw); - painter.drawLine(QLineF(x, max, x, p75)); - painter.drawLine(QLineF(x, min, x, p25)); - } - painter.restore(); - - if (drawMean) { - double mean=transformY(this->mean); - JKQTPPlotSymbol(painter, x, mean, meanSymbol, parent->pt2px(painter, meanSymbolSize), parent->pt2px(painter, meanSymbolWidth*parent->getLineWidthMultiplier()), color, fillColor); - } - - } - painter.restore(); //drawErrorsAfter(painter); } @@ -896,10 +920,10 @@ bool JKQTPBoxplotVerticalElement::getYMinMax(double& miny, double& maxy, double& void JKQTPBoxplotVerticalElement::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) { - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); QPen p=painter.pen(); p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); p.setJoinStyle(Qt::RoundJoin); p.setJoinStyle(Qt::RoundJoin); p.setCapStyle(Qt::RoundCap); @@ -922,17 +946,19 @@ void JKQTPBoxplotVerticalElement::drawKeyMarker(JKQTPEnhancedPainter& painter, Q double p75=max+0.25*rect.height(); painter.setPen(p); - painter.save(); - painter.setBrush(b); - painter.drawRect(QRectF(xmi, p75, fabs(xma-xmi), fabs(p75-p25))); - painter.restore(); + { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.setBrush(b); + painter.drawRect(QRectF(xmi, p75, fabs(xma-xmi), fabs(p75-p25))); + } + painter.drawLine(QLineF(xmi, median, xma, median)); painter.drawLine(QLineF(x-w/4.0, max, x+w/4.0, max)); painter.drawLine(QLineF(x-w/4.0, min, x+w/4.0, min)); painter.setPen(pw); painter.drawLine(QLineF(x, max, x, p75)); painter.drawLine(QLineF(x, min, x, p25)); - painter.restore(); + } QColor JKQTPBoxplotVerticalElement::getKeyLabelColor() { @@ -943,10 +969,10 @@ QColor JKQTPBoxplotVerticalElement::getKeyLabelColor() { void JKQTPBoxplotHorizontalElement::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) { - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); QPen p=painter.pen(); p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); p.setJoinStyle(Qt::RoundJoin); p.setJoinStyle(Qt::RoundJoin); p.setCapStyle(Qt::RoundCap); @@ -970,17 +996,19 @@ void JKQTPBoxplotHorizontalElement::drawKeyMarker(JKQTPEnhancedPainter& painter, double p75=min+0.25*rect.width(); painter.setPen(p); - painter.save(); - painter.setBrush(b); - painter.drawRect(QRectF(p75, ymi, fabs(p75-p25), fabs(yma-ymi))); - painter.restore(); + { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.setBrush(b); + painter.drawRect(QRectF(p75, ymi, fabs(p75-p25), fabs(yma-ymi))); + } + painter.drawLine(QLineF(median, ymi, median, yma)); painter.drawLine(QLineF(max, y-w/4.0, max, y+w/4.0)); painter.drawLine(QLineF(min, y-w/4.0, min, y+w/4.0)); painter.setPen(pw); painter.drawLine(QLineF(max, y, p75, y)); painter.drawLine(QLineF(min, y, p25, y)); - painter.restore(); + } bool JKQTPBoxplotHorizontalElement::getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) { @@ -1055,74 +1083,76 @@ void JKQTPBoxplotHorizontalElement::draw(JKQTPEnhancedPainter& painter) { if (parent==nullptr) return; //drawErrorsBefore(painter); + { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); - painter.save(); + QPen p=painter.pen(); + p.setColor(color); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); + p.setJoinStyle(Qt::RoundJoin); + p.setJoinStyle(Qt::RoundJoin); + p.setCapStyle(Qt::RoundCap); + QPen pw=p; + pw.setStyle(whiskerStyle); + QPen np(Qt::NoPen); - QPen p=painter.pen(); - p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); - p.setJoinStyle(Qt::RoundJoin); - p.setJoinStyle(Qt::RoundJoin); - p.setCapStyle(Qt::RoundCap); - QPen pw=p; - pw.setStyle(whiskerStyle); - QPen np(Qt::NoPen); + QBrush b=painter.brush(); + b.setColor(fillColor); + b.setStyle(fillStyle); + double yv=pos; + double p25v=percentile25; + double p75v=percentile75; + double minv=min; + double maxv=max; + double medianv=median; - QBrush b=painter.brush(); - b.setColor(fillColor); - b.setStyle(fillStyle); - double yv=pos; - double p25v=percentile25; - double p75v=percentile75; - double minv=min; - double maxv=max; - double medianv=median; + //std::cout<<"(xv, yv) = ( "<pt2px(painter, boxWidth); + double yma=y+w/2.0; + double ymi=y-w/2.0; - double w= parent->pt2px(painter, boxWidth); - double yma=y+w/2.0; - double ymi=y-w/2.0; + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.setPen(p); + { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.setBrush(b); + painter.drawRect(QRectF(p25, ymi, fabs(p75-p25), fabs(yma-ymi))); + } + + if (drawMedian) { + painter.drawLine(QLineF(median, ymi, median, yma)); + } + if (drawMinMax) { + painter.drawLine(QLineF(max, y-w/4.0, max, y+w/4.0)); + painter.drawLine(QLineF(min, y-w/4.0, min, y+w/4.0)); + painter.setPen(pw); + painter.drawLine(QLineF(max, y, p75, y)); + painter.drawLine(QLineF(min, y, p25, y)); + } + + + if (drawMean) { + double mean=transformY(this->mean); + JKQTPPlotSymbol(painter, mean, y, meanSymbol, parent->pt2px(painter, meanSymbolSize), parent->pt2px(painter, meanSymbolWidth*parent->getLineWidthMultiplier()), color, fillColor); + } - painter.save(); - painter.setPen(p); - painter.save(); - painter.setBrush(b); - painter.drawRect(QRectF(p25, ymi, fabs(p75-p25), fabs(yma-ymi))); - painter.restore(); - if (drawMedian) { - painter.drawLine(QLineF(median, ymi, median, yma)); } - if (drawMinMax) { - painter.drawLine(QLineF(max, y-w/4.0, max, y+w/4.0)); - painter.drawLine(QLineF(min, y-w/4.0, min, y+w/4.0)); - painter.setPen(pw); - painter.drawLine(QLineF(max, y, p75, y)); - painter.drawLine(QLineF(min, y, p25, y)); - } - painter.restore(); - - if (drawMean) { - double mean=transformY(this->mean); - JKQTPPlotSymbol(painter, mean, y, meanSymbol, parent->pt2px(painter, meanSymbolSize), parent->pt2px(painter, meanSymbolWidth*parent->getLineWidthMultiplier()), color, fillColor); - } - } - painter.restore(); //drawErrorsAfter(painter); } @@ -1135,7 +1165,7 @@ void JKQTPBoxplotHorizontalElement::draw(JKQTPEnhancedPainter& painter) { QPen JKQTPBoxplotVerticalGraph::getLinePen(JKQTPEnhancedPainter& painter) const { QPen p; p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH,parent->pt2px(painter, parent->getLineWidthMultiplier()*lineWidth))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH,parent->pt2px(painter, parent->getLineWidthMultiplier()*lineWidth))); p.setJoinStyle(Qt::RoundJoin); p.setCapStyle(Qt::RoundCap); @@ -1194,7 +1224,7 @@ QBrush JKQTPBoxplotVerticalElement::getBrush(JKQTPEnhancedPainter& /*painter*/) QPen JKQTPBoxplotVerticalElement::getLinePen(JKQTPEnhancedPainter& painter) const { QPen p; p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH,parent->pt2px(painter, parent->getLineWidthMultiplier()*lineWidth))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH,parent->pt2px(painter, parent->getLineWidthMultiplier()*lineWidth))); p.setJoinStyle(Qt::RoundJoin); p.setCapStyle(Qt::RoundCap); diff --git a/lib/jkqtplotter/jkqtpgraphsboxplot.h b/lib/jkqtplotter/jkqtpgraphsboxplot.h index 67e3ce951f..3da09e3e9f 100644 --- a/lib/jkqtplotter/jkqtpgraphsboxplot.h +++ b/lib/jkqtplotter/jkqtpgraphsboxplot.h @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -123,271 +123,237 @@ class JKQTP_LIB_EXPORT JKQTPBoxplotVerticalGraph: public JKQTPGraph { /** \copydoc JKQTPGraph::usesColumn() */ virtual bool usesColumn(int c) const override; - /*! \brief sets the property sortData ( \copybrief sortData ) to the specified \a __value. - \details Description of the parameter sortData is:
    \copydoc sortData
    - \see sortData for more information */ + /*! \copydoc sortData + \see see sortData for details */ inline virtual void setDataSortOrder(const DataSortOrder & __value) { this->sortData = __value; } - /*! \brief returns the property sortData ( \copybrief sortData ). - \details Description of the parameter sortData is:
    \copydoc sortData
    - \see sortData for more information */ + /*! \copydoc sortData + \see see sortData for details */ inline virtual DataSortOrder getDataSortOrder() const { return this->sortData; } /*! \brief sets the property sortData ( \copybrief sortData ) to the specified \a __value. \details Description of the parameter sortData is:
    \copydoc sortData
    \see sortData for more information */ void setDataSortOrder(int __value); - /*! \brief sets the property posColumn ( \copybrief posColumn ) to the specified \a __value. - \details Description of the parameter posColumn is:
    \copydoc posColumn
    - \see posColumn for more information */ + /*! \copydoc posColumn + \see see posColumn for details */ inline virtual void setPosColumn(int __value) { this->posColumn = __value; } - /*! \brief returns the property posColumn ( \copybrief posColumn ). - \details Description of the parameter posColumn is:
    \copydoc posColumn
    - \see posColumn for more information */ + /*! \copydoc posColumn + \see see posColumn for details */ inline virtual int getPosColumn() const { return this->posColumn; } /*! \brief sets the property posColumn ( \copybrief posColumn ) to the specified \a __value, where __value is static_cast'ed from size_t to int. \details Description of the parameter posColumn is:
    \copydoc posColumn
    - \see posColumn for more information */ + \see posColumn for more information */ inline virtual void setPosColumn (size_t __value) { this->posColumn = static_cast(__value); } - /*! \brief sets the property medianColumn ( \copybrief medianColumn ) to the specified \a __value. - \details Description of the parameter medianColumn is:
    \copydoc medianColumn
    - \see medianColumn for more information */ + /*! \copydoc medianColumn + \see see medianColumn for details */ inline virtual void setMedianColumn(int __value) { this->medianColumn = __value; } - /*! \brief returns the property medianColumn ( \copybrief medianColumn ). - \details Description of the parameter medianColumn is:
    \copydoc medianColumn
    - \see medianColumn for more information */ + /*! \copydoc medianColumn + \see see medianColumn for details */ inline virtual int getMedianColumn() const { return this->medianColumn; } /*! \brief sets the property medianColumn ( \copybrief medianColumn ) to the specified \a __value, where __value is static_cast'ed from size_t to int. \details Description of the parameter medianColumn is:
    \copydoc medianColumn
    - \see medianColumn for more information */ + \see medianColumn for more information */ inline virtual void setMedianColumn (size_t __value) { this->medianColumn = static_cast(__value); } - /*! \brief sets the property meanColumn ( \copybrief meanColumn ) to the specified \a __value. - \details Description of the parameter meanColumn is:
    \copydoc meanColumn
    - \see meanColumn for more information */ + /*! \copydoc meanColumn + \see see meanColumn for details */ inline virtual void setMeanColumn(int __value) { this->meanColumn = __value; } - /*! \brief returns the property meanColumn ( \copybrief meanColumn ). - \details Description of the parameter meanColumn is:
    \copydoc meanColumn
    - \see meanColumn for more information */ + /*! \copydoc meanColumn + \see see meanColumn for details */ inline virtual int getMeanColumn() const { return this->meanColumn; } /*! \brief sets the property meanColumn ( \copybrief meanColumn ) to the specified \a __value, where __value is static_cast'ed from size_t to int. \details Description of the parameter meanColumn is:
    \copydoc meanColumn
    - \see meanColumn for more information */ + \see meanColumn for more information */ inline virtual void setMeanColumn (size_t __value) { this->meanColumn = static_cast(__value); } - /*! \brief sets the property minColumn ( \copybrief minColumn ) to the specified \a __value. - \details Description of the parameter minColumn is:
    \copydoc minColumn
    - \see minColumn for more information */ + /*! \copydoc minColumn + \see see minColumn for details */ inline virtual void setMinColumn(int __value) { this->minColumn = __value; } - /*! \brief returns the property minColumn ( \copybrief minColumn ). - \details Description of the parameter minColumn is:
    \copydoc minColumn
    - \see minColumn for more information */ + /*! \copydoc minColumn + \see see minColumn for details */ inline virtual int getMinColumn() const { return this->minColumn; } /*! \brief sets the property minColumn ( \copybrief minColumn ) to the specified \a __value, where __value is static_cast'ed from size_t to int. \details Description of the parameter minColumn is:
    \copydoc minColumn
    - \see minColumn for more information */ + \see minColumn for more information */ inline virtual void setMinColumn( size_t __value) { this->minColumn = static_cast(__value); } - /*! \brief sets the property maxColumn ( \copybrief maxColumn ) to the specified \a __value. - \details Description of the parameter maxColumn is:
    \copydoc maxColumn
    - \see maxColumn for more information */ + /*! \copydoc maxColumn + \see see maxColumn for details */ inline virtual void setMaxColumn(int __value) { this->maxColumn = __value; } - /*! \brief returns the property maxColumn ( \copybrief maxColumn ). - \details Description of the parameter maxColumn is:
    \copydoc maxColumn
    - \see maxColumn for more information */ + /*! \copydoc maxColumn + \see see maxColumn for details */ inline virtual int getMaxColumn() const { return this->maxColumn; } /*! \brief sets the property maxColumn ( \copybrief maxColumn ) to the specified \a __value, where __value is static_cast'ed from size_t to int. \details Description of the parameter maxColumn is:
    \copydoc maxColumn
    - \see maxColumn for more information */ + \see maxColumn for more information */ inline virtual void setMaxColumn (size_t __value) { this->maxColumn = static_cast(__value); } - /*! \brief sets the property percentile25Column ( \copybrief percentile25Column ) to the specified \a __value. - \details Description of the parameter percentile25Column is:
    \copydoc percentile25Column
    - \see percentile25Column for more information */ + /*! \copydoc percentile25Column + \see see percentile25Column for details */ inline virtual void setPercentile25Column(int __value) { this->percentile25Column = __value; } - /*! \brief returns the property percentile25Column ( \copybrief percentile25Column ). - \details Description of the parameter percentile25Column is:
    \copydoc percentile25Column
    - \see percentile25Column for more information */ + /*! \copydoc percentile25Column + \see see percentile25Column for details */ inline virtual int getPercentile25Column() const { return this->percentile25Column; } /*! \brief sets the property percentile25Column ( \copybrief percentile25Column ) to the specified \a __value, where __value is static_cast'ed from size_t to int. \details Description of the parameter percentile25Column is:
    \copydoc percentile25Column
    - \see percentile25Column for more information */ + \see percentile25Column for more information */ inline virtual void setPercentile25Column (size_t __value) { this->percentile25Column = static_cast(__value); } - /*! \brief sets the property percentile75Column ( \copybrief percentile75Column ) to the specified \a __value. - \details Description of the parameter percentile75Column is:
    \copydoc percentile75Column
    - \see percentile75Column for more information */ + /*! \copydoc percentile75Column + \see see percentile75Column for details */ inline virtual void setPercentile75Column(int __value) { this->percentile75Column = __value; } - /*! \brief returns the property percentile75Column ( \copybrief percentile75Column ). - \details Description of the parameter percentile75Column is:
    \copydoc percentile75Column
    - \see percentile75Column for more information */ + /*! \copydoc percentile75Column + \see see percentile75Column for details */ inline virtual int getPercentile75Column() const { return this->percentile75Column; } /*! \brief sets the property percentile75Column ( \copybrief percentile75Column ) to the specified \a __value, where __value is static_cast'ed from size_t to int. \details Description of the parameter percentile75Column is:
    \copydoc percentile75Column
    - \see percentile75Column for more information */ + \see percentile75Column for more information */ inline virtual void setPercentile75Column (size_t __value) { this->percentile75Column = static_cast(__value); } - /*! \brief sets the property color ( \copybrief color ) to the specified \a __value. - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual void setColor(const QColor & __value) { this->color = __value; } - /*! \brief returns the property color ( \copybrief color ). - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual QColor getColor() const { return this->color; } - /*! \brief sets the property fillColor ( \copybrief fillColor ) to the specified \a __value. - \details Description of the parameter fillColor is:
    \copydoc fillColor
    - \see fillColor for more information */ + /*! \copydoc fillColor + \see see fillColor for details */ inline virtual void setFillColor(const QColor & __value) { this->fillColor = __value; } - /*! \brief returns the property fillColor ( \copybrief fillColor ). - \details Description of the parameter fillColor is:
    \copydoc fillColor
    - \see fillColor for more information */ + /*! \copydoc fillColor + \see see fillColor for details */ inline virtual QColor getFillColor() const { return this->fillColor; } - /*! \brief sets the property whiskerStyle ( \copybrief whiskerStyle ) to the specified \a __value. - \details Description of the parameter whiskerStyle is:
    \copydoc whiskerStyle
    - \see whiskerStyle for more information */ + /*! \copydoc whiskerStyle + \see see whiskerStyle for details */ inline virtual void setWhiskerStyle(const Qt::PenStyle & __value) { this->whiskerStyle = __value; } - /*! \brief returns the property whiskerStyle ( \copybrief whiskerStyle ). - \details Description of the parameter whiskerStyle is:
    \copydoc whiskerStyle
    - \see whiskerStyle for more information */ + /*! \copydoc whiskerStyle + \see see whiskerStyle for details */ inline virtual Qt::PenStyle getWhiskerStyle() const { return this->whiskerStyle; } - /*! \brief sets the property fillStyle ( \copybrief fillStyle ) to the specified \a __value. - \details Description of the parameter fillStyle is:
    \copydoc fillStyle
    - \see fillStyle for more information */ + /*! \copydoc fillStyle + \see see fillStyle for details */ inline virtual void setFillStyle(const Qt::BrushStyle & __value) { this->fillStyle = __value; } - /*! \brief returns the property fillStyle ( \copybrief fillStyle ). - \details Description of the parameter fillStyle is:
    \copydoc fillStyle
    - \see fillStyle for more information */ + /*! \copydoc fillStyle + \see see fillStyle for details */ inline virtual Qt::BrushStyle getFillStyle() const { return this->fillStyle; } - /*! \brief sets the property lineWidth ( \copybrief lineWidth ) to the specified \a __value. - \details Description of the parameter lineWidth is:
    \copydoc lineWidth
    - \see lineWidth for more information */ + /*! \copydoc lineWidth + \see see lineWidth for details */ inline virtual void setLineWidth(double __value) { this->lineWidth = __value; } - /*! \brief returns the property lineWidth ( \copybrief lineWidth ). - \details Description of the parameter lineWidth is:
    \copydoc lineWidth
    - \see lineWidth for more information */ + /*! \copydoc lineWidth + \see see lineWidth for details */ inline virtual double getLineWidth() const { return this->lineWidth; } - /*! \brief sets the property boxWidth ( \copybrief boxWidth ) to the specified \a __value. - \details Description of the parameter boxWidth is:
    \copydoc boxWidth
    - \see boxWidth for more information */ + /*! \copydoc boxWidth + \see see boxWidth for details */ inline virtual void setBoxWidth(double __value) { this->boxWidth = __value; } - /*! \brief returns the property boxWidth ( \copybrief boxWidth ). - \details Description of the parameter boxWidth is:
    \copydoc boxWidth
    - \see boxWidth for more information */ + /*! \copydoc boxWidth + \see see boxWidth for details */ inline virtual double getBoxWidth() const { return this->boxWidth; } - /*! \brief sets the property meanSymbol ( \copybrief meanSymbol ) to the specified \a __value. - \details Description of the parameter meanSymbol is:
    \copydoc meanSymbol
    - \see meanSymbol for more information */ + /*! \copydoc meanSymbol + \see see meanSymbol for details */ inline virtual void setMeanSymbol(const JKQTPGraphSymbols & __value) { this->meanSymbol = __value; } - /*! \brief returns the property meanSymbol ( \copybrief meanSymbol ). - \details Description of the parameter meanSymbol is:
    \copydoc meanSymbol
    - \see meanSymbol for more information */ + /*! \copydoc meanSymbol + \see see meanSymbol for details */ inline virtual JKQTPGraphSymbols getMeanSymbol() const { return this->meanSymbol; } - /*! \brief sets the property meanSymbolWidth ( \copybrief meanSymbolWidth ) to the specified \a __value. - \details Description of the parameter meanSymbolWidth is:
    \copydoc meanSymbolWidth
    - \see meanSymbolWidth for more information */ + /*! \copydoc meanSymbolWidth + \see see meanSymbolWidth for details */ inline virtual void setMeanSymbolWidth(double __value) { this->meanSymbolWidth = __value; } - /*! \brief returns the property meanSymbolWidth ( \copybrief meanSymbolWidth ). - \details Description of the parameter meanSymbolWidth is:
    \copydoc meanSymbolWidth
    - \see meanSymbolWidth for more information */ + /*! \copydoc meanSymbolWidth + \see see meanSymbolWidth for details */ inline virtual double getMeanSymbolWidth() const { return this->meanSymbolWidth; } - /*! \brief sets the property meanSymbolSize ( \copybrief meanSymbolSize ) to the specified \a __value. - \details Description of the parameter meanSymbolSize is:
    \copydoc meanSymbolSize
    - \see meanSymbolSize for more information */ + /*! \copydoc meanSymbolSize + \see see meanSymbolSize for details */ inline virtual void setMeanSymbolSize(double __value) { this->meanSymbolSize = __value; } - /*! \brief returns the property meanSymbolSize ( \copybrief meanSymbolSize ). - \details Description of the parameter meanSymbolSize is:
    \copydoc meanSymbolSize
    - \see meanSymbolSize for more information */ + /*! \copydoc meanSymbolSize + \see see meanSymbolSize for details */ inline virtual double getMeanSymbolSize() const { return this->meanSymbolSize; @@ -534,23 +500,20 @@ class JKQTP_LIB_EXPORT JKQTPBoxplotVerticalElement: public JKQTPPlotObject { virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) override; - /*! \brief sets the property pos ( \copybrief pos ) to the specified \a __value. - \details Description of the parameter pos is:
    \copydoc pos
    - \see pos for more information */ + /*! \copydoc pos + \see see pos for details */ inline virtual void setPos(double __value) { this->pos = __value; } - /*! \brief returns the property pos ( \copybrief pos ). - \details Description of the parameter pos is:
    \copydoc pos
    - \see pos for more information */ + /*! \copydoc pos + \see see pos for details */ inline virtual double getPos() const { return this->pos; } - /*! \brief sets the property median ( \copybrief median ) to the specified \a __value. - \details Description of the parameter median is:
    \copydoc median
    - \see median for more information */ + /*! \copydoc median + \see see median for details */ inline virtual void setMedian(double __value) { if (this->median != __value) { @@ -558,16 +521,14 @@ class JKQTP_LIB_EXPORT JKQTPBoxplotVerticalElement: public JKQTPPlotObject { drawMedian=true; } } - /*! \brief returns the property median ( \copybrief median ). - \details Description of the parameter median is:
    \copydoc median
    - \see median for more information */ + /*! \copydoc median + \see see median for details */ inline virtual double getMedian() const { return this->median; } - /*! \brief sets the property mean ( \copybrief mean ) to the specified \a __value. - \details Description of the parameter mean is:
    \copydoc mean
    - \see mean for more information */ + /*! \copydoc mean + \see see mean for details */ inline virtual void setMean(double __value) { if (this->mean != __value) { @@ -575,16 +536,14 @@ class JKQTP_LIB_EXPORT JKQTPBoxplotVerticalElement: public JKQTPPlotObject { drawMean=true; } } - /*! \brief returns the property mean ( \copybrief mean ). - \details Description of the parameter mean is:
    \copydoc mean
    - \see mean for more information */ + /*! \copydoc mean + \see see mean for details */ inline virtual double getMean() const { return this->mean; } - /*! \brief sets the property min ( \copybrief min ) to the specified \a __value. - \details Description of the parameter min is:
    \copydoc min
    - \see min for more information */ + /*! \copydoc min + \see see min for details */ inline virtual void setMin(double __value) { if (this->min != __value) { @@ -592,16 +551,14 @@ class JKQTP_LIB_EXPORT JKQTPBoxplotVerticalElement: public JKQTPPlotObject { drawMinMax=true; } } - /*! \brief returns the property min ( \copybrief min ). - \details Description of the parameter min is:
    \copydoc min
    - \see min for more information */ + /*! \copydoc min + \see see min for details */ inline virtual double getMin() const { return this->min; } - /*! \brief sets the property max ( \copybrief max ) to the specified \a __value. - \details Description of the parameter max is:
    \copydoc max
    - \see max for more information */ + /*! \copydoc max + \see see max for details */ inline virtual void setMax(double __value) { if (this->max != __value) { @@ -609,192 +566,165 @@ class JKQTP_LIB_EXPORT JKQTPBoxplotVerticalElement: public JKQTPPlotObject { drawMinMax=true; } } - /*! \brief returns the property max ( \copybrief max ). - \details Description of the parameter max is:
    \copydoc max
    - \see max for more information */ + /*! \copydoc max + \see see max for details */ inline virtual double getMax() const { return this->max; } - /*! \brief sets the property percentile25 ( \copybrief percentile25 ) to the specified \a __value. - \details Description of the parameter percentile25 is:
    \copydoc percentile25
    - \see percentile25 for more information */ + /*! \copydoc percentile25 + \see see percentile25 for details */ inline virtual void setPercentile25(double __value) { this->percentile25 = __value; } - /*! \brief returns the property percentile25 ( \copybrief percentile25 ). - \details Description of the parameter percentile25 is:
    \copydoc percentile25
    - \see percentile25 for more information */ + /*! \copydoc percentile25 + \see see percentile25 for details */ inline virtual double getPercentile25() const { return this->percentile25; } - /*! \brief sets the property percentile75 ( \copybrief percentile75 ) to the specified \a __value. - \details Description of the parameter percentile75 is:
    \copydoc percentile75
    - \see percentile75 for more information */ + /*! \copydoc percentile75 + \see see percentile75 for details */ inline virtual void setPercentile75(double __value) { this->percentile75 = __value; } - /*! \brief returns the property percentile75 ( \copybrief percentile75 ). - \details Description of the parameter percentile75 is:
    \copydoc percentile75
    - \see percentile75 for more information */ + /*! \copydoc percentile75 + \see see percentile75 for details */ inline virtual double getPercentile75() const { return this->percentile75; } - /*! \brief sets the property color ( \copybrief color ) to the specified \a __value. - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual void setColor(const QColor & __value) { this->color = __value; } - /*! \brief returns the property color ( \copybrief color ). - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual QColor getColor() const { return this->color; } - /*! \brief sets the property fillColor ( \copybrief fillColor ) to the specified \a __value. - \details Description of the parameter fillColor is:
    \copydoc fillColor
    - \see fillColor for more information */ + /*! \copydoc fillColor + \see see fillColor for details */ inline virtual void setFillColor(const QColor & __value) { this->fillColor = __value; } - /*! \brief returns the property fillColor ( \copybrief fillColor ). - \details Description of the parameter fillColor is:
    \copydoc fillColor
    - \see fillColor for more information */ + /*! \copydoc fillColor + \see see fillColor for details */ inline virtual QColor getFillColor() const { return this->fillColor; } - /*! \brief sets the property whiskerStyle ( \copybrief whiskerStyle ) to the specified \a __value. - \details Description of the parameter whiskerStyle is:
    \copydoc whiskerStyle
    - \see whiskerStyle for more information */ + /*! \copydoc whiskerStyle + \see see whiskerStyle for details */ inline virtual void setWhiskerStyle(const Qt::PenStyle & __value) { this->whiskerStyle = __value; } - /*! \brief returns the property whiskerStyle ( \copybrief whiskerStyle ). - \details Description of the parameter whiskerStyle is:
    \copydoc whiskerStyle
    - \see whiskerStyle for more information */ + /*! \copydoc whiskerStyle + \see see whiskerStyle for details */ inline virtual Qt::PenStyle getWhiskerStyle() const { return this->whiskerStyle; } - /*! \brief sets the property lineWidth ( \copybrief lineWidth ) to the specified \a __value. - \details Description of the parameter lineWidth is:
    \copydoc lineWidth
    - \see lineWidth for more information */ + /*! \copydoc lineWidth + \see see lineWidth for details */ inline virtual void setLineWidth(double __value) { this->lineWidth = __value; } - /*! \brief returns the property lineWidth ( \copybrief lineWidth ). - \details Description of the parameter lineWidth is:
    \copydoc lineWidth
    - \see lineWidth for more information */ + /*! \copydoc lineWidth + \see see lineWidth for details */ inline virtual double getLineWidth() const { return this->lineWidth; } - /*! \brief sets the property boxWidth ( \copybrief boxWidth ) to the specified \a __value. - \details Description of the parameter boxWidth is:
    \copydoc boxWidth
    - \see boxWidth for more information */ + /*! \copydoc boxWidth + \see see boxWidth for details */ inline virtual void setBoxWidth(double __value) { this->boxWidth = __value; } - /*! \brief returns the property boxWidth ( \copybrief boxWidth ). - \details Description of the parameter boxWidth is:
    \copydoc boxWidth
    - \see boxWidth for more information */ + /*! \copydoc boxWidth + \see see boxWidth for details */ inline virtual double getBoxWidth() const { return this->boxWidth; } - /*! \brief sets the property meanSymbol ( \copybrief meanSymbol ) to the specified \a __value. - \details Description of the parameter meanSymbol is:
    \copydoc meanSymbol
    - \see meanSymbol for more information */ + /*! \copydoc meanSymbol + \see see meanSymbol for details */ inline virtual void setMeanSymbol(const JKQTPGraphSymbols & __value) { this->meanSymbol = __value; } - /*! \brief returns the property meanSymbol ( \copybrief meanSymbol ). - \details Description of the parameter meanSymbol is:
    \copydoc meanSymbol
    - \see meanSymbol for more information */ + /*! \copydoc meanSymbol + \see see meanSymbol for details */ inline virtual JKQTPGraphSymbols getMeanSymbol() const { return this->meanSymbol; } - /*! \brief sets the property meanSymbolWidth ( \copybrief meanSymbolWidth ) to the specified \a __value. - \details Description of the parameter meanSymbolWidth is:
    \copydoc meanSymbolWidth
    - \see meanSymbolWidth for more information */ + /*! \copydoc meanSymbolWidth + \see see meanSymbolWidth for details */ inline virtual void setMeanSymbolWidth(double __value) { this->meanSymbolWidth = __value; } - /*! \brief returns the property meanSymbolWidth ( \copybrief meanSymbolWidth ). - \details Description of the parameter meanSymbolWidth is:
    \copydoc meanSymbolWidth
    - \see meanSymbolWidth for more information */ + /*! \copydoc meanSymbolWidth + \see see meanSymbolWidth for details */ inline virtual double getMeanSymbolWidth() const { return this->meanSymbolWidth; } - /*! \brief sets the property meanSymbolSize ( \copybrief meanSymbolSize ) to the specified \a __value. - \details Description of the parameter meanSymbolSize is:
    \copydoc meanSymbolSize
    - \see meanSymbolSize for more information */ + /*! \copydoc meanSymbolSize + \see see meanSymbolSize for details */ inline virtual void setMeanSymbolSize(double __value) { this->meanSymbolSize = __value; } - /*! \brief returns the property meanSymbolSize ( \copybrief meanSymbolSize ). - \details Description of the parameter meanSymbolSize is:
    \copydoc meanSymbolSize
    - \see meanSymbolSize for more information */ + /*! \copydoc meanSymbolSize + \see see meanSymbolSize for details */ inline virtual double getMeanSymbolSize() const { return this->meanSymbolSize; } - /*! \brief sets the property drawMean ( \copybrief drawMean ) to the specified \a __value. - \details Description of the parameter drawMean is:
    \copydoc drawMean
    - \see drawMean for more information */ + /*! \copydoc drawMean + \see see drawMean for details */ inline virtual void setDrawMean(bool __value) { this->drawMean = __value; } - /*! \brief returns the property drawMean ( \copybrief drawMean ). - \details Description of the parameter drawMean is:
    \copydoc drawMean
    - \see drawMean for more information */ + /*! \copydoc drawMean + \see see drawMean for details */ inline virtual bool getDrawMean() const { return this->drawMean; } - /*! \brief sets the property drawMedian ( \copybrief drawMedian ) to the specified \a __value. - \details Description of the parameter drawMedian is:
    \copydoc drawMedian
    - \see drawMedian for more information */ + /*! \copydoc drawMedian + \see see drawMedian for details */ inline virtual void setDrawMedian(bool __value) { this->drawMedian = __value; } - /*! \brief returns the property drawMedian ( \copybrief drawMedian ). - \details Description of the parameter drawMedian is:
    \copydoc drawMedian
    - \see drawMedian for more information */ + /*! \copydoc drawMedian + \see see drawMedian for details */ inline virtual bool getDrawMedian() const { return this->drawMedian; } - /*! \brief sets the property drawMinMax ( \copybrief drawMinMax ) to the specified \a __value. - \details Description of the parameter drawMinMax is:
    \copydoc drawMinMax
    - \see drawMinMax for more information */ + /*! \copydoc drawMinMax + \see see drawMinMax for details */ inline virtual void setDrawMinMax(bool __value) { this->drawMinMax = __value; } - /*! \brief returns the property drawMinMax ( \copybrief drawMinMax ). - \details Description of the parameter drawMinMax is:
    \copydoc drawMinMax
    - \see drawMinMax for more information */ + /*! \copydoc drawMinMax + \see see drawMinMax for details */ inline virtual bool getDrawMinMax() const { return this->drawMinMax; diff --git a/lib/jkqtplotter/jkqtpgraphscontour.cpp b/lib/jkqtplotter/jkqtpgraphscontour.cpp new file mode 100644 index 0000000000..8f5c7094d8 --- /dev/null +++ b/lib/jkqtplotter/jkqtpgraphscontour.cpp @@ -0,0 +1,488 @@ +/* + Copyright (c) 2008-2019 Jan W. Krieger & Sebastian Isbaner (contour plot) + + + + 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 . +*/ + + +#include "jkqtplotter/jkqtpgraphscontour.h" +#include "jkqtplotter/jkqtpbaseplotter.h" +#include "jkqtplottertools/jkqtpimagetools.h" +#include "jkqtplottertools/jkqtptools.h" +#include "jkqtplottertools/jkqtpenhancedpainter.h" +#include "jkqtplotter/jkqtplotter.h" +#include +#include +#include +#include +#include +#include +# include + + +void JKQTPContour::draw(JKQTPEnhancedPainter &painter) +{ + //qDebug()<<"JKQTPContourPlot::draw"; + + if(contourLevels.isEmpty()) createContourLevels(numberOfLevels); + else { + numberOfLevels=contourLevels.size(); +// qSort(contourLevels); + } + + if(contourLines.isEmpty()) { // contour lines are only calculated once + for(int i =0; i (0)); + } + this->calcContourLines(contourLines); + } + + + + // draw lines + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + QPen p; + p.setStyle(style); + p.setColor(lineColor); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); + + painter.setPen(p); + QImage colorLevels = getPaletteImage(palette,numberOfLevels); + QVector contourLinesTransformedSingleLevel; + QLineF lineTranformed; + for(int i =0; i::const_iterator line =contourLines.at(i).begin(); line!=contourLines.at(i).end();++line ) { + lineTranformed.setP1(transform(x+line->p1().x()/double(Nx-1)*width, y+line->p1().y()/double(Ny-1)*height)); + lineTranformed.setP2(transform(x+line->p2().x()/double(Nx-1)*width, y+line->p2().y()/double(Ny-1)*height)); + contourLinesTransformedSingleLevel.append(lineTranformed); + } + painter.drawLines(contourLinesTransformedSingleLevel); + contourLinesTransformedSingleLevel.clear(); + } + + +} + +void JKQTPContour::createContourLevels(int nLevels) +{ + if (!data) return; + if (nLevels<1) return; + double min,max; + getDataMinMax(min,max); + double delta=(max-min)/static_cast(nLevels+1); + + for(int i=1; i<=nLevels; ++i) { + contourLevels.append(min + i*delta); + } + relativeLevels=false; + +} + +void JKQTPContour::createContourLevelsLog(int nLevels, int m) +{ + if (!data) return; + if (nLevels<1) return; + double min,max; + getDataMinMax(min,max); + if(min<=0) min=1; // FIXME get smallest number greater zero + + int S=floor((log10(max)-log10(min))/log10(m)); + if(S<2) S=1; + int P = floor(static_cast(nLevels)/static_cast(S)); + if(P<1) P=1; + + double delta=min; + contourLevels.append(2*delta); + for (long s=0; sgetDatastore()->getColumn(columnID).getPointer(0); +} + + +void JKQTPContour::ensureImageData() +{ +} + +double JKQTPContour::value(int xIdx, int yIdx) +{ + // row-major in datastore + ensureImageData(); + if (!data) return 0; + switch(datatype) { + case JKQTPMathImageBase::DoubleArray: + return (static_cast(data))[yIdx*getNx()+xIdx]; + case JKQTPMathImageBase::FloatArray: + return (static_cast(data))[yIdx*getNx()+xIdx]; + case JKQTPMathImageBase::UInt8Array: + return (static_cast(data))[yIdx*getNx()+xIdx]; + case JKQTPMathImageBase::UInt16Array: + return (static_cast(data))[yIdx*getNx()+xIdx]; + case JKQTPMathImageBase::UInt32Array: + return (static_cast(data))[yIdx*getNx()+xIdx]; + case JKQTPMathImageBase::UInt64Array: + return (static_cast(data))[yIdx*getNx()+xIdx]; + case JKQTPMathImageBase::Int8Array: + return (static_cast(data))[yIdx*getNx()+xIdx]; + case JKQTPMathImageBase::Int16Array: + return (static_cast(data))[yIdx*getNx()+xIdx]; + case JKQTPMathImageBase::Int32Array: + return (static_cast(data))[yIdx*getNx()+xIdx]; + case JKQTPMathImageBase::Int64Array: + return (static_cast(data))[yIdx*getNx()+xIdx]; + default: + return 0; + } +} + +bool JKQTPContour::intersect(QLineF &line, const QVector3D &vertex1,const QVector3D &vertex2,const QVector3D &vertex3,double level) +{ + bool found = true; + + // Are the vertices below (-1), on (0) or above (1) the plane ? + const int eq1 = compare2level(vertex1,level); + const int eq2 = compare2level(vertex2,level); + const int eq3 = compare2level(vertex3,level); + + /* + (a) All the vertices lie below the contour level. + (b) Two vertices lie below and one on the contour level. + (c) Two vertices lie below and one above the contour level. + (d) One vertex lies below and two on the contour level. + (e) One vertex lies below, one on and one above the contour level. + (f) One vertex lies below and two above the contour level. + (g) Three vertices lie on the contour level. + (h) Two vertices lie on and one above the contour level. + (i) One vertex lies on and two above the contour level. + (j) All the vertices lie above the contour level. + */ + + static const int caseLUT[3][3][3] = + { + // jump table to avoid nested case statements + { { 0, 0, 8 }, { 0, 2, 5 }, { 7, 6, 9 } }, + { { 0, 3, 4 }, { 1, 10, 1 }, { 4, 3, 0 } }, + { { 9, 6, 7 }, { 5, 2, 0 }, { 8, 0, 0 } } + }; + + const int caseType = caseLUT[eq1+1][eq2+1][eq3+1]; + switch (caseType) + { + case 1: + // d(0,0,-1), h(0,0,1) + line.setP1(vertex1.toPointF()); + line.setP2(vertex2.toPointF()); + break; + case 2: + // d(-1,0,0), h(1,0,0) + line.setP1(vertex2.toPointF()); + line.setP2(vertex3.toPointF()); + break; + case 3: + // d(0,-1,0), h(0,1,0) + line.setP1(vertex3.toPointF()); + line.setP2(vertex1.toPointF()); + break; + case 4: + // e(0,-1,1), e(0,1,-1) + line.setP1(vertex1.toPointF()); + line.setP2(interpolatePoint(vertex2, vertex3, level)); + break; + case 5: + // e(-1,0,1), e(1,0,-1) + line.setP1(vertex2.toPointF()); + line.setP2(interpolatePoint(vertex3, vertex1, level)); + break; + case 6: + // e(-1,1,0), e(1,0,-1) + line.setP1(vertex3.toPointF()); + line.setP2(interpolatePoint(vertex1, vertex2, level)); + break; + case 7: + // c(-1,1,-1), f(1,1,-1) + line.setP1(interpolatePoint(vertex1, vertex2, level)); + line.setP2(interpolatePoint(vertex2, vertex3, level)); + break; + case 8: + // c(-1,-1,1), f(1,1,-1) + line.setP1(interpolatePoint(vertex2, vertex3, level)); + line.setP2(interpolatePoint(vertex3, vertex1, level)); + break; + case 9: + // f(-1,1,1), c(1,-1,-1) + line.setP1(interpolatePoint(vertex3, vertex1, level)); + line.setP2(interpolatePoint(vertex1, vertex2, level)); + break; + case 10: + // g(0,0,0) + // The CONREC algorithm has no satisfying solution for + // what to do, when all vertices are on the plane. + + if ( ignoreOnPlane ) + found = false; + else + { + line.setP1(vertex3.toPointF()); + line.setP2(vertex1.toPointF()); + } + break; + default: + found = false; + } +// qDebug()<getNextStyle(); + style=parent->getPlotStyle(parentPlotStyle).style(); + lineWidth=parent->getPlotStyle(parentPlotStyle).widthF(); + } +} + +JKQTPContour::JKQTPContour(double x, double y, double width, double height, void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette, DataType datatype, JKQTBasePlotter* parent) : + JKQTPMathImage( x, y, width, height, datatype, data, Nx, Ny, palette, parent) +{ + lineColor=QColor("red"); + colorBarRightVisible=false; + lineWidth=1; + style=Qt::SolidLine; + ignoreOnPlane=false; + numberOfLevels=1; + colorFromPalette=true; + relativeLevels=false; + + if (parent) { // get style settings from parent object + int parentPlotStyle=parent->getNextStyle(); + style=parent->getPlotStyle(parentPlotStyle).style(); + lineWidth=parent->getPlotStyle(parentPlotStyle).widthF(); + } +} + + +JKQTPContour::JKQTPContour(JKQTPlotter *parent) : + JKQTPContour(parent->getPlotter()) +{ + +} + +JKQTPContour::JKQTPContour(double x, double y, double width, double height, void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette, DataType datatype, JKQTPlotter* parent) : + JKQTPMathImage( x, y, width, height, datatype, data, Nx, Ny, palette, parent) +{ + lineColor=QColor("red"); + colorBarRightVisible=false; + lineWidth=1; + style=Qt::SolidLine; + ignoreOnPlane=false; + numberOfLevels=1; + colorFromPalette=true; + relativeLevels=false; +} +int JKQTPContour::compare2level(const QVector3D &vertex, double level) +{ + if (vertex.z() > level) + return 1; + + if (vertex.z() < level) + return -1; + + return 0; +} + +void JKQTPContour::calcContourLines(QList > &ContourLines) +{ + + double scale=1; ///< scale of the contour levels; + + if(relativeLevels) { + double min; + double max; + getDataMinMax(min,max); + scale=1/(max-min); + } + + enum Position + { + // the positions of points of one box + // vertex 1 +-------------------+ vertex 2 + // | \ / | + // | \ m=3 / | + // | \ / | + // | \ / | + // | m=2 X m=2 | the center is vertex 0 + // | / \ | + // | / \ | + // | / m=1 \ | + // | / \ | + // vertex 4 +-------------------+ vertex 3 + Center=0, + + TopLeft=1, + TopRight=2, + BottomRight=3, + BottomLeft=4, + + NumPositions=5 + }; + + + for ( int yp = 0; yp < (int64_t)getNy() - 1; ++yp ) { // go through image (pixel coordinates) in row major order + QVector vertices(NumPositions); + + for ( int xp = 0; xp < (int64_t)getNy() - 1; ++xp ) { + + if ( xp == 0 ) + { + vertices[TopRight].setX(xp); // will be used for TopLeft later + vertices[TopRight].setY(yp); + vertices[TopRight].setZ( + value( vertices[TopRight].x(), vertices[TopRight].y())*scale + ); + + vertices[BottomRight].setX(xp); + vertices[BottomRight].setY(yp+1); + vertices[BottomRight].setZ( + value(vertices[BottomRight].x(), vertices[BottomRight].y())*scale + ); + } + + vertices[TopLeft] = vertices[TopRight]; // use right vertices of the last box as new left vertices + vertices[BottomLeft] = vertices[BottomRight]; + + vertices[TopRight].setX(xp + 1); + vertices[TopRight].setY(yp); // <---- + vertices[TopRight].setZ( + value(vertices[TopRight].x(), vertices[TopRight].y())*scale + ); + + vertices[BottomRight].setX(xp + 1); + vertices[BottomRight].setY(yp + 1); + vertices[BottomRight].setZ( + value(vertices[BottomRight].x(), vertices[BottomRight].y())*scale + ); + + double zMin = vertices[TopLeft].z(); + double zMax = zMin; + double zSum = zMin; + + for ( int i = TopRight; i <= BottomLeft; ++i ) { + const double z = vertices[i].z(); + + zSum += z; + if ( z < zMin ) + zMin = z; + if ( z > zMax ) + zMax = z; + } + + + if ( zMax >= contourLevels.first() && zMin <= contourLevels.last() ) { + + vertices[Center].setX(xp + 0.5); // pseudo pixel coordinates + vertices[Center].setY(yp + 0.5); + vertices[Center].setZ(0.25 * zSum); + for (int levelIdx=0; levelIdx= zMin && contourLevels.at(levelIdx) <= zMax ) { + + QLineF line; + QVector triangle(3); + + /* triangle[1] + X + / \ + / \ + / m \ + / \ + triangle[2] +-------------------+ triangle[0] + */ + + for (int m = TopLeft; m < NumPositions; m++) { // construct triangles + triangle[0] = vertices[m]; + triangle[1] = vertices[Center]; + triangle[2] = vertices[(m!=BottomLeft)?(m + 1):TopLeft]; + + const bool intersects =intersect(line, triangle.at(0),triangle.at(1),triangle.at(2), + contourLevels.at(levelIdx)); + if ( intersects ) { + ContourLines[levelIdx]<http://paulbourke.net/papers/conrec/ + * The implementation for Qt is adapted from Qwt + * http://qwt.sourceforge.net/ + * + * The contour lines are calculated only once and then redrawn to save plotting time. + * Make sure you add a new graph when your data changes. The contour levels can be defined in + * contourLevels, each elemt in the list represents a contour plane. You can also create contour + * levels with createContourLevels(). The levels are linearly spaced between the maximum and minimum + * value in your data. For logarithmic data, use createContourLevelsLog() to create contour levels + * with logarithmic spacing. + * + * \author Sebastian Isbaner, 2013-2014 + * + * \image html JKQTPContour.png + */ +class JKQTP_LIB_EXPORT JKQTPContour: public JKQTPMathImage { + Q_OBJECT + public: + /** \brief class constructor */ + JKQTPContour(JKQTBasePlotter* parent=nullptr); + /** \brief class constructor */ + JKQTPContour(double x, double y, double width, double height, void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette=JKQTPMathImageGRAY, DataType datatype = JKQTPMathImageBase::DoubleArray, JKQTBasePlotter* parent=nullptr); + /** \brief class constructor */ + JKQTPContour(JKQTPlotter* parent); + /** \brief class constructor */ + JKQTPContour(double x, double y, double width, double height, void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette, DataType datatype , JKQTPlotter* parent); + /** \brief plots the graph to the plotter object specified as parent */ + virtual void draw(JKQTPEnhancedPainter& painter) override; + + /** \brief creates at nLevels contour levels linearly spaced between the data's minimum and maximum values */ + void createContourLevels(int nLevels=3); + /** \brief creates at least nLevels contour levels with logarithmic spacing. FIXME: Has not been tested yet */ + void createContourLevelsLog(int nLevels=3,int m=2); + + /*! \copydoc lineColor + \see see lineColor for details */ + inline virtual void setLineColor(const QColor & __value) + { + this->lineColor = __value; + } + /*! \copydoc lineColor + \see see lineColor for details */ + inline virtual QColor getLineColor() const + { + return this->lineColor; + } + /*! \copydoc style + \see see style for details */ + inline virtual void setStyle(const Qt::PenStyle & __value) + { + this->style = __value; + } + /*! \copydoc style + \see see style for details */ + inline virtual Qt::PenStyle getStyle() const + { + return this->style; + } + /*! \copydoc lineWidth + \see see lineWidth for details */ + inline virtual void setLineWidth(double __value) + { + this->lineWidth = __value; + } + /*! \copydoc lineWidth + \see see lineWidth for details */ + inline virtual double getLineWidth() const + { + return this->lineWidth; + } + /*! \copydoc ignoreOnPlane + \see see ignoreOnPlane for details */ + inline virtual void setIgnoreOnPlane(bool __value) + { + this->ignoreOnPlane = __value; + } + /*! \copydoc ignoreOnPlane + \see see ignoreOnPlane for details */ + inline virtual bool getIgnoreOnPlane() const + { + return this->ignoreOnPlane; + } + /*! \copydoc numberOfLevels + \see see numberOfLevels for details */ + inline virtual void setNumberOfLevels(int __value) + { + this->numberOfLevels = __value; + } + /*! \copydoc numberOfLevels + \see see numberOfLevels for details */ + inline virtual int getNumberOfLevels() const + { + return this->numberOfLevels; + } + /*! \copydoc colorFromPalette + \see see colorFromPalette for details */ + inline virtual void setColorFromPalette(bool __value) + { + this->colorFromPalette = __value; + } + /*! \copydoc colorFromPalette + \see see colorFromPalette for details */ + inline virtual bool getColorFromPalette() const + { + return this->colorFromPalette; + } + /*! \copydoc contourLevels + \see see contourLevels for details */ + inline virtual void setContourLevels(const QList & __value) + { + this->contourLevels = __value; + } + /*! \copydoc contourLevels + \see see contourLevels for details */ + inline virtual QList getContourLevels() const + { + return this->contourLevels; + } + /*! \copydoc relativeLevels + \see see relativeLevels for details */ + inline virtual void setRelativeLevels(bool __value) + { + this->relativeLevels = __value; + } + /*! \copydoc relativeLevels + \see see relativeLevels for details */ + inline virtual bool getRelativeLevels() const + { + return this->relativeLevels; + } + /** convenience function to work with JKQTPDatastore */ + void setImageColumn(size_t columnID); + + void addContourLevel(double &level); + + + + protected: + /** \brief color of the contour lines */ + QColor lineColor; + /** \brief linestyle of the contour lines */ + Qt::PenStyle style; + /** \brief width (pixels) of the graph */ + double lineWidth; + /** \brief if true, vertices that all lie on the contour plane will be ignored*/ + bool ignoreOnPlane; + /** \brief if true, the colors of the \a palette are used for the contour lines */ + bool colorFromPalette; + /** \brief the number of contour levels. Is only used if contourLevels is empty*/ + int numberOfLevels; + + /** \brief the list of contour levels */ + QList contourLevels; +// /** \brief indicates wether the contour levels are absolute values or relative to the maximum (max-min) */ + bool relativeLevels; + virtual void ensureImageData() override; + +private: + double value(int xIdx, int yIdx); + /// gives the intersection line of a plane defined by three vertices with a contour level in the x-y plane of heigth level + bool intersect(QLineF &line, const QVector3D &vertex1,const QVector3D &vertex2,const QVector3D &vertex3,double level); + /** + * @brief interpolatePoint linear interpolation of a line to the x-y plane using the z-value relative to level + * @param point1 start point of the line + * @param point2 end point of the line + * @param level the heigth for the interpolation (this z-value is projected onto the xy-plane) + * @return the interpolated point in the x-y plane + */ + QPointF interpolatePoint(const QVector3D &point1, const QVector3D &point2,double level); + /** + * @brief compare2level checks if the vertex lies above, under or on the contour plane level + * @param vertex + * @param level contour plane + * @return above (1), on the plane (0), below (-1); + */ + int compare2level(const QVector3D &vertex, double level); + /** + * @brief calcContourLines calculates the contour lines using the CONREC algorithm + */ + void calcContourLines(QList > &ContourLines); + /// the contour lines as vector of single lines (one for each triangle). the list index refers to the contour level. + QList > contourLines; // contour levels, squares on grid, line + +}; + + + + + +#endif // JKQTPGRAPHSCONTOUR_H + diff --git a/lib/jkqtplotter/jkqtpgraphsevaluatedfunction.cpp b/lib/jkqtplotter/jkqtpgraphsevaluatedfunction.cpp index b8fad8ce1d..26f05005d2 100644 --- a/lib/jkqtplotter/jkqtpgraphsevaluatedfunction.cpp +++ b/lib/jkqtplotter/jkqtpgraphsevaluatedfunction.cpp @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -71,11 +71,15 @@ JKQTPXFunctionLineGraph::JKQTPXFunctionLineGraph(JKQTBasePlotter* parent): parentPlotStyle=parent->getNextStyle(); //std::cout<<"got style settings from parent: "<getPlotStyle(parentPlotStyle).color(); - fillColor=color.lighter(); + fillColor=parent->getPlotStyle(parentPlotStyle).fillColor(); style=parent->getPlotStyle(parentPlotStyle).style(); - errorColor=color.lighter(); - errorFillColor=color.lighter(); - errorStyle=style; + lineWidth=parent->getPlotStyle(parentPlotStyle).widthF(); + fillStyle=parent->getPlotStyle(parentPlotStyle).fillStyle(); + errorColor=parent->getPlotStyle(parentPlotStyle).errorColor(); + errorStyle=parent->getPlotStyle(parentPlotStyle).errorStyle(); + errorLineWidth=parent->getPlotStyle(parentPlotStyle).errorWidthF(); + errorFillStyle=parent->getPlotStyle(parentPlotStyle).errorFillStyle(); + errorFillColor=parent->getPlotStyle(parentPlotStyle).errorFillColor(); } fillColor.setAlphaF(0.5); errorFillColor.setAlphaF(0.5); @@ -118,11 +122,15 @@ JKQTPXFunctionLineGraph::JKQTPXFunctionLineGraph(JKQTPlotter* parent): parentPlotStyle=parent->getNextStyle(); //std::cout<<"got style settings from parent: "<getPlotStyle(parentPlotStyle).color(); - fillColor=color.lighter(); + fillColor=parent->getPlotStyle(parentPlotStyle).fillColor(); style=parent->getPlotStyle(parentPlotStyle).style(); - errorColor=color.lighter(); - errorFillColor=color.lighter(); - errorStyle=style; + lineWidth=parent->getPlotStyle(parentPlotStyle).widthF(); + fillStyle=parent->getPlotStyle(parentPlotStyle).fillStyle(); + errorColor=parent->getPlotStyle(parentPlotStyle).errorColor(); + errorStyle=parent->getPlotStyle(parentPlotStyle).errorStyle(); + errorLineWidth=parent->getPlotStyle(parentPlotStyle).errorWidthF(); + errorFillStyle=parent->getPlotStyle(parentPlotStyle).errorFillStyle(); + errorFillColor=parent->getPlotStyle(parentPlotStyle).errorFillColor(); } fillColor.setAlphaF(0.5); errorFillColor.setAlphaF(0.5); @@ -189,7 +197,7 @@ jkqtpSimplePlotFunctionType JKQTPXFunctionLineGraph::getSimplePlotFunction() con void JKQTPXFunctionLineGraph::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) { - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); QPen p=painter.pen(); p.setJoinStyle(Qt::RoundJoin); p.setCapStyle(Qt::RoundCap); @@ -205,7 +213,7 @@ void JKQTPXFunctionLineGraph::drawKeyMarker(JKQTPEnhancedPainter& painter, QRect painter.setBrush(b); if (fillCurve) painter.drawRect(rect); if (!fillCurve & drawLine) painter.drawLine(QLineF(rect.left(), y, rect.right(), y)); - painter.restore(); + } QColor JKQTPXFunctionLineGraph::getKeyLabelColor() { @@ -380,158 +388,158 @@ void JKQTPXFunctionLineGraph::draw(JKQTPEnhancedPainter& painter) { //qDebug()<<"plot data created\n"; drawErrorsBefore(painter); + { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); - painter.save(); + QPen p=painter.pen(); + p.setColor(color); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); + p.setStyle(style); + p.setJoinStyle(Qt::RoundJoin); + p.setJoinStyle(Qt::RoundJoin); + p.setCapStyle(Qt::RoundCap); + QPen np(Qt::NoPen); - QPen p=painter.pen(); - p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); - p.setStyle(style); - p.setJoinStyle(Qt::RoundJoin); - p.setJoinStyle(Qt::RoundJoin); - p.setCapStyle(Qt::RoundCap); - QPen np(Qt::NoPen); + QPen ep=painter.pen(); + ep.setColor(errorColor); + ep.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, errorLineWidth*parent->getLineWidthMultiplier()))); + ep.setStyle(errorStyle); + ep.setJoinStyle(Qt::RoundJoin); - QPen ep=painter.pen(); - ep.setColor(errorColor); - ep.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, errorLineWidth*parent->getLineWidthMultiplier()))); - ep.setStyle(errorStyle); - ep.setJoinStyle(Qt::RoundJoin); + QBrush b=painter.brush(); + b.setColor(fillColor); + b.setStyle(fillStyle); - QBrush b=painter.brush(); - b.setColor(fillColor); - b.setStyle(fillStyle); - - QBrush eb=painter.brush(); - eb.setColor(errorFillColor); - eb.setStyle(errorFillStyle); + QBrush eb=painter.brush(); + eb.setColor(errorFillColor); + eb.setStyle(errorFillStyle); -// double xold=-1; -// double yold=-1; -// double ypeold=-1; -// double ymeold=-1; + // double xold=-1; + // double yold=-1; + // double ypeold=-1; + // double ymeold=-1; -// double x0=transformX(0); -// if (parent->getXAxis()->isLogAxis()) x0=transformX(parent->getXAxis()->getMin()); - double y0=transformY(0); - if (parent->getYAxis()->isLogAxis()) y0=transformY(parent->getYAxis()->getMin()); - bool first=false; - doublePair* d=data; - //QPainterPath pa, pfill; - //QPainterPath pel, pef; - QPolygonF filledPolygon, linePolygon, errorLineTop, errorLineBottom; - QList epTop, epBottom; - double yami=qMin(transformY(parent->getYAxis()->getMin()),transformY(parent->getYAxis()->getMax())); - double yama=qMax(transformY(parent->getYAxis()->getMin()),transformY(parent->getYAxis()->getMax())); - double dypix=fabs(yama-yami); - yami=yami-2*dypix; - yama=yama+2*dypix; - while (d!=nullptr) { - - double xv=d->x; - double yv=d->f; - //std::cout<<"(xv, yv) = ( "<(errorPlotFunction))) { - double e=errorPlotFunction(xv, errorParams); - ype=transformY(yv+e); - yme=transformY(yv-e); - ype=qBound(yami, ype, yama); - yme=qBound(yami, yme, yama); - } - - y=qBound(yami, y, yama); - - if (fillCurve) { - if (!first) filledPolygon<next) filledPolygon<(errorPlotFunction))) { - epTop<(errorPlotFunction))) { - errorLineTop<next; - } - if (drawErrorPolygons) { - painter.save(); - painter.setBrush(eb); - painter.setPen(np); - QPolygonF poly; - //poly << QPointF(xold, ypeold) << QPointF(x, ype)<< QPointF(x, yme) << QPointF(xold, ymeold) ; - for (int i=0; i=0; i--) { - poly<(errorPlotFunction))) { - painter.save(); - painter.setPen(ep); - painter.drawPolyline(errorLineTop); - painter.drawPolyline(errorLineBottom); - painter.restore(); - - } - - - QColor c=color; - c.setHsv(fmod(color.hue()+90, 360), color.saturation(), color.value()); - d=data; - if (displaySamplePoints) { - painter.save(); + // double x0=transformX(0); + // if (parent->getXAxis()->isLogAxis()) x0=transformX(parent->getXAxis()->getMin()); + double y0=transformY(0); + if (parent->getYAxis()->isLogAxis()) y0=transformY(parent->getYAxis()->getMin()); + bool first=false; + doublePair* d=data; + //QPainterPath pa, pfill; + //QPainterPath pel, pef; + QPolygonF filledPolygon, linePolygon, errorLineTop, errorLineBottom; + QList epTop, epBottom; + double yami=qMin(transformY(parent->getYAxis()->getMin()),transformY(parent->getYAxis()->getMax())); + double yama=qMax(transformY(parent->getYAxis()->getMin()),transformY(parent->getYAxis()->getMax())); + double dypix=fabs(yama-yami); + yami=yami-2*dypix; + yama=yama+2*dypix; while (d!=nullptr) { + double xv=d->x; double yv=d->f; //std::cout<<"(xv, yv) = ( "<getLineWidthMultiplier(), c, QColor(Qt::transparent)); + double ype=0, yme=0; + if ((drawErrorLines || drawErrorPolygons) && (static_cast(errorPlotFunction))) { + double e=errorPlotFunction(xv, errorParams); + ype=transformY(yv+e); + yme=transformY(yv-e); + ype=qBound(yami, ype, yama); + yme=qBound(yami, yme, yama); + } + + y=qBound(yami, y, yama); + + if (fillCurve) { + if (!first) filledPolygon<next) filledPolygon<(errorPlotFunction))) { + epTop<(errorPlotFunction))) { + errorLineTop<next; } - painter.restore(); + if (drawErrorPolygons) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.setBrush(eb); + painter.setPen(np); + QPolygonF poly; + //poly << QPointF(xold, ypeold) << QPointF(x, ype)<< QPointF(x, yme) << QPointF(xold, ymeold) ; + for (int i=0; i=0; i--) { + poly<(errorPlotFunction))) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.setPen(ep); + painter.drawPolyline(errorLineTop); + painter.drawPolyline(errorLineBottom); + + + } + + + QColor c=color; + c.setHsv(fmod(color.hue()+90, 360), color.saturation(), color.value()); + d=data; + if (displaySamplePoints) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + while (d!=nullptr) { + double xv=d->x; + double yv=d->f; + //std::cout<<"(xv, yv) = ( "<getLineWidthMultiplier(), c, QColor(Qt::transparent)); + } + d=d->next; + } + + } } - painter.restore(); drawErrorsAfter(painter); //std::cout<<"plot done\n"; } @@ -552,7 +560,7 @@ void JKQTPXFunctionLineGraph::draw(JKQTPEnhancedPainter& painter) { JKQTPYFunctionLineGraph::JKQTPYFunctionLineGraph(JKQTBasePlotter *parent):JKQTPXFunctionLineGraph(parent) {} -JKQTPYFunctionLineGraph::JKQTPYFunctionLineGraph(JKQTPlotter *parent):JKQTPXFunctionLineGraph(parent) {} +JKQTPYFunctionLineGraph::JKQTPYFunctionLineGraph(JKQTPlotter *parent):JKQTPYFunctionLineGraph(parent->getPlotter()) {} void JKQTPYFunctionLineGraph::draw(JKQTPEnhancedPainter& painter) { #ifdef JKQTBP_AUTOTIMER @@ -567,149 +575,149 @@ void JKQTPYFunctionLineGraph::draw(JKQTPEnhancedPainter& painter) { //std::cout<<"plot data created\n"; drawErrorsBefore(painter); + { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); - painter.save(); + QPen p=painter.pen(); + p.setColor(color); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); + p.setStyle(style); + p.setJoinStyle(Qt::RoundJoin); + p.setJoinStyle(Qt::RoundJoin); + p.setCapStyle(Qt::RoundCap); + QPen np(Qt::NoPen); - QPen p=painter.pen(); - p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); - p.setStyle(style); - p.setJoinStyle(Qt::RoundJoin); - p.setJoinStyle(Qt::RoundJoin); - p.setCapStyle(Qt::RoundCap); - QPen np(Qt::NoPen); + QPen ep=painter.pen(); + ep.setColor(errorColor); + ep.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, errorLineWidth*parent->getLineWidthMultiplier()))); + ep.setStyle(errorStyle); + ep.setJoinStyle(Qt::RoundJoin); - QPen ep=painter.pen(); - ep.setColor(errorColor); - ep.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, errorLineWidth*parent->getLineWidthMultiplier()))); - ep.setStyle(errorStyle); - ep.setJoinStyle(Qt::RoundJoin); + QBrush b=painter.brush(); + b.setColor(fillColor); + b.setStyle(fillStyle); - QBrush b=painter.brush(); - b.setColor(fillColor); - b.setStyle(fillStyle); - - QBrush eb=painter.brush(); - eb.setColor(errorFillColor); - eb.setStyle(errorFillStyle); + QBrush eb=painter.brush(); + eb.setColor(errorFillColor); + eb.setStyle(errorFillStyle); - double xold=-1; - double yold=-1; - double xpeold=-1; - double xmeold=-1; + double xold=-1; + double yold=-1; + double xpeold=-1; + double xmeold=-1; - double x0=transformX(0); - if (parent->getXAxis()->isLogAxis()) x0=transformX(parent->getXAxis()->getMin()); -// double y0=transformY(0); -// if (parent->getYAxis()->isLogAxis()) y0=transformY(parent->getYAxis()->getMin()); - bool first=false; - doublePair* d=data; + double x0=transformX(0); + if (parent->getXAxis()->isLogAxis()) x0=transformX(parent->getXAxis()->getMin()); + // double y0=transformY(0); + // if (parent->getYAxis()->isLogAxis()) y0=transformY(parent->getYAxis()->getMin()); + bool first=false; + doublePair* d=data; - while (d!=nullptr) { - double yv=d->x; - double xv=d->f; - //std::cout<<"(xv, yv) = ( "<(errorPlotFunction))) { - double e=errorPlotFunction(xv, errorParams); - xpe=transformX(xv+e); - xme=transformX(xv-e); + while (d!=nullptr) { + double yv=d->x; + double xv=d->f; + //std::cout<<"(xv, yv) = ( "<(errorPlotFunction))) { + double e=errorPlotFunction(xv, errorParams); + xpe=transformX(xv+e); + xme=transformX(xv-e); + } + + if (first) { + double xl1=xold; + double yl1=yold; + double xl2=x; + double yl2=y; + + if (fillCurve) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.setBrush(b); + painter.setPen(np); + QPolygonF poly; + poly << QPointF(xl1, yl1) << QPointF(xl2, yl2) << QPointF(x0, yl2) << QPointF(x0, yl1); + painter.drawConvexPolygon(poly); + + /*pfill.lineTo(x, y); + if (d->next==nullptr) { // last datapoint + pfill.lineTo(x, y0); + }*/ + } + + if (drawErrorPolygons && (static_cast(errorPlotFunction))) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.setBrush(eb); + painter.setPen(np); + QPolygonF poly; + poly << QPointF(xpeold, yold) << QPointF(xpe, y)<< QPointF(xme, y) << QPointF(xmeold, yold) ; + painter.drawConvexPolygon(poly); + + } + + if (drawLine) { + painter.setPen(p); + //pa.lineTo(x, y); + painter.drawLine(QLineF(xl1, yl1, xl2, yl2)); + } + + if (drawErrorLines && (static_cast(errorPlotFunction))) { + painter.setPen(ep); + painter.drawLine(QLineF(xpeold, yold, xpe, y)); + painter.drawLine(QLineF(xmeold, yold, xme, y)); + } + + //std::cout<<"line ("<next==nullptr) { // last datapoint - pfill.lineTo(x, y0); - }*/ - } - - if (drawErrorPolygons && (static_cast(errorPlotFunction))) { - painter.save(); - painter.setBrush(eb); - painter.setPen(np); - QPolygonF poly; - poly << QPointF(xpeold, yold) << QPointF(xpe, y)<< QPointF(xme, y) << QPointF(xmeold, yold) ; - painter.drawConvexPolygon(poly); - painter.restore(); - } - - if (drawLine) { - painter.setPen(p); - //pa.lineTo(x, y); - painter.drawLine(QLineF(xl1, yl1, xl2, yl2)); - } - - if (drawErrorLines && (static_cast(errorPlotFunction))) { - painter.setPen(ep); - painter.drawLine(QLineF(xpeold, yold, xpe, y)); - painter.drawLine(QLineF(xmeold, yold, xme, y)); - } - - //std::cout<<"line ("<next; } - d=d->next; - } - /*if (fillCurve) { - pfill.closeSubpath(); - painter.save(); - painter.setBrush(b); - painter.setPen(np); - painter.drawPath(pfill); - painter.restore(); - } + /*if (fillCurve) { + pfill.closeSubpath(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.setBrush(b); + painter.setPen(np); + painter.drawPath(pfill); - if (drawLine) { - painter.setPen(p); - painter.drawPath(pa); - painter.restore(); - }*/ - - QColor c=color; - c.setHsv(fmod(color.hue()+90, 360), color.saturation(), color.value()); - d=data; - if (displaySamplePoints) while (d!=nullptr) { - double yv=d->x; - double xv=d->f; - //std::cout<<"(xv, yv) = ( "<getLineWidthMultiplier(), c, QColor(Qt::transparent)); } - d=d->next; + + if (drawLine) { + painter.setPen(p); + painter.drawPath(pa); + + }*/ + + QColor c=color; + c.setHsv(fmod(color.hue()+90, 360), color.saturation(), color.value()); + d=data; + if (displaySamplePoints) while (d!=nullptr) { + double yv=d->x; + double xv=d->f; + //std::cout<<"(xv, yv) = ( "<getLineWidthMultiplier(), c, QColor(Qt::transparent)); + } + d=d->next; + } } - painter.restore(); drawErrorsAfter(painter); //std::cout<<"plot done\n"; } @@ -765,7 +773,7 @@ QBrush JKQTPXFunctionLineGraph::getBrush(JKQTPEnhancedPainter& /*painter*/) cons QPen JKQTPXFunctionLineGraph::getLinePen(JKQTPEnhancedPainter &painter) const { QPen p; p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH,parent->pt2px(painter, parent->getLineWidthMultiplier()*lineWidth))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH,parent->pt2px(painter, parent->getLineWidthMultiplier()*lineWidth))); p.setStyle(style); p.setJoinStyle(Qt::RoundJoin); p.setCapStyle(Qt::RoundCap); @@ -783,7 +791,7 @@ QBrush JKQTPXFunctionLineGraph::getErrorBrush(JKQTPEnhancedPainter& /*painter*/) QPen JKQTPXFunctionLineGraph::getErrorLinePen(JKQTPEnhancedPainter& painter) const { QPen p; p.setColor(errorColor); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH,parent->pt2px(painter, parent->getLineWidthMultiplier()*errorLineWidth))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH,parent->pt2px(painter, parent->getLineWidthMultiplier()*errorLineWidth))); p.setStyle(errorStyle); p.setJoinStyle(Qt::RoundJoin); p.setCapStyle(Qt::RoundCap); diff --git a/lib/jkqtplotter/jkqtpgraphsevaluatedfunction.h b/lib/jkqtplotter/jkqtpgraphsevaluatedfunction.h index 85e9695d6c..718458c209 100644 --- a/lib/jkqtplotter/jkqtpgraphsevaluatedfunction.h +++ b/lib/jkqtplotter/jkqtpgraphsevaluatedfunction.h @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -107,86 +107,74 @@ class JKQTP_LIB_EXPORT JKQTPXFunctionLineGraph: public JKQTPGraph { /** \brief clear the data sampled from the function. */ void clearData(); - /*! \brief sets the property color ( \copybrief color ) to the specified \a __value. - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual void setColor(const QColor & __value) { this->color = __value; } - /*! \brief returns the property color ( \copybrief color ). - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual QColor getColor() const { return this->color; } - /*! \brief sets the property fillColor ( \copybrief fillColor ) to the specified \a __value. - \details Description of the parameter fillColor is:
    \copydoc fillColor
    - \see fillColor for more information */ + /*! \copydoc fillColor + \see see fillColor for details */ inline virtual void setFillColor(const QColor & __value) { this->fillColor = __value; } - /*! \brief returns the property fillColor ( \copybrief fillColor ). - \details Description of the parameter fillColor is:
    \copydoc fillColor
    - \see fillColor for more information */ + /*! \copydoc fillColor + \see see fillColor for details */ inline virtual QColor getFillColor() const { return this->fillColor; } - /*! \brief sets the property fillStyle ( \copybrief fillStyle ) to the specified \a __value. - \details Description of the parameter fillStyle is:
    \copydoc fillStyle
    - \see fillStyle for more information */ + /*! \copydoc fillStyle + \see see fillStyle for details */ inline virtual void setFillStyle(const Qt::BrushStyle & __value) { this->fillStyle = __value; } - /*! \brief returns the property fillStyle ( \copybrief fillStyle ). - \details Description of the parameter fillStyle is:
    \copydoc fillStyle
    - \see fillStyle for more information */ + /*! \copydoc fillStyle + \see see fillStyle for details */ inline virtual Qt::BrushStyle getFillStyle() const { return this->fillStyle; } - /*! \brief sets the property style ( \copybrief style ) to the specified \a __value. - \details Description of the parameter style is:
    \copydoc style
    - \see style for more information */ + /*! \copydoc style + \see see style for details */ inline virtual void setStyle(const Qt::PenStyle & __value) { this->style = __value; } - /*! \brief returns the property style ( \copybrief style ). - \details Description of the parameter style is:
    \copydoc style
    - \see style for more information */ + /*! \copydoc style + \see see style for details */ inline virtual Qt::PenStyle getStyle() const { return this->style; } - /*! \brief sets the property lineWidth ( \copybrief lineWidth ) to the specified \a __value. - \details Description of the parameter lineWidth is:
    \copydoc lineWidth
    - \see lineWidth for more information */ + /*! \copydoc lineWidth + \see see lineWidth for details */ inline virtual void setLineWidth(double __value) { this->lineWidth = __value; } - /*! \brief returns the property lineWidth ( \copybrief lineWidth ). - \details Description of the parameter lineWidth is:
    \copydoc lineWidth
    - \see lineWidth for more information */ + /*! \copydoc lineWidth + \see see lineWidth for details */ inline virtual double getLineWidth() const { return this->lineWidth; } - /*! \brief sets the property drawLine ( \copybrief drawLine ) to the specified \a __value. - \details Description of the parameter drawLine is:
    \copydoc drawLine
    - \see drawLine for more information */ + /*! \copydoc drawLine + \see see drawLine for details */ inline virtual void setDrawLine(bool __value) { this->drawLine = __value; } - /*! \brief returns the property drawLine ( \copybrief drawLine ). - \details Description of the parameter drawLine is:
    \copydoc drawLine
    - \see drawLine for more information */ + /*! \copydoc drawLine + \see see drawLine for details */ inline virtual bool getDrawLine() const { return this->drawLine; @@ -217,9 +205,8 @@ class JKQTP_LIB_EXPORT JKQTPXFunctionLineGraph: public JKQTPGraph { /*! \brief returns the property simplePlotFunction ( \copybrief simplePlotFunction ). \see simplePlotFunction for more information */ \ virtual jkqtpSimplePlotFunctionType getSimplePlotFunction () const; - /*! \brief sets the property params ( \copybrief params ) to the specified \a __value. - \details Description of the parameter params is:
    \copydoc params
    - \see params for more information */ + /*! \copydoc params + \see see params for details */ inline virtual void setParams(void* __value) { if (this->params != __value) { @@ -227,9 +214,8 @@ class JKQTP_LIB_EXPORT JKQTPXFunctionLineGraph: public JKQTPGraph { clearData(); } } - /*! \brief returns the property params ( \copybrief params ). - \details Description of the parameter params is:
    \copydoc params
    - \see params for more information */ + /*! \copydoc params + \see see params for details */ inline virtual void* getParams() const { return this->params; @@ -253,114 +239,98 @@ class JKQTP_LIB_EXPORT JKQTPXFunctionLineGraph: public JKQTPGraph { QVector getInternalParams() const; /** \brief returns the currently set internal parameter vector */ QVector getInternalErrorParams() const; - /*! \brief sets the property minSamples ( \copybrief minSamples ) to the specified \a __value. - \details Description of the parameter minSamples is:
    \copydoc minSamples
    - \see minSamples for more information */ + /*! \copydoc minSamples + \see see minSamples for details */ inline virtual void setMinSamples(const unsigned int & __value) { this->minSamples = __value; } - /*! \brief returns the property minSamples ( \copybrief minSamples ). - \details Description of the parameter minSamples is:
    \copydoc minSamples
    - \see minSamples for more information */ + /*! \copydoc minSamples + \see see minSamples for details */ inline virtual unsigned int getMinSamples() const { return this->minSamples; } - /*! \brief sets the property maxRefinementDegree ( \copybrief maxRefinementDegree ) to the specified \a __value. - \details Description of the parameter maxRefinementDegree is:
    \copydoc maxRefinementDegree
    - \see maxRefinementDegree for more information */ + /*! \copydoc maxRefinementDegree + \see see maxRefinementDegree for details */ inline virtual void setMaxRefinementDegree(const unsigned int & __value) { this->maxRefinementDegree = __value; } - /*! \brief returns the property maxRefinementDegree ( \copybrief maxRefinementDegree ). - \details Description of the parameter maxRefinementDegree is:
    \copydoc maxRefinementDegree
    - \see maxRefinementDegree for more information */ + /*! \copydoc maxRefinementDegree + \see see maxRefinementDegree for details */ inline virtual unsigned int getMaxRefinementDegree() const { return this->maxRefinementDegree; } - /*! \brief sets the property slopeTolerance ( \copybrief slopeTolerance ) to the specified \a __value. - \details Description of the parameter slopeTolerance is:
    \copydoc slopeTolerance
    - \see slopeTolerance for more information */ + /*! \copydoc slopeTolerance + \see see slopeTolerance for details */ inline virtual void setSlopeTolerance(double __value) { this->slopeTolerance = __value; } - /*! \brief returns the property slopeTolerance ( \copybrief slopeTolerance ). - \details Description of the parameter slopeTolerance is:
    \copydoc slopeTolerance
    - \see slopeTolerance for more information */ + /*! \copydoc slopeTolerance + \see see slopeTolerance for details */ inline virtual double getSlopeTolerance() const { return this->slopeTolerance; } - /*! \brief sets the property minPixelPerSample ( \copybrief minPixelPerSample ) to the specified \a __value. - \details Description of the parameter minPixelPerSample is:
    \copydoc minPixelPerSample
    - \see minPixelPerSample for more information */ + /*! \copydoc minPixelPerSample + \see see minPixelPerSample for details */ inline virtual void setMinPixelPerSample(double __value) { this->minPixelPerSample = __value; } - /*! \brief returns the property minPixelPerSample ( \copybrief minPixelPerSample ). - \details Description of the parameter minPixelPerSample is:
    \copydoc minPixelPerSample
    - \see minPixelPerSample for more information */ + /*! \copydoc minPixelPerSample + \see see minPixelPerSample for details */ inline virtual double getMinPixelPerSample() const { return this->minPixelPerSample; } - /*! \brief sets the property plotRefinement ( \copybrief plotRefinement ) to the specified \a __value. - \details Description of the parameter plotRefinement is:
    \copydoc plotRefinement
    - \see plotRefinement for more information */ + /*! \copydoc plotRefinement + \see see plotRefinement for details */ inline virtual void setPlotRefinement(bool __value) { this->plotRefinement = __value; } - /*! \brief returns the property plotRefinement ( \copybrief plotRefinement ). - \details Description of the parameter plotRefinement is:
    \copydoc plotRefinement
    - \see plotRefinement for more information */ + /*! \copydoc plotRefinement + \see see plotRefinement for details */ inline virtual bool getPlotRefinement() const { return this->plotRefinement; } - /*! \brief sets the property displaySamplePoints ( \copybrief displaySamplePoints ) to the specified \a __value. - \details Description of the parameter displaySamplePoints is:
    \copydoc displaySamplePoints
    - \see displaySamplePoints for more information */ + /*! \copydoc displaySamplePoints + \see see displaySamplePoints for details */ inline virtual void setDisplaySamplePoints(bool __value) { this->displaySamplePoints = __value; } - /*! \brief returns the property displaySamplePoints ( \copybrief displaySamplePoints ). - \details Description of the parameter displaySamplePoints is:
    \copydoc displaySamplePoints
    - \see displaySamplePoints for more information */ + /*! \copydoc displaySamplePoints + \see see displaySamplePoints for details */ inline virtual bool getDisplaySamplePoints() const { return this->displaySamplePoints; } - /*! \brief sets the property drawErrorPolygons ( \copybrief drawErrorPolygons ) to the specified \a __value. - \details Description of the parameter drawErrorPolygons is:
    \copydoc drawErrorPolygons
    - \see drawErrorPolygons for more information */ + /*! \copydoc drawErrorPolygons + \see see drawErrorPolygons for details */ inline virtual void setDrawErrorPolygons(bool __value) { this->drawErrorPolygons = __value; } - /*! \brief returns the property drawErrorPolygons ( \copybrief drawErrorPolygons ). - \details Description of the parameter drawErrorPolygons is:
    \copydoc drawErrorPolygons
    - \see drawErrorPolygons for more information */ + /*! \copydoc drawErrorPolygons + \see see drawErrorPolygons for details */ inline virtual bool getDrawErrorPolygons() const { return this->drawErrorPolygons; } - /*! \brief sets the property drawErrorLines ( \copybrief drawErrorLines ) to the specified \a __value. - \details Description of the parameter drawErrorLines is:
    \copydoc drawErrorLines
    - \see drawErrorLines for more information */ + /*! \copydoc drawErrorLines + \see see drawErrorLines for details */ inline virtual void setDrawErrorLines(bool __value) { this->drawErrorLines = __value; } - /*! \brief returns the property drawErrorLines ( \copybrief drawErrorLines ). - \details Description of the parameter drawErrorLines is:
    \copydoc drawErrorLines
    - \see drawErrorLines for more information */ + /*! \copydoc drawErrorLines + \see see drawErrorLines for details */ inline virtual bool getDrawErrorLines() const { return this->drawErrorLines; @@ -389,16 +359,14 @@ class JKQTP_LIB_EXPORT JKQTPXFunctionLineGraph: public JKQTPGraph { virtual void setErrorPlotFunction (const jkqtpSimplePlotFunctionType & __value); /*! \brief returns the property errorSimplePlotFunction ( \copybrief errorSimplePlotFunction ). \see errorSimplePlotFunction for more information */ \ virtual jkqtpSimplePlotFunctionType getErrorSimplePlotFunction () const; - /*! \brief sets the property errorParams ( \copybrief errorParams ) to the specified \a __value. - \details Description of the parameter errorParams is:
    \copydoc errorParams
    - \see errorParams for more information */ + /*! \copydoc errorParams + \see see errorParams for details */ inline virtual void setErrorParams(void* __value) { this->errorParams = __value; } - /*! \brief returns the property errorParams ( \copybrief errorParams ). - \details Description of the parameter errorParams is:
    \copydoc errorParams
    - \see errorParams for more information */ + /*! \copydoc errorParams + \see see errorParams for details */ inline virtual void* getErrorParams() const { return this->errorParams; @@ -406,109 +374,95 @@ class JKQTP_LIB_EXPORT JKQTPXFunctionLineGraph: public JKQTPGraph { /** \brief sets the error params as a pointer to an internal COPY of the given vector (not the data of the vector, as then the size would be unknown!!!) */ void setErrorParams(const QVector& errorParams); - /*! \brief sets the property parameterColumn ( \copybrief parameterColumn ) to the specified \a __value. - \details Description of the parameter parameterColumn is:
    \copydoc parameterColumn
    - \see parameterColumn for more information */ + /*! \copydoc parameterColumn + \see see parameterColumn for details */ inline virtual void setParameterColumn(int __value) { this->parameterColumn = __value; } - /*! \brief returns the property parameterColumn ( \copybrief parameterColumn ). - \details Description of the parameter parameterColumn is:
    \copydoc parameterColumn
    - \see parameterColumn for more information */ + /*! \copydoc parameterColumn + \see see parameterColumn for details */ inline virtual int getParameterColumn() const { return this->parameterColumn; } /*! \brief sets the property parameterColumn ( \copybrief parameterColumn ) to the specified \a __value, where __value is static_cast'ed from size_t to int. \details Description of the parameter parameterColumn is:
    \copydoc parameterColumn
    - \see parameterColumn for more information */ + \see parameterColumn for more information */ inline virtual void setParameterColumn (size_t __value) { this->parameterColumn = static_cast(__value); } - /*! \brief sets the property errorParameterColumn ( \copybrief errorParameterColumn ) to the specified \a __value. - \details Description of the parameter errorParameterColumn is:
    \copydoc errorParameterColumn
    - \see errorParameterColumn for more information */ + /*! \copydoc errorParameterColumn + \see see errorParameterColumn for details */ inline virtual void setErrorParameterColumn(int __value) { this->errorParameterColumn = __value; } - /*! \brief returns the property errorParameterColumn ( \copybrief errorParameterColumn ). - \details Description of the parameter errorParameterColumn is:
    \copydoc errorParameterColumn
    - \see errorParameterColumn for more information */ + /*! \copydoc errorParameterColumn + \see see errorParameterColumn for details */ inline virtual int getErrorParameterColumn() const { return this->errorParameterColumn; } /*! \brief sets the property errorParameterColumn ( \copybrief errorParameterColumn ) to the specified \a __value, where __value is static_cast'ed from size_t to int. \details Description of the parameter errorParameterColumn is:
    \copydoc errorParameterColumn
    - \see errorParameterColumn for more information */ + \see errorParameterColumn for more information */ inline virtual void setErrorParameterColumn (size_t __value) { this->errorParameterColumn = static_cast(__value); } - /*! \brief sets the property errorColor ( \copybrief errorColor ) to the specified \a __value. - \details Description of the parameter errorColor is:
    \copydoc errorColor
    - \see errorColor for more information */ + /*! \copydoc errorColor + \see see errorColor for details */ inline virtual void setErrorColor(const QColor & __value) { this->errorColor = __value; } - /*! \brief returns the property errorColor ( \copybrief errorColor ). - \details Description of the parameter errorColor is:
    \copydoc errorColor
    - \see errorColor for more information */ + /*! \copydoc errorColor + \see see errorColor for details */ inline virtual QColor getErrorColor() const { return this->errorColor; } - /*! \brief sets the property errorFillColor ( \copybrief errorFillColor ) to the specified \a __value. - \details Description of the parameter errorFillColor is:
    \copydoc errorFillColor
    - \see errorFillColor for more information */ + /*! \copydoc errorFillColor + \see see errorFillColor for details */ inline virtual void setErrorFillColor(const QColor & __value) { this->errorFillColor = __value; } - /*! \brief returns the property errorFillColor ( \copybrief errorFillColor ). - \details Description of the parameter errorFillColor is:
    \copydoc errorFillColor
    - \see errorFillColor for more information */ + /*! \copydoc errorFillColor + \see see errorFillColor for details */ inline virtual QColor getErrorFillColor() const { return this->errorFillColor; } - /*! \brief sets the property errorFillStyle ( \copybrief errorFillStyle ) to the specified \a __value. - \details Description of the parameter errorFillStyle is:
    \copydoc errorFillStyle
    - \see errorFillStyle for more information */ + /*! \copydoc errorFillStyle + \see see errorFillStyle for details */ inline virtual void setErrorFillStyle(const Qt::BrushStyle & __value) { this->errorFillStyle = __value; } - /*! \brief returns the property errorFillStyle ( \copybrief errorFillStyle ). - \details Description of the parameter errorFillStyle is:
    \copydoc errorFillStyle
    - \see errorFillStyle for more information */ + /*! \copydoc errorFillStyle + \see see errorFillStyle for details */ inline virtual Qt::BrushStyle getErrorFillStyle() const { return this->errorFillStyle; } - /*! \brief sets the property errorStyle ( \copybrief errorStyle ) to the specified \a __value. - \details Description of the parameter errorStyle is:
    \copydoc errorStyle
    - \see errorStyle for more information */ + /*! \copydoc errorStyle + \see see errorStyle for details */ inline virtual void setErrorStyle(const Qt::PenStyle & __value) { this->errorStyle = __value; } - /*! \brief returns the property errorStyle ( \copybrief errorStyle ). - \details Description of the parameter errorStyle is:
    \copydoc errorStyle
    - \see errorStyle for more information */ + /*! \copydoc errorStyle + \see see errorStyle for details */ inline virtual Qt::PenStyle getErrorStyle() const { return this->errorStyle; } - /*! \brief sets the property errorLineWidth ( \copybrief errorLineWidth ) to the specified \a __value. - \details Description of the parameter errorLineWidth is:
    \copydoc errorLineWidth
    - \see errorLineWidth for more information */ + /*! \copydoc errorLineWidth + \see see errorLineWidth for details */ inline virtual void setErrorLineWidth(double __value) { this->errorLineWidth = __value; } - /*! \brief returns the property errorLineWidth ( \copybrief errorLineWidth ). - \details Description of the parameter errorLineWidth is:
    \copydoc errorLineWidth
    - \see errorLineWidth for more information */ + /*! \copydoc errorLineWidth + \see see errorLineWidth for details */ inline virtual double getErrorLineWidth() const { return this->errorLineWidth; diff --git a/lib/jkqtplotter/jkqtpgraphsfilledcurve.cpp b/lib/jkqtplotter/jkqtpgraphsfilledcurve.cpp index b898b6e5ed..52063dfa15 100644 --- a/lib/jkqtplotter/jkqtpgraphsfilledcurve.cpp +++ b/lib/jkqtplotter/jkqtpgraphsfilledcurve.cpp @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -54,32 +54,17 @@ JKQTPFilledCurveXGraph::JKQTPFilledCurveXGraph(JKQTBasePlotter* parent): parentPlotStyle=parent->getNextStyle(); //std::cout<<"got style settings from parent: "<getPlotStyle(parentPlotStyle).color(); + fillColor=parent->getPlotStyle(parentPlotStyle).fillColor(); style=parent->getPlotStyle(parentPlotStyle).style(); - fillColor=color.lighter(); + lineWidth=parent->getPlotStyle(parentPlotStyle).widthF(); + fillStyle=parent->getPlotStyle(parentPlotStyle).fillStyle(); } } JKQTPFilledCurveXGraph::JKQTPFilledCurveXGraph(JKQTPlotter *parent): - JKQTPXYGraph(parent) + JKQTPFilledCurveXGraph(parent->getPlotter()) { - baseline=0.0; - drawSelectionLine=false; - selectionLineColor=Qt::transparent; - color=QColor("red"); - fillColor=color.lighter(); - style=Qt::SolidLine; - lineWidth=2; - parentPlotStyle=-1; - drawLine=true; - fillStyle=Qt::SolidPattern; - if (parent) { // get style settings from parent object - parentPlotStyle=parent->getNextStyle(); - //std::cout<<"got style settings from parent: "<getPlotStyle(parentPlotStyle).color(); - style=parent->getPlotStyle(parentPlotStyle).style(); - fillColor=color.lighter(); - } } void JKQTPFilledCurveXGraph::draw(JKQTPEnhancedPainter& painter) { @@ -91,120 +76,120 @@ void JKQTPFilledCurveXGraph::draw(JKQTPEnhancedPainter& painter) { if (datastore==nullptr) return; drawErrorsBefore(painter); + { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); - painter.save(); + QPen p=painter.pen(); + p.setColor(color); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); + p.setStyle(style); + p.setJoinStyle(Qt::RoundJoin); + p.setCapStyle(Qt::RoundCap); + QPen np(Qt::NoPen); - QPen p=painter.pen(); - p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); - p.setStyle(style); - p.setJoinStyle(Qt::RoundJoin); - p.setCapStyle(Qt::RoundCap); - QPen np(Qt::NoPen); - - QBrush b=painter.brush(); - b.setColor(fillColor); - b.setStyle(fillStyle); - - int imax=static_cast(qMin(datastore->getColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(yColumn)).getRows())); - int imin=0; - if (imaxgetXAxis()->isLogAxis()) { -// if (baseline>0 && baseline>parent->getXAxis()->getMin()) x0=transformX(baseline); -// else x0=transformX(parent->getXAxis()->getMin()); -// } - double y0=transformY(baseline); - if (parent->getYAxis()->isLogAxis()) { - y0=transformY(parent->getYAxis()->getMin()); - if (baseline>0 && baseline>parent->getYAxis()->getMin()) y0=transformY(baseline); - else y0=transformY(parent->getYAxis()->getMin()); - } - bool first=true; - intSortData(); - for (int iii=imin; iiiget(static_cast(xColumn),static_cast(i)); - double yv=datastore->get(static_cast(yColumn),static_cast(i)); - //std::cout<<"(xv, yv) = ( "<(qMin(datastore->getColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(yColumn)).getRows())); + int imin=0; + if (imaxgetXAxis()->isLogAxis()) { + // if (baseline>0 && baseline>parent->getXAxis()->getMin()) x0=transformX(baseline); + // else x0=transformX(parent->getXAxis()->getMin()); + // } + double y0=transformY(baseline); + if (parent->getYAxis()->isLogAxis()) { + y0=transformY(parent->getYAxis()->getMin()); + if (baseline>0 && baseline>parent->getYAxis()->getMin()) y0=transformY(baseline); + else y0=transformY(parent->getYAxis()->getMin()); + } + bool first=true; + intSortData(); + for (int iii=imin; iiiget(static_cast(xColumn),static_cast(i)); + double yv=datastore->get(static_cast(yColumn),static_cast(i)); + //std::cout<<"(xv, yv) = ( "<getPlotter()) { } @@ -259,112 +244,112 @@ void JKQTPFilledCurveYGraph::draw(JKQTPEnhancedPainter& painter) { if (datastore==nullptr) return; drawErrorsBefore(painter); + { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); - painter.save(); + QPen p=painter.pen(); + p.setColor(color); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); + p.setStyle(style); + p.setJoinStyle(Qt::RoundJoin); + p.setCapStyle(Qt::RoundCap); + p.setJoinStyle(Qt::RoundJoin); + QPen np(Qt::NoPen); - QPen p=painter.pen(); - p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); - p.setStyle(style); - p.setJoinStyle(Qt::RoundJoin); - p.setCapStyle(Qt::RoundCap); - p.setJoinStyle(Qt::RoundJoin); - QPen np(Qt::NoPen); + QBrush b=painter.brush(); + b.setColor(fillColor); + b.setStyle(fillStyle); - QBrush b=painter.brush(); - b.setColor(fillColor); - b.setStyle(fillStyle); + int imax=static_cast(qMin(datastore->getColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(yColumn)).getRows())); + int imin=0; + if (imax(qMin(datastore->getColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(yColumn)).getRows())); - int imin=0; - if (imaxgetXAxis()->isLogAxis()) { + if (baseline>0 && baseline>parent->getXAxis()->getMin()) x0=transformX(baseline); + else x0=transformX(parent->getXAxis()->getMin()); + } + /*double y0=transformY(baseline); + if (parent->getYAxis()->isLogAxis()) { + y0=transformY(parent->getYAxis()->getMin()); + if (baseline>0 && baseline>parent->getYAxis()->getMin()) y0=transformY(baseline); + else y0=transformY(parent->getYAxis()->getMin()); + }*/ + bool first=true; + intSortData(); + for (int iii=imin; iiiget(static_cast(xColumn),static_cast(i)); + double yv=datastore->get(static_cast(yColumn),static_cast(i)); + //std::cout<<"(xv, yv) = ( "<getXAxis()->isLogAxis()) { - if (baseline>0 && baseline>parent->getXAxis()->getMin()) x0=transformX(baseline); - else x0=transformX(parent->getXAxis()->getMin()); - } - /*double y0=transformY(baseline); - if (parent->getYAxis()->isLogAxis()) { - y0=transformY(parent->getYAxis()->getMin()); - if (baseline>0 && baseline>parent->getYAxis()->getMin()) y0=transformY(baseline); - else y0=transformY(parent->getYAxis()->getMin()); - }*/ - bool first=true; - intSortData(); - for (int iii=imin; iiiget(static_cast(xColumn),static_cast(i)); - double yv=datastore->get(static_cast(yColumn),static_cast(i)); - //std::cout<<"(xv, yv) = ( "<pt2px(painter, parent->getLineWidthMultiplier()*lineWidth))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH,parent->pt2px(painter, parent->getLineWidthMultiplier()*lineWidth))); p.setStyle(style); p.setJoinStyle(Qt::RoundJoin); p.setCapStyle(Qt::RoundCap); @@ -397,15 +382,17 @@ QBrush JKQTPFilledCurveXGraph::getBrush(JKQTPEnhancedPainter& /*painter*/) const JKQTPFilledCurveXErrorGraph::JKQTPFilledCurveXErrorGraph(JKQTBasePlotter *parent): - JKQTPFilledCurveXGraph(parent), JKQTPYGraphErrors() + JKQTPFilledCurveXGraph(parent), JKQTPYGraphErrors(color, parent) { setErrorColorFromGraphColor(color); + if (parentPlotStyle>=0) setErrorStyleFromPen(parent->getPlotStyle(parentPlotStyle)); + } JKQTPFilledCurveXErrorGraph::JKQTPFilledCurveXErrorGraph(JKQTPlotter *parent): - JKQTPFilledCurveXGraph(parent), JKQTPYGraphErrors() + JKQTPFilledCurveXErrorGraph(parent->getPlotter()) { - setErrorColorFromGraphColor(color); + } bool JKQTPFilledCurveXErrorGraph::usesColumn(int c) const @@ -421,15 +408,17 @@ void JKQTPFilledCurveXErrorGraph::drawErrorsAfter(JKQTPEnhancedPainter &painter) } JKQTPFilledCurveYErrorGraph::JKQTPFilledCurveYErrorGraph(JKQTBasePlotter *parent): - JKQTPFilledCurveYGraph(parent), JKQTPXGraphErrors() + JKQTPFilledCurveYGraph(parent), JKQTPXGraphErrors(color, parent) { setErrorColorFromGraphColor(color); + if (parentPlotStyle>=0) setErrorStyleFromPen(parent->getPlotStyle(parentPlotStyle)); + } JKQTPFilledCurveYErrorGraph::JKQTPFilledCurveYErrorGraph(JKQTPlotter *parent): - JKQTPFilledCurveYGraph(parent), JKQTPXGraphErrors() + JKQTPFilledCurveYErrorGraph(parent->getPlotter()) { - setErrorColorFromGraphColor(color); + } bool JKQTPFilledCurveYErrorGraph::usesColumn(int c) const @@ -463,31 +452,18 @@ JKQTPFilledVerticalRangeGraph::JKQTPFilledVerticalRangeGraph(JKQTBasePlotter *pa parentPlotStyle=parent->getNextStyle(); //std::cout<<"got style settings from parent: "<getPlotStyle(parentPlotStyle).color(); + fillColor=parent->getPlotStyle(parentPlotStyle).fillColor(); style=parent->getPlotStyle(parentPlotStyle).style(); - fillColor=color.lighter(); + lineWidth=parent->getPlotStyle(parentPlotStyle).widthF(); + fillStyle=parent->getPlotStyle(parentPlotStyle).fillStyle(); + } } JKQTPFilledVerticalRangeGraph::JKQTPFilledVerticalRangeGraph(JKQTPlotter *parent): - JKQTPXYGraph(parent) + JKQTPFilledVerticalRangeGraph(parent->getPlotter()) { - drawSelectionLine=false; - selectionLineColor=Qt::transparent; - color=QColor("red"); - fillColor=color.lighter(); - style=Qt::SolidLine; - lineWidth=2; - parentPlotStyle=-1; - drawLine=true; - fillStyle=Qt::SolidPattern; - if (parent) { // get style settings from parent object - parentPlotStyle=parent->getNextStyle(); - //std::cout<<"got style settings from parent: "<getPlotStyle(parentPlotStyle).color(); - style=parent->getPlotStyle(parentPlotStyle).style(); - fillColor=color.lighter(); - } } bool JKQTPFilledVerticalRangeGraph::getYMinMax(double &miny, double &maxy, double &smallestGreaterZero) @@ -546,92 +522,92 @@ void JKQTPFilledVerticalRangeGraph::draw(JKQTPEnhancedPainter &painter) if (datastore==nullptr) return; drawErrorsBefore(painter); + { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); - painter.save(); + QPen p=painter.pen(); + p.setColor(color); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); + p.setStyle(style); + p.setJoinStyle(Qt::RoundJoin); + p.setCapStyle(Qt::RoundCap); + QPen np(Qt::NoPen); - QPen p=painter.pen(); - p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); - p.setStyle(style); - p.setJoinStyle(Qt::RoundJoin); - p.setCapStyle(Qt::RoundCap); - QPen np(Qt::NoPen); + QBrush b=painter.brush(); + b.setColor(fillColor); + b.setStyle(fillStyle); - QBrush b=painter.brush(); - b.setColor(fillColor); - b.setStyle(fillStyle); - - int imax=static_cast(qMin(qMin(datastore->getColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(yColumn)).getRows()), datastore->getColumn(static_cast(yColumn2)).getRows())); - int imin=0; - if (imaxget(static_cast(xColumn),static_cast(i)); - double yv=datastore->get(static_cast(yColumn),static_cast(i)); - double yv2=datastore->get(static_cast(yColumn2),static_cast(i)); - //std::cout<<"(xv, yv) = ( "<(qMin(qMin(datastore->getColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(yColumn)).getRows()), datastore->getColumn(static_cast(yColumn2)).getRows())); + int imin=0; + if (imax0) { - for (int i=plow.size()-1; i>=0; i--) { - poly_all.append(plow[i]); - } - } - painter.setBrush(b); - painter.setPen(np); - painter.drawPolygon(poly_all); + // upper points are added to poly_all, lower points to plow + // then plow points are added to poly_all in vewerse order + // then the whole thing is drawn + QPolygonF poly_all, phigh, plow; - painter.restore(); - if (drawLine) { - painter.save(); + intSortData(); + for (int iii=imin; iiiget(static_cast(xColumn),static_cast(i)); + double yv=datastore->get(static_cast(yColumn),static_cast(i)); + double yv2=datastore->get(static_cast(yColumn2),static_cast(i)); + //std::cout<<"(xv, yv) = ( "<0) { + for (int i=plow.size()-1; i>=0; i--) { + poly_all.append(plow[i]); + } + } + painter.setBrush(b); + painter.setPen(np); + painter.drawPolygon(poly_all); + + + if (drawLine) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + + if (drawSelectionLine) { + QPen penSelection=p; penSelection.setStyle(Qt::SolidLine); + QColor selcol=penSelection.color(); selcol.setAlphaF(0.5); penSelection.setColor(selcol); + if (selectionLineColor!=Qt::transparent) { + penSelection.setColor(selectionLineColor); + } + penSelection.setWidthF(penSelection.widthF()*3.0); + painter.setPen(penSelection); + painter.drawPolyline(phigh); + painter.drawPolyline(plow); + } + + + painter.setPen(p); painter.drawPolyline(phigh); painter.drawPolyline(plow); + } - - - painter.setPen(p); - painter.drawPolyline(phigh); - painter.drawPolyline(plow); - painter.restore(); } - drawErrorsAfter(painter); } void JKQTPFilledVerticalRangeGraph::drawKeyMarker(JKQTPEnhancedPainter &painter, QRectF &rect) { - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); QRectF r=rect; r.setHeight(r.height()/2.0); r.moveTo(r.x(), r.y()+r.height()-1); @@ -640,7 +616,7 @@ void JKQTPFilledVerticalRangeGraph::drawKeyMarker(JKQTPEnhancedPainter &painter, painter.setPen(getLinePen(painter)); painter.drawLine(QLineF(r.topLeft(), r.topRight())); } - painter.restore(); + } QColor JKQTPFilledVerticalRangeGraph::getKeyLabelColor() @@ -660,7 +636,7 @@ QPen JKQTPFilledVerticalRangeGraph::getLinePen(JKQTPEnhancedPainter &painter) co { QPen p; p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); p.setStyle(style); p.setJoinStyle(Qt::RoundJoin); p.setCapStyle(Qt::RoundCap); diff --git a/lib/jkqtplotter/jkqtpgraphsfilledcurve.h b/lib/jkqtplotter/jkqtpgraphsfilledcurve.h index 73804b59e5..979e49d013 100644 --- a/lib/jkqtplotter/jkqtpgraphsfilledcurve.h +++ b/lib/jkqtplotter/jkqtpgraphsfilledcurve.h @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -20,6 +20,7 @@ #include "jkqtplottertools/jkqtp_imexport.h" #include "jkqtplotter/jkqtpgraphsbase.h" +#include "jkqtplotter/jkqtpgraphsbaseerrors.h" #ifndef jkqtpgraphsfilledcurve_H #define jkqtpgraphsfilledcurve_H @@ -50,129 +51,111 @@ class JKQTP_LIB_EXPORT JKQTPFilledCurveXGraph: public JKQTPXYGraph { /** \brief returns the color to be used for the key label */ virtual QColor getKeyLabelColor() override; - /*! \brief sets the property color ( \copybrief color ) to the specified \a __value. - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual void setColor(const QColor & __value) { this->color = __value; } - /*! \brief returns the property color ( \copybrief color ). - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual QColor getColor() const { return this->color; } - /*! \brief sets the property fillColor ( \copybrief fillColor ) to the specified \a __value. - \details Description of the parameter fillColor is:
    \copydoc fillColor
    - \see fillColor for more information */ + /*! \copydoc fillColor + \see see fillColor for details */ inline virtual void setFillColor(const QColor & __value) { this->fillColor = __value; } - /*! \brief returns the property fillColor ( \copybrief fillColor ). - \details Description of the parameter fillColor is:
    \copydoc fillColor
    - \see fillColor for more information */ + /*! \copydoc fillColor + \see see fillColor for details */ inline virtual QColor getFillColor() const { return this->fillColor; } - /*! \brief sets the property style ( \copybrief style ) to the specified \a __value. - \details Description of the parameter style is:
    \copydoc style
    - \see style for more information */ + /*! \copydoc style + \see see style for details */ inline virtual void setStyle(const Qt::PenStyle & __value) { this->style = __value; } - /*! \brief returns the property style ( \copybrief style ). - \details Description of the parameter style is:
    \copydoc style
    - \see style for more information */ + /*! \copydoc style + \see see style for details */ inline virtual Qt::PenStyle getStyle() const { return this->style; } - /*! \brief sets the property lineWidth ( \copybrief lineWidth ) to the specified \a __value. - \details Description of the parameter lineWidth is:
    \copydoc lineWidth
    - \see lineWidth for more information */ + /*! \copydoc lineWidth + \see see lineWidth for details */ inline virtual void setLineWidth(double __value) { this->lineWidth = __value; } - /*! \brief returns the property lineWidth ( \copybrief lineWidth ). - \details Description of the parameter lineWidth is:
    \copydoc lineWidth
    - \see lineWidth for more information */ + /*! \copydoc lineWidth + \see see lineWidth for details */ inline virtual double getLineWidth() const { return this->lineWidth; } - /*! \brief sets the property baseline ( \copybrief baseline ) to the specified \a __value. - \details Description of the parameter baseline is:
    \copydoc baseline
    - \see baseline for more information */ + /*! \copydoc baseline + \see see baseline for details */ inline virtual void setBaseline(double __value) { this->baseline = __value; } - /*! \brief returns the property baseline ( \copybrief baseline ). - \details Description of the parameter baseline is:
    \copydoc baseline
    - \see baseline for more information */ + /*! \copydoc baseline + \see see baseline for details */ inline virtual double getBaseline() const { return this->baseline; } - /*! \brief sets the property drawLine ( \copybrief drawLine ) to the specified \a __value. - \details Description of the parameter drawLine is:
    \copydoc drawLine
    - \see drawLine for more information */ + /*! \copydoc drawLine + \see see drawLine for details */ inline virtual void setDrawLine(bool __value) { this->drawLine = __value; } - /*! \brief returns the property drawLine ( \copybrief drawLine ). - \details Description of the parameter drawLine is:
    \copydoc drawLine
    - \see drawLine for more information */ + /*! \copydoc drawLine + \see see drawLine for details */ inline virtual bool getDrawLine() const { return this->drawLine; } - /*! \brief sets the property fillStyle ( \copybrief fillStyle ) to the specified \a __value. - \details Description of the parameter fillStyle is:
    \copydoc fillStyle
    - \see fillStyle for more information */ + /*! \copydoc fillStyle + \see see fillStyle for details */ inline virtual void setFillStyle(const Qt::BrushStyle & __value) { this->fillStyle = __value; } - /*! \brief returns the property fillStyle ( \copybrief fillStyle ). - \details Description of the parameter fillStyle is:
    \copydoc fillStyle
    - \see fillStyle for more information */ + /*! \copydoc fillStyle + \see see fillStyle for details */ inline virtual Qt::BrushStyle getFillStyle() const { return this->fillStyle; } - /*! \brief sets the property drawSelectionLine ( \copybrief drawSelectionLine ) to the specified \a __value. - \details Description of the parameter drawSelectionLine is:
    \copydoc drawSelectionLine
    - \see drawSelectionLine for more information */ + /*! \copydoc drawSelectionLine + \see see drawSelectionLine for details */ inline virtual void setDrawSelectionLine(bool __value) { this->drawSelectionLine = __value; } - /*! \brief returns the property drawSelectionLine ( \copybrief drawSelectionLine ). - \details Description of the parameter drawSelectionLine is:
    \copydoc drawSelectionLine
    - \see drawSelectionLine for more information */ + /*! \copydoc drawSelectionLine + \see see drawSelectionLine for details */ inline virtual bool getDrawSelectionLine() const { return this->drawSelectionLine; } - /*! \brief sets the property selectionLineColor ( \copybrief selectionLineColor ) to the specified \a __value. - \details Description of the parameter selectionLineColor is:
    \copydoc selectionLineColor
    - \see selectionLineColor for more information */ + /*! \copydoc selectionLineColor + \see see selectionLineColor for details */ inline virtual void setSelectionLineColor(const QColor & __value) { this->selectionLineColor = __value; } - /*! \brief returns the property selectionLineColor ( \copybrief selectionLineColor ). - \details Description of the parameter selectionLineColor is:
    \copydoc selectionLineColor
    - \see selectionLineColor for more information */ + /*! \copydoc selectionLineColor + \see see selectionLineColor for details */ inline virtual QColor getSelectionLineColor() const { return this->selectionLineColor; @@ -324,120 +307,104 @@ class JKQTP_LIB_EXPORT JKQTPFilledVerticalRangeGraph: public JKQTPXYGraph { /** \brief returns the color to be used for the key label */ virtual QColor getKeyLabelColor() override; - /*! \brief sets the property yColumn2 ( \copybrief yColumn2 ) to the specified \a __value. - \details Description of the parameter yColumn2 is:
    \copydoc yColumn2
    - \see yColumn2 for more information */ + /*! \copydoc yColumn2 + \see see yColumn2 for details */ inline virtual void setYColumn2(int __value) { this->yColumn2 = __value; } - /*! \brief returns the property yColumn2 ( \copybrief yColumn2 ). - \details Description of the parameter yColumn2 is:
    \copydoc yColumn2
    - \see yColumn2 for more information */ + /*! \copydoc yColumn2 + \see see yColumn2 for details */ inline virtual int getYColumn2() const { return this->yColumn2; } /*! \brief sets the property yColumn2 ( \copybrief yColumn2 ) to the specified \a __value, where __value is static_cast'ed from size_t to int. \details Description of the parameter yColumn2 is:
    \copydoc yColumn2
    - \see yColumn2 for more information */ + \see yColumn2 for more information */ inline virtual void setYColumn2 (size_t __value) { this->yColumn2 = static_cast(__value); } - /*! \brief sets the property color ( \copybrief color ) to the specified \a __value. - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual void setColor(const QColor & __value) { this->color = __value; } - /*! \brief returns the property color ( \copybrief color ). - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual QColor getColor() const { return this->color; } - /*! \brief sets the property fillColor ( \copybrief fillColor ) to the specified \a __value. - \details Description of the parameter fillColor is:
    \copydoc fillColor
    - \see fillColor for more information */ + /*! \copydoc fillColor + \see see fillColor for details */ inline virtual void setFillColor(const QColor & __value) { this->fillColor = __value; } - /*! \brief returns the property fillColor ( \copybrief fillColor ). - \details Description of the parameter fillColor is:
    \copydoc fillColor
    - \see fillColor for more information */ + /*! \copydoc fillColor + \see see fillColor for details */ inline virtual QColor getFillColor() const { return this->fillColor; } - /*! \brief sets the property style ( \copybrief style ) to the specified \a __value. - \details Description of the parameter style is:
    \copydoc style
    - \see style for more information */ + /*! \copydoc style + \see see style for details */ inline virtual void setStyle(const Qt::PenStyle & __value) { this->style = __value; } - /*! \brief returns the property style ( \copybrief style ). - \details Description of the parameter style is:
    \copydoc style
    - \see style for more information */ + /*! \copydoc style + \see see style for details */ inline virtual Qt::PenStyle getStyle() const { return this->style; } - /*! \brief sets the property drawLine ( \copybrief drawLine ) to the specified \a __value. - \details Description of the parameter drawLine is:
    \copydoc drawLine
    - \see drawLine for more information */ + /*! \copydoc drawLine + \see see drawLine for details */ inline virtual void setDrawLine(bool __value) { this->drawLine = __value; } - /*! \brief returns the property drawLine ( \copybrief drawLine ). - \details Description of the parameter drawLine is:
    \copydoc drawLine
    - \see drawLine for more information */ + /*! \copydoc drawLine + \see see drawLine for details */ inline virtual bool getDrawLine() const { return this->drawLine; } - /*! \brief sets the property fillStyle ( \copybrief fillStyle ) to the specified \a __value. - \details Description of the parameter fillStyle is:
    \copydoc fillStyle
    - \see fillStyle for more information */ + /*! \copydoc fillStyle + \see see fillStyle for details */ inline virtual void setFillStyle(const Qt::BrushStyle & __value) { this->fillStyle = __value; } - /*! \brief returns the property fillStyle ( \copybrief fillStyle ). - \details Description of the parameter fillStyle is:
    \copydoc fillStyle
    - \see fillStyle for more information */ + /*! \copydoc fillStyle + \see see fillStyle for details */ inline virtual Qt::BrushStyle getFillStyle() const { return this->fillStyle; } - /*! \brief sets the property drawSelectionLine ( \copybrief drawSelectionLine ) to the specified \a __value. - \details Description of the parameter drawSelectionLine is:
    \copydoc drawSelectionLine
    - \see drawSelectionLine for more information */ + /*! \copydoc drawSelectionLine + \see see drawSelectionLine for details */ inline virtual void setDrawSelectionLine(bool __value) { this->drawSelectionLine = __value; } - /*! \brief returns the property drawSelectionLine ( \copybrief drawSelectionLine ). - \details Description of the parameter drawSelectionLine is:
    \copydoc drawSelectionLine
    - \see drawSelectionLine for more information */ + /*! \copydoc drawSelectionLine + \see see drawSelectionLine for details */ inline virtual bool getDrawSelectionLine() const { return this->drawSelectionLine; } - /*! \brief sets the property selectionLineColor ( \copybrief selectionLineColor ) to the specified \a __value. - \details Description of the parameter selectionLineColor is:
    \copydoc selectionLineColor
    - \see selectionLineColor for more information */ + /*! \copydoc selectionLineColor + \see see selectionLineColor for details */ inline virtual void setSelectionLineColor(const QColor & __value) { this->selectionLineColor = __value; } - /*! \brief returns the property selectionLineColor ( \copybrief selectionLineColor ). - \details Description of the parameter selectionLineColor is:
    \copydoc selectionLineColor
    - \see selectionLineColor for more information */ + /*! \copydoc selectionLineColor + \see see selectionLineColor for details */ inline virtual QColor getSelectionLineColor() const { return this->selectionLineColor; diff --git a/lib/jkqtplotter/jkqtpgraphsgeometric.cpp b/lib/jkqtplotter/jkqtpgraphsgeometric.cpp index ec0a5eb78f..91b18cbdc8 100644 --- a/lib/jkqtplotter/jkqtpgraphsgeometric.cpp +++ b/lib/jkqtplotter/jkqtpgraphsgeometric.cpp @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -21,9 +21,10 @@ #include "jkqtplotter/jkqtpgraphsgeometric.h" #include "jkqtplotter/jkqtpbaseplotter.h" +#include "jkqtplotter/jkqtplotter.h" #include #include - +#include #define SmallestGreaterZeroCompare_xvsgz() if ((xvsgz>10.0*DBL_MIN)&&((smallestGreaterZero<10.0*DBL_MIN) || (xvsgzpt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); return p; } void JKQTPGeoBaseLine::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) { - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.setPen(getPen(painter)); double y=rect.top()+rect.height()/2.0; if (rect.width()>0) painter.drawLine(QLineF(rect.left(), y, rect.right(), y)); - painter.restore(); + } QColor JKQTPGeoBaseLine::getKeyLabelColor() { @@ -123,11 +124,11 @@ QBrush JKQTPGeoBaseFilled::getBrush(JKQTPEnhancedPainter &/*painter*/) { } void JKQTPGeoBaseFilled::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) { - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.setPen(getPen(painter)); painter.setBrush(getBrush(painter)); painter.drawRect(rect); - painter.restore(); + } @@ -141,18 +142,19 @@ JKQTPGeoText::JKQTPGeoText(JKQTBasePlotter* parent, double x, double y, const QS this->y=y; this->text=text; this->fontSize=fontSize; + this->fontName=QApplication::font().family()+"+XITS"; this->color=color; + if (parent) { + this->fontSize=parent->getCurrentPlotterStyle().defaultFontSize; + this->fontName=parent->getCurrentPlotterStyle().defaultFontName; + } } JKQTPGeoText::JKQTPGeoText(JKQTPlotter* parent, double x, double y, const QString& text, double fontSize, QColor color): - JKQTPPlotObject(parent) + JKQTPGeoText(parent->getPlotter(),x,y,text,fontSize,color) { - this->x=x; - this->y=y; - this->text=text; - this->fontSize=fontSize; - this->color=color; } + bool JKQTPGeoText::getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) { minx=maxx=x; smallestGreaterZero=0; @@ -168,23 +170,21 @@ bool JKQTPGeoText::getYMinMax(double& miny, double& maxy, double& smallestGreate } void JKQTPGeoText::draw(JKQTPEnhancedPainter& painter) { - painter.save(); -#ifdef USE_XITS_FONTS - parent->getMathText()->useXITS(); -#endif + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + parent->getMathText()->setFontRomanOrSpecial(fontName); parent->getMathText()->setFontSize(fontSize*parent->getFontSizeMultiplier()); parent->getMathText()->setFontColor(color); parent->getMathText()->parse(text); parent->getMathText()->draw(painter, transformX(x), transformY(y)); - painter.restore(); + } void JKQTPGeoText::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) { - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.setPen(getPen(painter)); double y=rect.top()+rect.height()/2.0; if (rect.width()>0) painter.drawLine(QLineF(rect.left(), y, rect.right(), y)); - painter.restore(); + } QColor JKQTPGeoText::getKeyLabelColor() { @@ -240,11 +240,11 @@ bool JKQTPGeoLine::getYMinMax(double& miny, double& maxy, double& smallestGreate } void JKQTPGeoLine::draw(JKQTPEnhancedPainter& painter) { - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.setPen(getPen(painter)); QLineF l(QPointF(transformX(x1), transformY(y1)), QPointF(transformX(x2), transformY(y2))); if (l.length()>0) painter.drawLine(l); - painter.restore(); + } @@ -405,11 +405,11 @@ void JKQTPGeoInfiniteLine::draw(JKQTPEnhancedPainter& painter) { } if (doDraw) { - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.setPen(getPen(painter)); QLineF l(QPointF(transformX(x1), transformY(y1)), QPointF(transformX(x2), transformY(y2))); if (l.length()>0) painter.drawLine(l); - painter.restore(); + } } @@ -481,10 +481,10 @@ bool JKQTPGeoPolyLines::getYMinMax(double& miny, double& maxy, double& smallestG void JKQTPGeoPolyLines::draw(JKQTPEnhancedPainter& painter) { QPainterPath path=transformToLinePath(points); - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.setPen(getPen(painter)); painter.drawPath(path); - painter.restore(); + } @@ -597,11 +597,11 @@ void JKQTPGeoRectangle::draw(JKQTPEnhancedPainter& painter) { rect.append(QPointF(transformX(poly[i].x()), transformY(poly[i].y()))); } - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.setPen(getPen(painter)); painter.setBrush(getBrush(painter)); painter.drawPolygon(rect); - painter.restore(); + } @@ -674,11 +674,11 @@ bool JKQTPGeoPolygon::getYMinMax(double& miny, double& maxy, double& smallestGre void JKQTPGeoPolygon::draw(JKQTPEnhancedPainter& painter) { QPolygonF path=transformToPolygon(points); - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.setPen(getPen(painter)); painter.setBrush(getBrush(painter)); painter.drawPolygon(path); - painter.restore(); + } @@ -726,11 +726,11 @@ void JKQTPGeoEllipse::draw(JKQTPEnhancedPainter& painter) { rect.closeSubpath(); - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.setPen(getPen(painter)); painter.setBrush(getBrush(painter)); painter.drawPath(rect); - painter.restore(); + } @@ -766,10 +766,10 @@ void JKQTPGeoArc::draw(JKQTPEnhancedPainter& painter) { QPainterPath rect; rect=transformToLinePath(JKQTPDrawEllipse(x,y,width/2.0, height/2.0,angleStart,angleStop,angle, controlPoints)); - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.setPen(getPen(painter)); painter.drawPath(rect); - painter.restore(); + } @@ -826,11 +826,11 @@ void JKQTPGeoPie::draw(JKQTPEnhancedPainter& painter) { rect.closeSubpath(); - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.setPen(getPen(painter)); painter.setBrush(getBrush(painter)); painter.drawPath(rect); - painter.restore(); + } bool JKQTPGeoPie::getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) { @@ -883,11 +883,11 @@ void JKQTPGeoChord::draw(JKQTPEnhancedPainter& painter) { rect.closeSubpath(); - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.setPen(getPen(painter)); painter.setBrush(getBrush(painter)); painter.drawPath(rect); - painter.restore(); + } bool JKQTPGeoChord::getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) { @@ -961,9 +961,9 @@ bool JKQTPGeoSymbol::getYMinMax(double &miny, double &maxy, double &smallestGrea void JKQTPGeoSymbol::draw(JKQTPEnhancedPainter &painter) { - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); JKQTPPlotSymbol(painter, transformX(x), transformY(y), symbol, symbolSize, symbolWidth, color, fillColor); - painter.restore(); + } void JKQTPGeoSymbol::drawKeyMarker(JKQTPEnhancedPainter &painter, QRectF &rect) @@ -974,9 +974,9 @@ void JKQTPGeoSymbol::drawKeyMarker(JKQTPEnhancedPainter &painter, QRectF &rect) double symbolWidth=parent->pt2px(painter, this->symbolWidth*parent->getLineWidthMultiplier()); if (symbolWidth>0.3*symbolSize) symbolWidth=0.3*symbolSize; - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); JKQTPPlotSymbol(painter, rect.left()+rect.width()/2.0, rect.top()+rect.height()/2.0, symbol, symbolSize, symbolWidth, color, fillColor); - painter.restore(); + } QColor JKQTPGeoSymbol::getKeyLabelColor() diff --git a/lib/jkqtplotter/jkqtpgraphsgeometric.h b/lib/jkqtplotter/jkqtpgraphsgeometric.h index 0d3bc4990b..7bf0b2cba8 100644 --- a/lib/jkqtplotter/jkqtpgraphsgeometric.h +++ b/lib/jkqtplotter/jkqtpgraphsgeometric.h @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -54,44 +54,38 @@ class JKQTP_LIB_EXPORT JKQTPGeoBaseLine: public JKQTPPlotObject { explicit JKQTPGeoBaseLine(QColor color, double lineWidth, Qt::PenStyle style, JKQTPlotter* parent); - /*! \brief sets the property color ( \copybrief color ) to the specified \a __value. - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual void setColor(const QColor & __value) { this->color = __value; } - /*! \brief returns the property color ( \copybrief color ). - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual QColor getColor() const { return this->color; } - /*! \brief sets the property style ( \copybrief style ) to the specified \a __value. - \details Description of the parameter style is:
    \copydoc style
    - \see style for more information */ + /*! \copydoc style + \see see style for details */ inline virtual void setStyle(const Qt::PenStyle & __value) { this->style = __value; } - /*! \brief returns the property style ( \copybrief style ). - \details Description of the parameter style is:
    \copydoc style
    - \see style for more information */ + /*! \copydoc style + \see see style for details */ inline virtual Qt::PenStyle getStyle() const { return this->style; } - /*! \brief sets the property lineWidth ( \copybrief lineWidth ) to the specified \a __value. - \details Description of the parameter lineWidth is:
    \copydoc lineWidth
    - \see lineWidth for more information */ + /*! \copydoc lineWidth + \see see lineWidth for details */ inline virtual void setLineWidth(double __value) { this->lineWidth = __value; } - /*! \brief returns the property lineWidth ( \copybrief lineWidth ). - \details Description of the parameter lineWidth is:
    \copydoc lineWidth
    - \see lineWidth for more information */ + /*! \copydoc lineWidth + \see see lineWidth for details */ inline virtual double getLineWidth() const { return this->lineWidth; @@ -166,30 +160,26 @@ class JKQTP_LIB_EXPORT JKQTPGeoBaseFilled: public JKQTPGeoBaseLine { */ JKQTPGeoBaseFilled(QColor color, QColor fillColor, JKQTPlotter* parent); - /*! \brief sets the property fillColor ( \copybrief fillColor ) to the specified \a __value. - \details Description of the parameter fillColor is:
    \copydoc fillColor
    - \see fillColor for more information */ + /*! \copydoc fillColor + \see see fillColor for details */ inline virtual void setFillColor(const QColor & __value) { this->fillColor = __value; } - /*! \brief returns the property fillColor ( \copybrief fillColor ). - \details Description of the parameter fillColor is:
    \copydoc fillColor
    - \see fillColor for more information */ + /*! \copydoc fillColor + \see see fillColor for details */ inline virtual QColor getFillColor() const { return this->fillColor; } - /*! \brief sets the property fillStyle ( \copybrief fillStyle ) to the specified \a __value. - \details Description of the parameter fillStyle is:
    \copydoc fillStyle
    - \see fillStyle for more information */ + /*! \copydoc fillStyle + \see see fillStyle for details */ inline virtual void setFillStyle(const Qt::BrushStyle & __value) { this->fillStyle = __value; } - /*! \brief returns the property fillStyle ( \copybrief fillStyle ). - \details Description of the parameter fillStyle is:
    \copydoc fillStyle
    - \see fillStyle for more information */ + /*! \copydoc fillStyle + \see see fillStyle for details */ inline virtual Qt::BrushStyle getFillStyle() const { return this->fillStyle; @@ -245,100 +235,86 @@ class JKQTP_LIB_EXPORT JKQTPGeoSymbol: public JKQTPPlotObject { */ JKQTPGeoSymbol(JKQTPlotter* parent, double x, double y, JKQTPGraphSymbols symbol=JKQTPCross, double symbolSize=10, QColor color=QColor("black"), QColor fillColor=QColor("grey")); - /*! \brief sets the property color ( \copybrief color ) to the specified \a __value. - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual void setColor(const QColor & __value) { this->color = __value; } - /*! \brief returns the property color ( \copybrief color ). - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual QColor getColor() const { return this->color; } - /*! \brief sets the property fillColor ( \copybrief fillColor ) to the specified \a __value. - \details Description of the parameter fillColor is:
    \copydoc fillColor
    - \see fillColor for more information */ + /*! \copydoc fillColor + \see see fillColor for details */ inline virtual void setFillColor(const QColor & __value) { this->fillColor = __value; } - /*! \brief returns the property fillColor ( \copybrief fillColor ). - \details Description of the parameter fillColor is:
    \copydoc fillColor
    - \see fillColor for more information */ + /*! \copydoc fillColor + \see see fillColor for details */ inline virtual QColor getFillColor() const { return this->fillColor; } - /*! \brief sets the property symbol ( \copybrief symbol ) to the specified \a __value. - \details Description of the parameter symbol is:
    \copydoc symbol
    - \see symbol for more information */ + /*! \copydoc symbol + \see see symbol for details */ inline virtual void setSymbol(const JKQTPGraphSymbols & __value) { this->symbol = __value; } - /*! \brief returns the property symbol ( \copybrief symbol ). - \details Description of the parameter symbol is:
    \copydoc symbol
    - \see symbol for more information */ + /*! \copydoc symbol + \see see symbol for details */ inline virtual JKQTPGraphSymbols getSymbol() const { return this->symbol; } - /*! \brief sets the property symbolSize ( \copybrief symbolSize ) to the specified \a __value. - \details Description of the parameter symbolSize is:
    \copydoc symbolSize
    - \see symbolSize for more information */ + /*! \copydoc symbolSize + \see see symbolSize for details */ inline virtual void setSymbolSize(double __value) { this->symbolSize = __value; } - /*! \brief returns the property symbolSize ( \copybrief symbolSize ). - \details Description of the parameter symbolSize is:
    \copydoc symbolSize
    - \see symbolSize for more information */ + /*! \copydoc symbolSize + \see see symbolSize for details */ inline virtual double getSymbolSize() const { return this->symbolSize; } - /*! \brief sets the property symbolWidth ( \copybrief symbolWidth ) to the specified \a __value. - \details Description of the parameter symbolWidth is:
    \copydoc symbolWidth
    - \see symbolWidth for more information */ + /*! \copydoc symbolWidth + \see see symbolWidth for details */ inline virtual void setSymbolWidth(double __value) { this->symbolWidth = __value; } - /*! \brief returns the property symbolWidth ( \copybrief symbolWidth ). - \details Description of the parameter symbolWidth is:
    \copydoc symbolWidth
    - \see symbolWidth for more information */ + /*! \copydoc symbolWidth + \see see symbolWidth for details */ inline virtual double getSymbolWidth() const { return this->symbolWidth; } - /*! \brief sets the property x ( \copybrief x ) to the specified \a __value. - \details Description of the parameter x is:
    \copydoc x
    - \see x for more information */ + /*! \copydoc x + \see see x for details */ inline virtual void setX(double __value) { this->x = __value; } - /*! \brief returns the property x ( \copybrief x ). - \details Description of the parameter x is:
    \copydoc x
    - \see x for more information */ + /*! \copydoc x + \see see x for details */ inline virtual double getX() const { return this->x; } - /*! \brief sets the property y ( \copybrief y ) to the specified \a __value. - \details Description of the parameter y is:
    \copydoc y
    - \see y for more information */ + /*! \copydoc y + \see see y for details */ inline virtual void setY(double __value) { this->y = __value; } - /*! \brief returns the property y ( \copybrief y ). - \details Description of the parameter y is:
    \copydoc y
    - \see y for more information */ + /*! \copydoc y + \see see y for details */ inline virtual double getY() const { return this->y; @@ -403,72 +379,74 @@ class JKQTP_LIB_EXPORT JKQTPGeoText: public JKQTPPlotObject { */ JKQTPGeoText(JKQTPlotter* parent, double x, double y, const QString& text, double fontSize=10, QColor color=QColor("black")); - /*! \brief sets the property color ( \copybrief color ) to the specified \a __value. - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual void setColor(const QColor & __value) { this->color = __value; } - /*! \brief returns the property color ( \copybrief color ). - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual QColor getColor() const { return this->color; } - /*! \brief sets the property text ( \copybrief text ) to the specified \a __value. - \details Description of the parameter text is:
    \copydoc text
    - \see text for more information */ + /*! \copydoc text + \see see text for details */ inline virtual void setText(const QString & __value) { this->text = __value; } - /*! \brief returns the property text ( \copybrief text ). - \details Description of the parameter text is:
    \copydoc text
    - \see text for more information */ + /*! \copydoc fontName + \see see fontName for details */ + inline virtual void setFontName(const QString & __value) + { + this->fontName = __value; + } + /*! \copydoc text + \see see text for details */ inline virtual QString getText() const { return this->text; } - /*! \brief sets the property fontSize ( \copybrief fontSize ) to the specified \a __value. - \details Description of the parameter fontSize is:
    \copydoc fontSize
    - \see fontSize for more information */ + /*! \copydoc fontName + \see see fontName for details */ + inline virtual QString getFontName() const + { + return this->fontName; + } + /*! \copydoc fontSize + \see see fontSize for details */ inline virtual void setFontSize(double __value) { this->fontSize = __value; } - /*! \brief returns the property fontSize ( \copybrief fontSize ). - \details Description of the parameter fontSize is:
    \copydoc fontSize
    - \see fontSize for more information */ + /*! \copydoc fontSize + \see see fontSize for details */ inline virtual double getFontSize() const { return this->fontSize; } - /*! \brief sets the property x ( \copybrief x ) to the specified \a __value. - \details Description of the parameter x is:
    \copydoc x
    - \see x for more information */ + /*! \copydoc x + \see see x for details */ inline virtual void setX(double __value) { this->x = __value; } - /*! \brief returns the property x ( \copybrief x ). - \details Description of the parameter x is:
    \copydoc x
    - \see x for more information */ + /*! \copydoc x + \see see x for details */ inline virtual double getX() const { return this->x; } - /*! \brief sets the property y ( \copybrief y ) to the specified \a __value. - \details Description of the parameter y is:
    \copydoc y
    - \see y for more information */ + /*! \copydoc y + \see see y for details */ inline virtual void setY(double __value) { this->y = __value; } - /*! \brief returns the property y ( \copybrief y ). - \details Description of the parameter y is:
    \copydoc y
    - \see y for more information */ + /*! \copydoc y + \see see y for details */ inline virtual double getY() const { return this->y; @@ -496,6 +474,8 @@ class JKQTP_LIB_EXPORT JKQTPGeoText: public JKQTPPlotObject { /** \brief base font size of text */ double fontSize; /** \brief the text to display */ + QString fontName; + /** \brief the text to display */ QString text; /** \brief return a pen, that may be used for drawing */ QPen getPen(JKQTPEnhancedPainter& painter); @@ -544,58 +524,50 @@ class JKQTP_LIB_EXPORT JKQTPGeoLine: public JKQTPGeoBaseLine { /** \brief plots the graph to the plotter object specified as parent */ virtual void draw(JKQTPEnhancedPainter& painter) override; - /*! \brief sets the property x1 ( \copybrief x1 ) to the specified \a __value. - \details Description of the parameter x1 is:
    \copydoc x1
    - \see x1 for more information */ + /*! \copydoc x1 + \see see x1 for details */ inline virtual void setX1(double __value) { this->x1 = __value; } - /*! \brief returns the property x1 ( \copybrief x1 ). - \details Description of the parameter x1 is:
    \copydoc x1
    - \see x1 for more information */ + /*! \copydoc x1 + \see see x1 for details */ inline virtual double getX1() const { return this->x1; } - /*! \brief sets the property y1 ( \copybrief y1 ) to the specified \a __value. - \details Description of the parameter y1 is:
    \copydoc y1
    - \see y1 for more information */ + /*! \copydoc y1 + \see see y1 for details */ inline virtual void setY1(double __value) { this->y1 = __value; } - /*! \brief returns the property y1 ( \copybrief y1 ). - \details Description of the parameter y1 is:
    \copydoc y1
    - \see y1 for more information */ + /*! \copydoc y1 + \see see y1 for details */ inline virtual double getY1() const { return this->y1; } - /*! \brief sets the property x2 ( \copybrief x2 ) to the specified \a __value. - \details Description of the parameter x2 is:
    \copydoc x2
    - \see x2 for more information */ + /*! \copydoc x2 + \see see x2 for details */ inline virtual void setX2(double __value) { this->x2 = __value; } - /*! \brief returns the property x2 ( \copybrief x2 ). - \details Description of the parameter x2 is:
    \copydoc x2
    - \see x2 for more information */ + /*! \copydoc x2 + \see see x2 for details */ inline virtual double getX2() const { return this->x2; } - /*! \brief sets the property y2 ( \copybrief y2 ) to the specified \a __value. - \details Description of the parameter y2 is:
    \copydoc y2
    - \see y2 for more information */ + /*! \copydoc y2 + \see see y2 for details */ inline virtual void setY2(double __value) { this->y2 = __value; } - /*! \brief returns the property y2 ( \copybrief y2 ). - \details Description of the parameter y2 is:
    \copydoc y2
    - \see y2 for more information */ + /*! \copydoc y2 + \see see y2 for details */ inline virtual double getY2() const { return this->y2; @@ -652,72 +624,62 @@ class JKQTP_LIB_EXPORT JKQTPGeoInfiniteLine: public JKQTPGeoBaseLine { /** \brief plots the graph to the plotter object specified as parent */ virtual void draw(JKQTPEnhancedPainter& painter) override; - /*! \brief sets the property x ( \copybrief x ) to the specified \a __value. - \details Description of the parameter x is:
    \copydoc x
    - \see x for more information */ + /*! \copydoc x + \see see x for details */ inline virtual void setX(double __value) { this->x = __value; } - /*! \brief returns the property x ( \copybrief x ). - \details Description of the parameter x is:
    \copydoc x
    - \see x for more information */ + /*! \copydoc x + \see see x for details */ inline virtual double getX() const { return this->x; } - /*! \brief sets the property y ( \copybrief y ) to the specified \a __value. - \details Description of the parameter y is:
    \copydoc y
    - \see y for more information */ + /*! \copydoc y + \see see y for details */ inline virtual void setY(double __value) { this->y = __value; } - /*! \brief returns the property y ( \copybrief y ). - \details Description of the parameter y is:
    \copydoc y
    - \see y for more information */ + /*! \copydoc y + \see see y for details */ inline virtual double getY() const { return this->y; } - /*! \brief sets the property dx ( \copybrief dx ) to the specified \a __value. - \details Description of the parameter dx is:
    \copydoc dx
    - \see dx for more information */ + /*! \copydoc dx + \see see dx for details */ inline virtual void setDx(double __value) { this->dx = __value; } - /*! \brief returns the property dx ( \copybrief dx ). - \details Description of the parameter dx is:
    \copydoc dx
    - \see dx for more information */ + /*! \copydoc dx + \see see dx for details */ inline virtual double getDx() const { return this->dx; } - /*! \brief sets the property dy ( \copybrief dy ) to the specified \a __value. - \details Description of the parameter dy is:
    \copydoc dy
    - \see dy for more information */ + /*! \copydoc dy + \see see dy for details */ inline virtual void setDy(double __value) { this->dy = __value; } - /*! \brief returns the property dy ( \copybrief dy ). - \details Description of the parameter dy is:
    \copydoc dy
    - \see dy for more information */ + /*! \copydoc dy + \see see dy for details */ inline virtual double getDy() const { return this->dy; } - /*! \brief sets the property two_sided ( \copybrief two_sided ) to the specified \a __value. - \details Description of the parameter two_sided is:
    \copydoc two_sided
    - \see two_sided for more information */ + /*! \copydoc two_sided + \see see two_sided for details */ inline virtual void setTwoSided(bool __value) { this->two_sided = __value; } - /*! \brief returns the property two_sided ( \copybrief two_sided ). - \details Description of the parameter two_sided is:
    \copydoc two_sided
    - \see two_sided for more information */ + /*! \copydoc two_sided + \see see two_sided for details */ inline virtual bool getTwoSided() const { return this->two_sided; @@ -785,16 +747,14 @@ class JKQTP_LIB_EXPORT JKQTPGeoPolyLines: public JKQTPGeoBaseLine { /** \brief plots the graph to the plotter object specified as parent */ virtual void draw(JKQTPEnhancedPainter& painter) override; - /*! \brief sets the property points ( \copybrief points ) to the specified \a __value. - \details Description of the parameter points is:
    \copydoc points
    - \see points for more information */ + /*! \copydoc points + \see see points for details */ inline virtual void setPoints(const QVector & __value) { this->points = __value; } - /*! \brief returns the property points ( \copybrief points ). - \details Description of the parameter points is:
    \copydoc points
    - \see points for more information */ + /*! \copydoc points + \see see points for details */ inline virtual QVector getPoints() const { return this->points; @@ -914,72 +874,62 @@ class JKQTP_LIB_EXPORT JKQTPGeoRectangle: public JKQTPGeoBaseFilled { /** \brief plots the graph to the plotter object specified as parent */ virtual void draw(JKQTPEnhancedPainter& painter) override; - /*! \brief sets the property x ( \copybrief x ) to the specified \a __value. - \details Description of the parameter x is:
    \copydoc x
    - \see x for more information */ + /*! \copydoc x + \see see x for details */ inline virtual void setX(double __value) { this->x = __value; } - /*! \brief returns the property x ( \copybrief x ). - \details Description of the parameter x is:
    \copydoc x
    - \see x for more information */ + /*! \copydoc x + \see see x for details */ inline virtual double getX() const { return this->x; } - /*! \brief sets the property y ( \copybrief y ) to the specified \a __value. - \details Description of the parameter y is:
    \copydoc y
    - \see y for more information */ + /*! \copydoc y + \see see y for details */ inline virtual void setY(double __value) { this->y = __value; } - /*! \brief returns the property y ( \copybrief y ). - \details Description of the parameter y is:
    \copydoc y
    - \see y for more information */ + /*! \copydoc y + \see see y for details */ inline virtual double getY() const { return this->y; } - /*! \brief sets the property width ( \copybrief width ) to the specified \a __value. - \details Description of the parameter width is:
    \copydoc width
    - \see width for more information */ + /*! \copydoc width + \see see width for details */ inline virtual void setWidth(double __value) { this->width = __value; } - /*! \brief returns the property width ( \copybrief width ). - \details Description of the parameter width is:
    \copydoc width
    - \see width for more information */ + /*! \copydoc width + \see see width for details */ inline virtual double getWidth() const { return this->width; } - /*! \brief sets the property height ( \copybrief height ) to the specified \a __value. - \details Description of the parameter height is:
    \copydoc height
    - \see height for more information */ + /*! \copydoc height + \see see height for details */ inline virtual void setHeight(double __value) { this->height = __value; } - /*! \brief returns the property height ( \copybrief height ). - \details Description of the parameter height is:
    \copydoc height
    - \see height for more information */ + /*! \copydoc height + \see see height for details */ inline virtual double getHeight() const { return this->height; } - /*! \brief sets the property angle ( \copybrief angle ) to the specified \a __value. - \details Description of the parameter angle is:
    \copydoc angle
    - \see angle for more information */ + /*! \copydoc angle + \see see angle for details */ inline virtual void setAngle(double __value) { this->angle = __value; } - /*! \brief returns the property angle ( \copybrief angle ). - \details Description of the parameter angle is:
    \copydoc angle
    - \see angle for more information */ + /*! \copydoc angle + \see see angle for details */ inline virtual double getAngle() const { return this->angle; @@ -1061,16 +1011,14 @@ class JKQTP_LIB_EXPORT JKQTPGeoPolygon: public JKQTPGeoBaseFilled { /** \brief plots the graph to the plotter object specified as parent */ virtual void draw(JKQTPEnhancedPainter& painter) override; - /*! \brief sets the property points ( \copybrief points ) to the specified \a __value. - \details Description of the parameter points is:
    \copydoc points
    - \see points for more information */ + /*! \copydoc points + \see see points for details */ inline virtual void setPoints(const QVector & __value) { this->points = __value; } - /*! \brief returns the property points ( \copybrief points ). - \details Description of the parameter points is:
    \copydoc points
    - \see points for more information */ + /*! \copydoc points + \see see points for details */ inline virtual QVector getPoints() const { return this->points; @@ -1189,16 +1137,14 @@ class JKQTP_LIB_EXPORT JKQTPGeoEllipse: public JKQTPGeoRectangle { /** \brief plots the graph to the plotter object specified as parent */ virtual void draw(JKQTPEnhancedPainter& painter) override; - /*! \brief sets the property controlPoints ( \copybrief controlPoints ) to the specified \a __value. - \details Description of the parameter controlPoints is:
    \copydoc controlPoints
    - \see controlPoints for more information */ + /*! \copydoc controlPoints + \see see controlPoints for details */ inline virtual void setControlPoints(const unsigned int & __value) { this->controlPoints = __value; } - /*! \brief returns the property controlPoints ( \copybrief controlPoints ). - \details Description of the parameter controlPoints is:
    \copydoc controlPoints
    - \see controlPoints for more information */ + /*! \copydoc controlPoints + \see see controlPoints for details */ inline virtual unsigned int getControlPoints() const { return this->controlPoints; @@ -1253,114 +1199,98 @@ class JKQTP_LIB_EXPORT JKQTPGeoArc: public JKQTPGeoBaseLine { /** \brief plots the graph to the plotter object specified as parent */ virtual void draw(JKQTPEnhancedPainter& painter) override; - /*! \brief sets the property controlPoints ( \copybrief controlPoints ) to the specified \a __value. - \details Description of the parameter controlPoints is:
    \copydoc controlPoints
    - \see controlPoints for more information */ + /*! \copydoc controlPoints + \see see controlPoints for details */ inline virtual void setControlPoints(const unsigned int & __value) { this->controlPoints = __value; } - /*! \brief returns the property controlPoints ( \copybrief controlPoints ). - \details Description of the parameter controlPoints is:
    \copydoc controlPoints
    - \see controlPoints for more information */ + /*! \copydoc controlPoints + \see see controlPoints for details */ inline virtual unsigned int getControlPoints() const { return this->controlPoints; } - /*! \brief sets the property angleStart ( \copybrief angleStart ) to the specified \a __value. - \details Description of the parameter angleStart is:
    \copydoc angleStart
    - \see angleStart for more information */ + /*! \copydoc angleStart + \see see angleStart for details */ inline virtual void setAngleStart(double __value) { this->angleStart = __value; } - /*! \brief returns the property angleStart ( \copybrief angleStart ). - \details Description of the parameter angleStart is:
    \copydoc angleStart
    - \see angleStart for more information */ + /*! \copydoc angleStart + \see see angleStart for details */ inline virtual double getAngleStart() const { return this->angleStart; } - /*! \brief sets the property angleStop ( \copybrief angleStop ) to the specified \a __value. - \details Description of the parameter angleStop is:
    \copydoc angleStop
    - \see angleStop for more information */ + /*! \copydoc angleStop + \see see angleStop for details */ inline virtual void setAngleStop(double __value) { this->angleStop = __value; } - /*! \brief returns the property angleStop ( \copybrief angleStop ). - \details Description of the parameter angleStop is:
    \copydoc angleStop
    - \see angleStop for more information */ + /*! \copydoc angleStop + \see see angleStop for details */ inline virtual double getAngleStop() const { return this->angleStop; } - /*! \brief sets the property x ( \copybrief x ) to the specified \a __value. - \details Description of the parameter x is:
    \copydoc x
    - \see x for more information */ + /*! \copydoc x + \see see x for details */ inline virtual void setX(double __value) { this->x = __value; } - /*! \brief returns the property x ( \copybrief x ). - \details Description of the parameter x is:
    \copydoc x
    - \see x for more information */ + /*! \copydoc x + \see see x for details */ inline virtual double getX() const { return this->x; } - /*! \brief sets the property y ( \copybrief y ) to the specified \a __value. - \details Description of the parameter y is:
    \copydoc y
    - \see y for more information */ + /*! \copydoc y + \see see y for details */ inline virtual void setY(double __value) { this->y = __value; } - /*! \brief returns the property y ( \copybrief y ). - \details Description of the parameter y is:
    \copydoc y
    - \see y for more information */ + /*! \copydoc y + \see see y for details */ inline virtual double getY() const { return this->y; } - /*! \brief sets the property width ( \copybrief width ) to the specified \a __value. - \details Description of the parameter width is:
    \copydoc width
    - \see width for more information */ + /*! \copydoc width + \see see width for details */ inline virtual void setWidth(double __value) { this->width = __value; } - /*! \brief returns the property width ( \copybrief width ). - \details Description of the parameter width is:
    \copydoc width
    - \see width for more information */ + /*! \copydoc width + \see see width for details */ inline virtual double getWidth() const { return this->width; } - /*! \brief sets the property height ( \copybrief height ) to the specified \a __value. - \details Description of the parameter height is:
    \copydoc height
    - \see height for more information */ + /*! \copydoc height + \see see height for details */ inline virtual void setHeight(double __value) { this->height = __value; } - /*! \brief returns the property height ( \copybrief height ). - \details Description of the parameter height is:
    \copydoc height
    - \see height for more information */ + /*! \copydoc height + \see see height for details */ inline virtual double getHeight() const { return this->height; } - /*! \brief sets the property angle ( \copybrief angle ) to the specified \a __value. - \details Description of the parameter angle is:
    \copydoc angle
    - \see angle for more information */ + /*! \copydoc angle + \see see angle for details */ inline virtual void setAngle(double __value) { this->angle = __value; } - /*! \brief returns the property angle ( \copybrief angle ). - \details Description of the parameter angle is:
    \copydoc angle
    - \see angle for more information */ + /*! \copydoc angle + \see see angle for details */ inline virtual double getAngle() const { return this->angle; @@ -1436,30 +1366,26 @@ class JKQTP_LIB_EXPORT JKQTPGeoPie: public JKQTPGeoEllipse { /** \brief plots the graph to the plotter object specified as parent */ virtual void draw(JKQTPEnhancedPainter& painter) override; - /*! \brief sets the property angleStart ( \copybrief angleStart ) to the specified \a __value. - \details Description of the parameter angleStart is:
    \copydoc angleStart
    - \see angleStart for more information */ + /*! \copydoc angleStart + \see see angleStart for details */ inline virtual void setAngleStart(double __value) { this->angleStart = __value; } - /*! \brief returns the property angleStart ( \copybrief angleStart ). - \details Description of the parameter angleStart is:
    \copydoc angleStart
    - \see angleStart for more information */ + /*! \copydoc angleStart + \see see angleStart for details */ inline virtual double getAngleStart() const { return this->angleStart; } - /*! \brief sets the property angleStop ( \copybrief angleStop ) to the specified \a __value. - \details Description of the parameter angleStop is:
    \copydoc angleStop
    - \see angleStop for more information */ + /*! \copydoc angleStop + \see see angleStop for details */ inline virtual void setAngleStop(double __value) { this->angleStop = __value; } - /*! \brief returns the property angleStop ( \copybrief angleStop ). - \details Description of the parameter angleStop is:
    \copydoc angleStop
    - \see angleStop for more information */ + /*! \copydoc angleStop + \see see angleStop for details */ inline virtual double getAngleStop() const { return this->angleStop; diff --git a/lib/jkqtplotter/jkqtpgraphsimage.cpp b/lib/jkqtplotter/jkqtpgraphsimage.cpp index 383d9fa207..cb51502caf 100644 --- a/lib/jkqtplotter/jkqtpgraphsimage.cpp +++ b/lib/jkqtplotter/jkqtpgraphsimage.cpp @@ -1,11 +1,11 @@ /* - Copyright (c) 2008-2019 Jan W. Krieger & Sebastian Isbaner (contour plot) + Copyright (c) 2008-2019 Jan W. Krieger 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 of the License, or + 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, @@ -100,7 +100,7 @@ void JKQTPImageBase::plotImage(JKQTPEnhancedPainter& painter, QImage& image, dou if ((!JKQTPIsOKFloat(x))||(!JKQTPIsOKFloat(y))||(!JKQTPIsOKFloat(width))||(!JKQTPIsOKFloat(height))||(width<=0) || (height<=0) || image.isNull() || (image.width()<=0) || (image.height()<=0)) { return; } - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); double xmin=parent->getXMin(); double xmax=parent->getXMax(); @@ -139,7 +139,7 @@ void JKQTPImageBase::plotImage(JKQTPEnhancedPainter& painter, QImage& image, dou painter.drawImage(target, image, source); } } - painter.restore(); + } @@ -238,7 +238,7 @@ void JKQTPImage::createImageActions() { actSaveImage=new QAction(tr("Save JKQTPImage ..."), this); connect(actSaveImage, SIGNAL(triggered()), this, SLOT(saveImagePlotAsImage())); - actCopyImage=new QAction(tr("Copy JKQTPOverlayImage ..."), this); + actCopyImage=new QAction(tr("Copy JKQTPImage ..."), this); connect(actCopyImage, SIGNAL(triggered()), this, SLOT(copyImagePlotAsImage())); } @@ -676,8 +676,7 @@ void JKQTPMathImage::initJKQTPMathImage() { connect(actCopyPalette, SIGNAL(triggered()), this, SLOT(copyColorbarPlotAsImage())); colorBarRightAxis=new JKQTPVerticalIndependentAxis(0, 100, 0, 100, parent); - if (parent) colorBarRightAxis->loadSettings(parent->getYAxis()); - colorBarRightAxis->setDrawMode1(JKQTPCADMline); + colorBarRightAxis->setDrawMode1(JKQTPCADMLine); colorBarRightAxis->setDrawMode2(JKQTPCADMcomplete); colorBarRightAxis->setAxisLabel(""); colorBarRightAxis->setMinTicks(5); @@ -686,8 +685,7 @@ void JKQTPMathImage::initJKQTPMathImage() { colorBarRightAxis->setMinorTickOutsideLength(0); colorBarRightAxis->setShowZeroAxis(false); colorBarTopAxis=new JKQTPHorizontalIndependentAxis(0, 100, 0, 100, parent); - if (parent) colorBarTopAxis->loadSettings(parent->getXAxis()); - colorBarTopAxis->setDrawMode1(JKQTPCADMline); + colorBarTopAxis->setDrawMode1(JKQTPCADMLine); colorBarTopAxis->setDrawMode2(JKQTPCADMcomplete); colorBarTopAxis->setAxisLabel(""); colorBarTopAxis->setMinTicks(3); @@ -697,8 +695,7 @@ void JKQTPMathImage::initJKQTPMathImage() { colorBarTopAxis->setShowZeroAxis(false); modifierColorBarTopAxis=new JKQTPVerticalIndependentAxis(0, 100, 0, 100, parent); - if (parent) modifierColorBarTopAxis->loadSettings(parent->getXAxis()); - modifierColorBarTopAxis->setDrawMode1(JKQTPCADMline); + modifierColorBarTopAxis->setDrawMode1(JKQTPCADMLine); modifierColorBarTopAxis->setDrawMode2(JKQTPCADMcomplete); modifierColorBarTopAxis->setAxisLabel(""); modifierColorBarTopAxis->setMinTicks(3); @@ -707,8 +704,7 @@ void JKQTPMathImage::initJKQTPMathImage() { modifierColorBarTopAxis->setTickOutsideLength(0); modifierColorBarTopAxis->setMinorTickOutsideLength(0); modifierColorBarRightAxis=new JKQTPHorizontalIndependentAxis (0, 100, 0, 100, parent); - if (parent) modifierColorBarRightAxis->loadSettings(parent->getYAxis()); - modifierColorBarRightAxis->setDrawMode1(JKQTPCADMline); + modifierColorBarRightAxis->setDrawMode1(JKQTPCADMLine); modifierColorBarRightAxis->setDrawMode2(JKQTPCADMcomplete); modifierColorBarRightAxis->setAxisLabel(""); modifierColorBarRightAxis->setMinTicks(5); @@ -721,7 +717,6 @@ void JKQTPMathImage::initJKQTPMathImage() { this->colorBarTopVisible=true; this->colorBarRightVisible=true; this->palette=JKQTPMathImageGRAY; - this->imageNameFontName=parent->getKeyFont(); this->imageNameFontSize=parent->getKeyFontSize(); this->imageName=""; this->showColorBar=true; @@ -740,6 +735,7 @@ void JKQTPMathImage::initJKQTPMathImage() { this->colorBarTopVisible=false; this->colorBarRightVisible=true; this->autoModifierRange=true; + this->imageNameFontSize=parent->getDefaultTextSize(); } JKQTPMathImage::JKQTPMathImage(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette, JKQTBasePlotter* parent): @@ -753,6 +749,7 @@ JKQTPMathImage::JKQTPMathImage(JKQTBasePlotter *parent): JKQTPMathImageBase(0, 0, 1, 1, JKQTPMathImageBase::UInt8Array, nullptr, 0, 0, parent) { initJKQTPMathImage(); + if (parent) this->palette=parent->getCurrentPlotterStyle().defaultPalette; } @@ -768,6 +765,8 @@ JKQTPMathImage::JKQTPMathImage(JKQTPlotter *parent): JKQTPMathImageBase(0, 0, 1, 1, JKQTPMathImageBase::UInt8Array, nullptr, 0, 0, parent) { initJKQTPMathImage(); + if (parent) this->palette=parent->getPlotter()->getCurrentPlotterStyle().defaultPalette; + } void JKQTPMathImage::setParent(JKQTBasePlotter* parent) { @@ -923,16 +922,14 @@ void JKQTPMathImage::getOutsideSize(JKQTPEnhancedPainter& painter, int& leftSpac colorBarRightAxis->setAxisWidth(colorBarRelativeHeight*parent->getPlotHeight()); modifierColorBarRightAxis->setRange(internalModifierMin, internalModifierMax); modifierColorBarRightAxis->setAxisWidth(parent->pt2px(painter, colorBarModifiedWidth)); - QSize s=colorBarRightAxis->getSize2(painter); - /*parent->getMathText()->setFontSize(imageNameFontSize*parent->getFontSizeMultiplier()); - parent->getMathText()->setFontRoman(imageNameFontName); - parent->getMathText()->parse(imageName); - QSizeF names=parent->getMathText()->getSize(painter);*/ - QSizeF names=parent->getTextSizeSize(imageNameFontName, imageNameFontSize*parent->getFontSizeMultiplier(), imageName, painter); - rightSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset)+qMax(static_cast(s.width()), static_cast(names.width())); + QSizeF s1=colorBarRightAxis->getSize2(painter); + QSizeF s2=colorBarRightAxis->getSize1(painter); + + QSizeF names=parent->getTextSizeSize(parent->getCurrentPlotterStyle().defaultFontName, imageNameFontSize*parent->getFontSizeMultiplier(), imageName, painter); + rightSpace+=qMax(static_cast(s1.width()+s2.width()), static_cast(names.width())); //qDebug()<<"osr: "<pt2px(painter, colorBarModifiedWidth-colorBarWidth)); + rightSpace=rightSpace+(2.0*parent->pt2px(painter, colorBarModifiedWidth-colorBarWidth)); } //qDebug()<<" "<setAxisWidth(colorBarRelativeHeight*parent->getPlotWidth()); modifierColorBarTopAxis->setRange(internalModifierMin, internalModifierMax); modifierColorBarTopAxis->setAxisWidth(parent->pt2px(painter, colorBarModifiedWidth)); - QSize s=colorBarTopAxis->getSize2(painter); - /*parent->getMathText()->setFontSize(imageNameFontSize*parent->getFontSizeMultiplier()); - parent->getMathText()->setFontRoman(imageNameFontName); - parent->getMathText()->parse(imageName); - QSizeF names=parent->getMathText()->getSize(painter);*/ - QSizeF names=parent->getTextSizeSize(imageNameFontName, imageNameFontSize*parent->getFontSizeMultiplier(), imageName, painter); + QSizeF s1=colorBarTopAxis->getSize2(painter); + QSizeF s2=colorBarTopAxis->getSize1(painter); + QSizeF names=parent->getTextSizeSize(parent->getCurrentPlotterStyle().defaultFontName, imageNameFontSize*parent->getFontSizeMultiplier(), imageName, painter); //qDebug()<pt2px(painter, colorBarWidth+colorBarOffset); - topSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset)+qMax(static_cast(s.height()), static_cast(names.height())); + topSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset)+qMax(static_cast(s1.height()+s2.height()), static_cast(names.height())); if (modifierMode!=ModifyNone) { - topSpace=topSpace+(2*parent->pt2px(painter, colorBarModifiedWidth-colorBarWidth)); + topSpace=topSpace+(2.0*parent->pt2px(painter, colorBarModifiedWidth-colorBarWidth)); } //qDebug()<getTextSizeSize(imageNameFontName, imageNameFontSize*parent->getFontSizeMultiplier(), imageName, painter); + QSizeF names=parent->getTextSizeSize(parent->getCurrentPlotterStyle().defaultFontName, imageNameFontSize*parent->getFontSizeMultiplier(), imageName, painter); double icolorBarRelativeHeight=colorBarRelativeHeight; int barHeight=rightSpace.height()*icolorBarRelativeHeight; @@ -988,7 +982,7 @@ void JKQTPMathImage::drawOutside(JKQTPEnhancedPainter& painter, QRect /*leftSpac painter.drawImage(cb, b.mirrored(true, false)); QPen p=painter.pen(); p.setColor(colorBarRightAxis->getAxisColor()); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, colorBarRightAxis->getLineWidth()*parent->getLineWidthMultiplier()))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, colorBarRightAxis->getLineWidth()*parent->getLineWidthMultiplier()))); painter.setPen(p); painter.drawRect(cb); @@ -1009,14 +1003,14 @@ void JKQTPMathImage::drawOutside(JKQTPEnhancedPainter& painter, QRect /*leftSpac } parent->getMathText()->setFontSize(imageNameFontSize*parent->getFontSizeMultiplier()); - parent->getMathText()->setFontRoman(imageNameFontName); + parent->getMathText()->setFontRomanOrSpecial(parent->getCurrentPlotterStyle().defaultFontName); parent->getMathText()->parse(imageName); parent->getMathText()->draw(painter, Qt::AlignHCenter|Qt::AlignVCenter, QRect(rightSpace.x(), rightSpace.y(), rightSpace.width(), (rightSpace.height()-barHeight)/2)); - painter.restore(); + } if (colorBarTopVisible) { - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); @@ -1025,7 +1019,7 @@ void JKQTPMathImage::drawOutside(JKQTPEnhancedPainter& painter, QRect /*leftSpac QImage b=drawOutsidePalette(200); - QSizeF names=parent->getTextSizeSize(imageNameFontName, imageNameFontSize*parent->getFontSizeMultiplier(), imageName, painter); + QSizeF names=parent->getTextSizeSize(parent->getCurrentPlotterStyle().defaultFontName, imageNameFontSize*parent->getFontSizeMultiplier(), imageName, painter); double icolorBarRelativeHeight=colorBarRelativeHeight; int barWidth=topSpace.width()*icolorBarRelativeHeight; @@ -1043,7 +1037,7 @@ void JKQTPMathImage::drawOutside(JKQTPEnhancedPainter& painter, QRect /*leftSpac painter.drawImage(cb, b.transformed(rm)); QPen p=painter.pen(); p.setColor(colorBarTopAxis->getAxisColor()); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, colorBarTopAxis->getLineWidth()*parent->getLineWidthMultiplier()))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, colorBarTopAxis->getLineWidth()*parent->getLineWidthMultiplier()))); painter.setPen(p); painter.drawRect(cb); @@ -1065,11 +1059,11 @@ void JKQTPMathImage::drawOutside(JKQTPEnhancedPainter& painter, QRect /*leftSpac } parent->getMathText()->setFontSize(imageNameFontSize*parent->getFontSizeMultiplier()); - parent->getMathText()->setFontRoman(imageNameFontName); + parent->getMathText()->setFontRomanOrSpecial(parent->getCurrentPlotterStyle().defaultFontName); parent->getMathText()->parse(imageName); parent->getMathText()->draw(painter, Qt::AlignHCenter|Qt::AlignVCenter, QRect(topSpace.right()-(topSpace.width()-barWidth)/2, topSpace.y(), (topSpace.width()-barWidth)/2, topSpace.height())); - painter.restore(); + } } } @@ -1160,9 +1154,9 @@ int JKQTPMathImage::getPalettesCount() } QIcon JKQTPMathImage::getPaletteIcon(int i) { - QImage img=getPaletteImage(i, jkqtp_PALETTE_ICON_WIDTH); - QPixmap pix(jkqtp_PALETTE_ICON_WIDTH,8); - QRect r(0,0,jkqtp_PALETTE_ICON_WIDTH-1,7); + QImage img=getPaletteImage(i, JKQTPImageTools::PALETTE_ICON_WIDTH); + QPixmap pix(JKQTPImageTools::PALETTE_ICON_WIDTH,8); + QRect r(0,0,JKQTPImageTools::PALETTE_ICON_WIDTH-1,7); JKQTPEnhancedPainter p(&pix); p.drawImage(r, img); p.setPen(QPen(QColor("black"))); @@ -1195,9 +1189,9 @@ QImage JKQTPMathImage::getPaletteImage(JKQTPMathImageColorPalette palette, int w QIcon JKQTPMathImage::getPaletteKeyIcon(int i) { - QImage img=getPaletteKeyImage(i, jkqtp_PALETTE_ICON_WIDTH, jkqtp_PALETTE_IMAGEICON_HEIGHT); - QPixmap pix(jkqtp_PALETTE_ICON_WIDTH,jkqtp_PALETTE_IMAGEICON_HEIGHT); - QRect r(0,0,jkqtp_PALETTE_ICON_WIDTH-1,jkqtp_PALETTE_IMAGEICON_HEIGHT-1); + QImage img=getPaletteKeyImage(i, JKQTPImageTools::PALETTE_ICON_WIDTH, JKQTPImageTools::PALETTE_IMAGEICON_HEIGHT); + QPixmap pix(JKQTPImageTools::PALETTE_ICON_WIDTH,JKQTPImageTools::PALETTE_IMAGEICON_HEIGHT); + QRect r(0,0,JKQTPImageTools::PALETTE_ICON_WIDTH-1,JKQTPImageTools::PALETTE_IMAGEICON_HEIGHT-1); JKQTPEnhancedPainter p(&pix); p.drawImage(r, img); p.setPen(QPen(QColor("black"))); @@ -1288,1021 +1282,6 @@ void JKQTPMathImage::setPalette(int pal) { - - -JKQTPOverlayImage::JKQTPOverlayImage(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTBasePlotter* parent): - JKQTPImageBase(x, y, width, height, parent) -{ - actSaveImage=new QAction(tr("Save JKQTPOverlayImage ..."), this); - connect(actSaveImage, SIGNAL(triggered()), this, SLOT(saveImagePlotAsImage())); - actCopyImage=new QAction(tr("Copy JKQTPOverlayImage ..."), this); - connect(actCopyImage, SIGNAL(triggered()), this, SLOT(copyImagePlotAsImage())); - this->Nx=Nx; - this->Ny=Ny; - this->data=data; - this->trueColor=colTrue; - this->falseColor=QColor(Qt::transparent); -} - -JKQTPOverlayImage::JKQTPOverlayImage(JKQTBasePlotter *parent): - JKQTPImageBase(0,0,1,1, parent) -{ - actSaveImage=new QAction(tr("Save JKQTPOverlayImage ..."), this); - connect(actSaveImage, SIGNAL(triggered()), this, SLOT(saveImagePlotAsImage())); - actCopyImage=new QAction(tr("Copy JKQTPOverlayImage ..."), this); - connect(actCopyImage, SIGNAL(triggered()), this, SLOT(copyImagePlotAsImage())); - this->Nx=0; - this->Ny=0; - this->data=nullptr; - this->trueColor=QColor("red"); -} - -JKQTPOverlayImage::JKQTPOverlayImage(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTPlotter* parent): - JKQTPImageBase(x, y, width, height, parent) -{ - actSaveImage=new QAction(tr("Save JKQTPOverlayImage ..."), this); - connect(actSaveImage, SIGNAL(triggered()), this, SLOT(saveImagePlotAsImage())); - actCopyImage=new QAction(tr("Copy JKQTPOverlayImage ..."), this); - connect(actCopyImage, SIGNAL(triggered()), this, SLOT(copyImagePlotAsImage())); - this->Nx=Nx; - this->Ny=Ny; - this->data=data; - this->trueColor=colTrue; - this->falseColor=QColor(Qt::transparent); -} - -JKQTPOverlayImage::JKQTPOverlayImage(JKQTPlotter *parent): - JKQTPImageBase(0,0,1,1, parent) -{ - actSaveImage=new QAction(tr("Save JKQTPOverlayImage ..."), this); - connect(actSaveImage, SIGNAL(triggered()), this, SLOT(saveImagePlotAsImage())); - actCopyImage=new QAction(tr("Copy JKQTPOverlayImage ..."), this); - connect(actCopyImage, SIGNAL(triggered()), this, SLOT(copyImagePlotAsImage())); - this->Nx=0; - this->Ny=0; - this->data=nullptr; - this->trueColor=QColor("red"); -} - -void JKQTPOverlayImage::draw(JKQTPEnhancedPainter& painter) { - if (!data) return; - QImage img=drawImage(); - plotImage(painter, img, x, y, width, height); -} - -QImage JKQTPOverlayImage::drawImage() { - if (!data) return QImage(); - QImage img(Nx, Ny, QImage::Format_ARGB32); - - //QRgb tc=trueColor.rgba(); - //QRgb fc=falseColor.rgba(); - QRgb tc=qRgba(round(trueColor.red()*trueColor.alphaF()), round(trueColor.green()*trueColor.alphaF()), round(trueColor.blue()*trueColor.alphaF()), trueColor.alpha()); - QRgb fc=qRgba(round(falseColor.red()*falseColor.alphaF()), round(falseColor.green()*falseColor.alphaF()), round(falseColor.blue()*falseColor.alphaF()), falseColor.alpha()); - - for (int32_t y=0; ydata=data; - this->Nx=Nx; - this->Ny=Ny; -} - - -JKQTPOverlayImageEnhanced::JKQTPOverlayImageEnhanced(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTBasePlotter* parent): - JKQTPOverlayImage(x, y, width, height, data, Nx, Ny, colTrue, parent) -{ - symbol=JKQTPTarget; - symbolWidth=1; - drawAsRectangles=true; - symbolSizeFactor=0.9; - rectanglesAsImageOverlay=false; -} - -JKQTPOverlayImageEnhanced::JKQTPOverlayImageEnhanced(JKQTBasePlotter *parent): - JKQTPOverlayImage(0,0,1,1,nullptr,0,0, QColor("red"), parent) -{ - symbol=JKQTPTarget; - symbolWidth=1; - drawAsRectangles=true; - symbolSizeFactor=0.9; - rectanglesAsImageOverlay=false; -} - -JKQTPOverlayImageEnhanced::JKQTPOverlayImageEnhanced(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTPlotter* parent): - JKQTPOverlayImage(x, y, width, height, data, Nx, Ny, colTrue, parent) -{ - symbol=JKQTPTarget; - symbolWidth=1; - drawAsRectangles=true; - symbolSizeFactor=0.9; - rectanglesAsImageOverlay=false; -} - -JKQTPOverlayImageEnhanced::JKQTPOverlayImageEnhanced(JKQTPlotter *parent): - JKQTPOverlayImage(0,0,1,1,nullptr,0,0, QColor("red"), parent) -{ - symbol=JKQTPTarget; - symbolWidth=1; - drawAsRectangles=true; - symbolSizeFactor=0.9; - rectanglesAsImageOverlay=false; -} -void JKQTPOverlayImageEnhanced::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) { - if (drawAsRectangles) JKQTPOverlayImage::drawKeyMarker(painter, rect); - else JKQTPPlotSymbol(painter, rect.center().x(), rect.center().y(), symbol, qMin(rect.width(), rect.height()), parent->pt2px(painter, symbolWidth*parent->getLineWidthMultiplier()), trueColor, trueColor.lighter()); -} - -void JKQTPOverlayImageEnhanced::draw(JKQTPEnhancedPainter& painter) { - if (!data) return; - - if (drawAsRectangles && rectanglesAsImageOverlay) { - JKQTPOverlayImage::draw(painter); - } else { - - painter.save(); - - double dx=width/static_cast(Nx); - double dy=height/static_cast(Ny); - for (int ix=0; ix(Nx); ix++) { - for (int iy=0; iy(Ny); iy++) { - QPointF p1=transform(x+static_cast(ix)*dx, y+static_cast(iy)*dy); - QPointF p2=transform(x+static_cast(ix+1)*dx, y+static_cast(iy+1)*dx); - if (drawAsRectangles) { - if (data[ix+iy*Nx]) { - if (trueColor.alpha()>0) { - painter.fillRect(QRectF(qMin(p1.x(), p2.x())-1.0, qMin(p2.y(), p1.y())-1.0, fabs(p2.x()-p1.x())+1.0, fabs(p2.y()-p1.y())+1.0), QBrush(trueColor)); - //painter.setPen(QPen(trueColor)); - //painter.drawRect(QRectF(qMin(p1.x(), p2.x()), qMin(p2.y(), p1.y()), fabs(p2.x()-p1.x()), fabs(p2.y()-p1.y()))); - } - } else { - if (falseColor.alpha()>0) { - //painter.setPen(QPen(falseColor)); - painter.fillRect(QRectF(qMin(p1.x(), p2.x())-1.0, qMin(p2.y(), p1.y())-1.0, fabs(p2.x()-p1.x())+1.0, fabs(p2.y()-p1.y())+1.0), QBrush(falseColor)); - //painter.drawRect(QRectF(qMin(p1.x(), p2.x()), qMin(p2.y(), p1.y()), fabs(p2.x()-p1.x()), fabs(p2.y()-p1.y()))); - } - } - } else { - QPointF p=(p1+p2)/2.0; - if (data[ix+iy*Nx]) { - JKQTPPlotSymbol(painter, p.x(), p.y(), symbol, fabs(p2.x()-p1.x())*symbolSizeFactor, parent->pt2px(painter, symbolWidth*parent->getLineWidthMultiplier()), trueColor, trueColor.lighter()); - } - } - } - } - painter.restore(); - } -} - - - - - - - - - - - - - - - - - - -void JKQTPRGBMathImage::initObject() -{ - actSaveImage=new QAction(tr("Save JKQTPRGBMathImage ..."), this); - connect(actSaveImage, SIGNAL(triggered()), this, SLOT(saveImagePlotAsImage())); - actCopyImage=new QAction(tr("Copy JKQTPOverlayImage ..."), this); - connect(actCopyImage, SIGNAL(triggered()), this, SLOT(copyImagePlotAsImage())); - - rgbMode=JKQTPRGBMathImageModeRGBMode; - colorBarRightAxis=new JKQTPVerticalIndependentAxis(0, 100, 0, 100, parent); - if (parent) colorBarRightAxis->loadSettings(parent->getYAxis()); - colorBarRightAxis->setDrawMode1(JKQTPCADMline); - colorBarRightAxis->setDrawMode2(JKQTPCADMcomplete); - colorBarRightAxis->setAxisLabel(""); - colorBarRightAxis->setMinTicks(5); - colorBarRightAxis->setMinorTicks(0); - colorBarRightAxis->setTickOutsideLength(0); - colorBarRightAxis->setMinorTickOutsideLength(0); - colorBarRightAxis->setShowZeroAxis(false); - colorBarTopAxis=new JKQTPHorizontalIndependentAxis(0, 100, 0, 100, parent); - if (parent) colorBarTopAxis->loadSettings(parent->getXAxis()); - colorBarTopAxis->setDrawMode1(JKQTPCADMline); - colorBarTopAxis->setDrawMode2(JKQTPCADMcomplete); - colorBarTopAxis->setAxisLabel(""); - colorBarTopAxis->setMinTicks(3); - colorBarTopAxis->setMinorTicks(0); - colorBarTopAxis->setTickOutsideLength(0); - colorBarTopAxis->setMinorTickOutsideLength(0); - colorBarTopAxis->setShowZeroAxis(false); - - colorBarRightAxisG=new JKQTPVerticalIndependentAxis(0, 100, 0, 100, parent); - if (parent) colorBarRightAxisG->loadSettings(parent->getYAxis()); - colorBarRightAxisG->setDrawMode1(JKQTPCADMline); - colorBarRightAxisG->setDrawMode2(JKQTPCADMcomplete); - colorBarRightAxisG->setAxisLabel(""); - colorBarRightAxisG->setMinTicks(5); - colorBarRightAxisG->setShowZeroAxis(false); - colorBarRightAxisG->setMinorTicks(0); - colorBarRightAxisG->setTickOutsideLength(0); - colorBarRightAxisG->setMinorTickOutsideLength(0); - colorBarTopAxisG=new JKQTPHorizontalIndependentAxis(0, 100, 0, 100, parent); - if (parent) colorBarTopAxisG->loadSettings(parent->getXAxis()); - colorBarTopAxisG->setDrawMode1(JKQTPCADMline); - colorBarTopAxisG->setDrawMode2(JKQTPCADMcomplete); - colorBarTopAxisG->setAxisLabel(""); - colorBarTopAxisG->setMinTicks(3); - colorBarTopAxisG->setShowZeroAxis(false); - colorBarTopAxisG->setMinorTicks(0); - colorBarTopAxisG->setTickOutsideLength(0); - colorBarTopAxisG->setMinorTickOutsideLength(0); - - colorBarRightAxisB=new JKQTPVerticalIndependentAxis(0, 100, 0, 100, parent); - if (parent) colorBarRightAxisB->loadSettings(parent->getYAxis()); - colorBarRightAxisB->setDrawMode1(JKQTPCADMline); - colorBarRightAxisB->setDrawMode2(JKQTPCADMcomplete); - colorBarRightAxisB->setAxisLabel(""); - colorBarRightAxisB->setMinTicks(5); - colorBarRightAxisB->setShowZeroAxis(false); - colorBarRightAxisB->setMinorTicks(0); - colorBarRightAxisB->setTickOutsideLength(0); - colorBarRightAxisB->setMinorTickOutsideLength(0); - colorBarTopAxisB=new JKQTPHorizontalIndependentAxis(0, 100, 0, 100, parent); - if (parent) colorBarTopAxisB->loadSettings(parent->getXAxis()); - colorBarTopAxisB->setDrawMode1(JKQTPCADMline); - colorBarTopAxisB->setDrawMode2(JKQTPCADMcomplete); - colorBarTopAxisB->setAxisLabel(""); - colorBarTopAxisB->setMinTicks(3); - colorBarTopAxisB->setShowZeroAxis(false); - colorBarTopAxisB->setMinorTicks(0); - colorBarTopAxisB->setTickOutsideLength(0); - colorBarTopAxisB->setMinorTickOutsideLength(0); - - - this->colorBarTopVisible=true; - this->colorBarRightVisible=true; - this->imageNameFontName=parent->getKeyFont(); - this->imageNameFontSize=parent->getKeyFontSize(); - this->imageName=""; - this->showColorBar=true; - this->colorBarWidth=14; - this->colorBarRelativeHeight=0.75; - this->autoImageRange=true; - this->imageMin=0; - this->imageMax=1; - this->imageMinG=0; - this->imageMaxG=1; - this->imageMinB=0; - this->imageMaxB=1; - this->colorBarOffset=4; - this->colorBarTopVisible=false; - this->colorBarRightVisible=true; - this->colorbarsSideBySide=true; -} - - - -JKQTPRGBMathImage::JKQTPRGBMathImage(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTBasePlotter *parent): - JKQTPMathImageBase(x, y, width, height, datatype, data, Nx, Ny, parent) -{ - initObject(); -} - - -JKQTPRGBMathImage::JKQTPRGBMathImage(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTPlotter *parent): - JKQTPMathImageBase(x, y, width, height, datatype, data, Nx, Ny, parent) -{ - initObject(); -} - -JKQTPRGBMathImage::JKQTPRGBMathImage(JKQTBasePlotter *parent): - JKQTPMathImageBase(0,0,0,0, DoubleArray, nullptr, 0, 0, parent) -{ - initObject(); -} - - -JKQTPRGBMathImage::JKQTPRGBMathImage(JKQTPlotter *parent): - JKQTPMathImageBase(0,0,0,0, DoubleArray, nullptr, 0, 0, parent) -{ - initObject(); -} - -void JKQTPRGBMathImage::setParent(JKQTBasePlotter* parent) { - if (this->parent) { - this->parent->deregisterAdditionalAction(actSaveImage); - this->parent->deregisterAdditionalAction(actCopyImage); - } - JKQTPMathImageBase::setParent(parent); - colorBarRightAxis->setParent(parent); - colorBarTopAxis->setParent(parent); - - if (parent) { - parent->registerAdditionalAction(tr("Save Image Plot Images ..."), actSaveImage); - parent->registerAdditionalAction(tr("Copy Image Plot Images ..."), actCopyImage); - } - actSaveImage->setEnabled(parent); - actCopyImage->setEnabled(parent); - -} - - - -void JKQTPRGBMathImage::draw(JKQTPEnhancedPainter& painter) { - ensureImageData(); - if (!data && !dataG && !dataB) return; - QImage img=drawImage(); - plotImage(painter, img, x, y, width, height); -} - - - -void JKQTPRGBMathImage::getOutsideSize(JKQTPEnhancedPainter& painter, int& leftSpace, int& rightSpace, int& topSpace, int& bottomSpace) { - ensureImageData(); - JKQTPGraph::getOutsideSize(painter, leftSpace, rightSpace, topSpace, bottomSpace); - if (showColorBar) { - int visibleColorBars=0; - if (data) visibleColorBars++; - if (dataG) visibleColorBars++; - if (dataB) visibleColorBars++; - double sizeFactor=0.8/double(visibleColorBars); - if (!colorbarsSideBySide) sizeFactor=1; - - bool firstC=false; - - getDataMinMax(internalDataMin, internalDataMax); - if (data) { - if (colorBarRightVisible) { - if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) rightSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset); - colorBarRightAxis->setRange(internalDataMin, internalDataMax); - colorBarRightAxis->setAxisWidth(sizeFactor*colorBarRelativeHeight*parent->getPlotHeight()); - colorBarRightAxisB->setAxisLabel(imageName); - QSize s=colorBarRightAxis->getSize2(painter); - if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) rightSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset)+static_cast(s.width()); - /*QSize s=colorBarRightAxis->getSize2(painter); - parent->getMathText()->setFontSize(imageNameFontSize*parent->getFontSizeMultiplier()); - parent->getMathText()->setFontRoman(imageNameFontName); - parent->getMathText()->parse(imageName); - QSizeF names=parent->getMathText()->getSize(painter); - if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) rightSpace+=colorBarWidth+colorBarOffset+qMax(static_cast(s.width()), static_cast(names.width()));*/ - } - if (colorBarTopVisible) { - //if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) topSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset); - colorBarTopAxis->setRange(internalDataMin, internalDataMax); - colorBarTopAxis->setAxisWidth(sizeFactor*colorBarRelativeHeight*parent->getPlotWidth()); - colorBarTopAxisB->setAxisLabel(imageName); - QSize s=colorBarTopAxisB->getSize2(painter); - if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) topSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset)+static_cast(s.height()); - /*QSize s=colorBarTopAxis->getSize2(painter); - parent->getMathText()->setFontSize(imageNameFontSize*parent->getFontSizeMultiplier()); - parent->getMathText()->setFontRoman(imageNameFontName); - parent->getMathText()->parse(imageName); - QSizeF names=parent->getMathText()->getSize(painter); - if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) topSpace+=colorBarWidth+colorBarOffset+qMax(static_cast(s.height()), static_cast(names.height()));*/ - } - firstC=true; - } - - getDataMinMaxG(internalDataMinG, internalDataMaxG); - if (dataG) { - if (colorBarRightVisible) { - if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) rightSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset); - colorBarRightAxisG->setRange(internalDataMinG, internalDataMaxG); - colorBarRightAxisG->setAxisWidth(sizeFactor*colorBarRelativeHeight*parent->getPlotHeight()); - colorBarRightAxisB->setAxisLabel(imageNameG); - QSize s=colorBarRightAxis->getSize2(painter); - if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) rightSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset)+static_cast(s.width()); - /*QSize s=colorBarRightAxis->getSize2(painter); - parent->getMathText()->setFontSize(imageNameFontSize*parent->getFontSizeMultiplier()); - parent->getMathText()->setFontRoman(imageNameFontName); - parent->getMathText()->parse(imageNameG); - QSizeF names=parent->getMathText()->getSize(painter); - if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) rightSpace+=colorBarWidth+colorBarOffset+qMax(static_cast(s.width()), static_cast(names.width()));*/ - } - if (colorBarTopVisible) { - //if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) topSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset); - colorBarTopAxisG->setRange(internalDataMinG, internalDataMaxG); - colorBarTopAxisG->setAxisWidth(sizeFactor*colorBarRelativeHeight*parent->getPlotWidth()); - colorBarTopAxisB->setAxisLabel(imageNameG); - QSize s=colorBarTopAxisB->getSize2(painter); - if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) topSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset)+static_cast(s.height()); - /*QSize s=colorBarTopAxisG->getSize2(painter); - parent->getMathText()->setFontSize(imageNameFontSize*parent->getFontSizeMultiplier()); - parent->getMathText()->setFontRoman(imageNameFontName); - parent->getMathText()->parse(imageNameG); - QSizeF names=parent->getMathText()->getSize(painter); - if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) topSpace+=colorBarWidth+colorBarOffset+qMax(static_cast(s.height()), static_cast(names.height()));*/ - } - firstC=true; - } - - getDataMinMaxB(internalDataMinB, internalDataMaxB); - if (dataB) { - if (colorBarRightVisible) { - if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) rightSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset); - colorBarRightAxisB->setRange(internalDataMinB, internalDataMaxB); - colorBarRightAxisB->setAxisWidth(sizeFactor*colorBarRelativeHeight*parent->getPlotHeight()); - colorBarRightAxisB->setAxisLabel(imageNameB); - QSize s=colorBarRightAxis->getSize2(painter); - if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) rightSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset)+static_cast(s.width()); - /* - parent->getMathText()->setFontSize(imageNameFontSize*parent->getFontSizeMultiplier()); - parent->getMathText()->setFontRoman(imageNameFontName); - parent->getMathText()->parse(imageNameB); - QSizeF names=parent->getMathText()->getSize(painter); - if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) rightSpace+=colorBarWidth+colorBarOffset+qMax(static_cast(s.width()), static_cast(names.width()));*/ - } - if (colorBarTopVisible) { - //if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) topSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset); - colorBarTopAxisB->setRange(internalDataMinB, internalDataMaxB); - colorBarTopAxisB->setAxisWidth(sizeFactor*colorBarRelativeHeight*parent->getPlotWidth()); - colorBarTopAxisB->setAxisLabel(imageNameB); - QSize s=colorBarTopAxisB->getSize2(painter); - if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) topSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset)+static_cast(s.height()); - /*parent->getMathText()->setFontSize(imageNameFontSize*parent->getFontSizeMultiplier()); - parent->getMathText()->setFontRoman(imageNameFontName); - parent->getMathText()->parse(imageNameB); - QSizeF names=parent->getMathText()->getSize(painter); - if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) topSpace+=colorBarWidth+colorBarOffset+qMax(static_cast(s.height()), static_cast(names.height()));*/ - } - firstC=true; - } - } -} - -struct RGBOutsizeData { - double internalDataMin; - double internalDataMax; - void* data; - JKQTPVerticalIndependentAxis* colorBarRightAxis; - JKQTPHorizontalIndependentAxis* colorBarTopAxis; - QString name; - JKQTPMathImageColorPalette palette; - QImage paletteImage; -}; - -void JKQTPRGBMathImage::drawOutside(JKQTPEnhancedPainter& painter, QRect /*leftSpace*/, QRect rightSpace, QRect topSpace, QRect /*bottomSpace*/) { - ensureImageData(); - if (showColorBar) { - QList l; - int visibleColorBars=0; - const int pd_size=200; - uint8_t pd[pd_size]; - for (int i=0; i(pd, 1, pd_size, d.paletteImage, d.palette, 0, pd_size-1); - } else if (rgbMode==JKQTPRGBMathImageModeCMYMode) { - d.palette=JKQTPMathImageINVERTED_CYANWHITE; - d.paletteImage=QImage(1, pd_size, QImage::Format_ARGB32); - JKQTPImagePlot_array2image(pd, 1, pd_size, d.paletteImage, d.palette, 0, pd_size-1); - } else if (rgbMode==JKQTPRGBMathImageModeHSVMode || rgbMode==JKQTPRGBMathImageModeHSLMode) { - d.palette=JKQTPMathImageHSV; - d.paletteImage=QImage(1, pd_size, QImage::Format_ARGB32); - JKQTPImagePlot_array2image(pd, 1, pd_size, d.paletteImage, d.palette, 0, pd_size-1); - } - - l<(pd, 1, pd_size, d.paletteImage, d.palette, 0, 199); - if (rgbMode==JKQTPRGBMathImageModeRGBMode) { - d.palette=JKQTPMathImageGREEN; - d.paletteImage=QImage(1, pd_size, QImage::Format_ARGB32); - JKQTPImagePlot_array2image(pd, 1, pd_size, d.paletteImage, d.palette, 0, pd_size-1); - } else if (rgbMode==JKQTPRGBMathImageModeCMYMode) { - d.palette=JKQTPMathImageINVERTED_MAGENTAWHITE; - d.paletteImage=QImage(1, pd_size, QImage::Format_ARGB32); - JKQTPImagePlot_array2image(pd, 1, pd_size, d.paletteImage, d.palette, 0, pd_size-1); - } else if (rgbMode==JKQTPRGBMathImageModeHSVMode) { - d.palette=JKQTPMathImageGRAY; - d.paletteImage=QImage(1, pd_size, QImage::Format_ARGB32); - //JKQTPImagePlot_array2image(pd, 1, pd_size, d.paletteImage, l[li].palette, 0, pd_size-1); - QRgb* line=reinterpret_cast(d.paletteImage.scanLine(0)); - for (int i=0; i(pd, 1, pd_size, d.paletteImage, l[li].palette, 0, pd_size-1); - QRgb* line=reinterpret_cast(d.paletteImage.scanLine(0)); - for (int i=0; i(pd, 1, pd_size, d.paletteImage, d.palette, 0, 199); - if (rgbMode==JKQTPRGBMathImageModeRGBMode) { - d.palette=JKQTPMathImageBLUE; - d.paletteImage=QImage(1, pd_size, QImage::Format_ARGB32); - JKQTPImagePlot_array2image(pd, 1, pd_size, d.paletteImage, d.palette, 0, pd_size-1); - } else if (rgbMode==JKQTPRGBMathImageModeCMYMode) { - d.palette=JKQTPMathImageINVERTED_YELLOWWHITE; - d.paletteImage=QImage(1, pd_size, QImage::Format_ARGB32); - JKQTPImagePlot_array2image(pd, 1, pd_size, d.paletteImage, d.palette, 0, pd_size-1); - } else if (rgbMode==JKQTPRGBMathImageModeHSVMode) { - d.palette=JKQTPMathImageGRAY; - d.paletteImage=QImage(1, pd_size, QImage::Format_ARGB32); - //JKQTPImagePlot_array2image(pd, 1, pd_size, d.paletteImage, l[li].palette, 0, pd_size-1); - QRgb* line=reinterpret_cast(d.paletteImage.scanLine(0)); - for (int i=0; i(pd, 1, pd_size, d.paletteImage, l[li].palette, 0, pd_size-1); - QRgb* line=reinterpret_cast(d.paletteImage.scanLine(0)); - for (int i=0; i(round(static_cast(rightSpace.height())*icolorBarRelativeHeight))); - int gbarWidth=qMax(1, static_cast(round(static_cast(topSpace.width())*icolorBarRelativeHeight))); - - - - double rX=rightSpace.x()+parent->pt2px(painter, colorBarOffset); - double rY=rightSpace.top()+(rightSpace.height()-gbarHeight)/2; - double tX=topSpace.x()+(topSpace.width()-gbarWidth)/2; - double tY=topSpace.bottom()-parent->pt2px(painter, colorBarOffset+colorBarWidth); - if(colorbarsSideBySide) { - rY=rightSpace.top()+(rightSpace.height()-gbarHeight*visibleColorBars)/2; - tX=topSpace.x()+(topSpace.width()-gbarWidth*visibleColorBars)/2; - } - - - for (int li=0; lipt2px(painter, colorBarWidth), gbarHeight); - painter.drawImage(cb, l[li].paletteImage.mirrored(true, false)); - QPen p=painter.pen(); - p.setColor(l[li].colorBarRightAxis->getAxisColor()); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, l[li].colorBarRightAxis->getLineWidth()*parent->getLineWidthMultiplier()))); - painter.setPen(p); - painter.drawRect(cb); - - l[li].colorBarRightAxis->setRange(l[li].internalDataMin, l[li].internalDataMax); - l[li].colorBarRightAxis->setAxisWidth(cb.height()); - l[li].colorBarRightAxis->setAxisOffset(cb.top()); - l[li].colorBarRightAxis->setOtherAxisOffset(cb.left()); - l[li].colorBarRightAxis->setOtherAxisWidth(cb.width()); - l[li].colorBarRightAxis->setLabelFontSize(imageNameFontSize*parent->getFontSizeMultiplier()); - l[li].colorBarRightAxis->setLabelFont(imageNameFontName); - l[li].colorBarRightAxis->setAxisLabel(l[li].name); - l[li].colorBarRightAxis->drawAxes(painter); - - painter.restore(); - - if (!colorbarsSideBySide) { - rX=rX+static_cast(rightSpace.width())/static_cast(visibleColorBars); - } else { - rY=rY+static_cast(rightSpace.height())*shiftSizeFactor*colorBarRelativeHeight; - } - } - if (colorBarTopVisible) { - painter.save(); - - - QRect cb(tX, tY, gbarWidth, parent->pt2px(painter, colorBarWidth)); - QMatrix mt; - mt.rotate(90); - painter.drawImage(cb, l[li].paletteImage.transformed(mt)); - QPen p=painter.pen(); - p.setColor(l[li].colorBarTopAxis->getAxisColor()); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, l[li].colorBarTopAxis->getLineWidth()*parent->getLineWidthMultiplier()))); - painter.setPen(p); - painter.drawRect(cb); - - - l[li].colorBarTopAxis->setRange(l[li].internalDataMin, l[li].internalDataMax); - l[li].colorBarTopAxis->setAxisWidth(cb.width()); - l[li].colorBarTopAxis->setAxisOffset(cb.left()); - l[li].colorBarTopAxis->setOtherAxisOffset(cb.top()); - l[li].colorBarTopAxis->setOtherAxisWidth(cb.height()); - l[li].colorBarTopAxis->setLabelFontSize(imageNameFontSize*parent->getFontSizeMultiplier()); - l[li].colorBarTopAxis->setLabelFont(imageNameFontName); - l[li].colorBarTopAxis->setAxisLabel(l[li].name); - l[li].colorBarTopAxis->drawAxes(painter); - - painter.restore(); - if (!colorbarsSideBySide) { - tY=tY-topSpace.height()/double(visibleColorBars); - } else { - tX=tX+topSpace.width()*shiftSizeFactor*colorBarRelativeHeight; - } - } - } - } - -} - -void JKQTPRGBMathImage::getDataMinMax(double& imin, double& imax) { - ensureImageData(); - if (autoImageRange) { - JKQTPMathImageBase::getDataMinMax(imin, imax); - } else { - imin=imageMin; - imax=imageMax; - } -} - -void JKQTPRGBMathImage::getDataMinMaxG(double& imin, double& imax) { - ensureImageData(); - if (autoImageRange) { - imin=imax=0; - if (!dataG) return; - switch(datatype) { - case JKQTPMathImageBase::DoubleArray: - imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); - break; - case JKQTPMathImageBase::FloatArray: - imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); - break; - case JKQTPMathImageBase::UInt8Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); - break; - case JKQTPMathImageBase::UInt16Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); - break; - case JKQTPMathImageBase::UInt32Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); - break; - case JKQTPMathImageBase::UInt64Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); - break; - case JKQTPMathImageBase::Int8Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); - break; - case JKQTPMathImageBase::Int16Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); - break; - case JKQTPMathImageBase::Int32Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); - break; - case JKQTPMathImageBase::Int64Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); - break; - } - } else { - imin=imageMinG; - imax=imageMaxG; - } -} - -void JKQTPRGBMathImage::getDataMinMaxB(double& imin, double& imax) { - ensureImageData(); - if (autoImageRange) { - imin=imax=0; - if (!dataG) return; - switch(datatype) { - case JKQTPMathImageBase::DoubleArray: - imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); - break; - case JKQTPMathImageBase::FloatArray: - imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); - break; - case JKQTPMathImageBase::UInt8Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); - break; - case JKQTPMathImageBase::UInt16Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); - break; - case JKQTPMathImageBase::UInt32Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); - break; - case JKQTPMathImageBase::UInt64Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); - break; - case JKQTPMathImageBase::Int8Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); - break; - case JKQTPMathImageBase::Int16Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); - break; - case JKQTPMathImageBase::Int32Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); - break; - case JKQTPMathImageBase::Int64Array: - imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); - imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); - break; - } - } else { - imin=imageMinB; - imax=imageMaxB; - } -} - -double JKQTPRGBMathImage::getValueAt(double x, double y, int channel) -{ - ensureImageData(); - void* dd=data; - if (channel==0) dd=data; - if (channel==1) dd=dataG; - if (channel==2) dd=dataB; - int xx=static_cast(trunc((x-this->x)/width*Nx)); - int yy=static_cast(trunc((y-this->y)/height*Ny)); - if (xx>=0 && xx=0 && yy((static_cast(dd))[yy*Nx+xx]); break; - case JKQTPMathImageBase::FloatArray: return static_cast((static_cast(dd))[yy*Nx+xx]); break; - case JKQTPMathImageBase::UInt8Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; - case JKQTPMathImageBase::UInt16Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; - case JKQTPMathImageBase::UInt32Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; - case JKQTPMathImageBase::UInt64Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; - case JKQTPMathImageBase::Int8Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; - case JKQTPMathImageBase::Int16Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; - case JKQTPMathImageBase::Int32Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; - case JKQTPMathImageBase::Int64Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; - } } - return 0.0; -} - -void JKQTPRGBMathImage::drawKeyMarker(JKQTPEnhancedPainter &painter, QRectF &rect) -{ - painter.drawImage(rect, QPixmap(":/JKQTPlotter/jkqtp_plot_rgbimage.png").toImage()); -} - -void JKQTPRGBMathImage::setTitle(const QString &title) -{ - JKQTPImageBase::setTitle(title); - QString t=title; - if (t.isEmpty()) t="JKQTPRGBMathImage"; - actSaveImage->setText(tr("Save %1 ...").arg(t)); - actCopyImage->setText(tr("Copy %1 ...").arg(t)); -} - -void JKQTPRGBMathImage::saveImagePlotAsImage(const QString &filename, const QByteArray &outputFormat) -{ - if (parent) { - parent->loadUserSettings(); - QString currentSaveDirectory=parent->getCurrentSaveDirectory(); - QString currentFileFormat=parent->getCurrentFileFormat(); - QString fn=filename; - QStringList filt; - QList writerformats=QImageWriter::supportedImageFormats(); - for (int i=0; isetCurrentFileFormat(currentFileFormat); - parent->setCurrentSaveDirectory(currentSaveDirectory); - parent->saveUserSettings(); - if (!fn.isEmpty()) { - int filtID=filt.indexOf(selFormat); - QString form="NONE"; - if (filtID>=0 && filtID0) { - form =outputFormat; - } - - QImage image=drawImage(); - - if (form=="NONE") image.save(fn); - else image.save(fn, form.toLatin1().data()); - } - } -} - -void JKQTPRGBMathImage::copyImagePlotAsImage() -{ - QClipboard* clip=QApplication::clipboard(); - if (clip) { - clip->setPixmap(QPixmap::fromImage(drawImage())); - } -} - -QImage JKQTPRGBMathImage::drawImage() { - ensureImageData(); - if (!data && !dataG && !dataB) return QImage(); - QImage img(Nx, Ny, QImage::Format_ARGB32); - - if (rgbMode==JKQTPRGBMathImageModeRGBMode) { - img.fill(Qt::transparent); - } else if (rgbMode==JKQTPRGBMathImageModeCMYMode) { - img.fill(Qt::white); - } else if (rgbMode==JKQTPRGBMathImageModeHSVMode) { - QColor c("white"); - c.setHsv(0,255,255); - img.fill(c.rgba()); - } else if (rgbMode==JKQTPRGBMathImageModeHSLMode) { - QColor c("white"); - c.setHsv(0,255,127); - img.fill(c.rgba()); - } - getDataMinMax(internalDataMin, internalDataMax); - getDataMinMaxG(internalDataMinG, internalDataMaxG); - getDataMinMaxB(internalDataMinB, internalDataMaxB); - int palette = 0; - if (data) { - switch(datatype) { - case JKQTPMathImageBase::DoubleArray: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; - case JKQTPMathImageBase::FloatArray: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; - case JKQTPMathImageBase::UInt8Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; - case JKQTPMathImageBase::UInt16Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; - case JKQTPMathImageBase::UInt32Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; - case JKQTPMathImageBase::UInt64Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; - case JKQTPMathImageBase::Int8Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; - case JKQTPMathImageBase::Int16Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; - case JKQTPMathImageBase::Int32Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; - case JKQTPMathImageBase::Int64Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; - } - } - palette = 1; - if (dataG) { - switch(datatypeG) { - case JKQTPMathImageBase::DoubleArray: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; - case JKQTPMathImageBase::FloatArray: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; - case JKQTPMathImageBase::UInt8Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; - case JKQTPMathImageBase::UInt16Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; - case JKQTPMathImageBase::UInt32Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; - case JKQTPMathImageBase::UInt64Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; - case JKQTPMathImageBase::Int8Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; - case JKQTPMathImageBase::Int16Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; - case JKQTPMathImageBase::Int32Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; - case JKQTPMathImageBase::Int64Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; - } - } - palette = 2; - if (dataB) { - switch(datatypeB) { - case JKQTPMathImageBase::DoubleArray: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; - case JKQTPMathImageBase::FloatArray: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; - case JKQTPMathImageBase::UInt8Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; - case JKQTPMathImageBase::UInt16Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; - case JKQTPMathImageBase::UInt32Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; - case JKQTPMathImageBase::UInt64Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; - case JKQTPMathImageBase::Int8Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; - case JKQTPMathImageBase::Int16Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; - case JKQTPMathImageBase::Int32Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; - case JKQTPMathImageBase::Int64Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; - } - } - - modifyImage(img); - - return img; -} - -void JKQTPRGBMathImage::setData(void* data, int Nx, int Ny, DataType datatype) { - this->data=data; - this->datatype=datatype; - this->dataG=nullptr; - this->dataB=nullptr; - this->Nx=Nx; - this->Ny=Ny; -} - -void JKQTPRGBMathImage::setData(void* data, int Nx, int Ny) { - this->data=data; - this->Nx=Nx; - this->Ny=Ny; - this->dataG=nullptr; - this->dataB=nullptr; -} - - -void JKQTPRGBMathImage::setData(void *data, void *dataG, void *dataB, int Nx, int Ny, JKQTPMathImageBase::DataType datatype) { - this->data=data; - this->datatype=datatype; - this->datatypeG=datatype; - this->datatypeB=datatype; - this->dataG=dataG; - this->dataB=dataB; - this->Nx=Nx; - this->Ny=Ny; -} - -void JKQTPRGBMathImage::setData(void *data, void *dataG, void *dataB, int Nx, int Ny) { - this->data=data; - this->dataG=dataG; - this->dataB=dataB; - this->Nx=Nx; - this->Ny=Ny; -} @@ -2331,11 +1310,8 @@ JKQTPColumnMathImage::JKQTPColumnMathImage(double x, double y, double width, dou } JKQTPColumnMathImage::JKQTPColumnMathImage(JKQTPlotter *parent): - JKQTPMathImage(parent) + JKQTPColumnMathImage(parent->getPlotter()) { - this->modifierColumn=-1; - this->imageColumn=-1; - this->datatype=JKQTPMathImageBase::DoubleArray; } JKQTPColumnMathImage::JKQTPColumnMathImage(double x, double y, double width, double height, int Nx, int Ny, JKQTPlotter *parent): @@ -2386,773 +1362,3 @@ void JKQTPColumnMathImage::ensureImageData() } } -JKQTPColumnOverlayImageEnhanced::JKQTPColumnOverlayImageEnhanced(JKQTBasePlotter *parent): - JKQTPOverlayImageEnhanced(parent) -{ - imageColumn=-1; -} - -JKQTPColumnOverlayImageEnhanced::JKQTPColumnOverlayImageEnhanced(JKQTPlotter *parent): - JKQTPOverlayImageEnhanced(parent) -{ - imageColumn=-1; -} -void JKQTPColumnOverlayImageEnhanced::draw(JKQTPEnhancedPainter &painter) { - double* d=parent->getDatastore()->getColumn(imageColumn).getPointer(0); - int imgSize=parent->getDatastore()->getColumn(imageColumn).getRows(); - this->data=(bool*)malloc(imgSize*sizeof(bool)); - this->Ny=imgSize/this->Nx; - for (int i=0; imodifierColumn=-1; - this->imageRColumn=-1; - this->imageGColumn=-1; - this->imageBColumn=-1; - this->datatype=JKQTPMathImageBase::DoubleArray; -} - -JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int Nx, int Ny, JKQTBasePlotter *parent): - JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) -{ - this->modifierColumn=-1; - this->imageRColumn=-1; - this->imageGColumn=-1; - this->imageBColumn=-1; - this->datatype=JKQTPMathImageBase::DoubleArray; -} - -JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int Nx, int Ny, JKQTBasePlotter *parent): - JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) -{ - this->modifierColumn=-1; - this->imageRColumn=imageRColumn; - this->imageGColumn=-1; - this->imageBColumn=-1; - this->datatype=JKQTPMathImageBase::DoubleArray; -} - -JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int Nx, int Ny, JKQTBasePlotter *parent): - JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) -{ - this->modifierColumn=-1; - this->imageRColumn=imageRColumn; - this->imageGColumn=imageGColumn; - this->imageBColumn=-1; - this->datatype=JKQTPMathImageBase::DoubleArray; -} - -JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int imageBColumn, int Nx, int Ny, JKQTBasePlotter *parent): - JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) -{ - this->modifierColumn=-1; - this->imageRColumn=imageRColumn; - this->imageGColumn=imageGColumn; - this->imageBColumn=imageBColumn; - this->datatype=JKQTPMathImageBase::DoubleArray; -} - -JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(JKQTPlotter *parent): - JKQTPRGBMathImage(0,0,0,0,DoubleArray,nullptr,0,0,parent) -{ - this->modifierColumn=-1; - this->imageRColumn=-1; - this->imageGColumn=-1; - this->imageBColumn=-1; - this->datatype=JKQTPMathImageBase::DoubleArray; -} - -JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int Nx, int Ny, JKQTPlotter *parent): - JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) -{ - this->modifierColumn=-1; - this->imageRColumn=-1; - this->imageGColumn=-1; - this->imageBColumn=-1; - this->datatype=JKQTPMathImageBase::DoubleArray; -} - -JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int Nx, int Ny, JKQTPlotter *parent): - JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) -{ - this->modifierColumn=-1; - this->imageRColumn=imageRColumn; - this->imageGColumn=-1; - this->imageBColumn=-1; - this->datatype=JKQTPMathImageBase::DoubleArray; -} - -JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int Nx, int Ny, JKQTPlotter *parent): - JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) -{ - this->modifierColumn=-1; - this->imageRColumn=imageRColumn; - this->imageGColumn=imageGColumn; - this->imageBColumn=-1; - this->datatype=JKQTPMathImageBase::DoubleArray; -} - -JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int imageBColumn, int Nx, int Ny, JKQTPlotter *parent): - JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) -{ - this->modifierColumn=-1; - this->imageRColumn=imageRColumn; - this->imageGColumn=imageGColumn; - this->imageBColumn=imageBColumn; - this->datatype=JKQTPMathImageBase::DoubleArray; -} -bool JKQTPColumnRGBMathImage::usesColumn(int c) const -{ - return (c==imageRColumn)||(c==imageBColumn)||(c==imageGColumn)||(c==modifierColumn); -} - - -void JKQTPColumnRGBMathImage::ensureImageData() -{ - this->datatype=JKQTPMathImageBase::DoubleArray; - this->datatypeG=JKQTPMathImageBase::DoubleArray; - this->datatypeB=JKQTPMathImageBase::DoubleArray; - this->data=parent->getDatastore()->getColumn(imageRColumn).getPointer(0); - this->dataG=parent->getDatastore()->getColumn(imageGColumn).getPointer(0); - this->dataB=parent->getDatastore()->getColumn(imageBColumn).getPointer(0); - this->Ny=parent->getDatastore()->getColumn(imageRColumn).getRows()/this->Nx; - this->datatypeModifier=JKQTPMathImageBase::DoubleArray; - this->dataModifier=parent->getDatastore()->getColumn(modifierColumn).getPointer(0); -} - - -QVector JKQTPRGBMathImage::getDataGAsDoubleVector() const -{ - switch(datatype) { - case JKQTPMathImageBase::DoubleArray: - return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); - break; - case JKQTPMathImageBase::FloatArray: - return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); - break; - case JKQTPMathImageBase::UInt8Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); - break; - case JKQTPMathImageBase::UInt16Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); - break; - case JKQTPMathImageBase::UInt32Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); - break; - case JKQTPMathImageBase::UInt64Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); - break; - case JKQTPMathImageBase::Int8Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); - break; - case JKQTPMathImageBase::Int16Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); - break; - case JKQTPMathImageBase::Int32Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); - break; - case JKQTPMathImageBase::Int64Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); - break; - } - QVector res; - return res; -} - -QVector JKQTPRGBMathImage::getDataBAsDoubleVector() const -{ - switch(datatype) { - case JKQTPMathImageBase::DoubleArray: - return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); - break; - case JKQTPMathImageBase::FloatArray: - return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); - break; - case JKQTPMathImageBase::UInt8Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); - break; - case JKQTPMathImageBase::UInt16Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); - break; - case JKQTPMathImageBase::UInt32Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); - break; - case JKQTPMathImageBase::UInt64Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); - break; - case JKQTPMathImageBase::Int8Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); - break; - case JKQTPMathImageBase::Int16Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); - break; - case JKQTPMathImageBase::Int32Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); - break; - case JKQTPMathImageBase::Int64Array: - return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); - break; - } - QVector res; - return res; -} - - - - -QVector JKQTPOverlayImage::getDataAsDoubleVector() const -{ - return JKQTPImagePlot_BarrayToDVector(data, Nx*Ny); - -} - -void JKQTPOverlayImage::setTitle(const QString &title) -{ - JKQTPImageBase::setTitle(title); - QString t=title; - if (t.isEmpty()) t="JKQTPOverlayImage"; - actSaveImage->setText(tr("Save %1 ...").arg(t)); - actCopyImage->setText(tr("Copy %1 ...").arg(t)); - -} - -void JKQTPOverlayImage::setParent(JKQTBasePlotter *parent) -{ - if (this->parent) { - this->parent->deregisterAdditionalAction(actSaveImage); - this->parent->deregisterAdditionalAction(actCopyImage); - - } - JKQTPImageBase::setParent(parent); - - if (parent) { - parent->registerAdditionalAction(tr("Save Image Plot Images ..."), actSaveImage); - parent->registerAdditionalAction(tr("Copy Image Plot Images ..."), actCopyImage); - - } - actSaveImage->setEnabled(parent); - actCopyImage->setEnabled(parent); - -} - -void JKQTPOverlayImage::saveImagePlotAsImage(const QString &filename, const QByteArray &outputFormat) -{ - if (parent) { - parent->loadUserSettings(); - QString currentSaveDirectory=parent->getCurrentSaveDirectory(); - QString currentFileFormat=parent->getCurrentFileFormat(); - QString fn=filename; - QStringList filt; - QList writerformats=QImageWriter::supportedImageFormats(); - for (int i=0; isetCurrentFileFormat(currentFileFormat); - parent->setCurrentSaveDirectory(currentSaveDirectory); - parent->saveUserSettings(); - if (!fn.isEmpty()) { - int filtID=filt.indexOf(selFormat); - QString form="NONE"; - if (filtID>=0 && filtID0) { - form =outputFormat; - } - - QImage image=drawImage(); - - if (form=="NONE") image.save(fn); - else image.save(fn, form.toLatin1().data()); - } - } -} - -void JKQTPOverlayImage::copyImagePlotAsImage() -{ - QClipboard* clip=QApplication::clipboard(); - if (clip) { - clip->setPixmap(QPixmap::fromImage(drawImage())); - } -} - -# include -void JKQTPContour::draw(JKQTPEnhancedPainter &painter) -{ - //qDebug()<<"JKQTPContourPlot::draw"; - - if(contourLevels.isEmpty()) createContourLevels(numberOfLevels); - else { - numberOfLevels=contourLevels.size(); -// qSort(contourLevels); - } - - if(contourLines.isEmpty()) { // contour lines are only calculated once - for(int i =0; i (0)); - } - this->calcContourLines(contourLines); - } - - - - // draw lines - painter.save(); - QPen p; - p.setStyle(style); - p.setColor(lineColor); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); - - painter.setPen(p); - QImage colorLevels = getPaletteImage(palette,numberOfLevels); - QVector contourLinesTransformedSingleLevel; - QLineF lineTranformed; - for(int i =0; i::const_iterator line =contourLines.at(i).begin(); line!=contourLines.at(i).end();++line ) { - lineTranformed.setP1(transform(x+line->p1().x()/double(Nx-1)*width, y+line->p1().y()/double(Ny-1)*height)); - lineTranformed.setP2(transform(x+line->p2().x()/double(Nx-1)*width, y+line->p2().y()/double(Ny-1)*height)); - contourLinesTransformedSingleLevel.append(lineTranformed); - } - painter.drawLines(contourLinesTransformedSingleLevel); - contourLinesTransformedSingleLevel.clear(); - } - - painter.restore(); -} - -void JKQTPContour::createContourLevels(int nLevels) -{ - if (!data) return; - if (nLevels<1) return; - double min,max; - getDataMinMax(min,max); - double delta=(max-min)/static_cast(nLevels+1); - - for(int i=1; i<=nLevels; ++i) { - contourLevels.append(min + i*delta); - } - relativeLevels=false; - -} - -void JKQTPContour::createContourLevelsLog(int nLevels, int m) -{ - if (!data) return; - if (nLevels<1) return; - double min,max; - getDataMinMax(min,max); - if(min<=0) min=1; // FIXME get smallest number greater zero - - int S=floor((log10(max)-log10(min))/log10(m)); - if(S<2) S=1; - int P = floor(static_cast(nLevels)/static_cast(S)); - if(P<1) P=1; - - double delta=min; - contourLevels.append(2*delta); - for (long s=0; sgetDatastore()->getColumn(columnID).getPointer(0); -} - - -void JKQTPContour::ensureImageData() -{ -} - -double JKQTPContour::value(int xIdx, int yIdx) -{ - // row-major in datastore - ensureImageData(); - if (!data) return 0; - switch(datatype) { - case JKQTPMathImageBase::DoubleArray: - return (static_cast(data))[yIdx*getNx()+xIdx]; - case JKQTPMathImageBase::FloatArray: - return (static_cast(data))[yIdx*getNx()+xIdx]; - case JKQTPMathImageBase::UInt8Array: - return (static_cast(data))[yIdx*getNx()+xIdx]; - case JKQTPMathImageBase::UInt16Array: - return (static_cast(data))[yIdx*getNx()+xIdx]; - case JKQTPMathImageBase::UInt32Array: - return (static_cast(data))[yIdx*getNx()+xIdx]; - case JKQTPMathImageBase::UInt64Array: - return (static_cast(data))[yIdx*getNx()+xIdx]; - case JKQTPMathImageBase::Int8Array: - return (static_cast(data))[yIdx*getNx()+xIdx]; - case JKQTPMathImageBase::Int16Array: - return (static_cast(data))[yIdx*getNx()+xIdx]; - case JKQTPMathImageBase::Int32Array: - return (static_cast(data))[yIdx*getNx()+xIdx]; - case JKQTPMathImageBase::Int64Array: - return (static_cast(data))[yIdx*getNx()+xIdx]; - default: - return 0; - } -} - -bool JKQTPContour::intersect(QLineF &line, const QVector3D &vertex1,const QVector3D &vertex2,const QVector3D &vertex3,double level) -{ - bool found = true; - - // Are the vertices below (-1), on (0) or above (1) the plane ? - const int eq1 = compare2level(vertex1,level); - const int eq2 = compare2level(vertex2,level); - const int eq3 = compare2level(vertex3,level); - - /* - (a) All the vertices lie below the contour level. - (b) Two vertices lie below and one on the contour level. - (c) Two vertices lie below and one above the contour level. - (d) One vertex lies below and two on the contour level. - (e) One vertex lies below, one on and one above the contour level. - (f) One vertex lies below and two above the contour level. - (g) Three vertices lie on the contour level. - (h) Two vertices lie on and one above the contour level. - (i) One vertex lies on and two above the contour level. - (j) All the vertices lie above the contour level. - */ - - static const int caseLUT[3][3][3] = - { - // jump table to avoid nested case statements - { { 0, 0, 8 }, { 0, 2, 5 }, { 7, 6, 9 } }, - { { 0, 3, 4 }, { 1, 10, 1 }, { 4, 3, 0 } }, - { { 9, 6, 7 }, { 5, 2, 0 }, { 8, 0, 0 } } - }; - - const int caseType = caseLUT[eq1+1][eq2+1][eq3+1]; - switch (caseType) - { - case 1: - // d(0,0,-1), h(0,0,1) - line.setP1(vertex1.toPointF()); - line.setP2(vertex2.toPointF()); - break; - case 2: - // d(-1,0,0), h(1,0,0) - line.setP1(vertex2.toPointF()); - line.setP2(vertex3.toPointF()); - break; - case 3: - // d(0,-1,0), h(0,1,0) - line.setP1(vertex3.toPointF()); - line.setP2(vertex1.toPointF()); - break; - case 4: - // e(0,-1,1), e(0,1,-1) - line.setP1(vertex1.toPointF()); - line.setP2(interpolatePoint(vertex2, vertex3, level)); - break; - case 5: - // e(-1,0,1), e(1,0,-1) - line.setP1(vertex2.toPointF()); - line.setP2(interpolatePoint(vertex3, vertex1, level)); - break; - case 6: - // e(-1,1,0), e(1,0,-1) - line.setP1(vertex3.toPointF()); - line.setP2(interpolatePoint(vertex1, vertex2, level)); - break; - case 7: - // c(-1,1,-1), f(1,1,-1) - line.setP1(interpolatePoint(vertex1, vertex2, level)); - line.setP2(interpolatePoint(vertex2, vertex3, level)); - break; - case 8: - // c(-1,-1,1), f(1,1,-1) - line.setP1(interpolatePoint(vertex2, vertex3, level)); - line.setP2(interpolatePoint(vertex3, vertex1, level)); - break; - case 9: - // f(-1,1,1), c(1,-1,-1) - line.setP1(interpolatePoint(vertex3, vertex1, level)); - line.setP2(interpolatePoint(vertex1, vertex2, level)); - break; - case 10: - // g(0,0,0) - // The CONREC algorithm has no satisfying solution for - // what to do, when all vertices are on the plane. - - if ( ignoreOnPlane ) - found = false; - else - { - line.setP1(vertex3.toPointF()); - line.setP2(vertex1.toPointF()); - } - break; - default: - found = false; - } -// qDebug()<getPlotStyle(parent->getNextStyle()).color(); - } -} - -JKQTPContour::JKQTPContour(double x, double y, double width, double height, void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette, DataType datatype, JKQTBasePlotter* parent) : - JKQTPMathImage( x, y, width, height, datatype, data, Nx, Ny, palette, parent) -{ - lineColor=QColor("red"); - colorBarRightVisible=false; - lineWidth=1; - style=Qt::SolidLine; - ignoreOnPlane=false; - numberOfLevels=1; - colorFromPalette=true; - relativeLevels=false; -} - - -JKQTPContour::JKQTPContour(JKQTPlotter *parent) : - JKQTPMathImage(parent) -{ - lineColor=QColor("red"); - colorBarRightVisible=false; - lineWidth=1; - style=Qt::SolidLine; - ignoreOnPlane=false; - numberOfLevels=1; - colorFromPalette=true; - datatype=JKQTPMathImageBase::DoubleArray; - relativeLevels=false; - - if (parent) { // get style settings from parent object - lineColor=parent->getPlotStyle(parent->getNextStyle()).color(); - } -} - -JKQTPContour::JKQTPContour(double x, double y, double width, double height, void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette, DataType datatype, JKQTPlotter* parent) : - JKQTPMathImage( x, y, width, height, datatype, data, Nx, Ny, palette, parent) -{ - lineColor=QColor("red"); - colorBarRightVisible=false; - lineWidth=1; - style=Qt::SolidLine; - ignoreOnPlane=false; - numberOfLevels=1; - colorFromPalette=true; - relativeLevels=false; -} -int JKQTPContour::compare2level(const QVector3D &vertex, double level) -{ - if (vertex.z() > level) - return 1; - - if (vertex.z() < level) - return -1; - - return 0; -} - -void JKQTPContour::calcContourLines(QList > &ContourLines) -{ - - double scale=1; ///< scale of the contour levels; - - if(relativeLevels) { - double min; - double max; - getDataMinMax(min,max); - scale=1/(max-min); - } - - enum Position - { - // the positions of points of one box - // vertex 1 +-------------------+ vertex 2 - // | \ / | - // | \ m=3 / | - // | \ / | - // | \ / | - // | m=2 X m=2 | the center is vertex 0 - // | / \ | - // | / \ | - // | / m=1 \ | - // | / \ | - // vertex 4 +-------------------+ vertex 3 - Center=0, - - TopLeft=1, - TopRight=2, - BottomRight=3, - BottomLeft=4, - - NumPositions=5 - }; - - - for ( int yp = 0; yp < (int64_t)getNy() - 1; ++yp ) { // go through image (pixel coordinates) in row major order - QVector vertices(NumPositions); - - for ( int xp = 0; xp < (int64_t)getNy() - 1; ++xp ) { - - if ( xp == 0 ) - { - vertices[TopRight].setX(xp); // will be used for TopLeft later - vertices[TopRight].setY(yp); - vertices[TopRight].setZ( - value( vertices[TopRight].x(), vertices[TopRight].y())*scale - ); - - vertices[BottomRight].setX(xp); - vertices[BottomRight].setY(yp+1); - vertices[BottomRight].setZ( - value(vertices[BottomRight].x(), vertices[BottomRight].y())*scale - ); - } - - vertices[TopLeft] = vertices[TopRight]; // use right vertices of the last box as new left vertices - vertices[BottomLeft] = vertices[BottomRight]; - - vertices[TopRight].setX(xp + 1); - vertices[TopRight].setY(yp); // <---- - vertices[TopRight].setZ( - value(vertices[TopRight].x(), vertices[TopRight].y())*scale - ); - - vertices[BottomRight].setX(xp + 1); - vertices[BottomRight].setY(yp + 1); - vertices[BottomRight].setZ( - value(vertices[BottomRight].x(), vertices[BottomRight].y())*scale - ); - - double zMin = vertices[TopLeft].z(); - double zMax = zMin; - double zSum = zMin; - - for ( int i = TopRight; i <= BottomLeft; ++i ) { - const double z = vertices[i].z(); - - zSum += z; - if ( z < zMin ) - zMin = z; - if ( z > zMax ) - zMax = z; - } - - - if ( zMax >= contourLevels.first() && zMin <= contourLevels.last() ) { - - vertices[Center].setX(xp + 0.5); // pseudo pixel coordinates - vertices[Center].setY(yp + 0.5); - vertices[Center].setZ(0.25 * zSum); - for (int levelIdx=0; levelIdx= zMin && contourLevels.at(levelIdx) <= zMax ) { - - QLineF line; - QVector triangle(3); - - /* triangle[1] - X - / \ - / \ - / m \ - / \ - triangle[2] +-------------------+ triangle[0] - */ - - for (int m = TopLeft; m < NumPositions; m++) { // construct triangles - triangle[0] = vertices[m]; - triangle[1] = vertices[Center]; - triangle[2] = vertices[(m!=BottomLeft)?(m + 1):TopLeft]; - - const bool intersects =intersect(line, triangle.at(0),triangle.at(1),triangle.at(2), - contourLevels.at(levelIdx)); - if ( intersects ) { - ContourLines[levelIdx]<\copydoc imageColumn - \see imageColumn for more information */ + /*! \copydoc imageColumn + \see see imageColumn for details */ inline virtual void setImageColumn(int __value) { this->imageColumn = __value; } - /*! \brief returns the property imageColumn ( \copybrief imageColumn ). - \details Description of the parameter imageColumn is:
    \copydoc imageColumn
    - \see imageColumn for more information */ + /*! \copydoc imageColumn + \see see imageColumn for details */ inline virtual int getImageColumn() const { return this->imageColumn; } - /*! \brief sets the property modifierColumn ( \copybrief modifierColumn ) to the specified \a __value. - \details Description of the parameter modifierColumn is:
    \copydoc modifierColumn
    - \see modifierColumn for more information */ + /*! \copydoc modifierColumn + \see see modifierColumn for details */ inline virtual void setModifierColumn(int __value) { this->modifierColumn = __value; } - /*! \brief returns the property modifierColumn ( \copybrief modifierColumn ). - \details Description of the parameter modifierColumn is:
    \copydoc modifierColumn
    - \see modifierColumn for more information */ + /*! \copydoc modifierColumn + \see see modifierColumn for details */ inline virtual int getModifierColumn() const { return this->modifierColumn; @@ -1475,598 +882,6 @@ class JKQTP_LIB_EXPORT JKQTPColumnMathImage: public JKQTPMathImage { }; -/*! \brief like JKQTPRGBMathImage but reads images from columns of the datastore - \ingroup jkqtplotter_imagelots_elements - - - \image html rgbimageplots.png - \image html jkqtplotter_simpletest_rgbimageplot_opencv.png - */ -class JKQTP_LIB_EXPORT JKQTPColumnRGBMathImage: public JKQTPRGBMathImage { - Q_OBJECT - public: - - /** \brief class constructor */ - JKQTPColumnRGBMathImage(JKQTBasePlotter* parent=nullptr); - JKQTPColumnRGBMathImage(double x, double y, double width, double height, int Nx, int Ny, JKQTBasePlotter* parent=nullptr); - JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int Nx, int Ny, JKQTBasePlotter* parent=nullptr); - JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int Nx, int Ny, JKQTBasePlotter* parent=nullptr); - JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int imageBColumn, int Nx, int Ny, JKQTBasePlotter* parent=nullptr); - /** \brief class constructor */ - JKQTPColumnRGBMathImage(JKQTPlotter* parent); - JKQTPColumnRGBMathImage(double x, double y, double width, double height, int Nx, int Ny, JKQTPlotter* parent); - JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int Nx, int Ny, JKQTPlotter* parent); - JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int Nx, int Ny, JKQTPlotter* parent); - JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int imageBColumn, int Nx, int Ny, JKQTPlotter* parent); - - /*! \brief sets the property imageRColumn ( \copybrief imageRColumn ) to the specified \a __value. - \details Description of the parameter imageRColumn is:
    \copydoc imageRColumn
    - \see imageRColumn for more information */ - inline virtual void setImageRColumn(int __value) - { - this->imageRColumn = __value; - } - /*! \brief returns the property imageRColumn ( \copybrief imageRColumn ). - \details Description of the parameter imageRColumn is:
    \copydoc imageRColumn
    - \see imageRColumn for more information */ - inline virtual int getImageRColumn() const - { - return this->imageRColumn; - } - /*! \brief sets the property imageGColumn ( \copybrief imageGColumn ) to the specified \a __value. - \details Description of the parameter imageGColumn is:
    \copydoc imageGColumn
    - \see imageGColumn for more information */ - inline virtual void setImageGColumn(int __value) - { - this->imageGColumn = __value; - } - /*! \brief returns the property imageGColumn ( \copybrief imageGColumn ). - \details Description of the parameter imageGColumn is:
    \copydoc imageGColumn
    - \see imageGColumn for more information */ - inline virtual int getImageGColumn() const - { - return this->imageGColumn; - } - /*! \brief sets the property imageBColumn ( \copybrief imageBColumn ) to the specified \a __value. - \details Description of the parameter imageBColumn is:
    \copydoc imageBColumn
    - \see imageBColumn for more information */ - inline virtual void setImageBColumn(int __value) - { - this->imageBColumn = __value; - } - /*! \brief returns the property imageBColumn ( \copybrief imageBColumn ). - \details Description of the parameter imageBColumn is:
    \copydoc imageBColumn
    - \see imageBColumn for more information */ - inline virtual int getImageBColumn() const - { - return this->imageBColumn; - } - /*! \brief sets the property modifierColumn ( \copybrief modifierColumn ) to the specified \a __value. - \details Description of the parameter modifierColumn is:
    \copydoc modifierColumn
    - \see modifierColumn for more information */ - inline virtual void setModifierColumn(int __value) - { - this->modifierColumn = __value; - } - /*! \brief returns the property modifierColumn ( \copybrief modifierColumn ). - \details Description of the parameter modifierColumn is:
    \copydoc modifierColumn
    - \see modifierColumn for more information */ - inline virtual int getModifierColumn() const - { - return this->modifierColumn; - } - /** \copydoc JKQTPGraph::usesColumn() */ - virtual bool usesColumn(int c) const override; - - protected: - /** \brief image column for R channel */ - int imageRColumn; - /** \brief image column for G channel */ - int imageGColumn; - /** \brief image column for B channel */ - int imageBColumn; - /** \brief column containing the modifier image */ - int modifierColumn; - - void ensureImageData() override; -}; - - -/*! \brief class to plot an image from an 2-dimensional array of boolean values: alle \c true values are plotted in a given color, while the \c false pixels are drawn in another (default: transparent) - \ingroup jkqtplotter_imagelots_overlays - - \image html overlayimage.png - - */ -class JKQTP_LIB_EXPORT JKQTPOverlayImage: public JKQTPImageBase { - Q_OBJECT - public: - - /** \brief class constructor */ - JKQTPOverlayImage(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTBasePlotter* parent=nullptr); - JKQTPOverlayImage(JKQTBasePlotter* parent=nullptr); - - /** \brief class constructor */ - JKQTPOverlayImage(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTPlotter* parent); - JKQTPOverlayImage(JKQTPlotter* parent); - - /** \brief plots the graph to the plotter object specified as parent */ - virtual void draw(JKQTPEnhancedPainter& painter) override; - - /*! \brief return the plotted image only as a QImage */ - virtual QImage drawImage(); - - /** \brief plots a key marker inside the specified rectangle \a rect */ - virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) override; - /** \brief returns the color to be used for the key label */ - virtual QColor getKeyLabelColor() override; - - /*! \brief sets the property trueColor ( \copybrief trueColor ) to the specified \a __value. - \details Description of the parameter trueColor is:
    \copydoc trueColor
    - \see trueColor for more information */ - inline virtual void setTrueColor(const QColor & __value) - { - this->trueColor = __value; - } - /*! \brief returns the property trueColor ( \copybrief trueColor ). - \details Description of the parameter trueColor is:
    \copydoc trueColor
    - \see trueColor for more information */ - inline virtual QColor getTrueColor() const - { - return this->trueColor; - } - /*! \brief sets the property falseColor ( \copybrief falseColor ) to the specified \a __value. - \details Description of the parameter falseColor is:
    \copydoc falseColor
    - \see falseColor for more information */ - inline virtual void setFalseColor(const QColor & __value) - { - this->falseColor = __value; - } - /*! \brief returns the property falseColor ( \copybrief falseColor ). - \details Description of the parameter falseColor is:
    \copydoc falseColor
    - \see falseColor for more information */ - inline virtual QColor getFalseColor() const - { - return this->falseColor; - } - /*! \brief sets the property Nx ( \copybrief Nx ) to the specified \a __value. - \details Description of the parameter Nx is:
    \copydoc Nx
    - \see Nx for more information */ - inline virtual void setNx(int __value) - { - this->Nx = __value; - } - /*! \brief returns the property Nx ( \copybrief Nx ). - \details Description of the parameter Nx is:
    \copydoc Nx
    - \see Nx for more information */ - inline virtual int getNx() const - { - return this->Nx; - } - /*! \brief sets the property Ny ( \copybrief Ny ) to the specified \a __value. - \details Description of the parameter Ny is:
    \copydoc Ny
    - \see Ny for more information */ - inline virtual void setNy(int __value) - { - this->Ny = __value; - } - /*! \brief returns the property Ny ( \copybrief Ny ). - \details Description of the parameter Ny is:
    \copydoc Ny
    - \see Ny for more information */ - inline virtual int getNy() const - { - return this->Ny; - } - /*! \brief sets the property data ( \copybrief data ) to the specified \a __value. - \details Description of the parameter data is:
    \copydoc data
    - \see data for more information */ - inline virtual void setData(bool* __value) - { - this->data = __value; - } - /*! \brief returns the property data ( \copybrief data ). - \details Description of the parameter data is:
    \copydoc data
    - \see data for more information */ - inline virtual bool* getData() const - { - return this->data; - } - - void setData(bool* data, int Nx, int Ny); - - QVector getDataAsDoubleVector() const; - - protected: - /** \brief points to the data array, holding the image */ - bool* data; - /** \brief width of the data array data in pt */ - int Nx; - /** \brief height of the data array data in pt */ - int Ny; - - /** \brief color for \c true pixels */ - QColor trueColor; - /** \brief color for \c false pixels */ - QColor falseColor; - - protected: - QAction* actSaveImage; - QAction* actCopyImage; - public: - virtual void setTitle(const QString& title) override; - virtual void setParent(JKQTBasePlotter* parent) override; - public slots: - void saveImagePlotAsImage(const QString &filename=QString(""), const QByteArray &outputFormat=QByteArray()); - void copyImagePlotAsImage(); - -}; - - - -/*! \brief class to plot an image from an 2-dimensional array of boolean values: alle \c true values are plotted in a given color, while the \c false pixels are drawn in another (default: transparent) - \ingroup jkqtplotter_imagelots_overlays - - In contrast to JKQTPOverlayImage this class draws ist contents as rectangles, not as semi-transparent image. This may lead to nicer results,but could be slower. - Also it is possible to draw other types of markers (cross, circles, ...) - - \image html overlayimageenhanced.png - */ -class JKQTP_LIB_EXPORT JKQTPOverlayImageEnhanced: public JKQTPOverlayImage { - Q_OBJECT - public: - /** \brief class constructor */ - JKQTPOverlayImageEnhanced(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTBasePlotter* parent=nullptr); - JKQTPOverlayImageEnhanced(JKQTBasePlotter* parent=nullptr); - /** \brief class constructor */ - JKQTPOverlayImageEnhanced(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTPlotter* parent); - JKQTPOverlayImageEnhanced(JKQTPlotter* parent); - - /** \brief plots the graph to the plotter object specified as parent */ - virtual void draw(JKQTPEnhancedPainter& painter) override; - /** \brief plots a key marker inside the specified rectangle \a rect */ - virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) override; - - /*! \brief sets the property symbol ( \copybrief symbol ) to the specified \a __value. - \details Description of the parameter symbol is:
    \copydoc symbol
    - \see symbol for more information */ - inline virtual void setSymbol(const JKQTPGraphSymbols & __value) - { - this->symbol = __value; - } - /*! \brief returns the property symbol ( \copybrief symbol ). - \details Description of the parameter symbol is:
    \copydoc symbol
    - \see symbol for more information */ - inline virtual JKQTPGraphSymbols getSymbol() const - { - return this->symbol; - } - /*! \brief sets the property symbolWidth ( \copybrief symbolWidth ) to the specified \a __value. - \details Description of the parameter symbolWidth is:
    \copydoc symbolWidth
    - \see symbolWidth for more information */ - inline virtual void setSymbolWidth(double __value) - { - this->symbolWidth = __value; - } - /*! \brief returns the property symbolWidth ( \copybrief symbolWidth ). - \details Description of the parameter symbolWidth is:
    \copydoc symbolWidth
    - \see symbolWidth for more information */ - inline virtual double getSymbolWidth() const - { - return this->symbolWidth; - } - /*! \brief sets the property drawAsRectangles ( \copybrief drawAsRectangles ) to the specified \a __value. - \details Description of the parameter drawAsRectangles is:
    \copydoc drawAsRectangles
    - \see drawAsRectangles for more information */ - inline virtual void setDrawAsRectangles(bool __value) - { - this->drawAsRectangles = __value; - } - /*! \brief returns the property drawAsRectangles ( \copybrief drawAsRectangles ). - \details Description of the parameter drawAsRectangles is:
    \copydoc drawAsRectangles
    - \see drawAsRectangles for more information */ - inline virtual bool getDrawAsRectangles() const - { - return this->drawAsRectangles; - } - /*! \brief sets the property rectanglesAsImageOverlay ( \copybrief rectanglesAsImageOverlay ) to the specified \a __value. - \details Description of the parameter rectanglesAsImageOverlay is:
    \copydoc rectanglesAsImageOverlay
    - \see rectanglesAsImageOverlay for more information */ - inline virtual void setRectanglesAsImageOverlay(bool __value) - { - this->rectanglesAsImageOverlay = __value; - } - /*! \brief returns the property rectanglesAsImageOverlay ( \copybrief rectanglesAsImageOverlay ). - \details Description of the parameter rectanglesAsImageOverlay is:
    \copydoc rectanglesAsImageOverlay
    - \see rectanglesAsImageOverlay for more information */ - inline virtual bool getRectanglesAsImageOverlay() const - { - return this->rectanglesAsImageOverlay; - } - /*! \brief sets the property symbolSizeFactor ( \copybrief symbolSizeFactor ) to the specified \a __value. - \details Description of the parameter symbolSizeFactor is:
    \copydoc symbolSizeFactor
    - \see symbolSizeFactor for more information */ - inline virtual void setSymbolSizeFactor(double __value) - { - this->symbolSizeFactor = __value; - } - /*! \brief returns the property symbolSizeFactor ( \copybrief symbolSizeFactor ). - \details Description of the parameter symbolSizeFactor is:
    \copydoc symbolSizeFactor
    - \see symbolSizeFactor for more information */ - inline virtual double getSymbolSizeFactor() const - { - return this->symbolSizeFactor; - } - - protected: - /** \brief which symbol to use for the datapoints */ - JKQTPGraphSymbols symbol; - /** \brief width (in pt) of the lines used to plot the symbol for the data points */ - double symbolWidth; - - /** \brief indicates whether to draw filled rectangles (\c false, default) or symbols */ - bool drawAsRectangles; - - /** \brief a rescaling factor for the symbols */ - double symbolSizeFactor; - - /** \brief when \c drawAsRectangles==true this reactivates the drawing from JKQTPOverlayImage, i.e. the overlay is not drawn as separated rectangles, but as an overlay image */ - bool rectanglesAsImageOverlay; - -}; - - - - -/*! \brief class to plot an image from an 2-dimensional array of boolean values: alle \c true values are plotted in a given color, while the \c false pixels are drawn in another (default: transparent) - \ingroup jkqtplotter_imagelots_overlays - - In contrast to JKQTPOverlayImage this class draws ist contents as rectangles, not as semi-transparent image. This may lead to nicer results,but could be slower. - Also it is possible to draw other types of markers (cross, circles, ...) - - \image html overlayimageenhanced.png - - */ -class JKQTP_LIB_EXPORT JKQTPColumnOverlayImageEnhanced: public JKQTPOverlayImageEnhanced { - Q_OBJECT - public: - JKQTPColumnOverlayImageEnhanced(JKQTBasePlotter* parent=nullptr); - JKQTPColumnOverlayImageEnhanced(JKQTPlotter* parent); - - /*! \brief sets the property imageColumn ( \copybrief imageColumn ) to the specified \a __value. - \details Description of the parameter imageColumn is:
    \copydoc imageColumn
    - \see imageColumn for more information */ - inline virtual void setImageColumn(int __value) - { - this->imageColumn = __value; - } - /*! \brief returns the property imageColumn ( \copybrief imageColumn ). - \details Description of the parameter imageColumn is:
    \copydoc imageColumn
    - \see imageColumn for more information */ - inline virtual int getImageColumn() const - { - return this->imageColumn; - } - /** \brief plots the graph to the plotter object specified as parent */ - virtual void draw(JKQTPEnhancedPainter& painter) override; - - /** \copydoc JKQTPGraph::usesColumn() */ - virtual bool usesColumn(int c) const override; - - - protected: - /** \brief top color bar visible */ - int imageColumn; -}; - - - -/*! \brief class for a contour plot - * \ingroup jkqtplotter_imagelots_contour - * calculates the contour of a given image using the CONREC algorithm - * http://paulbourke.net/papers/conrec/ - * The implementation for Qt is adapted from Qwt - * http://qwt.sourceforge.net/ - * - * The contour lines are calculated only once and then redrawn to save plotting time. - * Make sure you add a new graph when your data changes. The contour levels can be defined in - * contourLevels, each elemt in the list represents a contour plane. You can also create contour - * levels with createContourLevels(). The levels are linearly spaced between the maximum and minimum - * value in your data. For logarithmic data, use createContourLevelsLog() to create contour levels - * with logarithmic spacing. - * - * \author Sebastian Isbaner, 2013-2014 - * - * \image html JKQTPContour.png - */ -class JKQTP_LIB_EXPORT JKQTPContour: public JKQTPMathImage { - Q_OBJECT - public: - /** \brief class constructor */ - JKQTPContour(JKQTBasePlotter* parent=nullptr); - /** \brief class constructor */ - JKQTPContour(double x, double y, double width, double height, void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette=JKQTPMathImageGRAY, DataType datatype = JKQTPMathImageBase::DoubleArray, JKQTBasePlotter* parent=nullptr); - /** \brief class constructor */ - JKQTPContour(JKQTPlotter* parent); - /** \brief class constructor */ - JKQTPContour(double x, double y, double width, double height, void* data, int Nx, int Ny, JKQTPMathImageColorPalette palette, DataType datatype , JKQTPlotter* parent); - /** \brief plots the graph to the plotter object specified as parent */ - virtual void draw(JKQTPEnhancedPainter& painter) override; - - /** \brief creates at nLevels contour levels linearly spaced between the data's minimum and maximum values */ - void createContourLevels(int nLevels=3); - /** \brief creates at least nLevels contour levels with logarithmic spacing. FIXME: Has not been tested yet */ - void createContourLevelsLog(int nLevels=3,int m=2); - - /*! \brief sets the property lineColor ( \copybrief lineColor ) to the specified \a __value. - \details Description of the parameter lineColor is:
    \copydoc lineColor
    - \see lineColor for more information */ - inline virtual void setLineColor(const QColor & __value) - { - this->lineColor = __value; - } - /*! \brief returns the property lineColor ( \copybrief lineColor ). - \details Description of the parameter lineColor is:
    \copydoc lineColor
    - \see lineColor for more information */ - inline virtual QColor getLineColor() const - { - return this->lineColor; - } - /*! \brief sets the property style ( \copybrief style ) to the specified \a __value. - \details Description of the parameter style is:
    \copydoc style
    - \see style for more information */ - inline virtual void setStyle(const Qt::PenStyle & __value) - { - this->style = __value; - } - /*! \brief returns the property style ( \copybrief style ). - \details Description of the parameter style is:
    \copydoc style
    - \see style for more information */ - inline virtual Qt::PenStyle getStyle() const - { - return this->style; - } - /*! \brief sets the property lineWidth ( \copybrief lineWidth ) to the specified \a __value. - \details Description of the parameter lineWidth is:
    \copydoc lineWidth
    - \see lineWidth for more information */ - inline virtual void setLineWidth(double __value) - { - this->lineWidth = __value; - } - /*! \brief returns the property lineWidth ( \copybrief lineWidth ). - \details Description of the parameter lineWidth is:
    \copydoc lineWidth
    - \see lineWidth for more information */ - inline virtual double getLineWidth() const - { - return this->lineWidth; - } - /*! \brief sets the property ignoreOnPlane ( \copybrief ignoreOnPlane ) to the specified \a __value. - \details Description of the parameter ignoreOnPlane is:
    \copydoc ignoreOnPlane
    - \see ignoreOnPlane for more information */ - inline virtual void setIgnoreOnPlane(bool __value) - { - this->ignoreOnPlane = __value; - } - /*! \brief returns the property ignoreOnPlane ( \copybrief ignoreOnPlane ). - \details Description of the parameter ignoreOnPlane is:
    \copydoc ignoreOnPlane
    - \see ignoreOnPlane for more information */ - inline virtual bool getIgnoreOnPlane() const - { - return this->ignoreOnPlane; - } - /*! \brief sets the property numberOfLevels ( \copybrief numberOfLevels ) to the specified \a __value. - \details Description of the parameter numberOfLevels is:
    \copydoc numberOfLevels
    - \see numberOfLevels for more information */ - inline virtual void setNumberOfLevels(int __value) - { - this->numberOfLevels = __value; - } - /*! \brief returns the property numberOfLevels ( \copybrief numberOfLevels ). - \details Description of the parameter numberOfLevels is:
    \copydoc numberOfLevels
    - \see numberOfLevels for more information */ - inline virtual int getNumberOfLevels() const - { - return this->numberOfLevels; - } - /*! \brief sets the property colorFromPalette ( \copybrief colorFromPalette ) to the specified \a __value. - \details Description of the parameter colorFromPalette is:
    \copydoc colorFromPalette
    - \see colorFromPalette for more information */ - inline virtual void setColorFromPalette(bool __value) - { - this->colorFromPalette = __value; - } - /*! \brief returns the property colorFromPalette ( \copybrief colorFromPalette ). - \details Description of the parameter colorFromPalette is:
    \copydoc colorFromPalette
    - \see colorFromPalette for more information */ - inline virtual bool getColorFromPalette() const - { - return this->colorFromPalette; - } - /*! \brief sets the property contourLevels ( \copybrief contourLevels ) to the specified \a __value. - \details Description of the parameter contourLevels is:
    \copydoc contourLevels
    - \see contourLevels for more information */ - inline virtual void setContourLevels(const QList & __value) - { - this->contourLevels = __value; - } - /*! \brief returns the property contourLevels ( \copybrief contourLevels ). - \details Description of the parameter contourLevels is:
    \copydoc contourLevels
    - \see contourLevels for more information */ - inline virtual QList getContourLevels() const - { - return this->contourLevels; - } - /*! \brief sets the property relativeLevels ( \copybrief relativeLevels ) to the specified \a __value. - \details Description of the parameter relativeLevels is:
    \copydoc relativeLevels
    - \see relativeLevels for more information */ - inline virtual void setRelativeLevels(bool __value) - { - this->relativeLevels = __value; - } - /*! \brief returns the property relativeLevels ( \copybrief relativeLevels ). - \details Description of the parameter relativeLevels is:
    \copydoc relativeLevels
    - \see relativeLevels for more information */ - inline virtual bool getRelativeLevels() const - { - return this->relativeLevels; - } - /** convenience function to work with JKQTPDatastore */ - void setImageColumn(size_t columnID); - - void addContourLevel(double &level); - - - - protected: - /** \brief color of the contour lines */ - QColor lineColor; - /** \brief linestyle of the contour lines */ - Qt::PenStyle style; - /** \brief width (pixels) of the graph */ - double lineWidth; - /** \brief if true, vertices that all lie on the contour plane will be ignored*/ - bool ignoreOnPlane; - /** \brief if true, the colors of the \a palette are used for the contour lines */ - bool colorFromPalette; - /** \brief the number of contour levels. Is only used if contourLevels is empty*/ - int numberOfLevels; - - /** \brief the list of contour levels */ - QList contourLevels; -// /** \brief indicates wether the contour levels are absolute values or relative to the maximum (max-min) */ - bool relativeLevels; - virtual void ensureImageData() override; - -private: - double value(int xIdx, int yIdx); - /// gives the intersection line of a plane defined by three vertices with a contour level in the x-y plane of heigth level - bool intersect(QLineF &line, const QVector3D &vertex1,const QVector3D &vertex2,const QVector3D &vertex3,double level); - /** - * @brief interpolatePoint linear interpolation of a line to the x-y plane using the z-value relative to level - * @param point1 start point of the line - * @param point2 end point of the line - * @param level the heigth for the interpolation (this z-value is projected onto the xy-plane) - * @return the interpolated point in the x-y plane - */ - QPointF interpolatePoint(const QVector3D &point1, const QVector3D &point2,double level); - /** - * @brief compare2level checks if the vertex lies above, under or on the contour plane level - * @param vertex - * @param level contour plane - * @return above (1), on the plane (0), below (-1); - */ - int compare2level(const QVector3D &vertex, double level); - /** - * @brief calcContourLines calculates the contour lines using the CONREC algorithm - */ - void calcContourLines(QList > &ContourLines); - /// the contour lines as vector of single lines (one for each triangle). the list index refers to the contour level. - QList > contourLines; // contour levels, squares on grid, line - -}; - - - - #endif // jkqtpgraphsimage_H diff --git a/lib/jkqtplotter/jkqtpgraphsimageoverlays.cpp b/lib/jkqtplotter/jkqtpgraphsimageoverlays.cpp new file mode 100644 index 0000000000..04a236d9e3 --- /dev/null +++ b/lib/jkqtplotter/jkqtpgraphsimageoverlays.cpp @@ -0,0 +1,361 @@ +/* + Copyright (c) 2008-2019 Jan W. Krieger & Sebastian Isbaner (contour plot) + + + + 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 . +*/ + + +#include "jkqtplotter/jkqtpgraphsimageoverlays.h" +#include "jkqtplotter/jkqtpbaseplotter.h" +#include "jkqtplottertools/jkqtpimagetools.h" +#include "jkqtplottertools/jkqtptools.h" +#include "jkqtplottertools/jkqtpenhancedpainter.h" +#include "jkqtplotter/jkqtplotter.h" +#include +#include +#include +#include +#include +#include + + +JKQTPOverlayImage::JKQTPOverlayImage(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTBasePlotter* parent): + JKQTPImageBase(x, y, width, height, parent) +{ + actSaveImage=new QAction(tr("Save JKQTPOverlayImage ..."), this); + connect(actSaveImage, SIGNAL(triggered()), this, SLOT(saveImagePlotAsImage())); + actCopyImage=new QAction(tr("Copy JKQTPOverlayImage ..."), this); + connect(actCopyImage, SIGNAL(triggered()), this, SLOT(copyImagePlotAsImage())); + this->Nx=Nx; + this->Ny=Ny; + this->data=data; + this->trueColor=colTrue; + this->falseColor=QColor(Qt::transparent); +} + +JKQTPOverlayImage::JKQTPOverlayImage(JKQTBasePlotter *parent): + JKQTPImageBase(0,0,1,1, parent) +{ + actSaveImage=new QAction(tr("Save JKQTPOverlayImage ..."), this); + connect(actSaveImage, SIGNAL(triggered()), this, SLOT(saveImagePlotAsImage())); + actCopyImage=new QAction(tr("Copy JKQTPOverlayImage ..."), this); + connect(actCopyImage, SIGNAL(triggered()), this, SLOT(copyImagePlotAsImage())); + this->Nx=0; + this->Ny=0; + this->data=nullptr; + this->trueColor=QColor("red"); +} + +JKQTPOverlayImage::JKQTPOverlayImage(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTPlotter* parent): + JKQTPImageBase(x, y, width, height, parent) +{ + actSaveImage=new QAction(tr("Save JKQTPOverlayImage ..."), this); + connect(actSaveImage, SIGNAL(triggered()), this, SLOT(saveImagePlotAsImage())); + actCopyImage=new QAction(tr("Copy JKQTPOverlayImage ..."), this); + connect(actCopyImage, SIGNAL(triggered()), this, SLOT(copyImagePlotAsImage())); + this->Nx=Nx; + this->Ny=Ny; + this->data=data; + this->trueColor=colTrue; + this->falseColor=QColor(Qt::transparent); +} + +JKQTPOverlayImage::JKQTPOverlayImage(JKQTPlotter *parent): + JKQTPImageBase(0,0,1,1, parent) +{ + actSaveImage=new QAction(tr("Save JKQTPOverlayImage ..."), this); + connect(actSaveImage, SIGNAL(triggered()), this, SLOT(saveImagePlotAsImage())); + actCopyImage=new QAction(tr("Copy JKQTPOverlayImage ..."), this); + connect(actCopyImage, SIGNAL(triggered()), this, SLOT(copyImagePlotAsImage())); + this->Nx=0; + this->Ny=0; + this->data=nullptr; + this->trueColor=QColor("red"); +} + +void JKQTPOverlayImage::draw(JKQTPEnhancedPainter& painter) { + if (!data) return; + QImage img=drawImage(); + plotImage(painter, img, x, y, width, height); +} + +QImage JKQTPOverlayImage::drawImage() { + if (!data) return QImage(); + QImage img(Nx, Ny, QImage::Format_ARGB32); + + //QRgb tc=trueColor.rgba(); + //QRgb fc=falseColor.rgba(); + QRgb tc=qRgba(round(trueColor.red()*trueColor.alphaF()), round(trueColor.green()*trueColor.alphaF()), round(trueColor.blue()*trueColor.alphaF()), trueColor.alpha()); + QRgb fc=qRgba(round(falseColor.red()*falseColor.alphaF()), round(falseColor.green()*falseColor.alphaF()), round(falseColor.blue()*falseColor.alphaF()), falseColor.alpha()); + + for (int32_t y=0; ydata=data; + this->Nx=Nx; + this->Ny=Ny; +} + + +JKQTPOverlayImageEnhanced::JKQTPOverlayImageEnhanced(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTBasePlotter* parent): + JKQTPOverlayImage(x, y, width, height, data, Nx, Ny, colTrue, parent) +{ + symbol=JKQTPTarget; + symbolWidth=1; + drawAsRectangles=true; + symbolSizeFactor=0.9; + rectanglesAsImageOverlay=false; +} + +JKQTPOverlayImageEnhanced::JKQTPOverlayImageEnhanced(JKQTBasePlotter *parent): + JKQTPOverlayImage(0,0,1,1,nullptr,0,0, QColor("red"), parent) +{ + symbol=JKQTPTarget; + symbolWidth=1; + drawAsRectangles=true; + symbolSizeFactor=0.9; + rectanglesAsImageOverlay=false; +} + +JKQTPOverlayImageEnhanced::JKQTPOverlayImageEnhanced(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTPlotter* parent): + JKQTPOverlayImage(x, y, width, height, data, Nx, Ny, colTrue, parent) +{ + symbol=JKQTPTarget; + symbolWidth=1; + drawAsRectangles=true; + symbolSizeFactor=0.9; + rectanglesAsImageOverlay=false; +} + +JKQTPOverlayImageEnhanced::JKQTPOverlayImageEnhanced(JKQTPlotter *parent): + JKQTPOverlayImage(0,0,1,1,nullptr,0,0, QColor("red"), parent) +{ + symbol=JKQTPTarget; + symbolWidth=1; + drawAsRectangles=true; + symbolSizeFactor=0.9; + rectanglesAsImageOverlay=false; +} +void JKQTPOverlayImageEnhanced::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) { + if (drawAsRectangles) JKQTPOverlayImage::drawKeyMarker(painter, rect); + else JKQTPPlotSymbol(painter, rect.center().x(), rect.center().y(), symbol, qMin(rect.width(), rect.height()), parent->pt2px(painter, symbolWidth*parent->getLineWidthMultiplier()), trueColor, trueColor.lighter()); +} + +void JKQTPOverlayImageEnhanced::draw(JKQTPEnhancedPainter& painter) { + if (!data) return; + + if (drawAsRectangles && rectanglesAsImageOverlay) { + JKQTPOverlayImage::draw(painter); + } else { + + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + + double dx=width/static_cast(Nx); + double dy=height/static_cast(Ny); + for (int ix=0; ix(Nx); ix++) { + for (int iy=0; iy(Ny); iy++) { + QPointF p1=transform(x+static_cast(ix)*dx, y+static_cast(iy)*dy); + QPointF p2=transform(x+static_cast(ix+1)*dx, y+static_cast(iy+1)*dx); + if (drawAsRectangles) { + if (data[ix+iy*Nx]) { + if (trueColor.alpha()>0) { + painter.fillRect(QRectF(qMin(p1.x(), p2.x())-1.0, qMin(p2.y(), p1.y())-1.0, fabs(p2.x()-p1.x())+1.0, fabs(p2.y()-p1.y())+1.0), QBrush(trueColor)); + //painter.setPen(QPen(trueColor)); + //painter.drawRect(QRectF(qMin(p1.x(), p2.x()), qMin(p2.y(), p1.y()), fabs(p2.x()-p1.x()), fabs(p2.y()-p1.y()))); + } + } else { + if (falseColor.alpha()>0) { + //painter.setPen(QPen(falseColor)); + painter.fillRect(QRectF(qMin(p1.x(), p2.x())-1.0, qMin(p2.y(), p1.y())-1.0, fabs(p2.x()-p1.x())+1.0, fabs(p2.y()-p1.y())+1.0), QBrush(falseColor)); + //painter.drawRect(QRectF(qMin(p1.x(), p2.x()), qMin(p2.y(), p1.y()), fabs(p2.x()-p1.x()), fabs(p2.y()-p1.y()))); + } + } + } else { + QPointF p=(p1+p2)/2.0; + if (data[ix+iy*Nx]) { + JKQTPPlotSymbol(painter, p.x(), p.y(), symbol, fabs(p2.x()-p1.x())*symbolSizeFactor, parent->pt2px(painter, symbolWidth*parent->getLineWidthMultiplier()), trueColor, trueColor.lighter()); + } + } + } + } + + } +} + + + + + + + + + + + + + + + +JKQTPColumnOverlayImageEnhanced::JKQTPColumnOverlayImageEnhanced(JKQTBasePlotter *parent): + JKQTPOverlayImageEnhanced(parent) +{ + imageColumn=-1; +} + +JKQTPColumnOverlayImageEnhanced::JKQTPColumnOverlayImageEnhanced(JKQTPlotter *parent): + JKQTPOverlayImageEnhanced(parent) +{ + imageColumn=-1; +} +void JKQTPColumnOverlayImageEnhanced::draw(JKQTPEnhancedPainter &painter) { + double* d=parent->getDatastore()->getColumn(imageColumn).getPointer(0); + int imgSize=parent->getDatastore()->getColumn(imageColumn).getRows(); + this->data=(bool*)malloc(imgSize*sizeof(bool)); + this->Ny=imgSize/this->Nx; + for (int i=0; i JKQTPOverlayImage::getDataAsDoubleVector() const +{ + return JKQTPImagePlot_BarrayToDVector(data, Nx*Ny); + +} + +void JKQTPOverlayImage::setTitle(const QString &title) +{ + JKQTPImageBase::setTitle(title); + QString t=title; + if (t.isEmpty()) t="JKQTPOverlayImage"; + actSaveImage->setText(tr("Save %1 ...").arg(t)); + actCopyImage->setText(tr("Copy %1 ...").arg(t)); + +} + +void JKQTPOverlayImage::setParent(JKQTBasePlotter *parent) +{ + if (this->parent) { + this->parent->deregisterAdditionalAction(actSaveImage); + this->parent->deregisterAdditionalAction(actCopyImage); + + } + JKQTPImageBase::setParent(parent); + + if (parent) { + parent->registerAdditionalAction(tr("Save Image Plot Images ..."), actSaveImage); + parent->registerAdditionalAction(tr("Copy Image Plot Images ..."), actCopyImage); + + } + actSaveImage->setEnabled(parent); + actCopyImage->setEnabled(parent); + +} + +void JKQTPOverlayImage::saveImagePlotAsImage(const QString &filename, const QByteArray &outputFormat) +{ + if (parent) { + parent->loadUserSettings(); + QString currentSaveDirectory=parent->getCurrentSaveDirectory(); + QString currentFileFormat=parent->getCurrentFileFormat(); + QString fn=filename; + QStringList filt; + QList writerformats=QImageWriter::supportedImageFormats(); + for (int i=0; isetCurrentFileFormat(currentFileFormat); + parent->setCurrentSaveDirectory(currentSaveDirectory); + parent->saveUserSettings(); + if (!fn.isEmpty()) { + int filtID=filt.indexOf(selFormat); + QString form="NONE"; + if (filtID>=0 && filtID0) { + form =outputFormat; + } + + QImage image=drawImage(); + + if (form=="NONE") image.save(fn); + else image.save(fn, form.toLatin1().data()); + } + } +} + +void JKQTPOverlayImage::copyImagePlotAsImage() +{ + QClipboard* clip=QApplication::clipboard(); + if (clip) { + clip->setPixmap(QPixmap::fromImage(drawImage())); + } +} + diff --git a/lib/jkqtplotter/jkqtpgraphsimageoverlays.h b/lib/jkqtplotter/jkqtpgraphsimageoverlays.h new file mode 100644 index 0000000000..babf5d0b0b --- /dev/null +++ b/lib/jkqtplotter/jkqtpgraphsimageoverlays.h @@ -0,0 +1,304 @@ +/* + Copyright (c) 2008-2019 Jan W. Krieger & Sebastian Isbaner (contour plot) + + + + 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 . +*/ + + +#ifndef JKQTPGRAPHSIMAGEOVERLAYS_H +#define JKQTPGRAPHSIMAGEOVERLAYS_H + + +#include +#include +#include +#include +#include "jkqtplotter/jkqtpgraphs.h" +#include "jkqtplottertools/jkqtptools.h" +#include "jkqtplotter/jkqtpbaseelements.h" +#include "jkqtplotter/jkqtpgraphsimage.h" +#include "jkqtplottertools/jkqtp_imexport.h" +#include "jkqtplottertools/jkqtpimagetools.h" + + + +/*! \brief class to plot an image from an 2-dimensional array of boolean values: alle \c true values are plotted in a given color, while the \c false pixels are drawn in another (default: transparent) + \ingroup jkqtplotter_imagelots_overlays + + \image html overlayimage.png + + */ +class JKQTP_LIB_EXPORT JKQTPOverlayImage: public JKQTPImageBase { + Q_OBJECT + public: + + /** \brief class constructor */ + JKQTPOverlayImage(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTBasePlotter* parent=nullptr); + JKQTPOverlayImage(JKQTBasePlotter* parent=nullptr); + + /** \brief class constructor */ + JKQTPOverlayImage(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTPlotter* parent); + JKQTPOverlayImage(JKQTPlotter* parent); + + /** \brief plots the graph to the plotter object specified as parent */ + virtual void draw(JKQTPEnhancedPainter& painter) override; + + /*! \brief return the plotted image only as a QImage */ + virtual QImage drawImage(); + + /** \brief plots a key marker inside the specified rectangle \a rect */ + virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) override; + /** \brief returns the color to be used for the key label */ + virtual QColor getKeyLabelColor() override; + + /*! \copydoc trueColor + \see see trueColor for details */ + inline virtual void setTrueColor(const QColor & __value) + { + this->trueColor = __value; + } + /*! \copydoc trueColor + \see see trueColor for details */ + inline virtual QColor getTrueColor() const + { + return this->trueColor; + } + /*! \copydoc falseColor + \see see falseColor for details */ + inline virtual void setFalseColor(const QColor & __value) + { + this->falseColor = __value; + } + /*! \copydoc falseColor + \see see falseColor for details */ + inline virtual QColor getFalseColor() const + { + return this->falseColor; + } + /*! \copydoc Nx + \see see Nx for details */ + inline virtual void setNx(int __value) + { + this->Nx = __value; + } + /*! \copydoc Nx + \see see Nx for details */ + inline virtual int getNx() const + { + return this->Nx; + } + /*! \copydoc Ny + \see see Ny for details */ + inline virtual void setNy(int __value) + { + this->Ny = __value; + } + /*! \copydoc Ny + \see see Ny for details */ + inline virtual int getNy() const + { + return this->Ny; + } + /*! \copydoc data + \see see data for details */ + inline virtual void setData(bool* __value) + { + this->data = __value; + } + /*! \copydoc data + \see see data for details */ + inline virtual bool* getData() const + { + return this->data; + } + + void setData(bool* data, int Nx, int Ny); + + QVector getDataAsDoubleVector() const; + + protected: + /** \brief points to the data array, holding the image */ + bool* data; + /** \brief width of the data array data in pt */ + int Nx; + /** \brief height of the data array data in pt */ + int Ny; + + /** \brief color for \c true pixels */ + QColor trueColor; + /** \brief color for \c false pixels */ + QColor falseColor; + + protected: + QAction* actSaveImage; + QAction* actCopyImage; + public: + virtual void setTitle(const QString& title) override; + virtual void setParent(JKQTBasePlotter* parent) override; + public slots: + void saveImagePlotAsImage(const QString &filename=QString(""), const QByteArray &outputFormat=QByteArray()); + void copyImagePlotAsImage(); + +}; + + + +/*! \brief class to plot an image from an 2-dimensional array of boolean values: alle \c true values are plotted in a given color, while the \c false pixels are drawn in another (default: transparent) + \ingroup jkqtplotter_imagelots_overlays + + In contrast to JKQTPOverlayImage this class draws ist contents as rectangles, not as semi-transparent image. This may lead to nicer results,but could be slower. + Also it is possible to draw other types of markers (cross, circles, ...) + + \image html overlayimageenhanced.png + */ +class JKQTP_LIB_EXPORT JKQTPOverlayImageEnhanced: public JKQTPOverlayImage { + Q_OBJECT + public: + /** \brief class constructor */ + JKQTPOverlayImageEnhanced(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTBasePlotter* parent=nullptr); + JKQTPOverlayImageEnhanced(JKQTBasePlotter* parent=nullptr); + /** \brief class constructor */ + JKQTPOverlayImageEnhanced(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTPlotter* parent); + JKQTPOverlayImageEnhanced(JKQTPlotter* parent); + + /** \brief plots the graph to the plotter object specified as parent */ + virtual void draw(JKQTPEnhancedPainter& painter) override; + /** \brief plots a key marker inside the specified rectangle \a rect */ + virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) override; + + /*! \copydoc symbol + \see see symbol for details */ + inline virtual void setSymbol(const JKQTPGraphSymbols & __value) + { + this->symbol = __value; + } + /*! \copydoc symbol + \see see symbol for details */ + inline virtual JKQTPGraphSymbols getSymbol() const + { + return this->symbol; + } + /*! \copydoc symbolWidth + \see see symbolWidth for details */ + inline virtual void setSymbolWidth(double __value) + { + this->symbolWidth = __value; + } + /*! \copydoc symbolWidth + \see see symbolWidth for details */ + inline virtual double getSymbolWidth() const + { + return this->symbolWidth; + } + /*! \copydoc drawAsRectangles + \see see drawAsRectangles for details */ + inline virtual void setDrawAsRectangles(bool __value) + { + this->drawAsRectangles = __value; + } + /*! \copydoc drawAsRectangles + \see see drawAsRectangles for details */ + inline virtual bool getDrawAsRectangles() const + { + return this->drawAsRectangles; + } + /*! \copydoc rectanglesAsImageOverlay + \see see rectanglesAsImageOverlay for details */ + inline virtual void setRectanglesAsImageOverlay(bool __value) + { + this->rectanglesAsImageOverlay = __value; + } + /*! \copydoc rectanglesAsImageOverlay + \see see rectanglesAsImageOverlay for details */ + inline virtual bool getRectanglesAsImageOverlay() const + { + return this->rectanglesAsImageOverlay; + } + /*! \copydoc symbolSizeFactor + \see see symbolSizeFactor for details */ + inline virtual void setSymbolSizeFactor(double __value) + { + this->symbolSizeFactor = __value; + } + /*! \copydoc symbolSizeFactor + \see see symbolSizeFactor for details */ + inline virtual double getSymbolSizeFactor() const + { + return this->symbolSizeFactor; + } + + protected: + /** \brief which symbol to use for the datapoints */ + JKQTPGraphSymbols symbol; + /** \brief width (in pt) of the lines used to plot the symbol for the data points */ + double symbolWidth; + + /** \brief indicates whether to draw filled rectangles (\c false, default) or symbols */ + bool drawAsRectangles; + + /** \brief a rescaling factor for the symbols */ + double symbolSizeFactor; + + /** \brief when \c drawAsRectangles==true this reactivates the drawing from JKQTPOverlayImage, i.e. the overlay is not drawn as separated rectangles, but as an overlay image */ + bool rectanglesAsImageOverlay; + +}; + + + + +/*! \brief class to plot an image from an 2-dimensional array of boolean values: alle \c true values are plotted in a given color, while the \c false pixels are drawn in another (default: transparent) + \ingroup jkqtplotter_imagelots_overlays + + In contrast to JKQTPOverlayImage this class draws ist contents as rectangles, not as semi-transparent image. This may lead to nicer results,but could be slower. + Also it is possible to draw other types of markers (cross, circles, ...) + + \image html overlayimageenhanced.png + + */ +class JKQTP_LIB_EXPORT JKQTPColumnOverlayImageEnhanced: public JKQTPOverlayImageEnhanced { + Q_OBJECT + public: + JKQTPColumnOverlayImageEnhanced(JKQTBasePlotter* parent=nullptr); + JKQTPColumnOverlayImageEnhanced(JKQTPlotter* parent); + + /*! \copydoc imageColumn + \see see imageColumn for details */ + inline virtual void setImageColumn(int __value) + { + this->imageColumn = __value; + } + /*! \copydoc imageColumn + \see see imageColumn for details */ + inline virtual int getImageColumn() const + { + return this->imageColumn; + } + /** \brief plots the graph to the plotter object specified as parent */ + virtual void draw(JKQTPEnhancedPainter& painter) override; + + /** \copydoc JKQTPGraph::usesColumn() */ + virtual bool usesColumn(int c) const override; + + + protected: + /** \brief top color bar visible */ + int imageColumn; +}; + + +#endif // JKQTPGRAPHSIMAGEOVERLAYS_H + diff --git a/lib/jkqtplotter/jkqtpgraphsimagergb.cpp b/lib/jkqtplotter/jkqtpgraphsimagergb.cpp new file mode 100644 index 0000000000..925f92bab1 --- /dev/null +++ b/lib/jkqtplotter/jkqtpgraphsimagergb.cpp @@ -0,0 +1,997 @@ +/* + Copyright (c) 2008-2019 Jan W. Krieger + + + + 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 . +*/ + + +#include "jkqtplotter/jkqtpgraphsimagergb.h" +#include "jkqtplotter/jkqtpbaseplotter.h" +#include "jkqtplottertools/jkqtpimagetools.h" +#include "jkqtplottertools/jkqtptools.h" +#include "jkqtplottertools/jkqtpenhancedpainter.h" +#include "jkqtplotter/jkqtplotter.h" +#include +#include +#include +#include +#include +#include + + + +void JKQTPRGBMathImage::initObject() +{ + actSaveImage=new QAction(tr("Save JKQTPRGBMathImage ..."), this); + connect(actSaveImage, SIGNAL(triggered()), this, SLOT(saveImagePlotAsImage())); + actCopyImage=new QAction(tr("Copy JKQTPRGBMathImage ..."), this); + connect(actCopyImage, SIGNAL(triggered()), this, SLOT(copyImagePlotAsImage())); + + rgbMode=JKQTPRGBMathImageModeRGBMode; + colorBarRightAxis=new JKQTPVerticalIndependentAxis(0, 100, 0, 100, parent); + colorBarRightAxis->setDrawMode1(JKQTPCADMLine); + colorBarRightAxis->setDrawMode2(JKQTPCADMcomplete); + colorBarRightAxis->setAxisLabel(""); + colorBarRightAxis->setMinTicks(5); + colorBarRightAxis->setMinorTicks(0); + colorBarRightAxis->setTickOutsideLength(0); + colorBarRightAxis->setMinorTickOutsideLength(0); + colorBarRightAxis->setShowZeroAxis(false); + colorBarTopAxis=new JKQTPHorizontalIndependentAxis(0, 100, 0, 100, parent); + colorBarTopAxis->setDrawMode1(JKQTPCADMLine); + colorBarTopAxis->setDrawMode2(JKQTPCADMcomplete); + colorBarTopAxis->setAxisLabel(""); + colorBarTopAxis->setMinTicks(3); + colorBarTopAxis->setMinorTicks(0); + colorBarTopAxis->setTickOutsideLength(0); + colorBarTopAxis->setMinorTickOutsideLength(0); + colorBarTopAxis->setShowZeroAxis(false); + + colorBarRightAxisG=new JKQTPVerticalIndependentAxis(0, 100, 0, 100, parent); + colorBarRightAxisG->setDrawMode1(JKQTPCADMLine); + colorBarRightAxisG->setDrawMode2(JKQTPCADMcomplete); + colorBarRightAxisG->setAxisLabel(""); + colorBarRightAxisG->setMinTicks(5); + colorBarRightAxisG->setShowZeroAxis(false); + colorBarRightAxisG->setMinorTicks(0); + colorBarRightAxisG->setTickOutsideLength(0); + colorBarRightAxisG->setMinorTickOutsideLength(0); + colorBarTopAxisG=new JKQTPHorizontalIndependentAxis(0, 100, 0, 100, parent); + colorBarTopAxisG->setDrawMode1(JKQTPCADMLine); + colorBarTopAxisG->setDrawMode2(JKQTPCADMcomplete); + colorBarTopAxisG->setAxisLabel(""); + colorBarTopAxisG->setMinTicks(3); + colorBarTopAxisG->setShowZeroAxis(false); + colorBarTopAxisG->setMinorTicks(0); + colorBarTopAxisG->setTickOutsideLength(0); + colorBarTopAxisG->setMinorTickOutsideLength(0); + + colorBarRightAxisB=new JKQTPVerticalIndependentAxis(0, 100, 0, 100, parent); + colorBarRightAxisB->setDrawMode1(JKQTPCADMLine); + colorBarRightAxisB->setDrawMode2(JKQTPCADMcomplete); + colorBarRightAxisB->setAxisLabel(""); + colorBarRightAxisB->setMinTicks(5); + colorBarRightAxisB->setShowZeroAxis(false); + colorBarRightAxisB->setMinorTicks(0); + colorBarRightAxisB->setTickOutsideLength(0); + colorBarRightAxisB->setMinorTickOutsideLength(0); + colorBarTopAxisB=new JKQTPHorizontalIndependentAxis(0, 100, 0, 100, parent); + colorBarTopAxisB->setDrawMode1(JKQTPCADMLine); + colorBarTopAxisB->setDrawMode2(JKQTPCADMcomplete); + colorBarTopAxisB->setAxisLabel(""); + colorBarTopAxisB->setMinTicks(3); + colorBarTopAxisB->setShowZeroAxis(false); + colorBarTopAxisB->setMinorTicks(0); + colorBarTopAxisB->setTickOutsideLength(0); + colorBarTopAxisB->setMinorTickOutsideLength(0); + + + this->colorBarTopVisible=true; + this->colorBarRightVisible=true; + this->imageNameFontSize=parent->getKeyFontSize(); + this->imageName=""; + this->showColorBar=true; + this->colorBarWidth=14; + this->colorBarRelativeHeight=0.75; + this->autoImageRange=true; + this->imageMin=0; + this->imageMax=1; + this->imageMinG=0; + this->imageMaxG=1; + this->imageMinB=0; + this->imageMaxB=1; + this->colorBarOffset=4; + this->colorBarTopVisible=false; + this->colorBarRightVisible=true; + this->colorbarsSideBySide=true; +} + + + +JKQTPRGBMathImage::JKQTPRGBMathImage(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTBasePlotter *parent): + JKQTPMathImageBase(x, y, width, height, datatype, data, Nx, Ny, parent) +{ + initObject(); +} + + +JKQTPRGBMathImage::JKQTPRGBMathImage(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTPlotter *parent): + JKQTPMathImageBase(x, y, width, height, datatype, data, Nx, Ny, parent) +{ + initObject(); +} + +JKQTPRGBMathImage::JKQTPRGBMathImage(JKQTBasePlotter *parent): + JKQTPMathImageBase(0,0,0,0, DoubleArray, nullptr, 0, 0, parent) +{ + initObject(); +} + + +JKQTPRGBMathImage::JKQTPRGBMathImage(JKQTPlotter *parent): + JKQTPMathImageBase(0,0,0,0, DoubleArray, nullptr, 0, 0, parent) +{ + initObject(); +} + +void JKQTPRGBMathImage::setParent(JKQTBasePlotter* parent) { + if (this->parent) { + this->parent->deregisterAdditionalAction(actSaveImage); + this->parent->deregisterAdditionalAction(actCopyImage); + } + JKQTPMathImageBase::setParent(parent); + colorBarRightAxis->setParent(parent); + colorBarTopAxis->setParent(parent); + + if (parent) { + parent->registerAdditionalAction(tr("Save Image Plot Images ..."), actSaveImage); + parent->registerAdditionalAction(tr("Copy Image Plot Images ..."), actCopyImage); + } + actSaveImage->setEnabled(parent); + actCopyImage->setEnabled(parent); + +} + + + +void JKQTPRGBMathImage::draw(JKQTPEnhancedPainter& painter) { + ensureImageData(); + if (!data && !dataG && !dataB) return; + QImage img=drawImage(); + plotImage(painter, img, x, y, width, height); +} + + + +void JKQTPRGBMathImage::getOutsideSize(JKQTPEnhancedPainter& painter, int& leftSpace, int& rightSpace, int& topSpace, int& bottomSpace) { + ensureImageData(); + JKQTPGraph::getOutsideSize(painter, leftSpace, rightSpace, topSpace, bottomSpace); + if (showColorBar) { + int visibleColorBars=0; + if (data) visibleColorBars++; + if (dataG) visibleColorBars++; + if (dataB) visibleColorBars++; + double sizeFactor=0.8/double(visibleColorBars); + if (!colorbarsSideBySide) sizeFactor=1; + + bool firstC=false; + + getDataMinMax(internalDataMin, internalDataMax); + if (data) { + if (colorBarRightVisible) { + if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) rightSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset); + colorBarRightAxis->setRange(internalDataMin, internalDataMax); + colorBarRightAxis->setAxisWidth(sizeFactor*colorBarRelativeHeight*parent->getPlotHeight()); + colorBarRightAxisB->setAxisLabel(imageName); + QSizeF s2=colorBarRightAxis->getSize2(painter); + QSizeF s1=colorBarRightAxis->getSize1(painter); + if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) rightSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset)+static_cast(s2.width()+s1.width()); + } + if (colorBarTopVisible) { + //if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) topSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset); + colorBarTopAxis->setRange(internalDataMin, internalDataMax); + colorBarTopAxis->setAxisWidth(sizeFactor*colorBarRelativeHeight*parent->getPlotWidth()); + colorBarTopAxisB->setAxisLabel(imageName); + QSizeF s2=colorBarTopAxisB->getSize2(painter); + QSizeF s1=colorBarTopAxisB->getSize2(painter); + if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) topSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset)+static_cast(s2.height()+s1.height()); + } + firstC=true; + } + + getDataMinMaxG(internalDataMinG, internalDataMaxG); + if (dataG) { + if (colorBarRightVisible) { + if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) rightSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset); + colorBarRightAxisG->setRange(internalDataMinG, internalDataMaxG); + colorBarRightAxisG->setAxisWidth(sizeFactor*colorBarRelativeHeight*parent->getPlotHeight()); + colorBarRightAxisB->setAxisLabel(imageNameG); + QSizeF s2=colorBarRightAxis->getSize2(painter); + QSizeF s1=colorBarRightAxis->getSize1(painter); + if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) rightSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset)+static_cast(s2.width()+s1.width()); + } + if (colorBarTopVisible) { + //if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) topSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset); + colorBarTopAxisG->setRange(internalDataMinG, internalDataMaxG); + colorBarTopAxisG->setAxisWidth(sizeFactor*colorBarRelativeHeight*parent->getPlotWidth()); + colorBarTopAxisB->setAxisLabel(imageNameG); + QSizeF s2=colorBarTopAxisB->getSize2(painter); + QSizeF s1=colorBarTopAxisB->getSize1(painter); + if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) topSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset)+static_cast(s2.height()+s1.height()); + } + firstC=true; + } + + getDataMinMaxB(internalDataMinB, internalDataMaxB); + if (dataB) { + if (colorBarRightVisible) { + if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) rightSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset); + colorBarRightAxisB->setRange(internalDataMinB, internalDataMaxB); + colorBarRightAxisB->setAxisWidth(sizeFactor*colorBarRelativeHeight*parent->getPlotHeight()); + colorBarRightAxisB->setAxisLabel(imageNameB); + QSizeF s2=colorBarRightAxis->getSize2(painter); + QSizeF s1=colorBarRightAxis->getSize1(painter); + if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) rightSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset)+static_cast(s2.width()+s1.width()); + } + if (colorBarTopVisible) { + //if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) topSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset); + colorBarTopAxisB->setRange(internalDataMinB, internalDataMaxB); + colorBarTopAxisB->setAxisWidth(sizeFactor*colorBarRelativeHeight*parent->getPlotWidth()); + colorBarTopAxisB->setAxisLabel(imageNameB); + QSizeF s2=colorBarTopAxisB->getSize2(painter); + QSizeF s1=colorBarTopAxisB->getSize1(painter); + if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) topSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset)+static_cast(s2.height()+s1.height()); + } + firstC=true; + } + } +} + +struct RGBOutsizeData { + double internalDataMin; + double internalDataMax; + void* data; + JKQTPVerticalIndependentAxis* colorBarRightAxis; + JKQTPHorizontalIndependentAxis* colorBarTopAxis; + QString name; + JKQTPMathImageColorPalette palette; + QImage paletteImage; +}; + +void JKQTPRGBMathImage::drawOutside(JKQTPEnhancedPainter& painter, QRect /*leftSpace*/, QRect rightSpace, QRect topSpace, QRect /*bottomSpace*/) { + ensureImageData(); + if (showColorBar) { + QList l; + int visibleColorBars=0; + const int pd_size=200; + uint8_t pd[pd_size]; + for (int i=0; i(pd, 1, pd_size, d.paletteImage, d.palette, 0, pd_size-1); + } else if (rgbMode==JKQTPRGBMathImageModeCMYMode) { + d.palette=JKQTPMathImageINVERTED_CYANWHITE; + d.paletteImage=QImage(1, pd_size, QImage::Format_ARGB32); + JKQTPImagePlot_array2image(pd, 1, pd_size, d.paletteImage, d.palette, 0, pd_size-1); + } else if (rgbMode==JKQTPRGBMathImageModeHSVMode || rgbMode==JKQTPRGBMathImageModeHSLMode) { + d.palette=JKQTPMathImageHSV; + d.paletteImage=QImage(1, pd_size, QImage::Format_ARGB32); + JKQTPImagePlot_array2image(pd, 1, pd_size, d.paletteImage, d.palette, 0, pd_size-1); + } + + l<(pd, 1, pd_size, d.paletteImage, d.palette, 0, 199); + if (rgbMode==JKQTPRGBMathImageModeRGBMode) { + d.palette=JKQTPMathImageGREEN; + d.paletteImage=QImage(1, pd_size, QImage::Format_ARGB32); + JKQTPImagePlot_array2image(pd, 1, pd_size, d.paletteImage, d.palette, 0, pd_size-1); + } else if (rgbMode==JKQTPRGBMathImageModeCMYMode) { + d.palette=JKQTPMathImageINVERTED_MAGENTAWHITE; + d.paletteImage=QImage(1, pd_size, QImage::Format_ARGB32); + JKQTPImagePlot_array2image(pd, 1, pd_size, d.paletteImage, d.palette, 0, pd_size-1); + } else if (rgbMode==JKQTPRGBMathImageModeHSVMode) { + d.palette=JKQTPMathImageGRAY; + d.paletteImage=QImage(1, pd_size, QImage::Format_ARGB32); + //JKQTPImagePlot_array2image(pd, 1, pd_size, d.paletteImage, l[li].palette, 0, pd_size-1); + QRgb* line=reinterpret_cast(d.paletteImage.scanLine(0)); + for (int i=0; i(pd, 1, pd_size, d.paletteImage, l[li].palette, 0, pd_size-1); + QRgb* line=reinterpret_cast(d.paletteImage.scanLine(0)); + for (int i=0; i(pd, 1, pd_size, d.paletteImage, d.palette, 0, 199); + if (rgbMode==JKQTPRGBMathImageModeRGBMode) { + d.palette=JKQTPMathImageBLUE; + d.paletteImage=QImage(1, pd_size, QImage::Format_ARGB32); + JKQTPImagePlot_array2image(pd, 1, pd_size, d.paletteImage, d.palette, 0, pd_size-1); + } else if (rgbMode==JKQTPRGBMathImageModeCMYMode) { + d.palette=JKQTPMathImageINVERTED_YELLOWWHITE; + d.paletteImage=QImage(1, pd_size, QImage::Format_ARGB32); + JKQTPImagePlot_array2image(pd, 1, pd_size, d.paletteImage, d.palette, 0, pd_size-1); + } else if (rgbMode==JKQTPRGBMathImageModeHSVMode) { + d.palette=JKQTPMathImageGRAY; + d.paletteImage=QImage(1, pd_size, QImage::Format_ARGB32); + //JKQTPImagePlot_array2image(pd, 1, pd_size, d.paletteImage, l[li].palette, 0, pd_size-1); + QRgb* line=reinterpret_cast(d.paletteImage.scanLine(0)); + for (int i=0; i(pd, 1, pd_size, d.paletteImage, l[li].palette, 0, pd_size-1); + QRgb* line=reinterpret_cast(d.paletteImage.scanLine(0)); + for (int i=0; i(round(static_cast(rightSpace.height())*icolorBarRelativeHeight))); + int gbarWidth=qMax(1, static_cast(round(static_cast(topSpace.width())*icolorBarRelativeHeight))); + + + + double rX=rightSpace.x()+parent->pt2px(painter, colorBarOffset); + double rY=rightSpace.top()+(rightSpace.height()-gbarHeight)/2; + double tX=topSpace.x()+(topSpace.width()-gbarWidth)/2; + double tY=topSpace.bottom()-parent->pt2px(painter, colorBarOffset+colorBarWidth); + if(colorbarsSideBySide) { + rY=rightSpace.top()+(rightSpace.height()-gbarHeight*visibleColorBars)/2; + tX=topSpace.x()+(topSpace.width()-gbarWidth*visibleColorBars)/2; + } + + + for (int li=0; lipt2px(painter, colorBarWidth), gbarHeight); + painter.drawImage(cb, l[li].paletteImage.mirrored(true, false)); + QPen p=painter.pen(); + p.setColor(l[li].colorBarRightAxis->getAxisColor()); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, l[li].colorBarRightAxis->getLineWidth()*parent->getLineWidthMultiplier()))); + painter.setPen(p); + painter.drawRect(cb); + + l[li].colorBarRightAxis->setRange(l[li].internalDataMin, l[li].internalDataMax); + l[li].colorBarRightAxis->setAxisWidth(cb.height()); + l[li].colorBarRightAxis->setAxisOffset(cb.top()); + l[li].colorBarRightAxis->setOtherAxisOffset(cb.left()); + l[li].colorBarRightAxis->setOtherAxisWidth(cb.width()); + l[li].colorBarRightAxis->setLabelFontSize(imageNameFontSize*parent->getFontSizeMultiplier()); + l[li].colorBarRightAxis->setAxisLabel(l[li].name); + l[li].colorBarRightAxis->drawAxes(painter); + + + + if (!colorbarsSideBySide) { + rX=rX+static_cast(rightSpace.width())/static_cast(visibleColorBars); + } else { + rY=rY+static_cast(rightSpace.height())*shiftSizeFactor*colorBarRelativeHeight; + } + } + if (colorBarTopVisible) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + + + QRect cb(tX, tY, gbarWidth, parent->pt2px(painter, colorBarWidth)); + QMatrix mt; + mt.rotate(90); + painter.drawImage(cb, l[li].paletteImage.transformed(mt)); + QPen p=painter.pen(); + p.setColor(l[li].colorBarTopAxis->getAxisColor()); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, l[li].colorBarTopAxis->getLineWidth()*parent->getLineWidthMultiplier()))); + painter.setPen(p); + painter.drawRect(cb); + + + l[li].colorBarTopAxis->setRange(l[li].internalDataMin, l[li].internalDataMax); + l[li].colorBarTopAxis->setAxisWidth(cb.width()); + l[li].colorBarTopAxis->setAxisOffset(cb.left()); + l[li].colorBarTopAxis->setOtherAxisOffset(cb.top()); + l[li].colorBarTopAxis->setOtherAxisWidth(cb.height()); + l[li].colorBarTopAxis->setLabelFontSize(imageNameFontSize*parent->getFontSizeMultiplier()); + l[li].colorBarTopAxis->setAxisLabel(l[li].name); + l[li].colorBarTopAxis->drawAxes(painter); + + + if (!colorbarsSideBySide) { + tY=tY-topSpace.height()/double(visibleColorBars); + } else { + tX=tX+topSpace.width()*shiftSizeFactor*colorBarRelativeHeight; + } + } + } + } + +} + +void JKQTPRGBMathImage::getDataMinMax(double& imin, double& imax) { + ensureImageData(); + if (autoImageRange) { + JKQTPMathImageBase::getDataMinMax(imin, imax); + } else { + imin=imageMin; + imax=imageMax; + } +} + +void JKQTPRGBMathImage::getDataMinMaxG(double& imin, double& imax) { + ensureImageData(); + if (autoImageRange) { + imin=imax=0; + if (!dataG) return; + switch(datatype) { + case JKQTPMathImageBase::DoubleArray: + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); + break; + case JKQTPMathImageBase::FloatArray: + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); + break; + case JKQTPMathImageBase::UInt8Array: + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); + break; + case JKQTPMathImageBase::UInt16Array: + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); + break; + case JKQTPMathImageBase::UInt32Array: + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); + break; + case JKQTPMathImageBase::UInt64Array: + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); + break; + case JKQTPMathImageBase::Int8Array: + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); + break; + case JKQTPMathImageBase::Int16Array: + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); + break; + case JKQTPMathImageBase::Int32Array: + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); + break; + case JKQTPMathImageBase::Int64Array: + imin= JKQTPImagePlot_getImageMin(static_cast(dataG), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataG), Nx, Ny); + break; + } + } else { + imin=imageMinG; + imax=imageMaxG; + } +} + +void JKQTPRGBMathImage::getDataMinMaxB(double& imin, double& imax) { + ensureImageData(); + if (autoImageRange) { + imin=imax=0; + if (!dataG) return; + switch(datatype) { + case JKQTPMathImageBase::DoubleArray: + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); + break; + case JKQTPMathImageBase::FloatArray: + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); + break; + case JKQTPMathImageBase::UInt8Array: + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); + break; + case JKQTPMathImageBase::UInt16Array: + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); + break; + case JKQTPMathImageBase::UInt32Array: + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); + break; + case JKQTPMathImageBase::UInt64Array: + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); + break; + case JKQTPMathImageBase::Int8Array: + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); + break; + case JKQTPMathImageBase::Int16Array: + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); + break; + case JKQTPMathImageBase::Int32Array: + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); + break; + case JKQTPMathImageBase::Int64Array: + imin= JKQTPImagePlot_getImageMin(static_cast(dataB), Nx, Ny); + imax= JKQTPImagePlot_getImageMax(static_cast(dataB), Nx, Ny); + break; + } + } else { + imin=imageMinB; + imax=imageMaxB; + } +} + +double JKQTPRGBMathImage::getValueAt(double x, double y, int channel) +{ + ensureImageData(); + void* dd=data; + if (channel==0) dd=data; + if (channel==1) dd=dataG; + if (channel==2) dd=dataB; + int xx=static_cast(trunc((x-this->x)/width*Nx)); + int yy=static_cast(trunc((y-this->y)/height*Ny)); + if (xx>=0 && xx=0 && yy((static_cast(dd))[yy*Nx+xx]); break; + case JKQTPMathImageBase::FloatArray: return static_cast((static_cast(dd))[yy*Nx+xx]); break; + case JKQTPMathImageBase::UInt8Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; + case JKQTPMathImageBase::UInt16Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; + case JKQTPMathImageBase::UInt32Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; + case JKQTPMathImageBase::UInt64Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; + case JKQTPMathImageBase::Int8Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; + case JKQTPMathImageBase::Int16Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; + case JKQTPMathImageBase::Int32Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; + case JKQTPMathImageBase::Int64Array: return static_cast((static_cast(dd))[yy*Nx+xx]); break; + } } + return 0.0; +} + +void JKQTPRGBMathImage::drawKeyMarker(JKQTPEnhancedPainter &painter, QRectF &rect) +{ + painter.drawImage(rect, QPixmap(":/JKQTPlotter/jkqtp_plot_rgbimage.png").toImage()); +} + +void JKQTPRGBMathImage::setTitle(const QString &title) +{ + JKQTPImageBase::setTitle(title); + QString t=title; + if (t.isEmpty()) t="JKQTPRGBMathImage"; + actSaveImage->setText(tr("Save %1 ...").arg(t)); + actCopyImage->setText(tr("Copy %1 ...").arg(t)); +} + +void JKQTPRGBMathImage::saveImagePlotAsImage(const QString &filename, const QByteArray &outputFormat) +{ + if (parent) { + parent->loadUserSettings(); + QString currentSaveDirectory=parent->getCurrentSaveDirectory(); + QString currentFileFormat=parent->getCurrentFileFormat(); + QString fn=filename; + QStringList filt; + QList writerformats=QImageWriter::supportedImageFormats(); + for (int i=0; isetCurrentFileFormat(currentFileFormat); + parent->setCurrentSaveDirectory(currentSaveDirectory); + parent->saveUserSettings(); + if (!fn.isEmpty()) { + int filtID=filt.indexOf(selFormat); + QString form="NONE"; + if (filtID>=0 && filtID0) { + form =outputFormat; + } + + QImage image=drawImage(); + + if (form=="NONE") image.save(fn); + else image.save(fn, form.toLatin1().data()); + } + } +} + +void JKQTPRGBMathImage::copyImagePlotAsImage() +{ + QClipboard* clip=QApplication::clipboard(); + if (clip) { + clip->setPixmap(QPixmap::fromImage(drawImage())); + } +} + +QImage JKQTPRGBMathImage::drawImage() { + ensureImageData(); + if (!data && !dataG && !dataB) return QImage(); + QImage img(Nx, Ny, QImage::Format_ARGB32); + + if (rgbMode==JKQTPRGBMathImageModeRGBMode) { + img.fill(Qt::transparent); + } else if (rgbMode==JKQTPRGBMathImageModeCMYMode) { + img.fill(Qt::white); + } else if (rgbMode==JKQTPRGBMathImageModeHSVMode) { + QColor c("white"); + c.setHsv(0,255,255); + img.fill(c.rgba()); + } else if (rgbMode==JKQTPRGBMathImageModeHSLMode) { + QColor c("white"); + c.setHsv(0,255,127); + img.fill(c.rgba()); + } + getDataMinMax(internalDataMin, internalDataMax); + getDataMinMaxG(internalDataMinG, internalDataMaxG); + getDataMinMaxB(internalDataMinB, internalDataMaxB); + int palette = 0; + if (data) { + switch(datatype) { + case JKQTPMathImageBase::DoubleArray: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageBase::FloatArray: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageBase::UInt8Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageBase::UInt16Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageBase::UInt32Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageBase::UInt64Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageBase::Int8Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageBase::Int16Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageBase::Int32Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + case JKQTPMathImageBase::Int64Array: JKQTPImagePlot_array2RGBimage(static_cast(data), Nx, Ny, img, palette, internalDataMin, internalDataMax, rgbMode); break; + } + } + palette = 1; + if (dataG) { + switch(datatypeG) { + case JKQTPMathImageBase::DoubleArray: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageBase::FloatArray: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageBase::UInt8Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageBase::UInt16Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageBase::UInt32Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageBase::UInt64Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageBase::Int8Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageBase::Int16Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageBase::Int32Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + case JKQTPMathImageBase::Int64Array: JKQTPImagePlot_array2RGBimage(static_cast(dataG), Nx, Ny, img, palette, internalDataMinG, internalDataMaxG, rgbMode); break; + } + } + palette = 2; + if (dataB) { + switch(datatypeB) { + case JKQTPMathImageBase::DoubleArray: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageBase::FloatArray: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageBase::UInt8Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageBase::UInt16Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageBase::UInt32Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageBase::UInt64Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageBase::Int8Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageBase::Int16Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageBase::Int32Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + case JKQTPMathImageBase::Int64Array: JKQTPImagePlot_array2RGBimage(static_cast(dataB), Nx, Ny, img, palette, internalDataMinB, internalDataMaxB, rgbMode); break; + } + } + + modifyImage(img); + + return img; +} + +void JKQTPRGBMathImage::setData(void* data, int Nx, int Ny, DataType datatype) { + this->data=data; + this->datatype=datatype; + this->dataG=nullptr; + this->dataB=nullptr; + this->Nx=Nx; + this->Ny=Ny; +} + +void JKQTPRGBMathImage::setData(void* data, int Nx, int Ny) { + this->data=data; + this->Nx=Nx; + this->Ny=Ny; + this->dataG=nullptr; + this->dataB=nullptr; +} + + +void JKQTPRGBMathImage::setData(void *data, void *dataG, void *dataB, int Nx, int Ny, JKQTPMathImageBase::DataType datatype) { + this->data=data; + this->datatype=datatype; + this->datatypeG=datatype; + this->datatypeB=datatype; + this->dataG=dataG; + this->dataB=dataB; + this->Nx=Nx; + this->Ny=Ny; +} + +void JKQTPRGBMathImage::setData(void *data, void *dataG, void *dataB, int Nx, int Ny) { + this->data=data; + this->dataG=dataG; + this->dataB=dataB; + this->Nx=Nx; + this->Ny=Ny; +} + + + +JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(JKQTBasePlotter *parent): + JKQTPRGBMathImage(0,0,0,0,DoubleArray,nullptr,0,0,parent) +{ + this->modifierColumn=-1; + this->imageRColumn=-1; + this->imageGColumn=-1; + this->imageBColumn=-1; + this->datatype=JKQTPMathImageBase::DoubleArray; +} + +JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int Nx, int Ny, JKQTBasePlotter *parent): + JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) +{ + this->modifierColumn=-1; + this->imageRColumn=-1; + this->imageGColumn=-1; + this->imageBColumn=-1; + this->datatype=JKQTPMathImageBase::DoubleArray; +} + +JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int Nx, int Ny, JKQTBasePlotter *parent): + JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) +{ + this->modifierColumn=-1; + this->imageRColumn=imageRColumn; + this->imageGColumn=-1; + this->imageBColumn=-1; + this->datatype=JKQTPMathImageBase::DoubleArray; +} + +JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int Nx, int Ny, JKQTBasePlotter *parent): + JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) +{ + this->modifierColumn=-1; + this->imageRColumn=imageRColumn; + this->imageGColumn=imageGColumn; + this->imageBColumn=-1; + this->datatype=JKQTPMathImageBase::DoubleArray; +} + +JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int imageBColumn, int Nx, int Ny, JKQTBasePlotter *parent): + JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) +{ + this->modifierColumn=-1; + this->imageRColumn=imageRColumn; + this->imageGColumn=imageGColumn; + this->imageBColumn=imageBColumn; + this->datatype=JKQTPMathImageBase::DoubleArray; +} + +JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(JKQTPlotter *parent): + JKQTPRGBMathImage(0,0,0,0,DoubleArray,nullptr,0,0,parent) +{ + this->modifierColumn=-1; + this->imageRColumn=-1; + this->imageGColumn=-1; + this->imageBColumn=-1; + this->datatype=JKQTPMathImageBase::DoubleArray; +} + +JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int Nx, int Ny, JKQTPlotter *parent): + JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) +{ + this->modifierColumn=-1; + this->imageRColumn=-1; + this->imageGColumn=-1; + this->imageBColumn=-1; + this->datatype=JKQTPMathImageBase::DoubleArray; +} + +JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int Nx, int Ny, JKQTPlotter *parent): + JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) +{ + this->modifierColumn=-1; + this->imageRColumn=imageRColumn; + this->imageGColumn=-1; + this->imageBColumn=-1; + this->datatype=JKQTPMathImageBase::DoubleArray; +} + +JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int Nx, int Ny, JKQTPlotter *parent): + JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) +{ + this->modifierColumn=-1; + this->imageRColumn=imageRColumn; + this->imageGColumn=imageGColumn; + this->imageBColumn=-1; + this->datatype=JKQTPMathImageBase::DoubleArray; +} + +JKQTPColumnRGBMathImage::JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int imageBColumn, int Nx, int Ny, JKQTPlotter *parent): + JKQTPRGBMathImage(x,y,width,height,DoubleArray,nullptr,Nx,Ny,parent) +{ + this->modifierColumn=-1; + this->imageRColumn=imageRColumn; + this->imageGColumn=imageGColumn; + this->imageBColumn=imageBColumn; + this->datatype=JKQTPMathImageBase::DoubleArray; +} +bool JKQTPColumnRGBMathImage::usesColumn(int c) const +{ + return (c==imageRColumn)||(c==imageBColumn)||(c==imageGColumn)||(c==modifierColumn); +} + + +void JKQTPColumnRGBMathImage::ensureImageData() +{ + this->datatype=JKQTPMathImageBase::DoubleArray; + this->datatypeG=JKQTPMathImageBase::DoubleArray; + this->datatypeB=JKQTPMathImageBase::DoubleArray; + this->data=parent->getDatastore()->getColumn(imageRColumn).getPointer(0); + this->dataG=parent->getDatastore()->getColumn(imageGColumn).getPointer(0); + this->dataB=parent->getDatastore()->getColumn(imageBColumn).getPointer(0); + this->Ny=parent->getDatastore()->getColumn(imageRColumn).getRows()/this->Nx; + this->datatypeModifier=JKQTPMathImageBase::DoubleArray; + this->dataModifier=parent->getDatastore()->getColumn(modifierColumn).getPointer(0); +} + + +QVector JKQTPRGBMathImage::getDataGAsDoubleVector() const +{ + switch(datatype) { + case JKQTPMathImageBase::DoubleArray: + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); + break; + case JKQTPMathImageBase::FloatArray: + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); + break; + case JKQTPMathImageBase::UInt8Array: + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); + break; + case JKQTPMathImageBase::UInt16Array: + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); + break; + case JKQTPMathImageBase::UInt32Array: + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); + break; + case JKQTPMathImageBase::UInt64Array: + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); + break; + case JKQTPMathImageBase::Int8Array: + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); + break; + case JKQTPMathImageBase::Int16Array: + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); + break; + case JKQTPMathImageBase::Int32Array: + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); + break; + case JKQTPMathImageBase::Int64Array: + return JKQTPImagePlot_arrayToDVector(static_cast(dataG), Nx*Ny); + break; + } + QVector res; + return res; +} + +QVector JKQTPRGBMathImage::getDataBAsDoubleVector() const +{ + switch(datatype) { + case JKQTPMathImageBase::DoubleArray: + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); + break; + case JKQTPMathImageBase::FloatArray: + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); + break; + case JKQTPMathImageBase::UInt8Array: + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); + break; + case JKQTPMathImageBase::UInt16Array: + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); + break; + case JKQTPMathImageBase::UInt32Array: + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); + break; + case JKQTPMathImageBase::UInt64Array: + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); + break; + case JKQTPMathImageBase::Int8Array: + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); + break; + case JKQTPMathImageBase::Int16Array: + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); + break; + case JKQTPMathImageBase::Int32Array: + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); + break; + case JKQTPMathImageBase::Int64Array: + return JKQTPImagePlot_arrayToDVector(static_cast(dataB), Nx*Ny); + break; + } + QVector res; + return res; +} + + + diff --git a/lib/jkqtplotter/jkqtpgraphsimagergb.h b/lib/jkqtplotter/jkqtpgraphsimagergb.h new file mode 100644 index 0000000000..361a652015 --- /dev/null +++ b/lib/jkqtplotter/jkqtpgraphsimagergb.h @@ -0,0 +1,607 @@ +/* + Copyright (c) 2008-2019 Jan W. Krieger + + + + 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 . +*/ + + +#ifndef JKQTPGRAPHSIMAGERGB_H +#define JKQTPGRAPHSIMAGERGB_H + + +#include +#include +#include +#include +#include "jkqtplotter/jkqtpgraphsimage.h" +#include "jkqtplottertools/jkqtptools.h" +#include "jkqtplotter/jkqtpbaseelements.h" +#include "jkqtplottertools/jkqtp_imexport.h" +#include "jkqtplottertools/jkqtpimagetools.h" + + + +/*! \brief class to plot an image from an 2-dimensional array of values + \ingroup jkqtplotter_imagelots_elements + + \image html rgbimageplots.png + \image html jkqtplotter_simpletest_rgbimageplot_opencv.png +*/ +class JKQTP_LIB_EXPORT JKQTPRGBMathImage: public JKQTPMathImageBase { + Q_OBJECT + public: + using JKQTPMathImageBase::setData; + + + /** \brief class constructor */ + JKQTPRGBMathImage(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTBasePlotter* parent=nullptr); + + /** \brief class constructor */ + JKQTPRGBMathImage(double x, double y, double width, double height, DataType datatype, void* data, int Nx, int Ny, JKQTPlotter* parent); + + /** \brief class constructor */ + JKQTPRGBMathImage(JKQTBasePlotter* parent=nullptr); + + /** \brief class constructor */ + JKQTPRGBMathImage(JKQTPlotter* parent); + + /** \brief plots the graph to the plotter object specified as parent */ + virtual void draw(JKQTPEnhancedPainter& painter) override; + + virtual void setParent(JKQTBasePlotter* parent) override; + + + + virtual void setData(void* data, void* dataG, void* dataB, int Nx, int Ny, DataType datatype); + virtual void setData(void* data, void* dataG, void* dataB, int Nx, int Ny); + + virtual void setData(void* data, int Nx, int Ny, DataType datatype) override; + virtual void setData(void* data, int Nx, int Ny) override ; + + + /** \brief determine min/max data value of the image */ + virtual void getDataMinMax(double& imin, double& imax) override; + + + /*! \copydoc dataG + \see see dataG for details */ + inline virtual void setDataG(void* __value) + { + this->dataG = __value; + } + /*! \copydoc dataG + \see see dataG for details */ + inline virtual void* getDataG() const + { + return this->dataG; + } + /*! \copydoc datatypeG + \see see datatypeG for details */ + inline virtual void setDatatypeG(const DataType & __value) + { + this->datatypeG = __value; + } + /*! \copydoc datatypeG + \see see datatypeG for details */ + inline virtual DataType getDatatypeG() const + { + return this->datatypeG; + } + /*! \copydoc dataB + \see see dataB for details */ + inline virtual void setDataB(void* __value) + { + this->dataB = __value; + } + /*! \copydoc dataB + \see see dataB for details */ + inline virtual void* getDataB() const + { + return this->dataB; + } + /*! \copydoc datatypeB + \see see datatypeB for details */ + inline virtual void setDatatypeB(const DataType & __value) + { + this->datatypeB = __value; + } + /*! \copydoc datatypeB + \see see datatypeB for details */ + inline virtual DataType getDatatypeB() const + { + return this->datatypeB; + } + /*! \copydoc showColorBar + \see see showColorBar for details */ + inline virtual void setShowColorBar(bool __value) + { + this->showColorBar = __value; + } + /*! \copydoc showColorBar + \see see showColorBar for details */ + inline virtual bool getShowColorBar() const + { + return this->showColorBar; + } + /*! \copydoc colorBarWidth + \see see colorBarWidth for details */ + inline virtual void setColorBarWidth(int __value) + { + this->colorBarWidth = __value; + } + /*! \copydoc colorBarWidth + \see see colorBarWidth for details */ + inline virtual int getColorBarWidth() const + { + return this->colorBarWidth; + } + /*! \copydoc colorBarOffset + \see see colorBarOffset for details */ + inline virtual void setColorBarOffset(int __value) + { + this->colorBarOffset = __value; + } + /*! \copydoc colorBarOffset + \see see colorBarOffset for details */ + inline virtual int getColorBarOffset() const + { + return this->colorBarOffset; + } + /*! \copydoc colorBarRelativeHeight + \see see colorBarRelativeHeight for details */ + inline virtual void setColorBarRelativeHeight(double __value) + { + this->colorBarRelativeHeight = __value; + } + /*! \copydoc colorBarRelativeHeight + \see see colorBarRelativeHeight for details */ + inline virtual double getColorBarRelativeHeight() const + { + return this->colorBarRelativeHeight; + } + /*! \copydoc imageMin + \see see imageMin for details */ + inline virtual void setImageMin(double __value) + { + this->imageMin = __value; + } + /*! \copydoc imageMin + \see see imageMin for details */ + inline virtual double getImageMin() const + { + return this->imageMin; + } + inline void setImageMinR(double m) { + setImageMin(m); + } + /*! \copydoc imageMax + \see see imageMax for details */ + inline virtual void setImageMax(double __value) + { + this->imageMax = __value; + } + /*! \copydoc imageMax + \see see imageMax for details */ + inline virtual double getImageMax() const + { + return this->imageMax; + } + inline void setImageMaxR(double m) { + setImageMax(m); + } + /*! \copydoc imageMinG + \see see imageMinG for details */ + inline virtual void setImageMinG(double __value) + { + this->imageMinG = __value; + } + /*! \copydoc imageMinG + \see see imageMinG for details */ + inline virtual double getImageMinG() const + { + return this->imageMinG; + } + /*! \copydoc imageMaxG + \see see imageMaxG for details */ + inline virtual void setImageMaxG(double __value) + { + this->imageMaxG = __value; + } + /*! \copydoc imageMaxG + \see see imageMaxG for details */ + inline virtual double getImageMaxG() const + { + return this->imageMaxG; + } + /*! \copydoc imageMinB + \see see imageMinB for details */ + inline virtual void setImageMinB(double __value) + { + this->imageMinB = __value; + } + /*! \copydoc imageMinB + \see see imageMinB for details */ + inline virtual double getImageMinB() const + { + return this->imageMinB; + } + /*! \copydoc imageMaxB + \see see imageMaxB for details */ + inline virtual void setImageMaxB(double __value) + { + this->imageMaxB = __value; + } + /*! \copydoc imageMaxB + \see see imageMaxB for details */ + inline virtual double getImageMaxB() const + { + return this->imageMaxB; + } + /*! \copydoc autoImageRange + \see see autoImageRange for details */ + inline virtual void setAutoImageRange(bool __value) + { + this->autoImageRange = __value; + } + /*! \copydoc autoImageRange + \see see autoImageRange for details */ + inline virtual bool getAutoImageRange() const + { + return this->autoImageRange; + } + /*! \copydoc imageName + \see see imageName for details */ + inline virtual void setImageName(const QString & __value) + { + this->imageName = __value; + } + /*! \copydoc imageName + \see see imageName for details */ + inline virtual QString getImageName() const + { + return this->imageName; + } + inline void setImageNameR(const QString& m) { + setImageName(m); + } + /*! \copydoc imageNameG + \see see imageNameG for details */ + inline virtual void setImageNameG(const QString & __value) + { + this->imageNameG = __value; + } + /*! \copydoc imageNameG + \see see imageNameG for details */ + inline virtual QString getImageNameG() const + { + return this->imageNameG; + } + /*! \copydoc imageNameB + \see see imageNameB for details */ + inline virtual void setImageNameB(const QString & __value) + { + this->imageNameB = __value; + } + /*! \copydoc imageNameB + \see see imageNameB for details */ + inline virtual QString getImageNameB() const + { + return this->imageNameB; + } + /*! \copydoc imageNameFontName + \see see imageNameFontName for details */ + inline virtual void setImageNameFontName(const QString & __value) + { + this->imageNameFontName = __value; + } + /*! \copydoc imageNameFontName + \see see imageNameFontName for details */ + inline virtual QString getImageNameFontName() const + { + return this->imageNameFontName; + } + /*! \copydoc imageNameFontSize + \see see imageNameFontSize for details */ + inline virtual void setImageNameFontSize(double __value) + { + this->imageNameFontSize = __value; + } + /*! \copydoc imageNameFontSize + \see see imageNameFontSize for details */ + inline virtual double getImageNameFontSize() const + { + return this->imageNameFontSize; + } + /*! \brief returns the property colorBarRightAxis ( \copybrief colorBarRightAxis ). \details Description of the parameter colorBarRightAxis is:
    \copydoc colorBarRightAxis
    . \see colorBarRightAxis for more information */ + inline JKQTPVerticalIndependentAxis* getColorBarRightAxis() { return this->colorBarRightAxis; } + /*! \brief returns the property colorBarTopAxis ( \copybrief colorBarTopAxis ). \details Description of the parameter colorBarTopAxis is:
    \copydoc colorBarTopAxis
    . \see colorBarTopAxis for more information */ + inline JKQTPHorizontalIndependentAxis* getColorBarTopAxis() { return this->colorBarTopAxis; } + /*! \brief returns the property colorBarRightAxisG ( \copybrief colorBarRightAxisG ). \details Description of the parameter colorBarRightAxisG is:
    \copydoc colorBarRightAxisG
    . \see colorBarRightAxisG for more information */ + inline JKQTPVerticalIndependentAxis* getColorBarRightAxisG() { return this->colorBarRightAxisG; } + /*! \brief returns the property colorBarTopAxisG ( \copybrief colorBarTopAxisG ). \details Description of the parameter colorBarTopAxisG is:
    \copydoc colorBarTopAxisG
    . \see colorBarTopAxisG for more information */ + inline JKQTPHorizontalIndependentAxis* getColorBarTopAxisG() { return this->colorBarTopAxisG; } + /*! \brief returns the property colorBarRightAxisB ( \copybrief colorBarRightAxisB ). \details Description of the parameter colorBarRightAxisB is:
    \copydoc colorBarRightAxisB
    . \see colorBarRightAxisB for more information */ + inline JKQTPVerticalIndependentAxis* getColorBarRightAxisB() { return this->colorBarRightAxisB; } + /*! \brief returns the property colorBarTopAxisB ( \copybrief colorBarTopAxisB ). \details Description of the parameter colorBarTopAxisB is:
    \copydoc colorBarTopAxisB
    . \see colorBarTopAxisB for more information */ + inline JKQTPHorizontalIndependentAxis* getColorBarTopAxisB() { return this->colorBarTopAxisB; } + /*! \brief returns the property colorBarRightAxis ( \copybrief colorBarRightAxis ). \details Description of the parameter colorBarRightAxis is:
    \copydoc colorBarRightAxis
    . \see colorBarRightAxis for more information */ + inline const JKQTPVerticalIndependentAxis* getColorBarRightAxis() const { return this->colorBarRightAxis; } + /*! \brief returns the property colorBarTopAxis ( \copybrief colorBarTopAxis ). \details Description of the parameter colorBarTopAxis is:
    \copydoc colorBarTopAxis
    . \see colorBarTopAxis for more information */ + inline const JKQTPHorizontalIndependentAxis* getColorBarTopAxis() const { return this->colorBarTopAxis; } + /*! \brief returns the property colorBarRightAxisG ( \copybrief colorBarRightAxisG ). \details Description of the parameter colorBarRightAxisG is:
    \copydoc colorBarRightAxisG
    . \see colorBarRightAxisG for more information */ + inline const JKQTPVerticalIndependentAxis* getColorBarRightAxisG() const { return this->colorBarRightAxisG; } + /*! \brief returns the property colorBarTopAxisG ( \copybrief colorBarTopAxisG ). \details Description of the parameter colorBarTopAxisG is:
    \copydoc colorBarTopAxisG
    . \see colorBarTopAxisG for more information */ + inline const JKQTPHorizontalIndependentAxis* getColorBarTopAxisG() const { return this->colorBarTopAxisG; } + /*! \brief returns the property colorBarRightAxisB ( \copybrief colorBarRightAxisB ). \details Description of the parameter colorBarRightAxisB is:
    \copydoc colorBarRightAxisB
    . \see colorBarRightAxisB for more information */ + inline const JKQTPVerticalIndependentAxis* getColorBarRightAxisB() const { return this->colorBarRightAxisB; } + /*! \brief returns the property colorBarTopAxisB ( \copybrief colorBarTopAxisB ). \details Description of the parameter colorBarTopAxisB is:
    \copydoc colorBarTopAxisB
    . \see colorBarTopAxisB for more information */ + inline const JKQTPHorizontalIndependentAxis* getColorBarTopAxisB() const { return this->colorBarTopAxisB; } + /*! \copydoc colorBarTopVisible + \see see colorBarTopVisible for details */ + inline virtual void setColorBarTopVisible(bool __value) + { + this->colorBarTopVisible = __value; + } + /*! \copydoc colorBarTopVisible + \see see colorBarTopVisible for details */ + inline virtual bool getColorBarTopVisible() const + { + return this->colorBarTopVisible; + } + /*! \copydoc colorBarRightVisible + \see see colorBarRightVisible for details */ + inline virtual void setColorBarRightVisible(bool __value) + { + this->colorBarRightVisible = __value; + } + /*! \copydoc colorBarRightVisible + \see see colorBarRightVisible for details */ + inline virtual bool getColorBarRightVisible() const + { + return this->colorBarRightVisible; + } + /*! \copydoc colorbarsSideBySide + \see see colorbarsSideBySide for details */ + inline virtual void setColorbarsSideBySide(bool __value) + { + this->colorbarsSideBySide = __value; + } + /*! \copydoc colorbarsSideBySide + \see see colorbarsSideBySide for details */ + inline virtual bool getColorbarsSideBySide() const + { + return this->colorbarsSideBySide; + } + /*! \copydoc rgbMode + \see see rgbMode for details */ + inline virtual void setRgbMode(const JKQTPRGBMathImageRGBMode & __value) + { + this->rgbMode = __value; + } + /*! \copydoc rgbMode + \see see rgbMode for details */ + inline virtual JKQTPRGBMathImageRGBMode getRgbMode() const + { + return this->rgbMode; + } + + QVector getDataGAsDoubleVector() const; + QVector getDataBAsDoubleVector() const; + + + /*! \brief if the graph plots outside the actual plot field of view (e.g. color bars, scale bars, ...) + + \note If you want to draw outside, then you'll also have to implement drawOutside() + */ + virtual void getOutsideSize(JKQTPEnhancedPainter& painter, int& leftSpace, int& rightSpace, int& topSpace, int& bottomSpace) override; + + /*! \brief plots outside the actual plot field of view (e.g. color bars, scale bars, ...) + + \note If you want to draw outside, then you'll also have to implement getOutsideSize(), so enough space is reserved + + The four value supplied tell the method where to draw (inside one of the rectangles). + */ + virtual void drawOutside(JKQTPEnhancedPainter& painter, QRect leftSpace, QRect rightSpace, QRect topSpace, QRect bottomSpace) override; + + /*! \brief return the plotted image only as a QImage */ + virtual QImage drawImage(); + + /** \brief determine min/max data value of the image */ + virtual void getDataMinMaxG(double& imin, double& imax); + /** \brief determine min/max data value of the image */ + virtual void getDataMinMaxB(double& imin, double& imax); + + /** \brief return the value (raw data!) of the contained image at the given coordinate */ + double getValueAt(double x, double y, int channel=0) ; + + /** \brief plots a key marker inside the specified rectangle \a rect */ + virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) override; + + protected: + void initObject(); + /** \brief points to the data array, holding the image */ + void* dataG; + /** \brief datatype of the data array data */ + DataType datatypeG; + /** \brief points to the data array, holding the image */ + void* dataB; + /** \brief datatype of the data array data */ + DataType datatypeB; + + JKQTPRGBMathImageRGBMode rgbMode; + + /** \brief top color bar visible */ + bool colorBarTopVisible; + /** \brief right color bar visible */ + bool colorBarRightVisible; + /** \brief name of the image displayed above color bar (may contain LaTeX markup!) */ + QString imageName; + /** \brief name of the image displayed above color bar (may contain LaTeX markup!) */ + QString imageNameG; + /** \brief name of the image displayed above color bar (may contain LaTeX markup!) */ + QString imageNameB; + /** \brief font name when displaying imageName */ + QString imageNameFontName; + /** \brief font size in points when displaying imageName */ + double imageNameFontSize; + + /** \brief indicate whether to display a color bar */ + bool showColorBar; + /** \brief width of the color bar */ + int colorBarWidth; + /** \brief height of the color bar, as multiple of plotHeight */ + double colorBarRelativeHeight; + /** \brief indicates whether to estimate min/max of the image automatically */ + bool autoImageRange; + /** \brief image value range minimum */ + double imageMin; + /** \brief image value range maximum */ + double imageMax; + /** \brief image value range minimum */ + double imageMinG; + /** \brief image value range maximum */ + double imageMaxG; + /** \brief image value range minimum */ + double imageMinB; + /** \brief image value range maximum */ + double imageMaxB; + /** \brief offset between outside space border and color bar */ + int colorBarOffset; + /** \brief if \c true the different color bars share the space of a single color bar, if set \c false each colorbar uses the space of a single colorbar */ + bool colorbarsSideBySide; + + + /** \brief object used for color bar axes + * + * \note this axis has some kind of a special role. It is used to format color bar axes + */ + JKQTPVerticalIndependentAxis* colorBarRightAxis; + JKQTPHorizontalIndependentAxis* colorBarTopAxis; + JKQTPVerticalIndependentAxis* colorBarRightAxisG; + JKQTPHorizontalIndependentAxis* colorBarTopAxisG; + JKQTPVerticalIndependentAxis* colorBarRightAxisB; + JKQTPHorizontalIndependentAxis* colorBarTopAxisB; + + + double internalDataMinG; + double internalDataMaxG; + double internalDataMinB; + double internalDataMaxB; + + protected: + QAction* actSaveImage; + QAction* actCopyImage; + public: + virtual void setTitle(const QString& title) override; + public slots: + void saveImagePlotAsImage(const QString &filename=QString(""), const QByteArray &outputFormat=QByteArray()); + void copyImagePlotAsImage(); +}; + + + +/*! \brief like JKQTPRGBMathImage but reads images from columns of the datastore + \ingroup jkqtplotter_imagelots_elements + + + \image html rgbimageplots.png + \image html jkqtplotter_simpletest_rgbimageplot_opencv.png + */ +class JKQTP_LIB_EXPORT JKQTPColumnRGBMathImage: public JKQTPRGBMathImage { + Q_OBJECT + public: + + /** \brief class constructor */ + JKQTPColumnRGBMathImage(JKQTBasePlotter* parent=nullptr); + JKQTPColumnRGBMathImage(double x, double y, double width, double height, int Nx, int Ny, JKQTBasePlotter* parent=nullptr); + JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int Nx, int Ny, JKQTBasePlotter* parent=nullptr); + JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int Nx, int Ny, JKQTBasePlotter* parent=nullptr); + JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int imageBColumn, int Nx, int Ny, JKQTBasePlotter* parent=nullptr); + /** \brief class constructor */ + JKQTPColumnRGBMathImage(JKQTPlotter* parent); + JKQTPColumnRGBMathImage(double x, double y, double width, double height, int Nx, int Ny, JKQTPlotter* parent); + JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int Nx, int Ny, JKQTPlotter* parent); + JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int Nx, int Ny, JKQTPlotter* parent); + JKQTPColumnRGBMathImage(double x, double y, double width, double height, int imageRColumn, int imageGColumn, int imageBColumn, int Nx, int Ny, JKQTPlotter* parent); + + /*! \copydoc imageRColumn + \see see imageRColumn for details */ + inline virtual void setImageRColumn(int __value) + { + this->imageRColumn = __value; + } + /*! \copydoc imageRColumn + \see see imageRColumn for details */ + inline virtual int getImageRColumn() const + { + return this->imageRColumn; + } + /*! \copydoc imageGColumn + \see see imageGColumn for details */ + inline virtual void setImageGColumn(int __value) + { + this->imageGColumn = __value; + } + /*! \copydoc imageGColumn + \see see imageGColumn for details */ + inline virtual int getImageGColumn() const + { + return this->imageGColumn; + } + /*! \copydoc imageBColumn + \see see imageBColumn for details */ + inline virtual void setImageBColumn(int __value) + { + this->imageBColumn = __value; + } + /*! \copydoc imageBColumn + \see see imageBColumn for details */ + inline virtual int getImageBColumn() const + { + return this->imageBColumn; + } + /*! \copydoc modifierColumn + \see see modifierColumn for details */ + inline virtual void setModifierColumn(int __value) + { + this->modifierColumn = __value; + } + /*! \copydoc modifierColumn + \see see modifierColumn for details */ + inline virtual int getModifierColumn() const + { + return this->modifierColumn; + } + /** \copydoc JKQTPGraph::usesColumn() */ + virtual bool usesColumn(int c) const override; + + protected: + /** \brief image column for R channel */ + int imageRColumn; + /** \brief image column for G channel */ + int imageGColumn; + /** \brief image column for B channel */ + int imageBColumn; + /** \brief column containing the modifier image */ + int modifierColumn; + + void ensureImageData() override; +}; + + + +#endif // JKQTPGRAPHSIMAGERGB_H + diff --git a/lib/jkqtplotter/jkqtpgraphsimpulses.cpp b/lib/jkqtplotter/jkqtpgraphsimpulses.cpp index 2938e920cf..511c3dfbf1 100644 --- a/lib/jkqtplotter/jkqtpgraphsimpulses.cpp +++ b/lib/jkqtplotter/jkqtpgraphsimpulses.cpp @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -45,6 +45,7 @@ JKQTPImpulsesHorizontalGraph::JKQTPImpulsesHorizontalGraph(JKQTBasePlotter* pare if (parent) { // get style settings from parent object parentPlotStyle=parent->getNextStyle(); color=parent->getPlotStyle(parentPlotStyle).color(); + lineWidth=parent->getPlotStyle(parentPlotStyle).widthF(); } } @@ -58,7 +59,9 @@ JKQTPImpulsesHorizontalGraph::JKQTPImpulsesHorizontalGraph(JKQTPlotter* parent): if (parent) { // get style settings from parent object parentPlotStyle=parent->getNextStyle(); + int parentPlotStyle=parent->getNextStyle(); color=parent->getPlotStyle(parentPlotStyle).color(); + lineWidth=parent->getPlotStyle(parentPlotStyle).widthF(); } } void JKQTPImpulsesHorizontalGraph::draw(JKQTPEnhancedPainter& painter) { @@ -70,77 +73,77 @@ void JKQTPImpulsesHorizontalGraph::draw(JKQTPEnhancedPainter& painter) { if (datastore==nullptr) return; drawErrorsBefore(painter); + { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); - painter.save(); + QPen p=painter.pen(); + p.setColor(color); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); + p.setStyle(Qt::SolidLine); + p.setCapStyle(Qt::FlatCap); - QPen p=painter.pen(); - p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); - p.setStyle(Qt::SolidLine); - p.setCapStyle(Qt::FlatCap); - - int imax=qMin(datastore->getColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(yColumn)).getRows()); - int imin=0; - if (imaxgetXAxis()->isLogAxis()) { - if (baseline>0 && baseline>parent->getXAxis()->getMin()) x0=transformX(baseline); - else x0=transformX(parent->getXAxis()->getMin()); - } -// double y0=transformY(baseline); -// if (parent->getYAxis()->isLogAxis()) { -// y0=transformY(parent->getYAxis()->getMin()); -// if (baseline>0 && baseline>parent->getYAxis()->getMin()) y0=transformY(baseline); -// else y0=transformY(parent->getYAxis()->getMin()); -// } - //bool first=false; - QVector lines; - intSortData(); - for (int iii=imin; iiiget(static_cast(xColumn),static_cast(i)); - double yv=datastore->get(static_cast(yColumn),static_cast(i)); - if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv)) { - double x=transformX(xv); - double y=transformY(yv); - - - lines.append(QLineF(x0, y, x, y)); - -// xold=x; -// yold=y; - //first=true; + int imax=qMin(datastore->getColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(yColumn)).getRows()); + int imin=0; + if (imax0) painter.drawLines(lines); - painter.restore(); + if (imin<0) imin=0; + if (imax<0) imax=0; + //double xold=-1; + //double yold=-1; + double x0=transformX(baseline); + if (parent->getXAxis()->isLogAxis()) { + if (baseline>0 && baseline>parent->getXAxis()->getMin()) x0=transformX(baseline); + else x0=transformX(parent->getXAxis()->getMin()); + } + // double y0=transformY(baseline); + // if (parent->getYAxis()->isLogAxis()) { + // y0=transformY(parent->getYAxis()->getMin()); + // if (baseline>0 && baseline>parent->getYAxis()->getMin()) y0=transformY(baseline); + // else y0=transformY(parent->getYAxis()->getMin()); + // } + //bool first=false; + QVector lines; + intSortData(); + for (int iii=imin; iiiget(static_cast(xColumn),static_cast(i)); + double yv=datastore->get(static_cast(yColumn),static_cast(i)); + if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv)) { + double x=transformX(xv); + double y=transformY(yv); + + + lines.append(QLineF(x0, y, x, y)); + + // xold=x; + // yold=y; + //first=true; + } + } + painter.setPen(p); + if (lines.size()>0) painter.drawLines(lines); + + } drawErrorsAfter(painter); } void JKQTPImpulsesHorizontalGraph::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) { - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); QPen p=painter.pen(); p.setColor(color); p.setStyle(Qt::SolidLine); p.setCapStyle(Qt::FlatCap); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH,qMin(parent->pt2px(painter, qMax(.01, lineWidth)), rect.height()/2.0)*parent->getLineWidthMultiplier())); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH,qMin(parent->pt2px(painter, qMax(.01, lineWidth)), rect.height()/2.0)*parent->getLineWidthMultiplier())); painter.setPen(p); int y=rect.top()+rect.height()/2.0; painter.drawLine(rect.left(), y, rect.right(), y); - painter.restore(); + } QColor JKQTPImpulsesHorizontalGraph::getKeyLabelColor() { @@ -177,60 +180,60 @@ void JKQTPImpulsesVerticalGraph::draw(JKQTPEnhancedPainter& painter) { if (datastore==nullptr) return; drawErrorsBefore(painter); + { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); - painter.save(); + QPen p=painter.pen(); + p.setColor(color); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); + p.setStyle(Qt::SolidLine); + p.setCapStyle(Qt::FlatCap); - QPen p=painter.pen(); - p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, parent->pt2px(painter, lineWidth*parent->getLineWidthMultiplier()))); - p.setStyle(Qt::SolidLine); - p.setCapStyle(Qt::FlatCap); - - int imax=qMin(datastore->getColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(yColumn)).getRows()); - int imin=0; - if (imaxgetXAxis()->isLogAxis()) { -// if (baseline>0 && baseline>parent->getXAxis()->getMin()) x0=transformX(baseline); -// else x0=transformX(parent->getXAxis()->getMin()); -// } - double y0=transformY(baseline); - if (parent->getYAxis()->isLogAxis()) { - y0=transformY(parent->getYAxis()->getMin()); - if (baseline>0 && baseline>parent->getYAxis()->getMin()) y0=transformY(baseline); - else y0=transformY(parent->getYAxis()->getMin()); - } - QVector lines; - intSortData(); - for (int iii=imin; iiiget(static_cast(xColumn),static_cast(i)); - double yv=datastore->get(static_cast(yColumn),static_cast(i)); - if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv) ) { - double x=transformX(xv); - double y=transformY(yv); - - - lines.append(QLineF(x, y0, x, y)); - - //xold=x; - //yold=y; - //first=true; + int imax=qMin(datastore->getColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(yColumn)).getRows()); + int imin=0; + if (imaxgetXAxis()->isLogAxis()) { + // if (baseline>0 && baseline>parent->getXAxis()->getMin()) x0=transformX(baseline); + // else x0=transformX(parent->getXAxis()->getMin()); + // } + double y0=transformY(baseline); + if (parent->getYAxis()->isLogAxis()) { + y0=transformY(parent->getYAxis()->getMin()); + if (baseline>0 && baseline>parent->getYAxis()->getMin()) y0=transformY(baseline); + else y0=transformY(parent->getYAxis()->getMin()); + } + QVector lines; + intSortData(); + for (int iii=imin; iiiget(static_cast(xColumn),static_cast(i)); + double yv=datastore->get(static_cast(yColumn),static_cast(i)); + if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv) ) { + double x=transformX(xv); + double y=transformY(yv); + + + lines.append(QLineF(x, y0, x, y)); + + //xold=x; + //yold=y; + //first=true; + } + } + painter.setPen(p); + if (lines.size()>0) painter.drawLines(lines); } - painter.setPen(p); - if (lines.size()>0) painter.drawLines(lines); - painter.restore(); drawErrorsAfter(painter); } @@ -242,7 +245,7 @@ void JKQTPImpulsesVerticalGraph::draw(JKQTPEnhancedPainter& painter) { QPen JKQTPImpulsesHorizontalGraph::getPen(JKQTPEnhancedPainter& painter) const { QPen p; p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH,parent->pt2px(painter, parent->getLineWidthMultiplier()*lineWidth))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH,parent->pt2px(painter, parent->getLineWidthMultiplier()*lineWidth))); return p; } @@ -250,15 +253,17 @@ QPen JKQTPImpulsesHorizontalGraph::getPen(JKQTPEnhancedPainter& painter) const { JKQTPImpulsesHorizontalErrorGraph::JKQTPImpulsesHorizontalErrorGraph(JKQTBasePlotter *parent): - JKQTPImpulsesHorizontalGraph(parent), JKQTPXGraphErrors() + JKQTPImpulsesHorizontalGraph(parent), JKQTPXGraphErrors(color, parent) { setErrorColorFromGraphColor(color); + if (parentPlotStyle>=0) setErrorStyleFromPen(parent->getPlotStyle(parentPlotStyle)); + } JKQTPImpulsesHorizontalErrorGraph::JKQTPImpulsesHorizontalErrorGraph(JKQTPlotter *parent): - JKQTPImpulsesHorizontalGraph(parent), JKQTPXGraphErrors() + JKQTPImpulsesHorizontalErrorGraph(parent->getPlotter()) { - setErrorColorFromGraphColor(color); + } bool JKQTPImpulsesHorizontalErrorGraph::usesColumn(int c) const @@ -273,15 +278,16 @@ void JKQTPImpulsesHorizontalErrorGraph::drawErrorsAfter(JKQTPEnhancedPainter &pa } JKQTPImpulsesVerticalErrorGraph::JKQTPImpulsesVerticalErrorGraph(JKQTBasePlotter *parent): - JKQTPImpulsesVerticalGraph(parent), JKQTPYGraphErrors() + JKQTPImpulsesVerticalGraph(parent), JKQTPYGraphErrors(color, parent) { setErrorColorFromGraphColor(color); + if (parentPlotStyle>=0) setErrorStyleFromPen(parent->getPlotStyle(parentPlotStyle)); } JKQTPImpulsesVerticalErrorGraph::JKQTPImpulsesVerticalErrorGraph(JKQTPlotter *parent): - JKQTPImpulsesVerticalGraph(parent), JKQTPYGraphErrors() + JKQTPImpulsesVerticalErrorGraph(parent->getPlotter()) { - setErrorColorFromGraphColor(color); + } bool JKQTPImpulsesVerticalErrorGraph::usesColumn(int c) const diff --git a/lib/jkqtplotter/jkqtpgraphsimpulses.h b/lib/jkqtplotter/jkqtpgraphsimpulses.h index e6cb43addd..be24d493a8 100644 --- a/lib/jkqtplotter/jkqtpgraphsimpulses.h +++ b/lib/jkqtplotter/jkqtpgraphsimpulses.h @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -19,7 +19,7 @@ #include "jkqtplottertools/jkqtp_imexport.h" #include "jkqtplotter/jkqtpgraphsbase.h" - +#include "jkqtplotter/jkqtpgraphsbaseerrors.h" #ifndef jkqtpgraphsimpulses_H #define jkqtpgraphsimpulses_H @@ -46,44 +46,38 @@ class JKQTP_LIB_EXPORT JKQTPImpulsesHorizontalGraph: public JKQTPXYGraph { /** \brief returns the color to be used for the key label */ virtual QColor getKeyLabelColor() override; - /*! \brief sets the property color ( \copybrief color ) to the specified \a __value. - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual void setColor(const QColor & __value) { this->color = __value; } - /*! \brief returns the property color ( \copybrief color ). - \details Description of the parameter color is:
    \copydoc color
    - \see color for more information */ + /*! \copydoc color + \see see color for details */ inline virtual QColor getColor() const { return this->color; } - /*! \brief sets the property lineWidth ( \copybrief lineWidth ) to the specified \a __value. - \details Description of the parameter lineWidth is:
    \copydoc lineWidth
    - \see lineWidth for more information */ + /*! \copydoc lineWidth + \see see lineWidth for details */ inline virtual void setLineWidth(double __value) { this->lineWidth = __value; } - /*! \brief returns the property lineWidth ( \copybrief lineWidth ). - \details Description of the parameter lineWidth is:
    \copydoc lineWidth
    - \see lineWidth for more information */ + /*! \copydoc lineWidth + \see see lineWidth for details */ inline virtual double getLineWidth() const { return this->lineWidth; } - /*! \brief sets the property baseline ( \copybrief baseline ) to the specified \a __value. - \details Description of the parameter baseline is:
    \copydoc baseline
    - \see baseline for more information */ + /*! \copydoc baseline + \see see baseline for details */ inline virtual void setBaseline(double __value) { this->baseline = __value; } - /*! \brief returns the property baseline ( \copybrief baseline ). - \details Description of the parameter baseline is:
    \copydoc baseline
    - \see baseline for more information */ + /*! \copydoc baseline + \see see baseline for details */ inline virtual double getBaseline() const { return this->baseline; diff --git a/lib/jkqtplotter/jkqtpgraphsparsedfunction.cpp b/lib/jkqtplotter/jkqtpgraphsparsedfunction.cpp index 91a39b425c..918d02a32c 100644 --- a/lib/jkqtplotter/jkqtpgraphsparsedfunction.cpp +++ b/lib/jkqtplotter/jkqtpgraphsparsedfunction.cpp @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -20,6 +20,7 @@ #include "jkqtplotter/jkqtpgraphsparsedfunction.h" #include "jkqtplotter/jkqtpgraphs.h" #include "jkqtplotter/jkqtpbaseplotter.h" +#include "jkqtplotter/jkqtplotter.h" #include "jkqtplottertools/jkqtptools.h" #include #include @@ -48,23 +49,8 @@ JKQTPXParsedFunctionLineGraph::JKQTPXParsedFunctionLineGraph(JKQTBasePlotter *pa } JKQTPXParsedFunctionLineGraph::JKQTPXParsedFunctionLineGraph(JKQTPlotter *parent): - JKQTPXFunctionLineGraph(parent) + JKQTPXParsedFunctionLineGraph(parent->getPlotter()) { - fdata.parser=new JKQTPMathParser(); - fdata.node=nullptr; - fdata.varcount=0; - function=""; - parameterColumn=-1; - setParams(&fdata); - setPlotFunction(&JKQTPXParsedFunctionLineGraph::JKQTPXParsedFunctionLineGraphFunction); - - efdata.parser=new JKQTPMathParser(); - efdata.node=nullptr; - efdata.varcount=0; - errorFunction=""; - errorParameterColumn=-1; - setErrorParams(&efdata); - setErrorPlotFunction(&JKQTPXParsedFunctionLineGraph::JKQTPXParsedFunctionLineGraphFunction); } JKQTPXParsedFunctionLineGraph::~JKQTPXParsedFunctionLineGraph() diff --git a/lib/jkqtplotter/jkqtpgraphsparsedfunction.h b/lib/jkqtplotter/jkqtpgraphsparsedfunction.h index 50ee851272..36c8cd9ca5 100644 --- a/lib/jkqtplotter/jkqtpgraphsparsedfunction.h +++ b/lib/jkqtplotter/jkqtpgraphsparsedfunction.h @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -57,31 +57,27 @@ class JKQTP_LIB_EXPORT JKQTPXParsedFunctionLineGraph: public JKQTPXFunctionLineG /** \brief class destructor */ virtual ~JKQTPXParsedFunctionLineGraph() override; - /*! \brief sets the property function ( \copybrief function ) to the specified \a __value. - \details Description of the parameter function is:
    \copydoc function
    - \see function for more information */ + /*! \copydoc function + \see see function for details */ inline virtual void setFunction(const QString & __value) { this->function = __value; } - /*! \brief returns the property function ( \copybrief function ). - \details Description of the parameter function is:
    \copydoc function
    - \see function for more information */ + /*! \copydoc function + \see see function for details */ inline virtual QString getFunction() const { return this->function; } - /*! \brief sets the property errorFunction ( \copybrief errorFunction ) to the specified \a __value. - \details Description of the parameter errorFunction is:
    \copydoc errorFunction
    - \see errorFunction for more information */ + /*! \copydoc errorFunction + \see see errorFunction for details */ inline virtual void setErrorFunction(const QString & __value) { this->errorFunction = __value; } - /*! \brief returns the property errorFunction ( \copybrief errorFunction ). - \details Description of the parameter errorFunction is:
    \copydoc errorFunction
    - \see errorFunction for more information */ + /*! \copydoc errorFunction + \see see errorFunction for details */ inline virtual QString getErrorFunction() const { return this->errorFunction; @@ -143,31 +139,27 @@ class JKQTP_LIB_EXPORT JKQTPYParsedFunctionLineGraph: public JKQTPYFunctionLineG /** \brief class destructor */ virtual ~JKQTPYParsedFunctionLineGraph() override; - /*! \brief sets the property function ( \copybrief function ) to the specified \a __value. - \details Description of the parameter function is:
    \copydoc function
    - \see function for more information */ + /*! \copydoc function + \see see function for details */ inline virtual void setFunction(const QString & __value) { this->function = __value; } - /*! \brief returns the property function ( \copybrief function ). - \details Description of the parameter function is:
    \copydoc function
    - \see function for more information */ + /*! \copydoc function + \see see function for details */ inline virtual QString getFunction() const { return this->function; } - /*! \brief sets the property errorFunction ( \copybrief errorFunction ) to the specified \a __value. - \details Description of the parameter errorFunction is:
    \copydoc errorFunction
    - \see errorFunction for more information */ + /*! \copydoc errorFunction + \see see errorFunction for details */ inline virtual void setErrorFunction(const QString & __value) { this->errorFunction = __value; } - /*! \brief returns the property errorFunction ( \copybrief errorFunction ). - \details Description of the parameter errorFunction is:
    \copydoc errorFunction
    - \see errorFunction for more information */ + /*! \copydoc errorFunction + \see see errorFunction for details */ inline virtual QString getErrorFunction() const { return this->errorFunction; diff --git a/lib/jkqtplotter/jkqtpgraphspeakstream.cpp b/lib/jkqtplotter/jkqtpgraphspeakstream.cpp index c3d4c901cc..3c05da67ea 100644 --- a/lib/jkqtplotter/jkqtpgraphspeakstream.cpp +++ b/lib/jkqtplotter/jkqtpgraphspeakstream.cpp @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -27,6 +27,7 @@ #include "jkqtplottertools/jkqtptools.h" #include "jkqtplotter/jkqtpbaseelements.h" #include "jkqtplotter/jkqtplotter.h" +#include "jkqtplottertools/jkqtpdrawingtools.h" #define SmallestGreaterZeroCompare_xvsgz() if ((xvsgz>10.0*DBL_MIN)&&((smallestGreaterZero<10.0*DBL_MIN) || (xvsgzgetPlotter()) { - baseline=0; - yPeaks=true; - peakHeight=1; - drawBaseline=true; } JKQTPPeakStreamGraph::JKQTPPeakStreamGraph(int dataColumn, double baseline, double peakHeight, QColor color, JKQTPlotter *parent): @@ -122,66 +119,66 @@ void JKQTPPeakStreamGraph::draw(JKQTPEnhancedPainter &painter) if (dataColumn<0) return; drawErrorsBefore(painter); + { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); - painter.save(); + QPen p=getLinePen(painter); + p.setCapStyle(Qt::FlatCap); - QPen p=getLinePen(painter); - p.setCapStyle(Qt::FlatCap); - - int imax=static_cast(datastore->getColumn(static_cast(dataColumn)).getRows()); - int imin=0; - if (imax lines; - - if (yPeaks) { - if (drawBaseline) { - lines<getXMin(), baseline), transform(parent->getXMax(), baseline)); + int imax=static_cast(datastore->getColumn(static_cast(dataColumn)).getRows()); + int imin=0; + if (imax(imin, getDataIndex(static_cast(iii)), imax); - const double xv=datastore->get(dataColumn,i); - if (JKQTPIsOKFloat(xv)) { - lines<getYMin()), transform(baseline, parent->getYMax())); - } - intSortData(); - for (int iii=imin; iii(imin, getDataIndex(iii), imax); - const double yv=datastore->get(dataColumn,i); - if (JKQTPIsOKFloat(yv)) { - lines< lines; + + if (yPeaks) { + if (drawBaseline) { + lines<getXMin(), baseline), transform(parent->getXMax(), baseline)); + } + intSortData(); + for (int iii=imin; iii(imin, getDataIndex(static_cast(iii)), imax); + const double xv=datastore->get(dataColumn,i); + if (JKQTPIsOKFloat(xv)) { + lines<getYMin()), transform(baseline, parent->getYMax())); + } + intSortData(); + for (int iii=imin; iii(imin, getDataIndex(iii), imax); + const double yv=datastore->get(dataColumn,i); + if (JKQTPIsOKFloat(yv)) { + lines<0) painter.drawLines(lines); + + } - painter.setPen(p); - if (lines.size()>0) painter.drawLines(lines); - - - painter.restore(); - drawErrorsAfter(painter); } void JKQTPPeakStreamGraph::drawKeyMarker(JKQTPEnhancedPainter &painter, QRectF &rect) { - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); QPen p=getLinePen(painter); painter.setPen(p); if (yPeaks) { - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH,qMin(parent->pt2px(painter, p.widthF()), rect.width()/10.0))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH,qMin(parent->pt2px(painter, p.widthF()), rect.width()/10.0))); if (drawBaseline) { if (peakHeight>=0) painter.drawLine(rect.bottomLeft(), rect.bottomRight()); else painter.drawLine(rect.topLeft(), rect.topRight()); @@ -191,7 +188,7 @@ void JKQTPPeakStreamGraph::drawKeyMarker(JKQTPEnhancedPainter &painter, QRectF & painter.drawLine(QPointF(rect.left()+rect.width()*0.75, rect.top()), QPointF(rect.left()+rect.width()*0.75, rect.bottom())); painter.drawLine(QPointF(rect.left()+rect.width()*0.9, rect.top()), QPointF(rect.left()+rect.width()*0.9, rect.bottom())); } else { - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH,qMin(parent->pt2px(painter, p.widthF()), rect.height()/15.0))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH,qMin(parent->pt2px(painter, p.widthF()), rect.height()/15.0))); if (drawBaseline) { if (peakHeight>=0) painter.drawLine(rect.bottomLeft(), rect.topLeft()); else painter.drawLine(rect.bottomRight(), rect.topRight()); @@ -202,7 +199,7 @@ void JKQTPPeakStreamGraph::drawKeyMarker(JKQTPEnhancedPainter &painter, QRectF & painter.drawLine(QPointF(rect.left(), rect.top()+rect.height()*0.9), QPointF(rect.right(), rect.top()+rect.height()*0.9)); } - painter.restore(); + } diff --git a/lib/jkqtplotter/jkqtpgraphspeakstream.h b/lib/jkqtplotter/jkqtpgraphspeakstream.h index 531646e421..bd2869e385 100644 --- a/lib/jkqtplotter/jkqtpgraphspeakstream.h +++ b/lib/jkqtplotter/jkqtpgraphspeakstream.h @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -70,58 +70,50 @@ class JKQTP_LIB_EXPORT JKQTPPeakStreamGraph: public JKQTPSingleColumnGraph { /** \brief plots a key marker inside the specified rectangle \a rect */ virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) override; - /*! \brief sets the property baseline ( \copybrief baseline ) to the specified \a __value. - \details Description of the parameter baseline is:
    \copydoc baseline
    - \see baseline for more information */ + /*! \copydoc baseline + \see see baseline for details */ inline virtual void setBaseline(double __value) { this->baseline = __value; } - /*! \brief returns the property baseline ( \copybrief baseline ). - \details Description of the parameter baseline is:
    \copydoc baseline
    - \see baseline for more information */ + /*! \copydoc baseline + \see see baseline for details */ inline virtual double getBaseline() const { return this->baseline; } - /*! \brief sets the property peakHeight ( \copybrief peakHeight ) to the specified \a __value. - \details Description of the parameter peakHeight is:
    \copydoc peakHeight
    - \see peakHeight for more information */ + /*! \copydoc peakHeight + \see see peakHeight for details */ inline virtual void setPeakHeight(double __value) { this->peakHeight = __value; } - /*! \brief returns the property peakHeight ( \copybrief peakHeight ). - \details Description of the parameter peakHeight is:
    \copydoc peakHeight
    - \see peakHeight for more information */ + /*! \copydoc peakHeight + \see see peakHeight for details */ inline virtual double getPeakHeight() const { return this->peakHeight; } - /*! \brief sets the property yPeaks ( \copybrief yPeaks ) to the specified \a __value. - \details Description of the parameter yPeaks is:
    \copydoc yPeaks
    - \see yPeaks for more information */ + /*! \copydoc yPeaks + \see see yPeaks for details */ inline virtual void setYPeaks(bool __value) { this->yPeaks = __value; } - /*! \brief returns the property yPeaks ( \copybrief yPeaks ). - \details Description of the parameter yPeaks is:
    \copydoc yPeaks
    - \see yPeaks for more information */ + /*! \copydoc yPeaks + \see see yPeaks for details */ inline virtual bool getYPeaks() const { return this->yPeaks; } - /*! \brief sets the property drawBaseline ( \copybrief drawBaseline ) to the specified \a __value. - \details Description of the parameter drawBaseline is:
    \copydoc drawBaseline
    - \see drawBaseline for more information */ + /*! \copydoc drawBaseline + \see see drawBaseline for details */ inline virtual void setDrawBaseline(bool __value) { this->drawBaseline = __value; } - /*! \brief returns the property drawBaseline ( \copybrief drawBaseline ). - \details Description of the parameter drawBaseline is:
    \copydoc drawBaseline
    - \see drawBaseline for more information */ + /*! \copydoc drawBaseline + \see see drawBaseline for details */ inline virtual bool getDrawBaseline() const { return this->drawBaseline; diff --git a/lib/jkqtplotter/jkqtpgraphssinglecolumnsymbols.cpp b/lib/jkqtplotter/jkqtpgraphssinglecolumnsymbols.cpp index d2915ea0cc..9e20c65564 100644 --- a/lib/jkqtplotter/jkqtpgraphssinglecolumnsymbols.cpp +++ b/lib/jkqtplotter/jkqtpgraphssinglecolumnsymbols.cpp @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -51,8 +51,14 @@ JKQTPSingleColumnSymbolsGraph::JKQTPSingleColumnSymbolsGraph(JKQTBasePlotter *pa if (parent) { // get style settings from parent object parentPlotStyle=parent->getNextStyle(); //std::cout<<"got style settings from parent: "<getNextStyle(); color=parent->getPlotStyle(parentPlotStyle).color(); + fillColor=parent->getPlotStyle(parentPlotStyle).fillColor(); style=parent->getPlotStyle(parentPlotStyle).style(); + lineWidth=parent->getPlotStyle(parentPlotStyle).widthF(); + symbolSize=parent->getPlotStyle(parentPlotStyle).symbolSize(); + symbolWidth=parent->getPlotStyle(parentPlotStyle).symbolLineWidthF(); + symbol=parent->getPlotStyle(parentPlotStyle).symbol(); } fillColor=color; } @@ -109,95 +115,95 @@ void JKQTPSingleColumnSymbolsGraph::draw(JKQTPEnhancedPainter &painter) if (dataColumn<0) return; drawErrorsBefore(painter); + { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); - painter.save(); - - int imax=static_cast(datastore->getColumn(static_cast(dataColumn)).getRows()); - int imin=0; - if (imax dRandomScatter{position-width/2.0, position+width/2.0}; - - const double symSize=parent->pt2px(painter, symbolSize); - - - QVector plotSymbols; // collects symbol locations e.g. for BeeSwarmScatter-plots - plotSymbols.reserve(qMax(100,imax-imin)); - auto doesCollide=[&plotSymbols,&symSize](double x, double y)->bool { - for (auto& p: plotSymbols) { - if (fabs(p.x()-x)(datastore->getColumn(static_cast(dataColumn)).getRows()); + int imin=0; + if (imax(imin, getDataIndex(static_cast(iii)), imax); - const double xv=datastore->get(dataColumn,i); - double yv=position; - if (positionScatterStyle==RandomScatter) { - yv=dRandomScatter(gen); - } - const double x=transformX(xv); - double y=transformY(yv); - if (positionScatterStyle==BeeSwarmScatter) { - while (doesCollide(x,y)) { - if (i%2==0) { - y=y-symSize; - } else { - y=y+symSize; - } + std::random_device rd; // random number generators: + std::minstd_rand gen{rd()}; + gen.seed(seedValue); + std::uniform_real_distribution<> dRandomScatter{position-width/2.0, position+width/2.0}; + + const double symSize=parent->pt2px(painter, symbolSize); + + + QVector plotSymbols; // collects symbol locations e.g. for BeeSwarmScatter-plots + plotSymbols.reserve(qMax(100,imax-imin)); + auto doesCollide=[&plotSymbols,&symSize](double x, double y)->bool { + for (auto& p: plotSymbols) { + if (fabs(p.x()-x)pt2px(painter, symbolWidth*parent->getLineWidthMultiplier()), color, fillColor); - } - } - } else { - intSortData(); - for (int iii=imin; iii(imin, getDataIndex(static_cast(iii)), imax); - double xv=position; - if (positionScatterStyle==RandomScatter) { - xv=dRandomScatter(gen); - } - const double yv=datastore->get(dataColumn,i); - double x=transformX(xv); - const double y=transformY(yv); - if (positionScatterStyle==BeeSwarmScatter) { - while (doesCollide(x,y)) { - if (i%2==0) { - x=x-symSize; - } else { - x=x+symSize; + return false; + }; + + if (dataDirection==DataDirection::X) { + intSortData(); + for (int iii=imin; iii(imin, getDataIndex(static_cast(iii)), imax); + const double xv=datastore->get(dataColumn,i); + double yv=position; + if (positionScatterStyle==RandomScatter) { + yv=dRandomScatter(gen); + } + const double x=transformX(xv); + double y=transformY(yv); + if (positionScatterStyle==BeeSwarmScatter) { + while (doesCollide(x,y)) { + if (i%2==0) { + y=y-symSize; + } else { + y=y+symSize; + } } } - } - plotSymbols.append(QPointF(x,y)); - if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv)) { plotSymbols.append(QPointF(x,y)); - JKQTPPlotSymbol(painter, x, y, symbol, symSize, parent->pt2px(painter, symbolWidth*parent->getLineWidthMultiplier()), color, fillColor); + if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv)) { + JKQTPPlotSymbol(painter, x, y, symbol, symSize, parent->pt2px(painter, symbolWidth*parent->getLineWidthMultiplier()), color, fillColor); + } + } + } else { + intSortData(); + for (int iii=imin; iii(imin, getDataIndex(static_cast(iii)), imax); + double xv=position; + if (positionScatterStyle==RandomScatter) { + xv=dRandomScatter(gen); + } + const double yv=datastore->get(dataColumn,i); + double x=transformX(xv); + const double y=transformY(yv); + if (positionScatterStyle==BeeSwarmScatter) { + while (doesCollide(x,y)) { + if (i%2==0) { + x=x-symSize; + } else { + x=x+symSize; + } + } + } + plotSymbols.append(QPointF(x,y)); + if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv)) { + plotSymbols.append(QPointF(x,y)); + JKQTPPlotSymbol(painter, x, y, symbol, symSize, parent->pt2px(painter, symbolWidth*parent->getLineWidthMultiplier()), color, fillColor); + } } } + + + } - - - painter.restore(); - drawErrorsAfter(painter); } @@ -212,14 +218,14 @@ void JKQTPSingleColumnSymbolsGraph::drawKeyMarker(JKQTPEnhancedPainter &painter, double lineWidth=parent->pt2px(painter, this->lineWidth*parent->getLineWidthMultiplier()); if (lineWidth>0.5*maxSize) lineWidth=0.5*maxSize; - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); QPen p=painter.pen(); p.setColor(getKeyLabelColor()); p.setStyle(style); p.setWidthF(lineWidth); painter.setPen(p); JKQTPPlotSymbol(painter, rect.left()+rect.width()/2.0, rect.top()+rect.height()/2.0, symbol, symbolSize, symbolWidth, getKeyLabelColor(), fillColor); - painter.restore(); + } @@ -227,7 +233,7 @@ void JKQTPSingleColumnSymbolsGraph::drawKeyMarker(JKQTPEnhancedPainter &painter, QPen JKQTPSingleColumnSymbolsGraph::getSymbolPen(JKQTPEnhancedPainter& painter) const { QPen p; p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH,parent->pt2px(painter, parent->getLineWidthMultiplier()*symbolWidth))); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH,parent->pt2px(painter, parent->getLineWidthMultiplier()*symbolWidth))); p.setStyle(style); p.setJoinStyle(Qt::RoundJoin); p.setCapStyle(Qt::RoundCap); diff --git a/lib/jkqtplotter/jkqtpgraphssinglecolumnsymbols.h b/lib/jkqtplotter/jkqtpgraphssinglecolumnsymbols.h index 389de286ef..ed36edc90f 100644 --- a/lib/jkqtplotter/jkqtpgraphssinglecolumnsymbols.h +++ b/lib/jkqtplotter/jkqtpgraphssinglecolumnsymbols.h @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -79,60 +79,52 @@ class JKQTP_LIB_EXPORT JKQTPSingleColumnSymbolsGraph: public JKQTPSingleColumnGr /** \brief plots a key marker inside the specified rectangle \a rect */ virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) override; - /*! \brief sets the property position ( \copybrief position ) to the specified \a __value. - \details Description of the parameter position is:
    \copydoc position
    - \see position for more information */ + /*! \copydoc position + \see see position for details */ inline virtual void setPosition(double __value) { this->position = __value; } - /*! \brief returns the property position ( \copybrief position ). - \details Description of the parameter position is:
    \copydoc position
    - \see position for more information */ + /*! \copydoc position + \see see position for details */ inline virtual double getPosition() const { return this->position; } - /*! \brief sets the property width ( \copybrief width ) to the specified \a __value. - \details Description of the parameter width is:
    \copydoc width
    - \see width for more information */ + /*! \copydoc width + \see see width for details */ inline virtual void setWidth(double __value) { this->width = __value; } - /*! \brief returns the property width ( \copybrief width ). - \details Description of the parameter width is:
    \copydoc width
    - \see width for more information */ + /*! \copydoc width + \see see width for details */ inline virtual double getWidth() const { return this->width; } - /*! \brief sets the property dataDirection ( \copybrief dataDirection ) to the specified \a __value. - \details Description of the parameter dataDirection is:
    \copydoc dataDirection
    - \see dataDirection for more information */ + /*! \copydoc dataDirection + \see see dataDirection for details */ inline virtual void setDataDirection(DataDirection __value) { this->dataDirection = __value; } - /*! \brief returns the property dataDirection ( \copybrief dataDirection ). - \details Description of the parameter dataDirection is:
    \copydoc dataDirection
    - \see dataDirection for more information */ + /*! \copydoc dataDirection + \see see dataDirection for details */ inline virtual DataDirection getDataDirection() const { return this->dataDirection; } - /*! \brief sets the property positionScatterStyle ( \copybrief positionScatterStyle ) to the specified \a __value. - \details Description of the parameter positionScatterStyle is:
    \copydoc positionScatterStyle
    - \see positionScatterStyle for more information */ + /*! \copydoc positionScatterStyle + \see see positionScatterStyle for details */ inline virtual void setPositionScatterStyle(ScatterStyle __value) { this->positionScatterStyle = __value; } - /*! \brief returns the property positionScatterStyle ( \copybrief positionScatterStyle ). - \details Description of the parameter positionScatterStyle is:
    \copydoc positionScatterStyle
    - \see positionScatterStyle for more information */ + /*! \copydoc positionScatterStyle + \see see positionScatterStyle for details */ inline virtual ScatterStyle getPositionScatterStyle() const { return this->positionScatterStyle; @@ -140,58 +132,50 @@ class JKQTP_LIB_EXPORT JKQTPSingleColumnSymbolsGraph: public JKQTPSingleColumnGr - /*! \brief sets the property fillColor ( \copybrief fillColor ) to the specified \a __value. - \details Description of the parameter fillColor is:
    \copydoc fillColor
    - \see fillColor for more information */ + /*! \copydoc fillColor + \see see fillColor for details */ inline virtual void setFillColor(const QColor & __value) { this->fillColor = __value; } - /*! \brief returns the property fillColor ( \copybrief fillColor ). - \details Description of the parameter fillColor is:
    \copydoc fillColor
    - \see fillColor for more information */ + /*! \copydoc fillColor + \see see fillColor for details */ inline virtual QColor getFillColor() const { return this->fillColor; } - /*! \brief sets the property symbol ( \copybrief symbol ) to the specified \a __value. - \details Description of the parameter symbol is:
    \copydoc symbol
    - \see symbol for more information */ + /*! \copydoc symbol + \see see symbol for details */ inline virtual void setSymbol(const JKQTPGraphSymbols & __value) { this->symbol = __value; } - /*! \brief returns the property symbol ( \copybrief symbol ). - \details Description of the parameter symbol is:
    \copydoc symbol
    - \see symbol for more information */ + /*! \copydoc symbol + \see see symbol for details */ inline virtual JKQTPGraphSymbols getSymbol() const { return this->symbol; } - /*! \brief sets the property symbolWidth ( \copybrief symbolWidth ) to the specified \a __value. - \details Description of the parameter symbolWidth is:
    \copydoc symbolWidth
    - \see symbolWidth for more information */ + /*! \copydoc symbolWidth + \see see symbolWidth for details */ inline virtual void setSymbolWidth(double __value) { this->symbolWidth = __value; } - /*! \brief returns the property symbolWidth ( \copybrief symbolWidth ). - \details Description of the parameter symbolWidth is:
    \copydoc symbolWidth
    - \see symbolWidth for more information */ + /*! \copydoc symbolWidth + \see see symbolWidth for details */ inline virtual double getSymbolWidth() const { return this->symbolWidth; } - /*! \brief sets the property symbolSize ( \copybrief symbolSize ) to the specified \a __value. - \details Description of the parameter symbolSize is:
    \copydoc symbolSize
    - \see symbolSize for more information */ + /*! \copydoc symbolSize + \see see symbolSize for details */ inline virtual void setSymbolSize(double __value) { this->symbolSize = __value; } - /*! \brief returns the property symbolSize ( \copybrief symbolSize ). - \details Description of the parameter symbolSize is:
    \copydoc symbolSize
    - \see symbolSize for more information */ + /*! \copydoc symbolSize + \see see symbolSize for details */ inline virtual double getSymbolSize() const { return this->symbolSize; diff --git a/lib/jkqtplotter/jkqtpkeystyle.cpp b/lib/jkqtplotter/jkqtpkeystyle.cpp new file mode 100644 index 0000000000..748ced902b --- /dev/null +++ b/lib/jkqtplotter/jkqtpkeystyle.cpp @@ -0,0 +1,105 @@ +/* + Copyright (c) 2008-2019 Jan W. Krieger (, ) + + + + This software is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License 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 for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ + + +#include "jkqtpkeystyle.h" +#include "jkqtpbaseplotterstyle.h" +#include + +JKQTPKeyStyle::JKQTPKeyStyle(): + frameVisible(true), + frameColor(QColor("black")), + frameWidth(1), + frameRounding(0), + backgroundColor(QColor("white")), + visible(true), + fontSize(9), + textColor(QColor("black")), + itemWidth(20), + itemHeight(2.2), + sampleLineLength(3), + xMargin(0.5), + yMargin(0.5), + xOffset(0.5), + yOffset(0.5), + xSeparation(0.75), + ySeparation(0.75), + position(JKQTPKeyInsideTopRight), + layout(JKQTPKeyLayoutOneColumn), + autosize(true) +{ + + + +} + +JKQTPKeyStyle::JKQTPKeyStyle(const JKQTBasePlotterStyle &baseStyle): + JKQTPKeyStyle() +{ + fontSize=baseStyle.defaultFontSize; + textColor=baseStyle.defaultTextColor; +} + +void JKQTPKeyStyle::loadSettings(const QSettings &settings, const QString &group, const JKQTPKeyStyle &defaultStyle) +{ + xOffset = settings.value(group+"xoffset", defaultStyle.xOffset).toDouble(); + yOffset = settings.value(group+"yoffset", defaultStyle.yOffset).toDouble(); + xMargin = settings.value(group+"xmargin", defaultStyle.xMargin).toDouble(); + yMargin = settings.value(group+"ymargin", defaultStyle.yMargin).toDouble(); + xSeparation = settings.value(group+"xseparation", defaultStyle.xSeparation).toDouble(); + ySeparation = settings.value(group+"yseparation", defaultStyle.ySeparation).toDouble(); + frameColor = jkqtp_String2QColor(settings.value(group+"frame_color", jkqtp_QColor2String(defaultStyle.frameColor)).toString()); + textColor = jkqtp_String2QColor(settings.value(group+"text_color", jkqtp_QColor2String(defaultStyle.textColor)).toString()); + frameWidth = settings.value(group+"frame_width", defaultStyle.frameWidth).toDouble(); + frameRounding = settings.value(group+"frame_rounding", defaultStyle.frameRounding).toDouble(); + frameVisible = settings.value(group+"frame_visible", defaultStyle.frameVisible).toBool(); + backgroundColor = jkqtp_String2QColor(settings.value(group+"background_color", jkqtp_QColor2String(defaultStyle.backgroundColor)).toString()); + visible = settings.value(group+"visible", defaultStyle.visible).toBool(); + position = String2JKQTPKeyPosition(settings.value(group+"position", JKQTPKeyPosition2String(defaultStyle.position)).toString()); + layout = String2JKQTPKeyLayout(settings.value(group+"layout", JKQTPKeyLayout2String(defaultStyle.layout)).toString()); + fontSize = settings.value(group+"fontsize", defaultStyle.fontSize).toDouble(); + itemWidth = settings.value(group+"item_width", defaultStyle.itemWidth).toDouble(); + itemHeight = settings.value(group+"item_height", defaultStyle.itemHeight).toDouble(); + sampleLineLength = settings.value(group+"line_width", defaultStyle.sampleLineLength).toDouble(); + autosize = settings.value(group+"autosize", defaultStyle.autosize).toBool(); +} + +void JKQTPKeyStyle::saveSettings(QSettings &settings, const QString &group) const +{ + settings.setValue(group+"xoffset", xOffset); + settings.setValue(group+"yoffset", yOffset); + settings.setValue(group+"xmargin", xMargin); + settings.setValue(group+"ymargin", yMargin); + settings.setValue(group+"xseparation", xSeparation); + settings.setValue(group+"yseparation", ySeparation); + settings.setValue(group+"frame_visible", frameVisible); + settings.setValue(group+"frame_color", jkqtp_QColor2String(frameColor)); + settings.setValue(group+"frame_width", frameWidth); + settings.setValue(group+"frame_rounding", frameRounding); + settings.setValue(group+"background_color", jkqtp_QColor2String(backgroundColor)); + settings.setValue(group+"visible", visible); + settings.setValue(group+"position", JKQTPKeyPosition2String(position)); + settings.setValue(group+"layout", JKQTPKeyLayout2String(layout)); + settings.setValue(group+"fontsize", fontSize); + settings.setValue(group+"text_color", jkqtp_QColor2String(textColor)); + settings.setValue(group+"item_width", itemWidth); + settings.setValue(group+"item_height", itemHeight); + settings.setValue(group+"line_width", sampleLineLength); + settings.setValue(group+"autosize", autosize); +} diff --git a/lib/jkqtplotter/jkqtpkeystyle.h b/lib/jkqtplotter/jkqtpkeystyle.h new file mode 100644 index 0000000000..f3de283fb6 --- /dev/null +++ b/lib/jkqtplotter/jkqtpkeystyle.h @@ -0,0 +1,102 @@ +/* + Copyright (c) 2008-2019 Jan W. Krieger (, ) + + + + This software is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License 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 for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ + +#ifndef JKQTPSTYLE_H +#define JKQTPSTYLE_H + +#include "jkqtplottertools/jkqtptools.h" +#include "jkqtplottertools/jkqtp_imexport.h" +#include +#include +#include + +class JKQTBasePlotterStyle; // forward + +/** \brief Support Class for JKQTBasePlotter, which summarizes all proeprties that define the visual styling of the key in a JKQTBasePlotter + * \ingroup jkqtpplotter_styling + * + * \see JKQTBasePlotter, JKQTBasePlotterStyle, \ref jkqtpplotter_styling + */ +class JKQTP_LIB_EXPORT JKQTPKeyStyle { + Q_GADGET + public: + JKQTPKeyStyle(); + JKQTPKeyStyle(const JKQTBasePlotterStyle& baseStyle); + + + /** \brief loads the plot properties from a QSettings object + * + * \param settings QSettings-object to read from + * \param group Group in the QSettings-object to read from + * \param defaultStyle If a setting cannot be found in \a settings, default values are taken from this object + * By default, this is a default-constructed object + */ + void loadSettings(const QSettings &settings, const QString& group=QString("plots/key/"), const JKQTPKeyStyle &defaultStyle=JKQTPKeyStyle()); + + /** \brief saves the plot properties into a QSettings object. + * + * \param settings QSettings-object to save to + * \param group Group in the QSettings-object to save to + */ + void saveSettings(QSettings& settings, const QString& group=QString("plots/key/")) const; + + + /** \brief indicates whether to plot a frame around the key */ + bool frameVisible; + /** \brief color of the key frame line */ + QColor frameColor; + /** \brief width of the key frame line [pt] */ + double frameWidth; + /** \brief rounding radius of the key frame rectangle (<=0 -> no rounded rectangle) [pt] */ + double frameRounding; + /** \brief color of the key background */ + QColor backgroundColor; + /** \brief indicates whether to plot a key */ + bool visible; + /** \brief font size for key labels [in points] */ + double fontSize; + /** \brief color of the key entries' text */ + QColor textColor; + /** \brief width of a key item in pt [in units of width of 'X' set in font, fontSize] */ + double itemWidth; + /** \brief height of a key item in pt [in units of height of font, fontSize] */ + double itemHeight; + /** \brief length of the line samples in the key in pt [in units of width of 'X' set in font, fontSize] */ + double sampleLineLength; + /** \brief x-distance between key frame and key content [in units of width of 'X' set in font, fontSize] */ + double xMargin; + /** \brief y-distance between key frame and key content [in units of width of 'x' set in font, fontSize] */ + double yMargin; + /** \brief x-offset of the key from the border of the plot [in units of width of 'X' set in font, fontSize] */ + double xOffset; + /** \brief y-offset of the key from the border of the plot [in units of width of 'x' set in font, fontSize] */ + double yOffset; + /** \brief distance between key line example and key text [in units of width of 'X' set in font, fontSize] */ + double xSeparation; + /** \brief distance between two key entries [in units of height of font, fontSize] */ + double ySeparation; + /** \brief key position */ + JKQTPKeyPosition position; + /** \brief the key layout */ + JKQTPKeyLayout layout; + /** \brief determine width of the key automatically */ + bool autosize; +}; + +#endif // JKQTPSTYLE_H diff --git a/lib/jkqtplotter/jkqtplotter.cpp b/lib/jkqtplotter/jkqtplotter.cpp index 56485d6972..62b81f583d 100644 --- a/lib/jkqtplotter/jkqtplotter.cpp +++ b/lib/jkqtplotter/jkqtplotter.cpp @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -42,29 +42,12 @@ * JKQTPlotter **************************************************************************************************************************/ JKQTPlotter::JKQTPlotter(bool datastore_internal, QWidget* parent, JKQTPDatastore* datast): - QWidget(parent, Qt::Widget) + QWidget(parent, Qt::Widget), + plotterStyle(JKQTPGetSystemDefaultStyle()) { initJKQTPlotterResources(); - init(datastore_internal, parent, datast); -} -JKQTPlotter::JKQTPlotter(JKQTPDatastore *datast, QWidget *parent): - QWidget(parent, Qt::Widget) -{ - initJKQTPlotterResources(); - init(false, parent, datast); -} - -JKQTPlotter::JKQTPlotter(QWidget *parent): - QWidget(parent, Qt::Widget) -{ - initJKQTPlotterResources(); - init(true, parent, nullptr); -} - -void JKQTPlotter::init(bool datastore_internal, QWidget* parent, JKQTPDatastore* datast) -{ - menuSpecialContextMenu=nullptr; + menujkqtpcmmSpecialContextMenu=nullptr; mouseContextX=0; mouseContextY=0; setParent(parent); @@ -73,10 +56,8 @@ void JKQTPlotter::init(bool datastore_internal, QWidget* parent, JKQTPDatastore* magnification=1; plotter=new JKQTBasePlotter(datastore_internal, this, datast); plotter->setEmittingSignalsEnabled(false); - plotter->setBackgroundColor(palette().color(QPalette::Window));//QPalette::Window - plotter->setDefaultBackgroundColor(palette().color(QPalette::Window));//QPalette::Window - //plotter->setPlotBackgroundColor(palette().color(QPalette::Base)); - //plotter->setDefaultPlotBackgroundColor((palette().color(QPalette::Base)); + fixBasePlotterSettings(); + mousePosX=0; mousePosY=0; @@ -89,23 +70,10 @@ void JKQTPlotter::init(bool datastore_internal, QWidget* parent, JKQTPDatastore* image=QImage(width(), height(), QImage::Format_ARGB32); oldImage=image; imageNoOverlays=image; - toolbarIconSize=16; mouseDragingRectangle=false; - default_userActionColor=QColor("steelblue"); userActionColor=default_userActionColor; - default_userActionCompositionMode=QPainter::CompositionMode_SourceOver; userActionCompositionMode=default_userActionCompositionMode; - default_mousePositionTemplate=QString("(%1; %2)"); mousePositionTemplate=default_mousePositionTemplate; - - displayMousePosition=true; - displayToolbar=true; - toolbarAlwaysOn=false; - // set default user-interactions: - contextMenuMode=ContextMenuModes::StandardContextMenu; - registerMouseDragAction(Qt::LeftButton, Qt::NoModifier, MouseDragActions::ZoomRectangle); - registerMouseDragAction(Qt::LeftButton, Qt::ControlModifier, MouseDragActions::PanPlotOnMove); - registerMouseDoubleClickAction(Qt::LeftButton, Qt::NoModifier, MouseDoubleClickActions::ClickMovesViewport); - registerMouseWheelAction(Qt::NoModifier, MouseWheelActions::ZoomByWheel); + contextMenuMode=JKQTPContextMenuModes::jkqtpcmmStandardContextMenu; // enable mouse-tracking, so mouseMoved-Events can be caught setMouseTracking(true); @@ -121,14 +89,9 @@ void JKQTPlotter::init(bool datastore_internal, QWidget* parent, JKQTPDatastore* toolbar->addSeparator(); populateToolbar(toolbar); - - contextMenu=new QMenu(this); - - - - QSize s=QSize(toolbarIconSize, toolbarIconSize); + QSize s=QSize(plotterStyle.toolbarIconSize, plotterStyle.toolbarIconSize); toolbar->setIconSize(s); //move(32,32); @@ -138,6 +101,17 @@ void JKQTPlotter::init(bool datastore_internal, QWidget* parent, JKQTPDatastore* redrawPlot(); } +JKQTPlotter::JKQTPlotter(JKQTPDatastore *datast, QWidget *parent): + JKQTPlotter(false, parent, datast) +{ + +} + +JKQTPlotter::JKQTPlotter(QWidget *parent): + JKQTPlotter(true, parent, nullptr) +{ + +} JKQTPlotter::~JKQTPlotter() { disconnect(plotter, SIGNAL(plotUpdated()), this, SLOT(redrawPlot())); @@ -147,6 +121,13 @@ JKQTPlotter::~JKQTPlotter() { delete plotter; } +void JKQTPlotter::fixBasePlotterSettings() +{ + if (plotterStyle.usePaletteColors) { + plotter->setBackgroundColor(palette().color(QPalette::Window)); + } +} + void JKQTPlotter::updateToolbarActions() { toolbar->clear(); @@ -158,114 +139,109 @@ void JKQTPlotter::updateToolbarActions() } void JKQTPlotter::setToolbarIconSize(int value) { - toolbarIconSize=value; - QSize s=QSize(toolbarIconSize, toolbarIconSize); + plotterStyle.toolbarIconSize=value; + QSize s=QSize(plotterStyle.toolbarIconSize, plotterStyle.toolbarIconSize); toolbar->setIconSize(s); } int JKQTPlotter::getToolbarIconSize() { - return toolbarIconSize; + return plotterStyle.toolbarIconSize; } -void JKQTPlotter::setToolbarVisible(bool __value) +void JKQTPlotter::setToolbarEnabled(bool __value) { - if (this->displayToolbar != __value) { - this->displayToolbar = __value; + if (plotterStyle.toolbarEnabled != __value) { + plotterStyle.toolbarEnabled = __value; updateToolbar(); } } -bool JKQTPlotter::isToolbarVisible() const +bool JKQTPlotter::isToolbarEnabled() const { - return this->displayToolbar; + return plotterStyle.toolbarEnabled; } void JKQTPlotter::setToolbarAlwaysOn(bool __value) { - if (this->toolbarAlwaysOn != __value) { - this->toolbarAlwaysOn = __value; + if (plotterStyle.toolbarAlwaysOn != __value) { + plotterStyle.toolbarAlwaysOn = __value; updateToolbar(); } } bool JKQTPlotter::isToolbarAlwaysOn() const { - return this->toolbarAlwaysOn; + return plotterStyle.toolbarAlwaysOn; } void JKQTPlotter::setMousePositionShown(bool __value) { - this->displayMousePosition = __value; + plotterStyle.displayMousePosition = __value; } bool JKQTPlotter::isMousePositionShown() const { - return this->displayMousePosition; + return plotterStyle.displayMousePosition; } void JKQTPlotter::setUserActionColor(const QColor &__value) { - if (this->userActionColor != __value) { - this->userActionColor = __value; + if (plotterStyle.userActionColor != __value) { + plotterStyle.userActionColor = __value; update(); } } QColor JKQTPlotter::getUserActionColor() const { - return this->userActionColor; + return plotterStyle.userActionColor; } void JKQTPlotter::setUserActionCompositionMode(const QPainter::CompositionMode &__value) { - if (this->userActionCompositionMode != __value) { - this->userActionCompositionMode = __value; + if (plotterStyle.userActionCompositionMode != __value) { + plotterStyle.userActionCompositionMode = __value; update(); } } -void JKQTPlotter::registerMouseWheelAction(Qt::KeyboardModifier modifier, JKQTPlotter::MouseWheelActions action) +void JKQTPlotter::registerMouseWheelAction(Qt::KeyboardModifiers modifier, JKQTPMouseWheelActions action) { - registeredMouseWheelActions[modifier]=action; + plotterStyle.registeredMouseWheelActions[modifier]=action; } -void JKQTPlotter::deregisterMouseWheelAction(Qt::KeyboardModifier modifier) +void JKQTPlotter::deregisterMouseWheelAction(Qt::KeyboardModifiers modifier) { - registeredMouseWheelActions.remove(modifier); + plotterStyle.registeredMouseWheelActions.remove(modifier); } void JKQTPlotter::clearAllMouseWheelActions() { - registeredMouseWheelActions.clear(); + plotterStyle.registeredMouseWheelActions.clear(); } QPainter::CompositionMode JKQTPlotter::getUserActionCompositionMode() const { - return this->userActionCompositionMode; + return plotterStyle.userActionCompositionMode; } void JKQTPlotter::loadSettings(const QSettings& settings, const QString& group) { plotter->loadSettings(settings, group); + plotterStyle.loadSettings(settings, group, JKQTPGetSystemDefaultStyle()); - setToolbarIconSize(settings.value(group+"toolbar_icon_size", toolbarIconSize).toInt()); - mousePositionTemplate=settings.value(group+"mouse_position_template", mousePositionTemplate).toString(); - userActionColor=QColor(settings.value(group+"zoomrect_color", jkqtp_QColor2String(userActionColor)).toString()); - + updateToolbar(); redrawPlot(); } void JKQTPlotter::saveSettings(QSettings& settings, const QString& group) const { + plotterStyle.saveSettings(settings, group); plotter->saveSettings(settings, group); - - if (userActionColor!=default_userActionColor) settings.setValue(group+"zoomrect_color", jkqtp_QColor2String(userActionColor)); - if (toolbarIconSize!=default_toolbarIconSize) settings.setValue(group+"toolbar_icon_size", toolbarIconSize); - if (mousePositionTemplate!=default_mousePositionTemplate) settings.setValue(group+"mouse_position_template", mousePositionTemplate); } @@ -276,11 +252,11 @@ void JKQTPlotter::paintUserAction() { JKQTPEnhancedPainter painter(&image); QPen p=painter.pen(); p.setWidthF(1); - p.setColor(QColor("black")); + p.setColor(plotterStyle.userActionColor.darker()); p.setStyle(Qt::DashLine); painter.setPen(p); QPainter::CompositionMode oldCMode=painter.compositionMode(); - painter.setCompositionMode(userActionCompositionMode); + painter.setCompositionMode(plotterStyle.userActionCompositionMode); if ((mouseDragRectXEnd!=mouseDragRectXStart) && (mouseDragRectYEnd!=mouseDragRectYStart)) { double x1=plotter->x2p(mouseDragRectXStart)*magnification; double y1=plotter->y2p(mouseDragRectYStart)*magnification; @@ -288,24 +264,24 @@ void JKQTPlotter::paintUserAction() { double y2=plotter->y2p(mouseDragRectYEnd)*magnification; double dx=x2-x1; double dy=y2-y1; - if ((currentMouseDragAction.mode==JKQTPlotter::ZoomRectangle) || (currentMouseDragAction.mode==JKQTPlotter::DrawRectangleForEvent)) { + if ((currentMouseDragAction.mode==jkqtpmdaZoomByRectangle) || (currentMouseDragAction.mode==jkqtpmdaDrawRectangleForEvent)) { painter.setOpacity(0.2); - painter.fillRect(QRectF(x1, y1, x2-x1, y2-y1), QBrush(userActionColor)); + painter.fillRect(QRectF(x1, y1, x2-x1, y2-y1), QBrush(plotterStyle.userActionColor)); painter.setOpacity(1.0); painter.drawRect(QRectF(x1, y1, x2-x1, y2-y1)); - } else if (currentMouseDragAction.mode==JKQTPlotter::DrawCircleForEvent) { - QColor zc=userActionColor; + } else if (currentMouseDragAction.mode==jkqtpmdaDrawCircleForEvent) { + QColor zc=plotterStyle.userActionColor; zc.setAlphaF(0.2); painter.setBrush(QBrush(zc)); painter.drawEllipse(QPointF(x1, y1), qMin(fabs(dx), fabs(dy)), qMin(fabs(dx), fabs(dy))); - } else if (currentMouseDragAction.mode==JKQTPlotter::DrawEllipseForEvent) { - QColor zc=userActionColor; + } else if (currentMouseDragAction.mode==jkqtpmdaDrawEllipseForEvent) { + QColor zc=plotterStyle.userActionColor; zc.setAlphaF(0.2); painter.setBrush(QBrush(zc)); painter.drawEllipse(QPointF(x1, y1), fabs(dx), fabs(dy)); - } else if (currentMouseDragAction.mode==JKQTPlotter::DrawLineForEvent) { + } else if (currentMouseDragAction.mode==jkqtpmdaDrawLineForEvent) { QPen pp=p; - pp.setColor(userActionColor); + pp.setColor(plotterStyle.userActionColor); painter.setPen(pp); painter.drawLine(QPointF(x1,y1), QPointF(x2,y2)); } @@ -318,34 +294,34 @@ void JKQTPlotter::paintUserAction() { void JKQTPlotter::mouseMoveEvent ( QMouseEvent * event ) { - if (displayMousePosition) { + if (plotterStyle.displayMousePosition) { mousePosX=plotter->p2x(event->x()/magnification); mousePosY=plotter->p2y((event->y()-getPlotYOffset())/magnification); update(); } - if (displayToolbar && (!toolbarAlwaysOn) && (!toolbar->isVisible())) { // decide whether to display toolbar + if (plotterStyle.toolbarEnabled && (!plotterStyle.toolbarAlwaysOn) && (!toolbar->isVisible())) { // decide whether to display toolbar int y1=10; if (event->y()/magnification>=0 && event->y()/magnification<=y1) { toolbar->show(); toolbar->move(1,1); } } - if (!displayToolbar) { + if (!plotterStyle.toolbarEnabled) { toolbar->hide(); } if (currentMouseDragAction.isValid()) { - if (( (currentMouseDragAction.mode==JKQTPlotter::ZoomRectangle) || - (currentMouseDragAction.mode==JKQTPlotter::DrawRectangleForEvent) || - (currentMouseDragAction.mode==JKQTPlotter::DrawCircleForEvent) || - (currentMouseDragAction.mode==JKQTPlotter::DrawEllipseForEvent) || - (currentMouseDragAction.mode==JKQTPlotter::ScribbleForEvents) || - (currentMouseDragAction.mode==JKQTPlotter::PanPlotOnMove) || - (currentMouseDragAction.mode==JKQTPlotter::PanPlotOnRelease) || - (currentMouseDragAction.mode==JKQTPlotter::DrawLineForEvent) ) && + if (( (currentMouseDragAction.mode==jkqtpmdaZoomByRectangle) || + (currentMouseDragAction.mode==jkqtpmdaDrawRectangleForEvent) || + (currentMouseDragAction.mode==jkqtpmdaDrawCircleForEvent) || + (currentMouseDragAction.mode==jkqtpmdaDrawEllipseForEvent) || + (currentMouseDragAction.mode==jkqtpmdaScribbleForEvents) || + (currentMouseDragAction.mode==jkqtpmdaPanPlotOnMove) || + (currentMouseDragAction.mode==jkqtpmdaPanPlotOnRelease) || + (currentMouseDragAction.mode==jkqtpmdaDrawLineForEvent) ) && mouseDragingRectangle) { - if (currentMouseDragAction.mode==JKQTPlotter::ScribbleForEvents || currentMouseDragAction.mode==JKQTPlotter::PanPlotOnMove) { + if (currentMouseDragAction.mode==jkqtpmdaScribbleForEvents || currentMouseDragAction.mode==jkqtpmdaPanPlotOnMove) { // start is last event position mouseDragRectXStart=mouseDragRectXEnd; mouseDragRectYStart=mouseDragRectYEnd; @@ -359,13 +335,13 @@ void JKQTPlotter::mouseMoveEvent ( QMouseEvent * event ) { paintUserAction(); event->accept(); //std::cout<modifiers()); } - if ((currentMouseDragAction.mode==JKQTPlotter::ScribbleForEvents) && ((mouseDragRectXStart!=mouseDragRectXEnd) || (mouseDragRectYStart!=mouseDragRectYEnd)) ) { + if ((currentMouseDragAction.mode==jkqtpmdaScribbleForEvents) && ((mouseDragRectXStart!=mouseDragRectXEnd) || (mouseDragRectYStart!=mouseDragRectYEnd)) ) { emit userScribbleClick(mouseDragRectXEnd, mouseDragRectYEnd, event->modifiers(), false, false); } - if ((currentMouseDragAction.mode==JKQTPlotter::PanPlotOnMove) && ((mouseDragRectXStart!=mouseDragRectXEnd) || (mouseDragRectYStart!=mouseDragRectYEnd)) ) { + if ((currentMouseDragAction.mode==jkqtpmdaPanPlotOnMove) && ((mouseDragRectXStart!=mouseDragRectXEnd) || (mouseDragRectYStart!=mouseDragRectYEnd)) ) { QRectF zoomRect= QRectF(QPointF(plotter->x2p(getXAxis()->getMin()),plotter->y2p(getYAxis()->getMax())), QPointF(plotter->x2p(getXAxis()->getMax()),plotter->y2p(getYAxis()->getMin()))); if ( (mouseLastClickX/magnificationgetInternalPlotBorderLeft()) || (mouseLastClickX/magnification>plotter->getPlotWidth()+plotter->getInternalPlotBorderLeft()) ) { zoomRect.translate(0, mouseDragRectYStartPixel-mouseDragRectYEndPixel); @@ -397,7 +373,7 @@ void JKQTPlotter::mousePressEvent ( QMouseEvent * event ){ currentMouseDragAction.clear(); auto actionIT=findMatchingMouseDragAction(event->button(), event->modifiers()); - if (actionIT!=registeredMouseDragActionModes.end()) { + if (actionIT!=plotterStyle.registeredMouseDragActionModes.end()) { // we found a matching action currentMouseDragAction=MouseDragAction(actionIT.key().first, actionIT.key().second, actionIT.value()); mouseLastClickX=event->x(); @@ -408,9 +384,9 @@ void JKQTPlotter::mousePressEvent ( QMouseEvent * event ){ mouseDragRectYEndPixel=mouseDragRectYStartPixel=event->y(); mouseDragingRectangle=true; oldImage=image; - if (currentMouseDragAction.mode==JKQTPlotter::ScribbleForEvents) emit userScribbleClick(mouseDragRectXStart, mouseDragRectYStart, event->modifiers(), true, false); + if (currentMouseDragAction.mode==jkqtpmdaScribbleForEvents) emit userScribbleClick(mouseDragRectXStart, mouseDragRectYStart, event->modifiers(), true, false); event->accept(); - } else if (event->button()==Qt::RightButton && event->modifiers()==Qt::NoModifier && contextMenuMode!=NoContextMenu) { + } else if (event->button()==Qt::RightButton && event->modifiers()==Qt::NoModifier && contextMenuMode!=jkqtpcmmNoContextMenu) { mouseLastClickX=event->x(); mouseLastClickY=event->y(); openContextMenu(event->x(), event->y()); @@ -446,7 +422,7 @@ void JKQTPlotter::mouseReleaseEvent ( QMouseEvent * event ){ double y2=mouseDragRectYEnd; if ((mouseDragRectXStart!=mouseDragRectXEnd) && (mouseDragRectYStart!=mouseDragRectYEnd)) { - if (currentMouseDragAction.mode==JKQTPlotter::ZoomRectangle) { + if (currentMouseDragAction.mode==jkqtpmdaZoomByRectangle) { double xmin=mouseDragRectXStart; double xmax=mouseDragRectXEnd; @@ -455,7 +431,7 @@ void JKQTPlotter::mouseReleaseEvent ( QMouseEvent * event ){ emit zoomChangedLocally(xmin, xmax, ymin, ymax, this); plotter->setXY(xmin, xmax, ymin, ymax); - } else if (currentMouseDragAction.mode==JKQTPlotter::PanPlotOnRelease) { + } else if (currentMouseDragAction.mode==jkqtpmdaPanPlotOnRelease) { QRectF zoomRect= QRectF(QPointF(plotter->x2p(getXAxis()->getMin()),plotter->y2p(getYAxis()->getMax())), QPointF(plotter->x2p(getXAxis()->getMax()),plotter->y2p(getYAxis()->getMin()))); if ( (mouseLastClickX/magnificationgetInternalPlotBorderLeft()) || (mouseLastClickX/magnification>plotter->getPlotWidth()+plotter->getInternalPlotBorderLeft()) ) { zoomRect.translate(0, mouseDragRectYStartPixel-mouseDragRectYEndPixel); @@ -465,18 +441,18 @@ void JKQTPlotter::mouseReleaseEvent ( QMouseEvent * event ){ zoomRect.translate(mouseDragRectXStartPixel-mouseDragRectXEndPixel, mouseDragRectYStartPixel-mouseDragRectYEndPixel); } setXY(plotter->p2x(zoomRect.left()), plotter->p2x(zoomRect.right()), plotter->p2y(zoomRect.bottom()), plotter->p2y(zoomRect.top())); - } else if (currentMouseDragAction.mode==JKQTPlotter::DrawRectangleForEvent) { + } else if (currentMouseDragAction.mode==jkqtpmdaDrawRectangleForEvent) { emit userRectangleFinished(x1, y1, x2-x1, y2-y1, event->modifiers()); - } else if (currentMouseDragAction.mode==JKQTPlotter::DrawCircleForEvent) { + } else if (currentMouseDragAction.mode==jkqtpmdaDrawCircleForEvent) { emit userCircleFinished(x1, y1, qMin(fabs(x2-x1), fabs(y2-y1)), event->modifiers()); - } else if (currentMouseDragAction.mode==JKQTPlotter::DrawEllipseForEvent) { + } else if (currentMouseDragAction.mode==jkqtpmdaDrawEllipseForEvent) { emit userEllipseFinished(x1, y1, fabs(x2-x1), fabs(y2-y1), event->modifiers()); - } else if (currentMouseDragAction.mode==JKQTPlotter::DrawLineForEvent) { + } else if (currentMouseDragAction.mode==jkqtpmdaDrawLineForEvent) { emit userLineFinished(x1, y1, x2, y2, event->modifiers()); } } - if (currentMouseDragAction.mode!=JKQTPlotter::ZoomRectangle) update(); - if (currentMouseDragAction.mode==JKQTPlotter::ScribbleForEvents) emit userScribbleClick(x1, y1, event->modifiers(), false, true); + if (currentMouseDragAction.mode!=jkqtpmdaZoomByRectangle) update(); + if (currentMouseDragAction.mode==jkqtpmdaScribbleForEvents) emit userScribbleClick(x1, y1, event->modifiers(), false, true); event->accept(); } @@ -487,15 +463,15 @@ void JKQTPlotter::mouseReleaseEvent ( QMouseEvent * event ){ void JKQTPlotter::mouseDoubleClickEvent ( QMouseEvent * event ){ auto itAction=findMatchingMouseDoubleClickAction(event->button(), event->modifiers()); - if (itAction!=registeredMouseDoubleClickActions.end()) { + if (itAction!=plotterStyle.registeredMouseDoubleClickActions.end()) { // we found an action to perform on this double-click - if (itAction.value()==MouseDoubleClickActions::ClickOpensContextMenu) { + if (itAction.value()==JKQTPMouseDoubleClickActions::jkqtpdcaClickOpensContextMenu) { openStandardContextMenu(event->x(), event->y()); - } else if (itAction.value()==MouseDoubleClickActions::ClickOpensSpecialContextMenu) { + } else if (itAction.value()==JKQTPMouseDoubleClickActions::jkqtpdcaClickOpensSpecialContextMenu) { openSpecialContextMenu(event->x(), event->y()); - } else if (itAction.value()==MouseDoubleClickActions::ClickZoomsIn || itAction.value()==MouseDoubleClickActions::ClickZoomsOut) { + } else if (itAction.value()==JKQTPMouseDoubleClickActions::jkqtpdcaClickZoomsIn || itAction.value()==JKQTPMouseDoubleClickActions::jkqtpdcaClickZoomsOut) { double factor=4.0; - if (itAction.value()==MouseDoubleClickActions::ClickZoomsOut) factor=1; + if (itAction.value()==JKQTPMouseDoubleClickActions::jkqtpdcaClickZoomsOut) factor=1; double xmin=plotter->p2x(static_cast(event->x())/magnification-static_cast(plotter->getPlotWidth())/factor); double xmax=plotter->p2x(static_cast(event->x())/magnification+static_cast(plotter->getPlotWidth())/factor); @@ -510,7 +486,7 @@ void JKQTPlotter::mouseDoubleClickEvent ( QMouseEvent * event ){ } plotter->setXY(xmin, xmax, ymin, ymax); update(); - } else if (itAction.value()==MouseDoubleClickActions::ClickMovesViewport) { + } else if (itAction.value()==JKQTPMouseDoubleClickActions::jkqtpdcaClickMovesViewport) { QRectF zoomRect= QRectF(QPointF(plotter->x2p(getXAxis()->getMin()),plotter->y2p(getYAxis()->getMax())), QPointF(plotter->x2p(getXAxis()->getMax()),plotter->y2p(getYAxis()->getMin()))); if ( (event->x()/magnificationgetInternalPlotBorderLeft()) || (event->x()/magnification>plotter->getPlotWidth()+plotter->getInternalPlotBorderLeft()) ) { zoomRect.moveCenter(QPointF(zoomRect.center().x(), event->y())); @@ -555,8 +531,8 @@ void JKQTPlotter::keyReleaseEvent(QKeyEvent *event) { void JKQTPlotter::wheelEvent ( QWheelEvent * event ) { auto itAction=findMatchingMouseWheelAction(event->modifiers()); - if (itAction!=registeredMouseWheelActions.end()) { - if (itAction.value()==MouseWheelActions::ZoomByWheel) { + if (itAction!=plotterStyle.registeredMouseWheelActions.end()) { + if (itAction.value()==JKQTPMouseWheelActions::jkqtpmwaZoomByWheel) { double factor=pow(2.0, 1.0*static_cast(event->delta())/120.0)*2.0; double xmin=plotter->p2x(static_cast(event->x())/magnification-static_cast(plotter->getPlotWidth())/factor); double xmax=plotter->p2x(static_cast(event->x())/magnification+static_cast(plotter->getPlotWidth())/factor); @@ -570,7 +546,7 @@ void JKQTPlotter::wheelEvent ( QWheelEvent * event ) { ymax=getYMax(); } plotter->setXY(xmin, xmax, ymin, ymax); - } else if (itAction.value()==MouseWheelActions::PanByWheel) { + } else if (itAction.value()==JKQTPMouseWheelActions::jkqtpmwaPanByWheel) { QRectF zoomRect= QRectF(QPointF(plotter->x2p(getXAxis()->getMin()),plotter->y2p(getYAxis()->getMax())), QPointF(plotter->x2p(getXAxis()->getMax()),plotter->y2p(getYAxis()->getMin()))); QPointF d=QPointF(event->angleDelta().x()/120.0*zoomRect.width()/10.0, event->angleDelta().y()/120.0*zoomRect.height()/10.0); @@ -604,10 +580,10 @@ void JKQTPlotter::wheelEvent ( QWheelEvent * event ) { int JKQTPlotter::getPlotYOffset() { int plotYOffset=0; - if (displayMousePosition) { + if (plotterStyle.displayMousePosition) { plotYOffset=plotYOffset+QFontMetrics(font()).height()+2; } - if (displayToolbar && toolbarAlwaysOn) { + if (plotterStyle.toolbarEnabled && plotterStyle.toolbarAlwaysOn) { plotYOffset=plotYOffset+toolbar->height(); } return plotYOffset; @@ -687,29 +663,29 @@ void JKQTPlotter::updateCursor() { if (!currentMouseDragAction.isValid()) { setCursor(QCursor(Qt::ArrowCursor)); } else { - if (currentMouseDragAction.mode==JKQTPlotter::ZoomRectangle) { + if (currentMouseDragAction.mode==jkqtpmdaZoomByRectangle) { static QBitmap cursor(":/JKQTPlotter/jkqtp_cursor_zoom.png"); static QBitmap mask(":/JKQTPlotter/jkqtp_cursor_zoom_mask.png"); setCursor(QCursor(cursor, mask, 9, 14)); - } else if (currentMouseDragAction.mode==JKQTPlotter::DrawRectangleForEvent) { + } else if (currentMouseDragAction.mode==jkqtpmdaDrawRectangleForEvent) { static QBitmap cursor(":/JKQTPlotter/jkqtp_cursor_rectangle.png"); static QBitmap mask(":/JKQTPlotter/jkqtp_cursor_rectangle_mask.png"); setCursor(QCursor(cursor, mask, 9, 14)); - } else if (currentMouseDragAction.mode==JKQTPlotter::PanPlotOnMove || currentMouseDragAction.mode==JKQTPlotter::PanPlotOnRelease) { + } else if (currentMouseDragAction.mode==jkqtpmdaPanPlotOnMove || currentMouseDragAction.mode==jkqtpmdaPanPlotOnRelease) { setCursor(QCursor(Qt::ClosedHandCursor)); - } else if (currentMouseDragAction.mode==JKQTPlotter::DrawCircleForEvent) { + } else if (currentMouseDragAction.mode==jkqtpmdaDrawCircleForEvent) { static QBitmap cursor(":/JKQTPlotter/jkqtp_cursor_circle.png"); static QBitmap mask(":/JKQTPlotter/jkqtp_cursor_circle_mask.png"); setCursor(QCursor(cursor, mask, 9, 14)); - } else if (currentMouseDragAction.mode==JKQTPlotter::DrawEllipseForEvent) { + } else if (currentMouseDragAction.mode==jkqtpmdaDrawEllipseForEvent) { static QBitmap cursor(":/JKQTPlotter/jkqtp_cursor_ellipse.png"); static QBitmap mask(":/JKQTPlotter/jkqtp_cursor_ellipse_mask.png"); setCursor(QCursor(cursor, mask, 9, 14)); - } else if (currentMouseDragAction.mode==JKQTPlotter::DrawLineForEvent) { + } else if (currentMouseDragAction.mode==jkqtpmdaDrawLineForEvent) { static QBitmap cursor(":/JKQTPlotter/jkqtp_cursor_line.png"); static QBitmap mask(":/JKQTPlotter/jkqtp_cursor_line_mask.png"); setCursor(QCursor(cursor, mask, 9, 14)); - } else if (currentMouseDragAction.mode==JKQTPlotter::ScribbleForEvents) { + } else if (currentMouseDragAction.mode==jkqtpmdaScribbleForEvents) { static QBitmap cursor(":/JKQTPlotter/jkqtp_cursor_scribble.png"); static QBitmap mask(":/JKQTPlotter/jkqtp_cursor_scribble_mask.png"); setCursor(QCursor(cursor, mask, 9, 14)); @@ -758,7 +734,7 @@ void JKQTPlotter::redrawPlot() { if (!doDrawing) return; disconnect(plotter, SIGNAL(plotUpdated()), this, SLOT(redrawPlot())); disconnect(plotter, SIGNAL(overlaysUpdated()), this, SLOT(redrawOverlays())); - plotter->resize(width()/magnification, height()/magnification-getPlotYOffset()); + plotter->setWidgetSize(width()/magnification, height()/magnification-getPlotYOffset()); JKQTPEnhancedPainter painter(&image); if (painter.isActive()) { painter.scale(magnification, magnification); @@ -793,8 +769,8 @@ void JKQTPlotter::paintEvent(QPaintEvent *event){ p->setPen(palette().color(QPalette::Window)); p->drawRect(geometry()); p->restore(); - if (displayMousePosition ) { - p->drawText(plotter->getInternalPlotBorderLeft(), getPlotYOffset()-1, mousePositionTemplate.arg(mousePosX).arg(mousePosY)); + if (plotterStyle.displayMousePosition ) { + p->drawText(plotter->getInternalPlotBorderLeft(), getPlotYOffset()-1, plotterStyle.mousePositionTemplate.arg(mousePosX).arg(mousePosY)); } int plotImageWidth=width(); @@ -854,13 +830,14 @@ void JKQTPlotter::delayedResizeEvent() } void JKQTPlotter::leaveEvent(QEvent * /*event*/) { - if (!toolbarAlwaysOn) toolbar->hide(); + if (!plotterStyle.toolbarAlwaysOn) toolbar->hide(); } void JKQTPlotter::updateToolbar() { - if (displayToolbar) { - if (toolbarAlwaysOn) { + toolbar->setIconSize(QSize(plotterStyle.toolbarIconSize, plotterStyle.toolbarIconSize)); + if (plotterStyle.toolbarEnabled) { + if (plotterStyle.toolbarAlwaysOn) { toolbar->setToolbarVanishesEnabled(false); toolbar->show(); toolbar->move(1,1); @@ -976,20 +953,20 @@ void JKQTPlotter::reactGraphVisible(bool visible) } } -void JKQTPlotter::setContextMenuMode(JKQTPlotter::ContextMenuModes mode) { +void JKQTPlotter::setContextMenuMode(JKQTPContextMenuModes mode) { contextMenuMode=mode; } QMenu *JKQTPlotter::getSpecialContextMenu() const { - return this->menuSpecialContextMenu; + return this->menujkqtpcmmSpecialContextMenu; } void JKQTPlotter::setSpecialContextMenu(QMenu *menu) { - menuSpecialContextMenu=menu; - if (menuSpecialContextMenu) { - menuSpecialContextMenu->setParent(this); - menuSpecialContextMenu->close(); + menujkqtpcmmSpecialContextMenu=menu; + if (menujkqtpcmmSpecialContextMenu) { + menujkqtpcmmSpecialContextMenu->setParent(this); + menujkqtpcmmSpecialContextMenu->close(); } } @@ -1009,10 +986,44 @@ int JKQTPlotter::getMouseLastClickY() const { return this->mouseLastClickY; } -JKQTPlotter::ContextMenuModes JKQTPlotter::getContextMenuMode() const { +JKQTPContextMenuModes JKQTPlotter::getContextMenuMode() const { return contextMenuMode; } +const JKQTPlotterStyle &JKQTPlotter::getCurrentPlotterStyle() const +{ + return plotterStyle; +} + +void JKQTPlotter::setCurrentPlotterStyle(const JKQTPlotterStyle &style) +{ + plotterStyle=style; + updateToolbar(); + redrawPlot(); +} + +void JKQTPlotter::setCurrentPlotterStyle(const JKQTPlotterStyle &style, const JKQTBasePlotterStyle &baseStyle) +{ + plotterStyle=style; + plotter->setCurrentPlotterStyle(baseStyle); + updateToolbar(); + redrawPlot(); +} + +void JKQTPlotter::loadCurrentPlotterStyle(const QSettings &settings, const QString &group, bool alsoLoadBaseStyle) +{ + plotterStyle.loadSettings(settings, group); + if (alsoLoadBaseStyle) plotter->loadCurrentPlotterStyle(settings, group); + updateToolbar(); + redrawPlot(); +} + +void JKQTPlotter::saveCurrentPlotterStyle(QSettings &settings, const QString &group, bool alsoSaveBaseStyle) const +{ + plotterStyle.saveSettings(settings, group); + if (alsoSaveBaseStyle) plotter->saveCurrentPlotterStyle(settings, group); +} + void JKQTPlotter::setMagnification(double m) { magnification=m; @@ -1023,6 +1034,7 @@ void JKQTPlotter::modifyContextMenu(QMenu * /*menu*/) { } + void JKQTPlotter::populateToolbar(QToolBar *toolbar) const { toolbar->addAction(plotter->getActionSaveData()); @@ -1054,11 +1066,11 @@ void JKQTPlotter::openContextMenu() void JKQTPlotter::openContextMenu(int x, int y) { - if (contextMenuMode==ContextMenuModes::StandardContextMenu) { + if (contextMenuMode==JKQTPContextMenuModes::jkqtpcmmStandardContextMenu) { openStandardContextMenu(x,y); - } else if (contextMenuMode==ContextMenuModes::SpecialContextMenu) { + } else if (contextMenuMode==JKQTPContextMenuModes::jkqtpcmmSpecialContextMenu) { openSpecialContextMenu(x,y); - } else if (contextMenuMode==ContextMenuModes::StandardAndSpecialContextMenu) { + } else if (contextMenuMode==JKQTPContextMenuModes::jkqtpcmmStandardAndSpecialContextMenu) { openStandardAndSpecialContextMenu(x,y); } } @@ -1089,19 +1101,19 @@ void JKQTPlotter::openSpecialContextMenu() void JKQTPlotter::openSpecialContextMenu(int x, int y) { - //qDebug()<<"openSpecialContextMenu("<actions().size(); i++) { - //qDebug()<<" - "<actions().at(i)->text(); + //qDebug()<<"openSpecialContextMenu("<actions().size(); i++) { + //qDebug()<<" - "<actions().at(i)->text(); } mouseContextX=plotter->p2x(x/magnification); mouseContextY=plotter->p2y((y-getPlotYOffset())/magnification); - menuSpecialContextMenu->close(); - menuSpecialContextMenu->popup(mapToGlobal(QPoint(x,y))); - menuSpecialContextMenu->resize(menuSpecialContextMenu->sizeHint()); - //qDebug()<<" -> "<size()<pos()<parent(); - emit contextMenuOpened(mouseContextX, mouseContextY, menuSpecialContextMenu); - //qDebug()<<"openSpecialContextMenu("<close(); + menujkqtpcmmSpecialContextMenu->popup(mapToGlobal(QPoint(x,y))); + menujkqtpcmmSpecialContextMenu->resize(menujkqtpcmmSpecialContextMenu->sizeHint()); + //qDebug()<<" -> "<size()<pos()<parent(); + emit contextMenuOpened(mouseContextX, mouseContextY, menujkqtpcmmSpecialContextMenu); + //qDebug()<<"openSpecialContextMenu("<close(); initContextMenu(); - if (menuSpecialContextMenu) { + if (menujkqtpcmmSpecialContextMenu) { contextMenu->addSeparator(); - for (QAction* act: menuSpecialContextMenu->actions()) { + for (QAction* act: menujkqtpcmmSpecialContextMenu->actions()) { contextMenu->addAction(act); } } @@ -1132,61 +1144,19 @@ void JKQTPlotter::openStandardAndSpecialContextMenu(int x, int y) } -QHash, JKQTPlotter::MouseDragActions>::const_iterator JKQTPlotter::findMatchingMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifiers) const +JKQTPMouseDragActionsHashMapIterator JKQTPlotter::findMatchingMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifiers) const { - if (modifiers.testFlag(Qt::ShiftModifier)) { - return registeredMouseDragActionModes.find(qMakePair(button, Qt::ShiftModifier)); - } else if (modifiers.testFlag(Qt::ControlModifier)) { - return registeredMouseDragActionModes.find(qMakePair(button, Qt::ControlModifier)); - } else if (modifiers.testFlag(Qt::AltModifier)) { - return registeredMouseDragActionModes.find(qMakePair(button, Qt::AltModifier)); - } else if (modifiers.testFlag(Qt::MetaModifier)) { - return registeredMouseDragActionModes.find(qMakePair(button, Qt::MetaModifier)); - } else if (modifiers.testFlag(Qt::KeypadModifier)) { - return registeredMouseDragActionModes.find(qMakePair(button, Qt::KeypadModifier)); - } else if (modifiers.testFlag(Qt::GroupSwitchModifier)) { - return registeredMouseDragActionModes.find(qMakePair(button, Qt::GroupSwitchModifier)); - } else { - return registeredMouseDragActionModes.find(qMakePair(button, Qt::NoModifier)); - } + return plotterStyle.registeredMouseDragActionModes.find(qMakePair(button, modifiers)); } -QHash, JKQTPlotter::MouseDoubleClickActions>::const_iterator JKQTPlotter::findMatchingMouseDoubleClickAction(Qt::MouseButton button, Qt::KeyboardModifiers modifiers) const +JKQTPMouseDoubleClickActionsHashMapIterator JKQTPlotter::findMatchingMouseDoubleClickAction(Qt::MouseButton button, Qt::KeyboardModifiers modifiers) const { - if (modifiers.testFlag(Qt::ShiftModifier)) { - return registeredMouseDoubleClickActions.find(qMakePair(button, Qt::ShiftModifier)); - } else if (modifiers.testFlag(Qt::ControlModifier)) { - return registeredMouseDoubleClickActions.find(qMakePair(button, Qt::ControlModifier)); - } else if (modifiers.testFlag(Qt::AltModifier)) { - return registeredMouseDoubleClickActions.find(qMakePair(button, Qt::AltModifier)); - } else if (modifiers.testFlag(Qt::MetaModifier)) { - return registeredMouseDoubleClickActions.find(qMakePair(button, Qt::MetaModifier)); - } else if (modifiers.testFlag(Qt::KeypadModifier)) { - return registeredMouseDoubleClickActions.find(qMakePair(button, Qt::KeypadModifier)); - } else if (modifiers.testFlag(Qt::GroupSwitchModifier)) { - return registeredMouseDoubleClickActions.find(qMakePair(button, Qt::GroupSwitchModifier)); - } else { - return registeredMouseDoubleClickActions.find(qMakePair(button, Qt::NoModifier)); - } + return plotterStyle.registeredMouseDoubleClickActions.find(qMakePair(button, modifiers)); } -QHash::const_iterator JKQTPlotter::findMatchingMouseWheelAction(Qt::KeyboardModifiers modifiers) const +JKQTPMouseWheelActionsHashMapIterator JKQTPlotter::findMatchingMouseWheelAction(Qt::KeyboardModifiers modifiers) const { - if (modifiers.testFlag(Qt::ShiftModifier)) { - return registeredMouseWheelActions.find(Qt::ShiftModifier); - } else if (modifiers.testFlag(Qt::ControlModifier)) { - return registeredMouseWheelActions.find(Qt::ControlModifier); - } else if (modifiers.testFlag(Qt::AltModifier)) { - return registeredMouseWheelActions.find(Qt::AltModifier); - } else if (modifiers.testFlag(Qt::MetaModifier)) { - return registeredMouseWheelActions.find(Qt::MetaModifier); - } else if (modifiers.testFlag(Qt::KeypadModifier)) { - return registeredMouseWheelActions.find(Qt::KeypadModifier); - } else if (modifiers.testFlag(Qt::GroupSwitchModifier)) { - return registeredMouseWheelActions.find(Qt::GroupSwitchModifier); - } else { - return registeredMouseWheelActions.find(Qt::NoModifier); - } + return plotterStyle.registeredMouseWheelActions.find(modifiers); } void JKQTPlotter::setPlotUpdateEnabled(bool enable) @@ -1196,34 +1166,34 @@ void JKQTPlotter::setPlotUpdateEnabled(bool enable) //qDebug()< X, Y; + * fillDataVectors(X, Y); + * + * // make data available to the internal datastore of the plotter: + * size_t columnX=plot->getDatastore()->addCopiedColumn(X, "x"); + * size_t columnY=plot->getDatastore()->addCopiedColumn(Y, "y"); + * + * // create a graph/curve, which displays the data + * JKQTPXYLineGraph* graph1=new JKQTPXYLineGraph(plot); + * graph1->setXColumn(columnX); + * graph1->setYColumn(columnY); + * graph1->setTitle(QObject::tr("graph title")); + * plot->addGraph(graph1); + * + * // autoscale the plot + * plot->zoomToFit(); + * // alternatively set the axis dimension by hand: + * plot->setXY(-10,10,-10,10); + * \endcode + * + * The result should look something like this: + * + * \image html jkqtplotter_simpletest1.png + * + * Starting from this basic example, you can observe several important principles: + * # Data is stored in an (internal) instance of JKQTPDatastore, which is accessible through + * JKQTPlotter::getDatastore(). + * This datastore can either own its data (which is done here, as we copy the data into the store + * by calling JKQTPDatastore::addCopiedColumn(), or it can merely reference to the data (then + * data needs to be available as array of \c double values). + * # Naming conventions: + * - \b plot is the complete drawn image, including the axes, the graphs, the key and all other visual elements + * - plot element any sub element of the plot, e.g. a single coordinate axis, the key, but also any graph/curve + * - \b graph is a single curve/image/geometric element in the plot + * - geometric element is a special graph that does not represent a curve based on data from the JKQTPDatastore, + * but a single graphic element, like a rectangle/circle/line/..., some text, a single symbol + * - \b key is the legend of the plot + * - coordinate axis is each of the x- or y-axis (there might be addition axes, e.g. when showing a color-scale) + * . + * # Each graph is represented by a class derived from JKQTPPlotElement (in the example we instanciated a JKQTPXYLineGraph, + * which shows data as a scatter of symbols that may (or may not) be connected by a line). + * Creating the graph class does not yet add it to the plotter. To add it, call JKQTPlotter::addGraph(). Only + * after this sep, the graph is displayed. You can modify the apperance of the graph (e.g. colors, + * name in the key ...) by setting properties in the graph class instance. + * # You can auto-zoom the axis ranges of the plot by calling JKQTPlotter::zoomToFit(), or set them + * exlicitly by calling JKQTPlotter::setXY(). The user can later zoom in/out by the mouse (and other means). + * You can limit this zoom range by setting an absolute axis range, calling e.g. JKQTPlotter::setAbsoluteXY(). + * The the user cannot zoom farther out than the given range(s). + * # If you want to style the plot itself, you need to set properties of the underlying JKQTBasePloter instance, which + * is accessible through JKQTPlotter::getPlotter(). If you want to style the coordinate axes, you can acces their + * representing objects by caling JKQTPlotter::getXAxis() or JKQTPlotter::getYAxis(). + * . + * + * \see \ref JKQTPlotterSimpleTest and \see JKQTPlotterQtCreator + * * \section JKQTPLOTTER_SYNCMULTIPLOT Synchronizing Several Plots * * Often a single plot is not sufficient, but several plots need to be aligned with respect to each other: @@ -132,7 +199,7 @@ JKQTP_LIB_EXPORT void initJKQTPlotterResources(); * \subsection JKQTPLOTTER_TOOLBAR Toolbar of JKQTPlotter * * In addition to the context-menu, a JKQtPlotter also also provides a toolbar at its top that offers - * most of the functionality of the context menu. Usually this toolbar is enabled (see displayToolbar) + * most of the functionality of the context menu. Usually this toolbar is enabled (see toolbarEnabled) * and is in a mode where it is hidden, until the mouse moves over an area at the top of the plot (see toolbarAlwaysOn): * * \image html jkqtplotter_toolbar_hidden.png "Hidden Toolbar" @@ -144,7 +211,7 @@ JKQTP_LIB_EXPORT void initJKQTPlotterResources(); * * \image html jkqtplotter_toolbar_alwayson.png * - * \see displayToolbar, toolbarAlwaysOn, \ref JKQTPlotterUserInteraction + * \see toolbarEnabled, toolbarAlwaysOn, \ref JKQTPlotterUserInteraction * * * @@ -202,8 +269,8 @@ JKQTP_LIB_EXPORT void initJKQTPlotterResources(); * when a specified mouse button is pushed while a specified (or no) keyborad modifiers (e.g. CTRL,ALT,SHIFT...) is pressed. * By default JKQTPlotter calls these two registers in its constructors: * \code - * registerMouseDragAction(Qt::LeftButton, Qt::NoModifier, JKQTPlotter::MouseActionMode::ZoomRectangle); - * registerMouseDragAction(Qt::LeftButton, Qt::ControlModifier, JKQTPlotter::MouseActionMode::PanPlotOnMove); + * registerMouseDragAction(Qt::LeftButton, Qt::NoModifier, JKQTPlotter::MouseActionMode::jkqtpmdaZoomByRectangle); + * registerMouseDragAction(Qt::LeftButton, Qt::ControlModifier, JKQTPlotter::MouseActionMode::jkqtpmdaPanPlotOnMove); * \endcode * Therefore by default you can draw a zoom rectangle with the left mouse button without modifiers * and you can pan/drag the plot with the left mouse-button while keeping CTRL pressed. @@ -213,7 +280,7 @@ JKQTP_LIB_EXPORT void initJKQTPlotterResources(); * * Pressing the \c ESC key will stop the current JKQTPlotter::MouseActionMode. * - * If e.g. the mode JKQTPlotter::MouseActionMode::ZoomRectangle is selected, while you drag the mouse, the + * If e.g. the mode JKQTPlotter::MouseActionMode::jkqtpmdaZoomByRectangle is selected, while you drag the mouse, the * zoom rectangle is drawn over the plot. You can modify the style of drawing using these functions: * - setUserActionColor() sets the color of the drawn shape * - setUserActionCompositionMode() specifies how to combine the shape with the existing plot @@ -228,8 +295,8 @@ JKQTP_LIB_EXPORT void initJKQTPlotterResources(); * * \subsubsection JKQTPLOTTER_USERMOUSEINTERACTION_MOUSECLICK Actions After (Double-)Clicks on the Mouse Buttons * The right mouse button has a special role: If it is single-clicked and no JKQTPlotter::MouseActionMode is specified - * for the vent, it opens the context menu, unless you call \c setContextMenuMoode(JKQTPlotter::NoContextMenu) . - * You can also use setContextMenuMoode() to specify which type of context menu is shown. See JKQTPlotter::ContextMenuModes + * for the vent, it opens the context menu, unless you call \c setContextMenuMoode(jkqtpcmmNoContextMenu) . + * You can also use setContextMenuMoode() to specify which type of context menu is shown. See JKQTPContextMenuModes * for details on the available modes. * * For any mouse-click, one of the following signals is emitted: @@ -238,13 +305,13 @@ JKQTP_LIB_EXPORT void initJKQTPlotterResources(); * . * * The reaction to double-clicks of the mouse buttons can be specified separately. The possible - * actions are listed in JKQTPlotter::MouseDoubleClickActions. You can bind one of these actions + * actions are listed in JKQTPMouseDoubleClickActions. You can bind one of these actions * to a specific click with these functions: - * - registerMouseDoubleClickAction() tells JKQTPlotter to perform a certain action (selected from JKQTPlotter::MouseDoubleClickActions) + * - registerMouseDoubleClickAction() tells JKQTPlotter to perform a certain action (selected from JKQTPMouseDoubleClickActions) * when a specified mouse button is pushed while a specified (or no) keyborad modifiers (e.g. CTRL,ALT,SHIFT...) is pressed. * By default JKQTPlotter calls this in its constructors: * \code - * registerMouseDoubleClickAction(Qt::LeftButton, Qt::NoModifier, JKQTPlotter::MouseDoubleClickActions::ClickMovesViewport); + * registerMouseDoubleClickAction(Qt::LeftButton, Qt::NoModifier, JKQTPMouseDoubleClickActions::jkqtpdcaClickMovesViewport); * \endcode * Therefore by default you can pan the plot/move the viewport by double clicking a location * - deregisterMouseDoubleClickAction() deletes a previously defined user-interaction @@ -255,14 +322,14 @@ JKQTP_LIB_EXPORT void initJKQTPlotterResources(); * \image html contextmenu_graphvisibility.gif * * \subsubsection JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEWHEEL Actions When a Mouse Wheel Event Occurs - * The actions to be performed when the mouse hweel is operated are specified in JKQTPlotter::MouseWheelActions. - * You can bind one of these actions to the mouse-wheel (under the condition that a specified Qt::KeyboardModifier + * The actions to be performed when the mouse hweel is operated are specified in JKQTPMouseWheelActions. + * You can bind one of these actions to the mouse-wheel (under the condition that a specified Qt::KeyboardModifiers * is pressed) by using these functions: - * - registerMouseWheelAction() tells JKQTPlotter to perform a certain action (selected from JKQTPlotter::MouseWheelActions) + * - registerMouseWheelAction() tells JKQTPlotter to perform a certain action (selected from JKQTPMouseWheelActions) * when a specified mouse button is pushed while a specified (or no) keyborad modifiers (e.g. CTRL,ALT,SHIFT...) is pressed. * By default JKQTPlotter calls this in its constructors: * \code - * registerMouseWheelAction(Qt::NoModifier, JKQTPlotter::MouseWheelActions::ZoomByWheel); + * registerMouseWheelAction(Qt::NoModifier, JKQTPMouseWheelActions::jkqtpmwaZoomByWheel); * \endcode * Therefore by default you can zoom into and out of the plot, using the mouse wheel. * - deregisterMouseWheelAction() deletes a previously defined user-interaction @@ -280,6 +347,19 @@ JKQTP_LIB_EXPORT void initJKQTPlotterResources(); * * \image html mousepositiondisplay.gif * + * + * \subsubsection JKQTPLOTTER_USERMOUSEINTERACTION_FASTRESIZING Fast Resizing of a Plot Widget + * When the user resized the widget, the graph would in principle have to be readrawn for every intermediate step. + * As this is very timeconsuming, JKQTPlotter uses a different approach: Actual Redrawing is delayed a few 100ms + * and this delay is reset whenever the widget size changes. Only after the last delay expires, the plot is redrawn. + * In between an image of the last state of the plot is simple stretched/compressed to fill the new/current + * widget size. In sum this looks like this: + * + * \image html jkqtplotter_fastresizing.gif + * + * + * + * * \section JKQTPLOTTER_USEQTCREATOR How to use JKQTPlotter in the Qt Form Designer * * As JKQTPlotter is a standard Qt widget, you can also use it in Qt UI-files designed with the Qt From Designer (e.g. from within QTCreator). @@ -299,54 +379,12 @@ JKQTP_LIB_EXPORT void initJKQTPlotterResources(); * * * - * \see \ref JKQTPlotterQtCreator + * \see \ref JKQTPlotterQtCreator
    Also see \ref JKQTPlotterStyling for another example of using the Qt UI Designer with JKQTPlotter * */ class JKQTP_LIB_EXPORT JKQTPlotter: public QWidget { Q_OBJECT public: - /** \brief Availble action this JKQtPlotter can perform when mouse events occur. - * This allows you to e.g. draw rectangles or lines over the plot and receive a signal, when the drawing finishes - */ - enum MouseDragActions { - PanPlotOnMove=0, /*!< \brief the user can drag the current plot window while keeping the left mouse-button pushed down (=panning), the new widow is applied/displayed whenever the mouse moves \image html drag_viewport.gif "Drag the Plot Viewport" */ - PanPlotOnRelease, /*!< \brief the user can drag the current plot window while keeping the left mouse-button pushed down (=panning), the new widow is applied/displayed when the left mouse button is released */ - ZoomRectangle, /*!< \brief draw a rectangle and when finish zoom to that rectangle */ - DrawRectangleForEvent, /*!< \brief draw a rectangle and when finished execute the signal userRectangleFinished() \image html draw_rectangle.gif "Draw Rectangle User-Action" */ - DrawCircleForEvent, /*!< \brief draw a circle and when finished execute the signal userCircleFinished() \image html draw_circle.gif "Draw Circle User-Action" */ - DrawEllipseForEvent, /*!< \brief draw an ellipse and when finished execute the signal userEllipseFinished() \image html draw_ellipse.gif "Draw Ellipse User-Action" */ - DrawLineForEvent, /*!< \brief draw a line and when finished execute the signal userLineFinished() \image html draw_line.gif "Draw Lines User-Action" */ - ScribbleForEvents, /*!< \brief let the user scribble on the plot (left mouse button is kept pressed) and call userScribbleClick() for each new position */ - }; - - /** \brief actions that can be bound to a double-click of the mouse */ - enum MouseDoubleClickActions { - ClickZoomsIn=0, /*!< \brief a double-click zooms into the plot at the current mouse location */ - ClickZoomsOut, /*!< \brief a double-click zooms out of the plot at the current mouse location */ - ClickOpensContextMenu, /*!< \brief a double-click opens the context menu */ - ClickOpensSpecialContextMenu, /*!< \brief a double-click opens the special context menu \see setSpecialContextMenu() */ - ClickMovesViewport, /*!< \brief a double-click centers the x/y-range around the clicked position */ - }; - - /** \brief actions that can be bound to a mouse wheel event */ - enum MouseWheelActions { - ZoomByWheel=0, /*!< \brief use the mouse-wheel for zooming */ - PanByWheel, /*!< \brief use the mouse-wheel for panning the plot */ - }; - - /** \brief modes for the context menu */ - enum ContextMenuModes { - StandardContextMenu=0, /*!< \brief only show the standard context menu \image html zoomin_mouse_contextmenu.gif "Zooming with the mouse" */ - SpecialContextMenu, /*!< \brief only show the special context menu \see setSpecialContextMenu() */ - StandardAndSpecialContextMenu, /*!< \brief show the standard context menu, with the special context menu incorporated \see setSpecialContextMenu() */ - NoContextMenu, /*!< \brief don't show a context menu at all */ - }; - - - - - - /** \brief class constructor * * If \a datastore_internal \c ==false, you can supply an external JKQTPDatastore with the parameter \a datast @@ -379,17 +417,26 @@ class JKQTP_LIB_EXPORT JKQTPlotter: public QWidget { /** \brief returns the class internally used for plotting */ const JKQTBasePlotter* getConstplotter() const { return const_cast(plotter); } - /*! \brief returns the property displayToolbar ( \copybrief displayToolbar ). - \details Description of the parameter displayToolbar is:
    \copydoc displayToolbar
    - \see displayToolbar for more information */ - bool isToolbarVisible() const; - /*! \brief returns the property toolbarAlwaysOn ( \copybrief toolbarAlwaysOn ). - \details Description of the parameter toolbarAlwaysOn is:
    \copydoc toolbarAlwaysOn
    - \see toolbarAlwaysOn for more information */ + /** \brief returns whether the toolbar is enabled + * + * \copydetails JKQTPlotterStyle::toolbarEnabled + * + * \see setToolbarEnabled(), JKQTPlotterStyle::toolbarEnabled + */ + bool isToolbarEnabled() const; + /** \brief returns whether the toolbar is always visible or only when the mouse moves to the upper left area + * + * \copydetails JKQTPlotterStyle::toolbarAlwaysOn + * + * \see setToolbarAlwaysOn(), JKQTPlotterStyle::toolbarAlwaysOn + */ bool isToolbarAlwaysOn() const; - /*! \brief returns the property displayMousePosition ( \copybrief displayMousePosition ). - \details Description of the parameter displayMousePosition is:
    \copydoc displayMousePosition
    - \see displayMousePosition for more information */ + /** \brief specifies whether to display the current position of the mouse in the top border of the plot (this may automatically extent the + * top border, so the position fits in. The default widget font is used for the output. + * + * \copydetails JKQTPlotterStyle::displayMousePosition + * + * \see setMousePositionShown(), JKQTPlotterStyle::displayMousePosition, \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEMOVE */ bool isMousePositionShown() const; /** \brief returns the fill color of the zoom rectangle \see \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEDRAG */ QColor getUserActionColor() const; @@ -398,14 +445,14 @@ class JKQTP_LIB_EXPORT JKQTPlotter: public QWidget { QPainter::CompositionMode getUserActionCompositionMode() const; - /** \brief loads the plot properties from a QSettings object */ - void loadSettings(const QSettings &settings, const QString& group=QString("plots")); + /** \brief loads the plot properties from a QSettings object */ + void loadSettings(const QSettings &settings, const QString& group=QString("plots/")); - /** \brief saves the plot properties into a QSettings object. + /** \brief saves the plot properties into a QSettings object. * * This method only saves those properties that differ from their default value. */ - void saveSettings(QSettings& settings, const QString& group=QString("plots")) const; + void saveSettings(QSettings& settings, const QString& group=QString("plots/")) const; /** \brief returns the minimum size of the widget */ QSize minimumSizeHint() const; @@ -541,39 +588,39 @@ class JKQTP_LIB_EXPORT JKQTPlotter: public QWidget { /** \copydoc JKQTBasePlotter::isEmittingSignalsEnabled() */ inline bool isEmittingSignalsEnabled() { return plotter->isEmittingSignalsEnabled(); } - /** \brief returns, whether updating the plot is currently activated (e.g. you can deactivate this with setPlotUpdateEnabled() while performing major updates on the plot) + /** \brief returns, whether automatic redrawing the plot is currently activated (e.g. you can deactivate this with setPlotUpdateEnabled() while performing major updates on the plot) * * \see setPlotUpdateEnabled() */ bool isPlotUpdateEnabled() const; - /** \brief sets whether updating the plot is currently activated (e.g. you can sett his to \c false while performing major updates on the plot) + /** \brief sets whether automatic redrawing the plot is currently activated (e.g. you can sett his to \c false while performing major updates on the plot) * - * \see isPlotUpdateEnabled(); + * \see isPlotUpdateEnabled() */ void setPlotUpdateEnabled(bool enable); /** \brief registeres a certain mouse drag action \a action to be executed when a mouse drag operation is * initialized with the given \a button and \a modifier */ - void registerMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifier modifier, MouseDragActions action); + void registerMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier, JKQTPMouseDragActions action); /** \brief deregisteres the mouse drag action to be executed when a mouse drag operation is * initialized with the given \a button and \a modifier */ - void deregisterMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifier modifier); + void deregisterMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier); /** \brief clear all registeres mouse drag actions */ void clearAllRegisteredMouseDragActions(); /** \brief registeres a certain mouse action \a action to be executed when a mouse double-click occurs * with the given \a button and \a modifier */ - void registerMouseDoubleClickAction(Qt::MouseButton button, Qt::KeyboardModifier modifier, MouseDoubleClickActions action); + void registerMouseDoubleClickAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier, JKQTPMouseDoubleClickActions action); /** \brief deregisteres the mouse action \a action to be executed when a mouse double-click occurs * with the given \a button and \a modifier */ - void deregisterMouseDoubleClickAction(Qt::MouseButton button, Qt::KeyboardModifier modifier); + void deregisterMouseDoubleClickAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier); /** \brief clear all registered mouse double-click actions */ void clearAllRegisteredMouseDoubleClickActions(); /** \brief specifies the action to perform on a mouse wheel event when a given modifier is pressed \see deregisterMouseWheelAction(), clearAllMouseWheelActions(), \ref JKQTPLOTTER_USERMOUSEINTERACTION */ - void registerMouseWheelAction(Qt::KeyboardModifier modifier, MouseWheelActions action); + void registerMouseWheelAction(Qt::KeyboardModifiers modifier, JKQTPMouseWheelActions action); /** \brief deletes all mouse-wheel actions registered for a given \a modifier \see registerMouseWheelAction(), clearAllMouseWheelActions(), \ref JKQTPLOTTER_USERMOUSEINTERACTION */ - void deregisterMouseWheelAction(Qt::KeyboardModifier modifier); + void deregisterMouseWheelAction(Qt::KeyboardModifiers modifier); /** \brief deletes all mouse-wheel actions \see registerMouseWheelAction(), deregisterMouseWheelAction(), \ref JKQTPLOTTER_USERMOUSEINTERACTION */ void clearAllMouseWheelActions(); @@ -584,50 +631,56 @@ class JKQTP_LIB_EXPORT JKQTPlotter: public QWidget { void setSpecialContextMenu(QMenu* menu); - /** \brief returns the property mouseContextX ( \copybrief mouseContextX ). - \details Description of the parameter mouseContextX is:
    \copydoc mouseContextX
    . - \see mouseContextX for more information */ + /** \brief x-position of the mouse (in plot coordinates) when a user mouse-action was started (e.g. drawing a rectangle) + * + * \see getMouseContextY(), getMouseLastClickX(), getMouseLastClickY() + */ double getMouseContextX() const; - /** \brief returns the property mouseContextY ( \copybrief mouseContextY ). - \details Description of the parameter mouseContextY is:
    \copydoc mouseContextY
    . - \see mouseContextY for more information */ + /** \brief y-position of the mouse (in plot coordinates) when a user mouse-action was started (e.g. drawing a rectangle) + * + * \see getMouseContextX(), getMouseLastClickX(), getMouseLastClickY() + */ double getMouseContextY() const; - /** \brief returns the property mouseLastClickX ( \copybrief mouseLastClickX ). - \details Description of the parameter mouseLastClickX is:
    \copydoc mouseLastClickX
    . - \see mouseLastClickX for more information */ + /** \brief x-position of the last mouse-click (in screen pixels) + * + * \see getMouseLastClickY(), getMouseContextX(), getMouseContextY() + */ int getMouseLastClickX() const; - /** \brief returns the property mouseLastClickY ( \copybrief mouseLastClickY ). - \details Description of the parameter mouseLastClickY is:
    \copydoc mouseLastClickY
    . - \see mouseLastClickY for more information */ + /** \brief y-position of the last mouse-click (in screen pixels) + * + * \see getMouseLastClickX(), getMouseContextX(), getMouseContextY() + */ int getMouseLastClickY() const; - /** \brief returns the coordinate axis object for the x-axis */ + /** \brief returns the coordinate axis object for the x-axis \see JKQTBasePlotter::getXAxis() */ inline JKQTPHorizontalAxis* getXAxis() { return plotter->getXAxis(); } - /** \brief returns the coordinate axis object for the y-axis */ + /** \brief returns the coordinate axis object for the y-axis \see JKQTBasePlotter::getYAxis() */ inline JKQTPVerticalAxis* getYAxis() { return plotter->getYAxis(); } - /** \brief returns the coordinate axis object for the x-axis as a const pointer */ + /** \brief returns the coordinate axis object for the x-axis as a const pointer \see JKQTBasePlotter::getXAxis() */ inline const JKQTPHorizontalAxis* getXAxis() const { return plotter->getXAxis(); } - /** \brief returns the coordinate axis object for the y-axis as a const pointer */ + /** \brief returns the coordinate axis object for the y-axis as a const pointer \see JKQTBasePlotter::getYAxis() */ inline const JKQTPVerticalAxis* getYAxis() const { return plotter->getYAxis(); } - /** \brief returns the \a i -th graph (of type JKQTPPlotElement) in this plotter instance */ + /** \brief returns the \a i -th graph (of type JKQTPPlotElement) in this plotter instance \see JKQTBasePlotter::getGraph() */ inline JKQTPPlotElement* getGraph(size_t i) { return plotter->getGraph(i); } - /** \brief returns the number of graphs */ + /** \brief returns the number of graphs \see JKQTBasePlotter::getGraphCount() */ inline size_t getGraphCount() { return plotter->getGraphCount(); } - /** \brief remove the i-th graph */ + /** \brief remove the i-th graph \see JKQTBasePlotter::deleteGraph() */ inline void deleteGraph(size_t i, bool deletegraph=true) { plotter->deleteGraph(i, deletegraph); } - /** \brief returns \c true, if the given graph is present */ + /** \brief returns \c true, if the given graph is present \see JKQTBasePlotter::containsGraph() */ inline bool containsGraph(JKQTPPlotElement* gr) { return plotter->containsGraph(gr); } - /** \brief remove the given graph, if it is contained */ + /** \brief remove the given graph, if it is contained \see JKQTBasePlotter::deleteGraph() */ inline void deleteGraph(JKQTPPlotElement* gr, bool deletegraph=true) { plotter->deleteGraph(gr, deletegraph); } /** \brief remove all plots * * \param deleteGraphs if set \c true (default) the graph objects will also be deleted + * + * \see JKQTBasePlotter::clearGraphs() */ inline void clearGraphs(bool deleteGraphs=true) { plotter->clearGraphs(deleteGraphs); } @@ -636,6 +689,7 @@ class JKQTP_LIB_EXPORT JKQTPlotter: public QWidget { * \param gr graph object (of type JKQTPPlotElement) to be added. \b Note: The JKQTPlotter takes ownership of graph \a gr . * \return ID of the added graph object \a gr in the internal list of graphs * + * \see JKQTBasePlotter::addGraph() */ inline size_t addGraph(JKQTPPlotElement* gr) { return plotter->addGraph(gr); } @@ -643,6 +697,8 @@ class JKQTP_LIB_EXPORT JKQTPlotter: public QWidget { * * \param gr graph object (of type JKQTPPlotElement) to be moved (needs to be containing to the JKQTPlotter already!) * \return ID of the added graph object \a gr in the internal list of graphs + * + * \see JKQTBasePlotter::moveGraphTop() */ inline size_t moveGraphTop(JKQTPPlotElement* gr) { return plotter->moveGraphTop(gr); } @@ -650,24 +706,35 @@ class JKQTP_LIB_EXPORT JKQTPlotter: public QWidget { * * \param gr graph object (of type JKQTPPlotElement) to be moved (needs to be containing to the JKQTPlotter already!) * \return ID of the added graph object \a gr in the internal list of graphs + * + * \see JKQTBasePlotter::moveGraphBottom() */ inline size_t moveGraphBottom(JKQTPPlotElement* gr) { return plotter->moveGraphBottom(gr); } - /** \brief add a new graphs from a QVector, QList, std::vector ... or any standard-iterateable container with JKQTPPlotElement*-items */ + /** \brief add a new graphs from a QVector, QList, std::vector ... or any standard-iterateable container with JKQTPPlotElement*-items + * + * \tparam TJKQTPGraphContainer a container type with default C++-sytle iterator interface + * (i.e. methods \c begin() and \c end() and an iterator, which may be + * moved to the next element with the operator \c ++ . + * \param gr Container of type TJKQTPGraphContainer, which contains the graphs \b Note: The JKQTPlotter takes ownership of graphs in \a gr . + * \param[out] graphIDsOut optional output parameter, the vector will contain the IDs of each graph added to theis plot + * + * \see JKQTBasePlotter::addGraphs() + */ template - inline void addGraphs(const TJKQTPGraphContainer& gr) { plotter->addGraphs(gr); } + inline void addGraphs(const TJKQTPGraphContainer& gr, QVector* graphIDsOut=nullptr) { plotter->addGraphs(gr, graphIDsOut); } - /** \brief returns the current x-axis min */ + /** \brief returns the current x-axis min \see JKQTBasePlotter::getYAxis() */ inline double getXMin() const {return plotter->getXMin(); } - /** \brief returns the current x-axis max */ + /** \brief returns the current x-axis max \see JKQTBasePlotter::getYAxis() */ inline double getXMax() const {return plotter->getXMax(); } - /** \brief returns the current y-axis min */ + /** \brief returns the current y-axis min \see JKQTBasePlotter::getYAxis() */ inline double getYMin() const {return plotter->getYMin(); } - /** \brief returns the current y-axis max */ + /** \brief returns the current y-axis max \see JKQTBasePlotter::getYAxis() */ inline double getYMax() const {return plotter->getYMax(); } @@ -696,19 +763,49 @@ class JKQTP_LIB_EXPORT JKQTPlotter: public QWidget { return getConstplotter()->getPlotStyle(i); } - /** \brief font face for key labels */ - inline QString getKeyFont() const { - return getConstplotter()->getKeyFont(); - } /** \brief font size for key labels [in points] */ inline double getKeyFontSize() const { return getConstplotter()->getKeyFontSize(); } - /** \brief returns the currently set mode for the context menu \see ContextMenuModes, \ref JKQTPLOTTER_USERMOUSEINTERACTION */ - ContextMenuModes getContextMenuMode() const; + /** \brief returns the currently set mode for the context menu \see JKQTPContextMenuModes, \ref JKQTPLOTTER_USERMOUSEINTERACTION */ + JKQTPContextMenuModes getContextMenuMode() const; + /** \brief current style properties for this JKQTPlotter + * + * \see JKQTPSetSystemDefaultStyle(), JKQTPSetSystemDefaultStyle(), \ref jkqtpplotter_styling + */ + const JKQTPlotterStyle& getCurrentPlotterStyle() const; + + /** \brief replace the current style properties for this JKQTBasePlotter + * + * \see JKQTPSetSystemDefaultStyle(), JKQTPSetSystemDefaultStyle(), getCurrentPlotterStyle(), \ref jkqtpplotter_styling + */ + void setCurrentPlotterStyle(const JKQTPlotterStyle& style); + /** \brief replace the current style properties for this JKQTBasePlotter + * + * \see JKQTPSetSystemDefaultStyle(), JKQTPSetSystemDefaultStyle(), getCurrentPlotterStyle(), \ref jkqtpplotter_styling + */ + void setCurrentPlotterStyle(const JKQTPlotterStyle& style, const JKQTBasePlotterStyle &baseStyle); + /** \brief replace the current style properties for this JKQTBasePlotter with properties loaded from \a settings + * + * \param settings the QSettings object to read from + * \param group group in \a settings to read from + * \param alsoLoadBaseStyle if \c true, then also JKQTBasePlotter::loadCurrentPlotterStyle() of the internal JKQTBasePlotter is called + * + * \see JKQTPSetSystemDefaultStyle(), JKQTPSetSystemDefaultStyle(), getCurrentPlotterStyle(), \ref jkqtpplotter_styling + */ + void loadCurrentPlotterStyle(const QSettings& settings, const QString& group="plot/", bool alsoLoadBaseStyle=true); + /** \brief store the current style properties for this JKQTBasePlotter with properties loaded from \a settings + * + * \param settings the QSettings object to write to + * \param group group in \a settings to write to + * \param alsoSaveBaseStyle if \c true, then also JKQTBasePlotter::saveCurrentPlotterStyle() of the internal JKQTBasePlotter is called + * + * \see JKQTPSetSystemDefaultStyle(), JKQTPSetSystemDefaultStyle(), getCurrentPlotterStyle(), \ref jkqtpplotter_styling + */ + void saveCurrentPlotterStyle(QSettings& settings, const QString& group="plot/", bool alsoSaveBaseStyle=true) const; public slots: /** \brief set the current plot magnification */ @@ -791,25 +888,38 @@ class JKQTP_LIB_EXPORT JKQTPlotter: public QWidget { */ void redrawOverlays(); - /*! \brief sets the property displayToolbar ( \copybrief displayToolbar ) to the specified \a __value. - \details Description of the parameter displayToolbar is:
    \copydoc displayToolbar
    - \see displayToolbar for more information */ - void setToolbarVisible(bool __value); - /*! \brief sets the property toolbarAlwaysOn ( \copybrief toolbarAlwaysOn ) to the specified \a __value. - \details Description of the parameter toolbarAlwaysOn is:
    \copydoc toolbarAlwaysOn
    - \see toolbarAlwaysOn for more information */ + /** \brief returns whether the toolbar is enabled + * + * \copydetails JKQTPlotterStyle::toolbarEnabled + * + * \see isToolbarEnabled(), JKQTPlotterStyle::toolbarEnabled + */ + void setToolbarEnabled(bool __value); + /** \brief returns whether the toolbar is always visible or only when the mouse moves to the upper left area + * + * \copydetails JKQTPlotterStyle::toolbarAlwaysOn + * + * \see isToolbarAlwaysOn(), JKQTPlotterStyle::toolbarAlwaysOn + */ void setToolbarAlwaysOn(bool __value); - /*! \brief sets the property displayMousePosition ( \copybrief displayMousePosition ) to the specified \a __value. - \details Description of the parameter displayMousePosition is:
    \copydoc displayMousePosition
    - \see \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEMOVE */ + /** \brief specifies whether to display the current position of the mouse in the top border of the plot (this may automatically extent the + * top border, so the position fits in. The default widget font is used for the output. + * + * \copydetails JKQTPlotterStyle::displayMousePosition + * + * \see isMousePositionShown(), JKQTPlotterStyle::displayMousePosition, \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEMOVE */ void setMousePositionShown(bool __value); - /** \brief set the fill color of the zoom rectangle \see \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEDRAG */ + /** \brief set the fill color of the zoom rectangle + * + * \see getUserActionColor(), JKQTPlotterStyle::userActionColor \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEDRAG */ void setUserActionColor(const QColor & __value); - /** \brief set the QPainter::CompositionMode used to draw the zoom rectangle etc. \see \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEDRAG */ + /** \brief set the QPainter::CompositionMode used to draw the zoom rectangle etc. + * + * \see getUserActionCompositionMode(), JKQTPlotterStyle::userActionColor \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEDRAG */ void setUserActionCompositionMode(const QPainter::CompositionMode & __value); - /** \brief sets the mode if the standard context menu \see ContextMenuModes, \ref JKQTPLOTTER_USERMOUSEINTERACTION */ - void setContextMenuMode(ContextMenuModes mode); + /** \brief sets the mode if the standard context menu \see JKQTPContextMenuModes, \ref JKQTPLOTTER_USERMOUSEINTERACTION */ + void setContextMenuMode(JKQTPContextMenuModes mode); /** \brief may be connected to zoomChangedLocally() of a different plot and synchronizes the local x-axis to the other x-axis \see \ref JKQTBASEPLOTTER_SYNCMULTIPLOT */ void synchronizeXAxis(double newxmin, double newxmax, double newymin, double newymax, JKQTPlotter* sender); @@ -819,7 +929,10 @@ class JKQTP_LIB_EXPORT JKQTPlotter: public QWidget { void synchronizeXYAxis(double newxmin, double newxmax, double newymin, double newymax, JKQTPlotter* sender); - /** \brief popuplate the given toolbar with all actions shown in a toolbar from this class ... */ + /** \brief popuplate the given toolbar \a toolbar with all actions shown in a toolbar from this class ... + * + * This function can be used to populate an external toolbar with actions for this JKQTPlotter. + */ void populateToolbar(QToolBar* toolbar) const; /** \brief open the context menu at the mouse position of the last click */ @@ -841,23 +954,92 @@ class JKQTP_LIB_EXPORT JKQTPlotter: public QWidget { /** \brief open the standard context menu with the special context menu integrated at the mouse position \a x and \a y */ void openStandardAndSpecialContextMenu(int x, int y); - /** \brief sets absolute minimum and maximum x-value to plot */ + /** \brief sets absolutely limiting x-range of the plot + * + * \param xminn absolute minimum of x-axis + * \param xmaxx absolute maximum of x-axis + * + * \note if the aspect ratio of this does not fit into the widget, it is possible that you don't see the complete contents! + * + * \see setAbsoluteXY(), setAbsoluteY(), JKQTBasePlotter::setAbsoluteX() + */ inline void setAbsoluteX(double xminn, double xmaxx) { plotter->setAbsoluteX(xminn, xmaxx); } - /** \brief sets absolute minimum and maximum y-value to plot */ + /** \brief sets absolute minimum and maximum y-value to plot + * + * \param yminn absolute minimum of y-axis + * \param ymaxx absolute maximum of y-axis + * + * \note if the aspect ratio of this does not fit into the widget, it is possible that you don't see the complete contents! + * + * \see setAbsoluteXY(), setAbsoluteX(), JKQTBasePlotter::setAbsoluteY() + */ inline void setAbsoluteY(double yminn, double ymaxx) { plotter->setAbsoluteY(yminn, ymaxx); } - /** \brief sets absolute minimum and maximum x- and y-values to plot */ + /** \brief sets absolutely limiting x- and y-range of the plot + * + * The user (or programmer) cannot zoom to a viewport that is larger than the range given to this function. + * + * \param xminn absolute minimum of x-axis + * \param xmaxx absolute maximum of x-axis + * \param yminn absolute minimum of y-axis + * \param ymaxx absolute maximum of y-axis + * + * \note if the aspect ratio of this does not fit into the widget, it is possible that you don't see the complete contents! + * + * \see setAbsoluteX(), setAbsoluteY(), zoomToFit(), JKQTBasePlotter::setAbsoluteXY() + */ inline void setAbsoluteXY(double xminn, double xmaxx, double yminn, double ymaxx) { plotter->setAbsoluteXY(xminn, xmaxx, yminn, ymaxx); } - /** \brief sets minimum and maximum x-value to plot */ + /** \brief sets the x-range of the plot (minimum and maximum x-value on the x-axis) + * + * \param xminn absolute minimum of x-axis + * \param xmaxx absolute maximum of x-axis + * + * \note You cannot expand the x-range outside the absolute x-range set e.g. by setAbsoluteX()! + * Also the range will be limited to possible values (e.g. to positive values if you use + * logarithmic axes). + * + * Uppon setting, this function emits the signal zoomChangedLocally(), if emitting signals + * is activated at the moment (e.g. using JKQTBasePlotter::setEmittingSignalsEnabled() ). + * + * \see setY(), setXY(), zoomToFit(), setAbsoluteXY(), JKQTBasePlotter::setY() + */ inline void setX(double xminn, double xmaxx) { plotter->setX(xminn, xmaxx); } - /** \brief sets minimum and maximum y-value to plot */ + /** \brief sets the y-range of the plot (minimum and maximum y-value on the y-axis) + * + * \param yminn absolute minimum of y-axis + * \param ymaxx absolute maximum of y-axis + * + * \note You cannot expand the y-range outside the absolute y-range set e.g. by setAbsoluteY()! + * Also the range will be limited to possible values (e.g. to positive values if you use + * logarithmic axes). + * + * Uppon setting, this function emits the signal zoomChangedLocally(), if emitting signals + * is activated at the moment (e.g. using JKQTBasePlotter::setEmittingSignalsEnabled() ). + * + * \see setX(), setXY(), zoomToFit(), setAbsoluteXY(), JKQTBasePlotter::setX() + */ inline void setY(double yminn, double ymaxx) { plotter->setY(yminn, ymaxx); } - /** \brief sets minimum and maximum x- and y-values to plot */ - inline void setXY(double xminn, double xmaxx, double yminn, double ymaxx) { plotter->setXY(xminn, xmaxx, yminn, ymaxx); } + /** \brief sets the x- and y-range of the plot (minimum and maximum values on the x-/y-axis) + * + * \param xminn absolute minimum of x-axis + * \param xmaxx absolute maximum of x-axis + * \param yminn absolute minimum of y-axis + * \param ymaxx absolute maximum of y-axis + * + * \note You cannot expand the ranges outside the absolute ranges set e.g. by setAbsoluteXY()! + * Also the range will be limited to possible values (e.g. to positive values if you use + * logarithmic axes). + * + * Uppon setting, this function emits the signal zoomChangedLocally(), if emitting signals + * is activated at the moment (e.g. using JKQTBasePlotter::setEmittingSignalsEnabled() ). + * + * \see setX(), setX(), zoomToFit(), setAbsoluteXY(), JKQTBasePlotter::setXY() + */ + inline void setXY(double xminn, double xmaxx, double yminn, double ymaxx) { plotter->setXY(xminn, xmaxx, yminn, ymaxx); } signals: /** \brief emitted whenever the mouse moves @@ -891,7 +1073,7 @@ class JKQTP_LIB_EXPORT JKQTPlotter: public QWidget { * \param deltaAngleY amount of rotation (in eighths of a degree) of the wheel in y-direction */ void plotMouseWheelOperated(double x, double y, Qt::KeyboardModifiers modifiers, int deltaAngleX, int deltaAngleY); - /** \brief emitted when the mouse action JKQTPlotter::ZoomRectangle and the drawing of the new zoom rectangle is finished (=mouse key released) + /** \brief emitted when the mouse action jkqtpmdaZoomByRectangle and the drawing of the new zoom rectangle is finished (=mouse key released) * * \param mouseDragRectXStart start of the selected x-range (in plot coordinates) * \param mouseDragRectXEnd end of the selected x-range (in plot coordinates) @@ -989,9 +1171,9 @@ class JKQTP_LIB_EXPORT JKQTPlotter: public QWidget { struct JKQTP_LIB_EXPORT MouseDragAction { /** \brief constructs an invalid object */ MouseDragAction(); - MouseDragAction(Qt::MouseButton _mouseButton, Qt::KeyboardModifier _modifier, MouseDragActions _mode); - MouseDragActions mode; - Qt::KeyboardModifier modifier; + MouseDragAction(Qt::MouseButton _mouseButton, Qt::KeyboardModifiers _modifier, JKQTPMouseDragActions _mode); + JKQTPMouseDragActions mode; + Qt::KeyboardModifiers modifier; Qt::MouseButton mouseButton; bool isValid() const; void clear(); @@ -1002,24 +1184,14 @@ class JKQTP_LIB_EXPORT JKQTPlotter: public QWidget { /** \brief the currently executed MouseDragAction */ MouseDragAction currentMouseDragAction; - /** \brief lists all availble mouse drag action modes */ - QHash, MouseDragActions> registeredMouseDragActionModes; + /** \brief searches JKQTPlotterStyle::registeredMouseActionModes for a matching action */ + JKQTPMouseDragActionsHashMapIterator findMatchingMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifiers) const; - /** \brief searches registeredMouseActionModes for a matching action */ - QHash, MouseDragActions>::const_iterator findMatchingMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifiers) const; + /** \brief searches JKQTPlotterStyle::registeredMouseWheelActions for a matching action */ + JKQTPMouseWheelActionsHashMapIterator findMatchingMouseWheelAction(Qt::KeyboardModifiers modifiers) const; - /** \brief lists all availble mouse wheel action modes */ - QHash registeredMouseWheelActions; - - /** \brief searches registeredMouseWheelActions for a matching action */ - QHash::const_iterator findMatchingMouseWheelAction(Qt::KeyboardModifiers modifiers) const; - - - /** \brief action to perform on a double-click of the mouse buttons (depending on the button and the modifiers) */ - QHash, MouseDoubleClickActions> registeredMouseDoubleClickActions; - - /** \brief searches registeredMouseDoubleClickActions for a matching action */ - QHash, MouseDoubleClickActions>::const_iterator findMatchingMouseDoubleClickAction(Qt::MouseButton button, Qt::KeyboardModifiers modifiers) const; + /** \brief searches JKQTPlotterStyle::registeredMouseDoubleClickActions for a matching action */ + JKQTPMouseDoubleClickActionsHashMapIterator findMatchingMouseDoubleClickAction(Qt::MouseButton button, Qt::KeyboardModifiers modifiers) const; /** \brief you may overwrite this method to modify the given context emnu before it is displayed. * @@ -1027,28 +1199,18 @@ class JKQTP_LIB_EXPORT JKQTPlotter: public QWidget { */ void modifyContextMenu(QMenu* menu); - void init(bool datastore_internal, QWidget* parent, JKQTPDatastore* datast); - + /** \brief indicates whether the plot is updated automatically at the moment + * + * \see setPlotUpdateEnabled(), isPlotUpdateEnabled() + */ bool doDrawing; /** \brief JKQTBasePlotter used to plot */ JKQTBasePlotter* plotter; + /** \brief modifies the settings of \a plotter to match those of this object */ + void fixBasePlotterSettings(); - /** \brief fill color of the zoom rectangle \see \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEDRAG */ - QColor userActionColor; - /*! \brief default value for property property userActionColor. \see userActionColor for more information */ - QColor default_userActionColor; - - /** \brief the QPainter::CompositionMode used to draw the zoom rectangle etc. \see \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEDRAG */ - QPainter::CompositionMode userActionCompositionMode; - /*! \brief default value for property property userActionCompositionMode. \see userActionCompositionMode for more information */ - QPainter::CompositionMode default_userActionCompositionMode; - - /** \brief width/height of the icons in the plotter toolbar in pt */ - int toolbarIconSize; - /*! \brief default value for property property toolbarIconSize. \see toolbarIconSize for more information */ - int default_toolbarIconSize; /** \brief this is set \c true if we are drawing a zoom rectangle */ bool mouseDragingRectangle; @@ -1096,7 +1258,7 @@ class JKQTP_LIB_EXPORT JKQTPlotter: public QWidget { /** \brief use this QMenu instance instead of the standard context emnu of this widget */ - QMenu* menuSpecialContextMenu; + QMenu* menujkqtpcmmSpecialContextMenu; @@ -1108,7 +1270,10 @@ class JKQTP_LIB_EXPORT JKQTPlotter: public QWidget { void paintUserAction(); - /** \brief event handler for a double click (zoom in on time axis) */ + /** \brief event handler for a double click + * + * \see registerMouseDoubleClickAction(), deregisterMouseDoubleClickAction() + */ void mouseDoubleClickEvent ( QMouseEvent * event ); /*! \brief react on key presses. @@ -1122,14 +1287,12 @@ class JKQTP_LIB_EXPORT JKQTPlotter: public QWidget { /** \brief event handler for a mouse move * * This implements two behaviours: - * - If no mouse button is pressed this simply emits a plotMouseMove() event which - * allows for some other widget to display the current position of the mouse inside - * the plot - * - If the left mouse button is pressed (private property mouseZooming is \c true ) - * this displays a rectangle. If the mouse is release ( mouseReleaseEvent() ) the control - * zooms the specified region. So you can use the mouse to select a range to zoom into. - * This stores the current mouse position in mouseZoomingTEnd . + * - if displayMousePosition is \c true , stores the current mouse position in mousePosX, mousePosY + * - if necessary, contributes to user-actions started by mousePressEvent() + * - emits plotMouseMove() if the mouse is inside the plot rectangle . * . + * + * \see mousePosX, mousePosY */ void mouseMoveEvent ( QMouseEvent * event ); @@ -1137,6 +1300,8 @@ class JKQTP_LIB_EXPORT JKQTPlotter: public QWidget { * * This event determines the action to be performed from registeredMouseActionModes * and then sets currentMouseDragAction accordingly and starts the mouse action. + * + * \see registerMouseDragAction(), deregisterMouseDragAction(), registeredJKQTPMouseDragActions */ void mousePressEvent ( QMouseEvent * event ); @@ -1147,8 +1312,11 @@ class JKQTP_LIB_EXPORT JKQTPlotter: public QWidget { void mouseReleaseEvent ( QMouseEvent * event ); /** \brief event handler for a turn of the mouse wheel - * turning forward the mous wheel will zoom out and turning it backwards will zoom - * in by a factor of \f$ 2^{\mbox{delta\_wheel}} \f$. */ + * + * Executes the user action defined for the mouse wheel. + * + * \see registerMouseWheelAction(), deregisterMouseWheelAction(), registeredMouseWheelActions + */ void wheelEvent(QWheelEvent * event); /** \brief this simply paints the stored image to the widget's surface */ @@ -1160,48 +1328,10 @@ class JKQTP_LIB_EXPORT JKQTPlotter: public QWidget { /** \brief called, when the mouse leaves the widget, hides the toolbar (if visible) */ void leaveEvent ( QEvent * event ); - /** \brief specifies whether to display a toolbar with buttons when the mouse is in the upper border of the plot - * - * \image html jkqtplotter_toolbar_alwayson.png - * - * \see toolbarAlwaysOn, \ref JKQTPlotterUserInteraction - */ - bool displayToolbar; - /** \brief specifies whether the toolbar is always visible or only when the mouse moves to the upper left area - * - * If toolbarAlwaysOn is set to \c true: - * - * \image html jkqtplotter_toolbar_alwayson.png - * - * If toolbarAlwaysOn is set to \c false, the toolbar only appears when the mouse is in the right location: - * - * \image html jkqtplotter_toolbar_hidden.png "Hidden Toolbar" - * \image html jkqtplotter_toolbar_shown.png "Shown Toolbar" - * - * \see displayToolbar, \ref JKQTPlotterUserInteraction - */ - bool toolbarAlwaysOn; + /** \brief update settings of the toolbar */ void updateToolbar(); - /** \brief specifies whether to display the current position of the mouse in the top border of the plot (this may automatically extent the - * top border, so the position fits in. The default widget font is used for the output. - * - * \image html jkqtplotter_mousepositiondisplay.png - * - * \see mousePositionTemplate, \ref JKQTPlotterUserInteraction, \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEMOVE - */ - bool displayMousePosition; - /** \brief this string is used to generate the position output above the graph (\c %1 is replaced by the x-position, \c %2 by the y-position) - * - * By default simply "(%1, %2) is used to format this display (e.g. (1.35, -4.56)). - * - * \image html jkqtplotter_mousepositiondisplay.png - * - * \see mousePositionTemplate, \ref JKQTPlotterUserInteraction */ - QString mousePositionTemplate; - /*! \brief default value for property property mousePositionTemplate. \see mousePositionTemplate for more information */ - QString default_mousePositionTemplate; /** \brief the master plotter, this plotter is connected to in x-direction. */ QPointer masterPlotterX; @@ -1211,17 +1341,19 @@ class JKQTP_LIB_EXPORT JKQTPlotter: public QWidget { /** \brief calculate the y-axis shift of the plot, so there is space for the potentially displayed mouse position label */ int getPlotYOffset(); + /** \brief x-position of the mouse during the last mouseMoveEvent() calls (in plot coordinates) */ double mousePosX; + /** \brief y-position of the mouse during the last mouseMoveEvent() calls (in plot coordinates) */ double mousePosY; /** \brief magnification factor for the display of the plot */ double magnification; - + /** \brief current minimal size of the JKQTPlotter widget to properly display the plot */ QSize minSize; /** \brief the context menu object used by this JKQTPlotter */ QMenu* contextMenu; /** \brief current mode for the default context menu (i.e. the right-click context menu) */ - ContextMenuModes contextMenuMode; + JKQTPContextMenuModes contextMenuMode; /** \brief x-position of the mouse (in plot coordinates) when a user mouse-action was started (e.g. drawing a rectangle) */ double mouseContextX; /** \brief y-position of the mouse (in plot coordinates) when a user mouse-action was started (e.g. drawing a rectangle) */ @@ -1236,9 +1368,28 @@ class JKQTP_LIB_EXPORT JKQTPlotter: public QWidget { /** \brief set the current mouse cursor shappe according to currentMouseDragAction */ void updateCursor(); + /** \brief current style properties for this JKQTPlotter + * + * \see JKQTPSetSystemDefaultStyle(), JKQTPSetSystemDefaultStyle(), getCurrentPlotterStyle(), \ref jkqtpplotter_styling + */ + JKQTPlotterStyle plotterStyle; + + /** \brief timer used while the graph is resized to delay the redrawing with new size (in the meantime, an intermediate graphic is displayed) + * \internal + * \see delayedResizeEvent() + * + * \image html jkqtplotter_fastresizing.gif + */ QTimer resizeTimer; + protected slots: + /** \brief while the window is resized, the plot is only redrawn after a restartable delay, implemented by this function and resizeTimer + * \internal + * \see resizeTimer + * + * \image html jkqtplotter_fastresizing.gif + */ void delayedResizeEvent(); /** \brief connected to plotScalingRecalculated() of the masterPlotter */ @@ -1259,7 +1410,7 @@ class JKQTP_LIB_EXPORT JKQTPlotter: public QWidget { * \ingroup jkqtpplotterclasses_tools */ template<> -inline uint qHash(const QPair &key, uint seed ) noexcept(noexcept(qHash(key.first, seed)) && noexcept(qHash(key.second, seed))) { +inline uint qHash(const QPair &key, uint seed ) noexcept(noexcept(qHash(key.first, seed)) && noexcept(qHash(key.second, seed))) { return static_cast(key.first)+static_cast(key.second); } @@ -1277,7 +1428,7 @@ inline uint qHash(const Qt::MouseButton &key, uint /*seed*/ ) noexcept(noexcept( * \ingroup jkqtpplotterclasses_tools */ template<> -inline uint qHash(const Qt::KeyboardModifier &key, uint /*seed*/ ) noexcept(noexcept(qHash(key))) { +inline uint qHash(const Qt::KeyboardModifiers &key, uint /*seed*/ ) noexcept(noexcept(qHash(key))) { return static_cast(key); } diff --git a/lib/jkqtplotter/jkqtplotterstyle.cpp b/lib/jkqtplotter/jkqtplotterstyle.cpp new file mode 100644 index 0000000000..c787bf4e30 --- /dev/null +++ b/lib/jkqtplotter/jkqtplotterstyle.cpp @@ -0,0 +1,130 @@ +#include "jkqtplotterstyle.h" +#include "jkqtplottertools/jkqttools.h" +#include "jkqtplottertools/jkqtptools.h" + +JKQTPlotterStyle::JKQTPlotterStyle(): + toolbarIconSize(16), + userActionColor("steelblue"), + userActionCompositionMode(QPainter::CompositionMode_SourceOver), + mousePositionTemplate("(%1; %2)"), + displayMousePosition(true), + toolbarEnabled(true), + toolbarAlwaysOn(false), + usePaletteColors(true) +{ + // default user-actions: + registeredMouseDragActionModes[qMakePair(Qt::LeftButton, Qt::NoModifier)]=JKQTPMouseDragActions::jkqtpmdaZoomByRectangle; + registeredMouseDragActionModes[qMakePair(Qt::LeftButton, Qt::ControlModifier)]=JKQTPMouseDragActions::jkqtpmdaPanPlotOnMove; + registeredMouseDoubleClickActions[qMakePair(Qt::LeftButton, Qt::NoModifier)]=JKQTPMouseDoubleClickActions::jkqtpdcaClickMovesViewport; + registeredMouseWheelActions[Qt::NoModifier]=JKQTPMouseWheelActions::jkqtpmwaZoomByWheel; +} + +void JKQTPlotterStyle::loadSettings(const QSettings &settings, const QString &group, const JKQTPlotterStyle &defaultStyle) +{ + toolbarIconSize=settings.value(group+"toolbar_icon_size", defaultStyle.toolbarIconSize).toInt(); + mousePositionTemplate=settings.value(group+"mouse_position_template", defaultStyle.mousePositionTemplate).toString(); + userActionColor=jkqtp_String2QColor(settings.value(group+"useraction_color", jkqtp_QColor2String(defaultStyle.userActionColor)).toString()); + toolbarEnabled=settings.value(group+"toolbar_enabled", defaultStyle.toolbarEnabled).toBool(); + toolbarAlwaysOn=settings.value(group+"toolbar_always_visible", defaultStyle.toolbarAlwaysOn).toBool(); + displayMousePosition=settings.value(group+"display_mouse_position", defaultStyle.displayMousePosition).toBool(); + usePaletteColors=settings.value(group+"use_palette_colors", defaultStyle.usePaletteColors).toBool(); + + + auto readID=[](const QString& k, const QString& start) { + if (k.startsWith(start)) { + QString kk=k; + kk.remove(0, start.size()); + QString num=""; + while (kk.front().isDigit()) { + num+=kk.front(); + kk.remove(0, 1); + } + bool ok=false; + int id=num.toUInt(&ok); + if (ok) { + return id; + } + } + return -1; + }; + + registeredMouseWheelActions.clear(); + registeredMouseDragActionModes.clear(); + registeredMouseDoubleClickActions.clear(); + QStringList allk=settings.allKeys(); + for (auto& k: allk) { + if (k.endsWith("/action")) { + int id=readID(k, group+"actions/mouse_drag"); + if (id>=0) { + auto button=jkqtp_String2MouseButton(settings.value(group+"actions/mouse_drag"+QString::number(id)+"/button", Qt::NoButton).toString()); + auto modifiers=jkqtp_String2KeyboardModifiers(settings.value(group+"actions/mouse_drag"+QString::number(id)+"/modifiers", Qt::NoModifier).toString()); + auto action=String2JKQTPMouseDragActions(settings.value(group+"actions/mouse_drag"+QString::number(id)+"/action", jkqtpmdaZoomByRectangle).toString()); + registeredMouseDragActionModes[qMakePair(button, modifiers)]=action; + } + + id=readID(k, group+"actions/mouse_doubleclick"); + if (id>=0) { + auto button=jkqtp_String2MouseButton(settings.value(group+"actions/mouse_doubleclick"+QString::number(id)+"/button", Qt::NoButton).toString()); + auto modifiers=jkqtp_String2KeyboardModifiers(settings.value(group+"actions/mouse_doubleclick"+QString::number(id)+"/modifiers", Qt::NoModifier).toString()); + auto action=String2JKQTPMouseDoubleClickActions(settings.value(group+"actions/mouse_doubleclick"+QString::number(id)+"/action", jkqtpdcaClickZoomsIn).toString()); + registeredMouseDoubleClickActions[qMakePair(button, modifiers)]=action; + } + + id=readID(k, group+"actions/mouse_wheel"); + if (id>=0) { + auto modifiers=jkqtp_String2KeyboardModifiers(settings.value(group+"actions/mouse_wheel"+QString::number(id)+"/modifiers", Qt::NoModifier).toString()); + auto action=String2JKQTPMouseWheelActions(settings.value(group+"actions/mouse_wheel"+QString::number(id)+"/action", jkqtpmwaZoomByWheel).toString()); + registeredMouseWheelActions[modifiers]=action; + } + } + } +} + +void JKQTPlotterStyle::saveSettings(QSettings &settings, const QString &group) const +{ + int cnt=0; + + settings.setValue(group+"useraction_color", jkqtp_QColor2String(userActionColor)); + settings.setValue(group+"toolbar_enabled", toolbarEnabled); + settings.setValue(group+"toolbar_always_visible", toolbarAlwaysOn); + settings.setValue(group+"toolbar_icon_size", toolbarIconSize); + settings.setValue(group+"mouse_position_template", mousePositionTemplate); + settings.setValue(group+"display_mouse_position", displayMousePosition); + settings.setValue(group+"use_palette_colors", usePaletteColors); + + + cnt=0; + for (auto it=registeredMouseDragActionModes.begin(); it!=registeredMouseDragActionModes.end(); ++it) { + settings.setValue(group+"actions/mouse_drag"+QString::number(cnt)+"/button", jkqtp_MouseButton2String(it.key().first)); + settings.setValue(group+"actions/mouse_drag"+QString::number(cnt)+"/modifiers", jkqtp_KeyboardModifiers2String(it.key().second)); + settings.setValue(group+"actions/mouse_drag"+QString::number(cnt)+"/action", JKQTPMouseDragActions2String(it.value())); + cnt++; + } + + cnt=0; + for (auto it=registeredMouseDoubleClickActions.begin(); it!=registeredMouseDoubleClickActions.end(); ++it) { + settings.setValue(group+"actions/mouse_doubleclick"+QString::number(cnt)+"/button", jkqtp_MouseButton2String(it.key().first)); + settings.setValue(group+"actions/mouse_doubleclick"+QString::number(cnt)+"/modifiers", jkqtp_KeyboardModifiers2String(it.key().second)); + settings.setValue(group+"actions/mouse_doubleclick"+QString::number(cnt)+"/action", JKQTPMouseDoubleClickActions2String(it.value())); + cnt++; + } + + cnt=0; + for (auto it=registeredMouseWheelActions.begin(); it!=registeredMouseWheelActions.end(); ++it) { + settings.setValue(group+"actions/mouse_wheel"+QString::number(cnt)+"/modifiers", jkqtp_KeyboardModifiers2String(it.key())); + settings.setValue(group+"actions/mouse_wheel"+QString::number(cnt)+"/action", JKQTPMouseWheelActions2String(it.value())); + cnt++; + } +} + + +JKQTPlotterStyle &JKQTPGetSystemDefaultStyle() +{ + static JKQTPlotterStyle instance=JKQTPlotterStyle(); + return instance; +} + +void JKQTPSetSystemDefaultStyle(JKQTPlotterStyle &newStyle) +{ + JKQTPGetSystemDefaultStyle().operator=(newStyle); +} diff --git a/lib/jkqtplotter/jkqtplotterstyle.h b/lib/jkqtplotter/jkqtplotterstyle.h new file mode 100644 index 0000000000..0a8ab55658 --- /dev/null +++ b/lib/jkqtplotter/jkqtplotterstyle.h @@ -0,0 +1,145 @@ +/* + Copyright (c) 2008-2019 Jan W. Krieger (, ) + + + + This software is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License 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 for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ + +#ifndef JKQTPLOTTERSTYLE_H +#define JKQTPLOTTERSTYLE_H + +#include "jkqtplottertools/jkqtptools.h" +#include "jkqtplottertools/jkqtp_imexport.h" +#include +#include +#include +#include +#include +#include +#include + + +/** \brief Support Class for JKQTPlotter, which summarizes all proeprties that define the visual styling of a JKQTPlotter + * \ingroup jkqtpplotter_styling + * + * \see JKQTPlotter, \ref jkqtpplotter_styling + */ +class JKQTP_LIB_EXPORT JKQTPlotterStyle { + Q_GADGET +public: + /** \brief initialize with default values */ + JKQTPlotterStyle(); + + + + /** \brief loads the plot properties from a QSettings object + * + * \param settings QSettings-object to read from + * \param group Group in the QSettings-object to read from + * \param defaultStyle If a setting cannot be found in \a settings, default values are taken from this object + * By default, this is a default-constructed object + */ + void loadSettings(const QSettings &settings, const QString& group=QString("plots/"), const JKQTPlotterStyle &defaultStyle=JKQTPlotterStyle()); + + /** \brief saves the plot properties into a QSettings object. + * + * \param settings QSettings-object to save to + * \param group Group in the QSettings-object to save to + */ + void saveSettings(QSettings& settings, const QString& group=QString("plots/")) const; + + + + + + /** \brief width/height of the icons in the plotter toolbar in pixel */ + int toolbarIconSize; + /** \brief fill color of the zoom rectangle \see \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEDRAG */ + QColor userActionColor; + /** \brief the QPainter::CompositionMode used to draw the zoom rectangle etc. \see \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEDRAG */ + QPainter::CompositionMode userActionCompositionMode; + /** \brief this string is used to generate the position output above the graph (\c %1 is replaced by the x-position, \c %2 by the y-position) + * + * By default simply "(%1, %2) is used to format this display (e.g. (1.35, -4.56)). + * + * \image html jkqtplotter_mousepositiondisplay.png + * + * \see mousePositionTemplate, \ref JKQTPlotterUserInteraction */ + QString mousePositionTemplate; + + /** \brief specifies whether to display the current position of the mouse in the top border of the plot (this may automatically extent the + * top border, so the position fits in. The default widget font is used for the output. + * + * \image html jkqtplotter_mousepositiondisplay.png + * + * \see mousePositionTemplate, \ref JKQTPlotterUserInteraction, \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEMOVE + */ + bool displayMousePosition; + + /** \brief specifies whether to display a toolbar with buttons when the mouse is in the upper border of the plot + * + * \image html jkqtplotter_toolbar_alwayson.png + * + * \see toolbarAlwaysOn, \ref JKQTPlotterUserInteraction + */ + bool toolbarEnabled; + /** \brief specifies whether the toolbar is always visible or only when the mouse moves to the upper left area + * + * If toolbarAlwaysOn is set to \c true: + * + * \image html jkqtplotter_toolbar_alwayson.png + * + * If toolbarAlwaysOn is set to \c false, the toolbar only appears when the mouse is in the right location: + * + * \image html jkqtplotter_toolbar_hidden.png "Hidden Toolbar" + * \image html jkqtplotter_toolbar_shown.png "Shown Toolbar" + * + * \see toolbarEnabled, \ref JKQTPlotterUserInteraction + */ + bool toolbarAlwaysOn; + + /** \brief if set (\c true ), JKQTPlotter uses QPalette::Window and other colors from QPalette as background color for the plot + * + * \note setting this (default: \c true ) will overwrite some settings from JKQTBasePlotterStyle! */ + bool usePaletteColors; + + /** \brief lists all availble mouse drag action modes */ + JKQTPMouseDragActionsHashMap registeredMouseDragActionModes; + + /** \brief lists all availble mouse wheel action modes */ + JKQTPMouseWheelActionsHashMap registeredMouseWheelActions; + + /** \brief action to perform on a double-click of the mouse buttons (depending on the button and the modifiers) */ + JKQTPMouseDoubleClickActionsHashMap registeredMouseDoubleClickActions; + +}; + + +/** \brief returns the system-wide default JKQTPlotterStyle + * \ingroup jkqtpplotter_styling + * + * \see JKQTPSetSystemDefaultStyle(), JKQTPGetSystemDefaultBaseStyle(), JKQTPSetSystemDefaultBaseStyle(), \ref jkqtpplotter_styling + */ +JKQTP_LIB_EXPORT JKQTPlotterStyle& JKQTPGetSystemDefaultStyle(); + +/** \brief replaces the system-wide default JKQTPlotterStyle with the given \a newStyle + * \ingroup jkqtpplotter_styling + * + * \see JKQTPGetSystemDefaultStyle(), JKQTPGetSystemDefaultBaseStyle(), JKQTPSetSystemDefaultBaseStyle(), \ref jkqtpplotter_styling + */ +JKQTP_LIB_EXPORT void JKQTPSetSystemDefaultStyle(JKQTPlotterStyle& newStyle); + + +#endif // JKQTPLOTTERSTYLE_H diff --git a/lib/jkqtplotter/jkqtpopencvinterface.h b/lib/jkqtplotter/jkqtpopencvinterface.h index fa775be636..c30f937d4e 100644 --- a/lib/jkqtplotter/jkqtpopencvinterface.h +++ b/lib/jkqtplotter/jkqtpopencvinterface.h @@ -5,7 +5,7 @@ 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 of the License, or + 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, diff --git a/lib/jkqtplottergui/jkqtpcomboboxes.cpp b/lib/jkqtplottergui/jkqtpcomboboxes.cpp index 7dd0db4ba3..6eec75d5fe 100644 --- a/lib/jkqtplottergui/jkqtpcomboboxes.cpp +++ b/lib/jkqtplottergui/jkqtpcomboboxes.cpp @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -30,7 +30,7 @@ JKQTPMathImageColorPaletteComboBox::JKQTPMathImageColorPaletteComboBox(QWidget *parent): QComboBox(parent) { - setIconSize(QSize(jkqtp_PALETTE_ICON_WIDTH,16)); + setIconSize(QSize(JKQTPImageTools::PALETTE_ICON_WIDTH,16)); QStringList pal=JKQTPImagePlot_getPredefinedPalettes(); clear(); for (int i=0; i) 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 of the License, or + 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, diff --git a/lib/jkqtplottergui/jkqtpenhancedspinboxes.h b/lib/jkqtplottergui/jkqtpenhancedspinboxes.h index cdfb7f2e00..ff2fd55235 100644 --- a/lib/jkqtplottergui/jkqtpenhancedspinboxes.h +++ b/lib/jkqtplottergui/jkqtpenhancedspinboxes.h @@ -4,16 +4,16 @@ This software is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or + it under the terms of the GNU Lesser General Public License 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 General Public License for more details. + GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License + You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ diff --git a/lib/jkqtplottergui/jkqtpenhancedtableview.cpp b/lib/jkqtplottergui/jkqtpenhancedtableview.cpp index c8537adc3b..40dfd1fa58 100644 --- a/lib/jkqtplottergui/jkqtpenhancedtableview.cpp +++ b/lib/jkqtplottergui/jkqtpenhancedtableview.cpp @@ -7,7 +7,7 @@ Copyright (c) 2008-2019 Jan W. Krieger () 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 of the License, or + 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, @@ -511,7 +511,7 @@ void JKQTPEnhancedTableView::paint(QPainter &painter, QRect pageRect) { QRect pageRec=pageRect; if (pageRec.width()==0 || pageRec.height()==0) pageRec=QRect(QPoint(0,0), getTotalSize().toSize()); - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.translate(pageRec.topLeft()); QSizeF size=getTotalSize(); double vhw=verticalHeader()->width()+8; @@ -523,7 +523,7 @@ void JKQTPEnhancedTableView::paint(QPainter &painter, QRect pageRect) pageCols<<0<columnCount(); pageRows<<0<rowCount(); paint(painter, scale, -1, hhh, vhw, pageCols, pageRows); - painter.restore(); + } QSizeF JKQTPEnhancedTableView::getTotalSize() const @@ -550,7 +550,7 @@ QSizeF JKQTPEnhancedTableView::getTotalSize() const void JKQTPEnhancedTableView::paint(QPainter &painter, double scale, int page, double hhh, double vhw, const QList& pageCols, const QList& pageRows, QPrinter* p) { - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); QStyleOptionViewItem option = viewOptions(); painter.scale(scale, scale); QPen headerPen("black"); @@ -636,7 +636,7 @@ void JKQTPEnhancedTableView::paint(QPainter &painter, double scale, int page, do } if (p && phnewPage(); } - painter.restore(); + } diff --git a/lib/jkqtplottergui/jkqtpenhancedtableview.h b/lib/jkqtplottergui/jkqtpenhancedtableview.h index 4f325ae860..5d608f456c 100644 --- a/lib/jkqtplottergui/jkqtpenhancedtableview.h +++ b/lib/jkqtplottergui/jkqtpenhancedtableview.h @@ -4,16 +4,16 @@ This software is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or + it under the terms of the GNU Lesser General Public License 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 General Public License for more details. + GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License + You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ diff --git a/lib/jkqtplottergui/jkqtpgraphsmodel.cpp b/lib/jkqtplottergui/jkqtpgraphsmodel.cpp index 683fef4a48..3148d8e843 100644 --- a/lib/jkqtplottergui/jkqtpgraphsmodel.cpp +++ b/lib/jkqtplottergui/jkqtpgraphsmodel.cpp @@ -5,7 +5,7 @@ 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 of the License, or + 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, diff --git a/lib/jkqtplottergui/jkqtpgraphsmodel.h b/lib/jkqtplottergui/jkqtpgraphsmodel.h index 9445ef5dc4..4e6270c598 100644 --- a/lib/jkqtplottergui/jkqtpgraphsmodel.h +++ b/lib/jkqtplottergui/jkqtpgraphsmodel.h @@ -5,7 +5,7 @@ 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 of the License, or + 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, diff --git a/lib/jkqtplottergui/jkvanishqtoolbar.cpp b/lib/jkqtplottergui/jkvanishqtoolbar.cpp index e2a82a62a0..a5cb88dac7 100644 --- a/lib/jkqtplottergui/jkvanishqtoolbar.cpp +++ b/lib/jkqtplottergui/jkvanishqtoolbar.cpp @@ -5,7 +5,7 @@ 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 of the License, or + 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, diff --git a/lib/jkqtplottergui/jkvanishqtoolbar.h b/lib/jkqtplottergui/jkvanishqtoolbar.h index f151c39659..49288d1c90 100644 --- a/lib/jkqtplottergui/jkvanishqtoolbar.h +++ b/lib/jkqtplottergui/jkvanishqtoolbar.h @@ -5,7 +5,7 @@ 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 of the License, or + 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, diff --git a/lib/jkqtplotterressources/jkqtpstyles.qrc b/lib/jkqtplotterressources/jkqtpstyles.qrc new file mode 100644 index 0000000000..752f364545 --- /dev/null +++ b/lib/jkqtplotterressources/jkqtpstyles.qrc @@ -0,0 +1,11 @@ + + + styles/blackandwhite.ini + styles/blueprint.ini + styles/dark.ini + styles/default.ini + styles/simple_axesoffset.ini + styles/simple_axesoffset_plotbox.ini + styles/simple_gridandticks.ini + + diff --git a/lib/jkqtplotterressources/math_fonts/xits.pri b/lib/jkqtplotterressources/math_fonts/xits.pri index 26b26056bb..e95d0323f2 100644 --- a/lib/jkqtplotterressources/math_fonts/xits.pri +++ b/lib/jkqtplotterressources/math_fonts/xits.pri @@ -1 +1,6 @@ -RESOURCES += $$PWD/xits.qrc +contains(DEFINES, NO_XITS_FONTS) { + warning("NO_XITS_FONTS was defined ==> we do not link XITS fonts as ressource ... Think about installing them separately on the target machine") +} else { + message("Happy joy, we are linking XITS fonts as a ressource") + RESOURCES += $$PWD/xits.qrc +} diff --git a/lib/jkqtplotterressources/styles/blackandwhite.ini b/lib/jkqtplotterressources/styles/blackandwhite.ini new file mode 100644 index 0000000000..9806cad8ff --- /dev/null +++ b/lib/jkqtplotterressources/styles/blackandwhite.ini @@ -0,0 +1,254 @@ +[plot] +useraction_color=red +toolbar_enabled=true +toolbar_always_visible=false +toolbar_icon_size=16 +mouse_position_template="(%1; %2)" +display_mouse_position=true +use_palette_colors=true +actions\mouse_drag0\button=LEFT +actions\mouse_drag0\modifiers=CTRL +actions\mouse_drag0\action=PanOnMove +actions\mouse_drag1\button=LEFT +actions\mouse_drag1\modifiers=NONE +actions\mouse_drag1\action=ZoomRectangle +actions\mouse_doubleclick0\button=LEFT +actions\mouse_doubleclick0\modifiers=NONE +actions\mouse_doubleclick0\action=moveviewport +actions\mouse_wheel0\modifiers=NONE +actions\mouse_wheel0\action=zoom +csv_decimal_separator=. +csv_comment_initializer="# " +debug_show_region_boxes=false +debug_region_linewidth=3 +antialiase_system=true +antialiase_graphs=true +antialiase_text=true +widget_background_color=white +widget_background_color_for_export=white +plot_background_color=white +plot_border_left=5 +plot_border_right=5 +plot_border_top=5 +plot_border_bottom=5 +graph_default_linewidth=1 +graph_default_symbolsize=10 +graph_default_symbol_linewidtht=1 +graph_default_palette=InvGray +graph_default_fill_color_mode=lighter +graph_default_error_color_mode=same +graph_default_error_fill_color_mode=even_lighter +text_default_color=black +text_default_size=10 +text_default_font_name=XITS +plot_label_font_name=XITS +plot_label_font_size=12 +plot_frame_visible=false +plot_frame_color=black +plot_frame_width=2 +plot_frame_rounded=0 +key\xoffset=0.5 +key\yoffset=0.5 +key\xmargin=0.5 +key\ymargin=0.5 +key\xseparation=0.75 +key\yseparation=0.75 +key\frame_visible=true +key\frame_color=black +key\frame_width=1 +key\frame_rounding=0 +key\background_color=white +key\visible=true +key\position=inside_topright +key\layout=one_column +key\fontsize=8 +key\text_color=black +key\item_width=20 +key\item_height=2.2 +key\line_width=3 +key\autosize=true +axis_x\color=black +axis_x\draw_mode1=all +axis_x\draw_mode2=line+ticks +axis_x\line_width=1 +axis_x\axis_lines_offset=0 +axis_x\min_ticks=5 +axis_x\grid\enabled=true +axis_x\grid\color=silver +axis_x\grid\width=0.5 +axis_x\grid\style=dash +axis_x\axis_label\distance=5 +axis_x\axis_label\font_size=10 +axis_x\axis_label\position=center +axis_x\axis_label\type=exponent +axis_x\minor_grid\enabled=false +axis_x\minor_grid\color=silver +axis_x\minor_grid\style=dot +axis_x\minor_grid\width=0.25 +axis_x\minor_tick\labels_enabled=false +axis_x\minor_tick\inside_length=2 +axis_x\minor_tick\label_font_size=7 +axis_x\minor_tick\label_full_number=true +axis_x\minor_tick\outside_length=0 +axis_x\minor_tick\width=1 +axis_x\minor_tick\count=1 +axis_x\ticks\date_format=dd.MM.yyyy +axis_x\ticks\datetime_format=dd.MM.yyyy HH:mm +axis_x\ticks\inside_length=4 +axis_x\ticks\label_distance=3 +axis_x\ticks\label_font_size=8 +axis_x\ticks\mode=lin_or_power +axis_x\ticks\outside_length=0 +axis_x\ticks\time_format=HH:mm +axis_x\ticks\width=1 +axis_x\zero_line\enabled=true +axis_x\zero_line\line_width=1 +axis_x\zero_line\color=black +axis_x\zero_line\style=solid +axis_y\color=black +axis_y\draw_mode1=all +axis_y\draw_mode2=line+ticks +axis_y\line_width=1 +axis_y\axis_lines_offset=0 +axis_y\min_ticks=5 +axis_y\grid\enabled=true +axis_y\grid\color=silver +axis_y\grid\width=0.5 +axis_y\grid\style=dash +axis_y\axis_label\distance=5 +axis_y\axis_label\font_size=10 +axis_y\axis_label\position=center +axis_y\axis_label\type=exponent +axis_y\minor_grid\enabled=false +axis_y\minor_grid\color=silver +axis_y\minor_grid\style=dot +axis_y\minor_grid\width=0.25 +axis_y\minor_tick\labels_enabled=false +axis_y\minor_tick\inside_length=2 +axis_y\minor_tick\label_font_size=7 +axis_y\minor_tick\label_full_number=true +axis_y\minor_tick\outside_length=0 +axis_y\minor_tick\width=1 +axis_y\minor_tick\count=1 +axis_y\ticks\date_format=dd.MM.yyyy +axis_y\ticks\datetime_format=dd.MM.yyyy HH:mm +axis_y\ticks\inside_length=4 +axis_y\ticks\label_distance=3 +axis_y\ticks\label_font_size=8 +axis_y\ticks\mode=lin_or_power +axis_y\ticks\outside_length=0 +axis_y\ticks\time_format=HH:mm +axis_y\ticks\width=1 +axis_y\zero_line\enabled=true +axis_y\zero_line\line_width=1 +axis_y\zero_line\color=black +axis_y\zero_line\style=solid +axis_colorbar_right\color=black +axis_colorbar_right\draw_mode1=all +axis_colorbar_right\draw_mode2=line+ticks +axis_colorbar_right\line_width=1 +axis_colorbar_right\axis_lines_offset=0 +axis_colorbar_right\min_ticks=5 +axis_colorbar_right\grid\enabled=true +axis_colorbar_right\grid\color=black +axis_colorbar_right\grid\width=0.5 +axis_colorbar_right\grid\style=dash +axis_colorbar_right\axis_label\distance=5 +axis_colorbar_right\axis_label\font_size=8 +axis_colorbar_right\axis_label\position=center +axis_colorbar_right\axis_label\type=exponent +axis_colorbar_right\minor_grid\enabled=false +axis_colorbar_right\minor_grid\color=black +axis_colorbar_right\minor_grid\style=dot +axis_colorbar_right\minor_grid\width=0.25 +axis_colorbar_right\minor_tick\labels_enabled=false +axis_colorbar_right\minor_tick\inside_length=2 +axis_colorbar_right\minor_tick\label_font_size=7 +axis_colorbar_right\minor_tick\label_full_number=true +axis_colorbar_right\minor_tick\outside_length=0 +axis_colorbar_right\minor_tick\width=1 +axis_colorbar_right\minor_tick\count=1 +axis_colorbar_right\ticks\date_format=dd.MM.yyyy +axis_colorbar_right\ticks\datetime_format=dd.MM.yyyy HH:mm +axis_colorbar_right\ticks\inside_length=4 +axis_colorbar_right\ticks\label_distance=3 +axis_colorbar_right\ticks\label_font_size=8 +axis_colorbar_right\ticks\mode=lin_or_power +axis_colorbar_right\ticks\outside_length=0 +axis_colorbar_right\ticks\time_format=HH:mm +axis_colorbar_right\ticks\width=1 +axis_colorbar_right\zero_line\enabled=true +axis_colorbar_right\zero_line\line_width=1 +axis_colorbar_right\zero_line\color=black +axis_colorbar_right\zero_line\style=solid +axis_colorbar_top\color=black +axis_colorbar_top\draw_mode1=all +axis_colorbar_top\draw_mode2=line+ticks +axis_colorbar_top\line_width=1 +axis_colorbar_top\axis_lines_offset=0 +axis_colorbar_top\min_ticks=5 +axis_colorbar_top\grid\enabled=true +axis_colorbar_top\grid\color=black +axis_colorbar_top\grid\width=0.5 +axis_colorbar_top\grid\style=dash +axis_colorbar_top\axis_label\distance=5 +axis_colorbar_top\axis_label\font_size=8 +axis_colorbar_top\axis_label\position=center +axis_colorbar_top\axis_label\type=exponent +axis_colorbar_top\minor_grid\enabled=false +axis_colorbar_top\minor_grid\color=black +axis_colorbar_top\minor_grid\style=dot +axis_colorbar_top\minor_grid\width=0.25 +axis_colorbar_top\minor_tick\labels_enabled=false +axis_colorbar_top\minor_tick\inside_length=2 +axis_colorbar_top\minor_tick\label_font_size=7 +axis_colorbar_top\minor_tick\label_full_number=true +axis_colorbar_top\minor_tick\outside_length=0 +axis_colorbar_top\minor_tick\width=1 +axis_colorbar_top\minor_tick\count=1 +axis_colorbar_top\ticks\date_format=dd.MM.yyyy +axis_colorbar_top\ticks\datetime_format=dd.MM.yyyy HH:mm +axis_colorbar_top\ticks\inside_length=4 +axis_colorbar_top\ticks\label_distance=3 +axis_colorbar_top\ticks\label_font_size=8 +axis_colorbar_top\ticks\mode=lin_or_power +axis_colorbar_top\ticks\outside_length=0 +axis_colorbar_top\ticks\time_format=HH:mm +axis_colorbar_top\ticks\width=1 +axis_colorbar_top\zero_line\enabled=true +axis_colorbar_top\zero_line\line_width=1 +axis_colorbar_top\zero_line\color=black +axis_colorbar_top\zero_line\style=solid +default_graph_styles\color0=black +default_graph_styles\line_style0=solid +default_graph_styles\line_style1=dash +default_graph_styles\line_style2=dot +default_graph_styles\line_style3=dashdot +default_graph_styles\line_style4=dashdotdot +default_graph_styles\fill_style0=solid +default_graph_styles\fill_style1=bdiag +default_graph_styles\fill_style2=vdiag +default_graph_styles\fill_style3=ver +default_graph_styles\fill_style4=hor +default_graph_styles\fill_style5=cross +default_graph_styles\fill_style6=diagcross +default_graph_styles\symbol0=symbol_cross +default_graph_styles\symbol1=symbol_plus +default_graph_styles\symbol2=symbol_circle +default_graph_styles\symbol3=symbol_filled_circle +default_graph_styles\symbol4=symbol_rect +default_graph_styles\symbol5=symbol_filled_rect +default_graph_styles\symbol6=symbol_triangle +default_graph_styles\symbol7=symbol_filled_triangle +default_graph_styles\symbol8=symbol_down_triangle +default_graph_styles\symbol9=symbol_filled_down_triangle +default_graph_styles\symbol10=symbol_diamond +default_graph_styles\symbol11=symbol_filled_diamond +default_graph_styles\symbol12=symbol_star +default_graph_styles\symbol13=symbol_filled_star +default_graph_styles\symbol14=symbol_pentagon +default_graph_styles\symbol15=symbol_filled_pentagon +default_graph_styles\symbol16=symbol_asterisc +default_graph_styles\symbol17=symbol_target +default_graph_styles\symbol18=symbol_rect_cross +default_graph_styles\symbol19=symbol_rect_plus diff --git a/lib/jkqtplotterressources/styles/blueprint.ini b/lib/jkqtplotterressources/styles/blueprint.ini new file mode 100644 index 0000000000..c774526dcf --- /dev/null +++ b/lib/jkqtplotterressources/styles/blueprint.ini @@ -0,0 +1,249 @@ +[plot] +[plot] +useraction_color=red +toolbar_enabled=true +toolbar_always_visible=false +toolbar_icon_size=16 +mouse_position_template="(%1; %2)" +display_mouse_position=true +use_palette_colors=true +actions\mouse_drag0\button=LEFT +actions\mouse_drag0\modifiers=NONE +actions\mouse_drag0\action=ZoomRectangle +actions\mouse_drag1\button=LEFT +actions\mouse_drag1\modifiers=CTRL +actions\mouse_drag1\action=PanOnMove +actions\mouse_doubleclick0\button=LEFT +actions\mouse_doubleclick0\modifiers=NONE +actions\mouse_doubleclick0\action=moveviewport +actions\mouse_wheel0\modifiers=NONE +actions\mouse_wheel0\action=zoom +csv_decimal_separator=. +csv_comment_initializer="# " +debug_show_region_boxes=false +debug_region_linewidth=3 +antialiase_system=true +antialiase_graphs=true +antialiase_text=true +widget_background_color=#212571 +widget_background_color_for_export=#212571 +plot_background_color=transparent +plot_border_left=5 +plot_border_right=5 +plot_border_top=5 +plot_border_bottom=5 +graph_default_linewidth=1 +graph_default_symbolsize=8 +graph_default_symbol_linewidtht=0.75 +graph_default_palette=Matlab +graph_default_fill_color_mode=darker +graph_default_error_color_mode=lighter +graph_default_error_fill_color_mode=even_lighter +text_default_color=#FAFAFA +text_default_size=8 +text_default_font_name=Arial+XITS +plot_label_font_name=Arial+XITS +plot_label_font_size=12 +plot_frame_visible=false +plot_frame_color=#FAFAFA +plot_frame_width=2 +plot_frame_rounded=0 +key\xoffset=0.5 +key\yoffset=0.5 +key\xmargin=0.5 +key\ymargin=0.5 +key\xseparation=0.75 +key\yseparation=0.75 +key\frame_visible=true +key\frame_color=#FAFAFA +key\frame_width=1 +key\frame_rounding=0 +key\background_color=#181c67 +key\visible=true +key\position=inside_topright +key\layout=one_column +key\fontsize=8 +key\text_color=#FAFAFA +key\item_width=20 +key\item_height=2.2 +key\line_width=3 +key\autosize=true +axis_x\color=#FAFAFA +axis_x\draw_mode1=all +axis_x\draw_mode2=line+ticks +axis_x\line_width=1 +axis_x\axis_lines_offset=0 +axis_x\min_ticks=5 +axis_x\grid\enabled=true +axis_x\grid\style=dash +axis_x\grid\color=#616161 +axis_x\grid\width=0.75 +axis_x\axis_label\distance=5 +axis_x\axis_label\font_size=8 +axis_x\axis_label\position=center +axis_x\axis_label\type=exponent +axis_x\minor_grid\enabled=false +axis_x\minor_grid\style=dot +axis_x\minor_grid\color=#616161 +axis_x\minor_grid\width=0.5 +axis_x\minor_tick\labels_enabled=false +axis_x\minor_tick\inside_length=2 +axis_x\minor_tick\label_font_size=6.4 +axis_x\minor_tick\label_full_number=true +axis_x\minor_tick\outside_length=2 +axis_x\minor_tick\width=1 +axis_x\minor_tick\count=1 +axis_x\ticks\date_format=dd.MM.yyyy +axis_x\ticks\datetime_format=dd.MM.yyyy HH:mm +axis_x\ticks\inside_length=3 +axis_x\ticks\label_distance=3 +axis_x\ticks\label_font_size=8 +axis_x\ticks\mode=lin_or_power +axis_x\ticks\outside_length=3 +axis_x\ticks\time_format=HH:mm +axis_x\ticks\width=1 +axis_x\zero_line\enabled=true +axis_x\zero_line\line_width=1 +axis_x\zero_line\color=#FAFAFA +axis_x\zero_line\style=solid +axis_y\color=#FAFAFA +axis_y\draw_mode1=all +axis_y\draw_mode2=line+ticks +axis_y\line_width=1 +axis_y\axis_lines_offset=0 +axis_y\min_ticks=5 +axis_y\grid\enabled=true +axis_y\grid\color=#616161 +axis_y\grid\style=dash +axis_y\grid\width=0.75 +axis_y\axis_label\distance=5 +axis_y\axis_label\font_size=8 +axis_y\axis_label\position=center +axis_y\axis_label\type=exponent +axis_y\minor_grid\enabled=false +axis_y\minor_grid\color=#616161 +axis_y\minor_grid\style=dot +axis_y\minor_grid\width=0.5 +axis_y\minor_tick\labels_enabled=false +axis_y\minor_tick\inside_length=2 +axis_y\minor_tick\label_font_size=6.4 +axis_y\minor_tick\label_full_number=true +axis_y\minor_tick\outside_length=2 +axis_y\minor_tick\width=1 +axis_y\minor_tick\count=1 +axis_y\ticks\date_format=dd.MM.yyyy +axis_y\ticks\datetime_format=dd.MM.yyyy HH:mm +axis_y\ticks\inside_length=3 +axis_y\ticks\label_distance=3 +axis_y\ticks\label_font_size=8 +axis_y\ticks\mode=lin_or_power +axis_y\ticks\outside_length=3 +axis_y\ticks\time_format=HH:mm +axis_y\ticks\width=1 +axis_y\zero_line\enabled=true +axis_y\zero_line\line_width=1 +axis_y\zero_line\color=#FAFAFA +axis_y\zero_line\style=solid +axis_colorbar_right\color=#FAFAFA +axis_colorbar_right\draw_mode1=all +axis_colorbar_right\draw_mode2=line+ticks+labels+axislabel +axis_colorbar_right\line_width=1 +axis_colorbar_right\axis_lines_offset=0 +axis_colorbar_right\min_ticks=5 +axis_colorbar_right\grid\enabled=true +axis_colorbar_right\grid\color=#616161 +axis_colorbar_right\grid\width=0.75 +axis_colorbar_right\axis_label\distance=5 +axis_colorbar_right\axis_label\font_size=8 +axis_colorbar_right\axis_label\position=center +axis_colorbar_right\axis_label\type=exponent +axis_colorbar_right\minor_grid\enabled=false +axis_colorbar_right\minor_grid\style=dot +axis_colorbar_right\minor_grid\width=0.5 +axis_colorbar_right\minor_tick\labels_enabled=false +axis_colorbar_right\minor_tick\inside_length=2 +axis_colorbar_right\minor_tick\label_font_size=6.4 +axis_colorbar_right\minor_tick\label_full_number=true +axis_colorbar_right\minor_tick\outside_length=2 +axis_colorbar_right\minor_tick\width=1 +axis_colorbar_right\minor_tick\count=1 +axis_colorbar_right\ticks\date_format=dd.MM.yyyy +axis_colorbar_right\ticks\datetime_format=dd.MM.yyyy HH:mm +axis_colorbar_right\ticks\inside_length=3 +axis_colorbar_right\ticks\label_distance=3 +axis_colorbar_right\ticks\label_font_size=8 +axis_colorbar_right\ticks\mode=lin_or_power +axis_colorbar_right\ticks\outside_length=3 +axis_colorbar_right\ticks\time_format=HH:mm +axis_colorbar_right\ticks\width=1 +axis_colorbar_right\zero_line\enabled=true +axis_colorbar_right\zero_line\line_width=1 +axis_colorbar_right\zero_line\color=#FAFAFA +axis_colorbar_right\zero_line\style=solid +axis_colorbar_top\color=#FAFAFA +axis_colorbar_top\draw_mode1=all +axis_colorbar_top\draw_mode2=line+ticks +axis_colorbar_top\line_width=1 +axis_colorbar_top\axis_lines_offset=0 +axis_colorbar_top\min_ticks=5 +axis_colorbar_top\grid\enabled=true +axis_colorbar_top\grid\color=#616161 +axis_colorbar_top\grid\width=0.75 +axis_colorbar_top\axis_label\distance=5 +axis_colorbar_top\axis_label\font_size=8 +axis_colorbar_top\axis_label\position=center +axis_colorbar_top\axis_label\type=exponent +axis_colorbar_top\minor_grid\enabled=false +axis_colorbar_top\minor_grid\style=dot +axis_colorbar_top\minor_grid\width=0.5 +axis_colorbar_top\minor_tick\labels_enabled=false +axis_colorbar_top\minor_tick\inside_length=2 +axis_colorbar_top\minor_tick\label_font_size=6.4 +axis_colorbar_top\minor_tick\label_full_number=true +axis_colorbar_top\minor_tick\outside_length=2 +axis_colorbar_top\minor_tick\width=1 +axis_colorbar_top\minor_tick\count=1 +axis_colorbar_top\ticks\date_format=dd.MM.yyyy +axis_colorbar_top\ticks\datetime_format=dd.MM.yyyy HH:mm +axis_colorbar_top\ticks\inside_length=3 +axis_colorbar_top\ticks\label_distance=3 +axis_colorbar_top\ticks\label_font_size=8 +axis_colorbar_top\ticks\mode=lin_or_power +axis_colorbar_top\ticks\outside_length=3 +axis_colorbar_top\ticks\time_format=HH:mm +axis_colorbar_top\ticks\width=1 +axis_colorbar_top\zero_line\enabled=true +axis_colorbar_top\zero_line\line_width=1 +axis_colorbar_top\zero_line\color=#FAFAFA +axis_colorbar_top\zero_line\style=solid +default_graph_styles\color0=#EF9A9A +default_graph_styles\color1=#4DB6AC +default_graph_styles\color2="#90CAF9" +default_graph_styles\color3="#E6EE9C" +default_graph_styles\color4="#FFB74D" +default_graph_styles\color5="#CE93D8" +default_graph_styles\line_style0=solid +default_graph_styles\line_style1=dash +default_graph_styles\line_style2=dot +default_graph_styles\line_style3=dashdot +default_graph_styles\line_style4=dashdotdot +default_graph_styles\symbol0=symbol_cross +default_graph_styles\symbol1=symbol_plus +default_graph_styles\symbol2=symbol_circle +default_graph_styles\symbol3=symbol_filled_circle +default_graph_styles\symbol4=symbol_rect +default_graph_styles\symbol5=symbol_filled_rect +default_graph_styles\symbol6=symbol_triangle +default_graph_styles\symbol7=symbol_filled_triangle +default_graph_styles\symbol8=symbol_down_triangle +default_graph_styles\symbol9=symbol_filled_down_triangle +default_graph_styles\symbol10=symbol_diamond +default_graph_styles\symbol11=symbol_filled_diamond +default_graph_styles\symbol12=symbol_star +default_graph_styles\symbol13=symbol_filled_star +default_graph_styles\symbol14=symbol_pentagon +default_graph_styles\symbol15=symbol_filled_pentagon +default_graph_styles\symbol16=symbol_asterisc +default_graph_styles\symbol17=symbol_target +default_graph_styles\symbol18=symbol_rect_cross +default_graph_styles\symbol19=symbol_rect_plus diff --git a/lib/jkqtplotterressources/styles/dark.ini b/lib/jkqtplotterressources/styles/dark.ini new file mode 100644 index 0000000000..7c7a217d77 --- /dev/null +++ b/lib/jkqtplotterressources/styles/dark.ini @@ -0,0 +1,251 @@ +[plot] +[plot] +useraction_color=red +toolbar_enabled=true +toolbar_always_visible=false +toolbar_icon_size=16 +mouse_position_template="(%1; %2)" +display_mouse_position=true +use_palette_colors=true +actions\mouse_drag0\button=LEFT +actions\mouse_drag0\modifiers=NONE +actions\mouse_drag0\action=ZoomRectangle +actions\mouse_drag1\button=LEFT +actions\mouse_drag1\modifiers=CTRL +actions\mouse_drag1\action=PanOnMove +actions\mouse_doubleclick0\button=LEFT +actions\mouse_doubleclick0\modifiers=NONE +actions\mouse_doubleclick0\action=moveviewport +actions\mouse_wheel0\modifiers=NONE +actions\mouse_wheel0\action=zoom +csv_decimal_separator=. +csv_comment_initializer="# " +debug_show_region_boxes=false +debug_region_linewidth=3 +antialiase_system=true +antialiase_graphs=true +antialiase_text=true +widget_background_color=#212121 +widget_background_color_for_export=#212121 +plot_background_color=transparent +plot_border_left=5 +plot_border_right=5 +plot_border_top=5 +plot_border_bottom=5 +graph_default_linewidth=1 +graph_default_symbolsize=8 +graph_default_symbol_linewidtht=0.75 +graph_default_palette=Matlab +graph_default_fill_color_mode=darker +graph_default_error_color_mode=lighter +graph_default_error_fill_color_mode=even_lighter +text_default_color=#FAFAFA +text_default_size=8 +text_default_font_name=Arial+XITS +plot_label_font_name=Arial+XITS +plot_label_font_size=12 +plot_frame_visible=false +plot_frame_color=#FAFAFA +plot_frame_width=2 +plot_frame_rounded=0 +key\xoffset=0.5 +key\yoffset=0.5 +key\xmargin=0.5 +key\ymargin=0.5 +key\xseparation=0.75 +key\yseparation=0.75 +key\frame_visible=true +key\frame_color=#FAFAFA +key\frame_width=1 +key\frame_rounding=0 +key\background_color=#424242 +key\visible=true +key\position=inside_topright +key\layout=one_column +key\fontsize=8 +key\text_color=#FAFAFA +key\item_width=20 +key\item_height=2.2 +key\line_width=3 +key\autosize=true +axis_x\color=#FAFAFA +axis_x\draw_mode1=all +axis_x\draw_mode2=line+ticks +axis_x\line_width=1 +axis_x\axis_lines_offset=0 +axis_x\min_ticks=5 +axis_x\grid\enabled=true +axis_x\grid\style=dash +axis_x\grid\color=#616161 +axis_x\grid\width=0.75 +axis_x\axis_label\distance=5 +axis_x\axis_label\font_size=8 +axis_x\axis_label\position=center +axis_x\axis_label\type=exponent +axis_x\minor_grid\enabled=false +axis_x\minor_grid\style=dot +axis_x\minor_grid\color=#616161 +axis_x\minor_grid\width=0.5 +axis_x\minor_tick\labels_enabled=false +axis_x\minor_tick\inside_length=2 +axis_x\minor_tick\label_font_size=6.4 +axis_x\minor_tick\label_full_number=true +axis_x\minor_tick\outside_length=2 +axis_x\minor_tick\width=1 +axis_x\minor_tick\count=1 +axis_x\ticks\date_format=dd.MM.yyyy +axis_x\ticks\datetime_format=dd.MM.yyyy HH:mm +axis_x\ticks\inside_length=3 +axis_x\ticks\label_distance=3 +axis_x\ticks\label_font_size=8 +axis_x\ticks\mode=lin_or_power +axis_x\ticks\outside_length=3 +axis_x\ticks\time_format=HH:mm +axis_x\ticks\width=1 +axis_x\zero_line\enabled=true +axis_x\zero_line\line_width=1 +axis_x\zero_line\color=#FAFAFA +axis_x\zero_line\style=solid +axis_y\color=#FAFAFA +axis_y\draw_mode1=all +axis_y\draw_mode2=line+ticks +axis_y\line_width=1 +axis_y\axis_lines_offset=0 +axis_y\min_ticks=5 +axis_y\grid\enabled=true +axis_y\grid\color=#616161 +axis_y\grid\style=dash +axis_y\grid\width=0.75 +axis_y\axis_label\distance=5 +axis_y\axis_label\font_size=8 +axis_y\axis_label\position=center +axis_y\axis_label\type=exponent +axis_y\minor_grid\enabled=false +axis_y\minor_grid\color=#616161 +axis_y\minor_grid\style=dot +axis_y\minor_grid\width=0.5 +axis_y\minor_tick\labels_enabled=false +axis_y\minor_tick\inside_length=2 +axis_y\minor_tick\label_font_size=6.4 +axis_y\minor_tick\label_full_number=true +axis_y\minor_tick\outside_length=2 +axis_y\minor_tick\width=1 +axis_y\minor_tick\count=1 +axis_y\ticks\date_format=dd.MM.yyyy +axis_y\ticks\datetime_format=dd.MM.yyyy HH:mm +axis_y\ticks\inside_length=3 +axis_y\ticks\label_distance=3 +axis_y\ticks\label_font_size=8 +axis_y\ticks\mode=lin_or_power +axis_y\ticks\outside_length=3 +axis_y\ticks\time_format=HH:mm +axis_y\ticks\width=1 +axis_y\zero_line\enabled=true +axis_y\zero_line\line_width=1 +axis_y\zero_line\color=#FAFAFA +axis_y\zero_line\style=solid +axis_colorbar_right\color=#FAFAFA +axis_colorbar_right\draw_mode1=all +axis_colorbar_right\draw_mode2=line+ticks+labels+axislabel +axis_colorbar_right\line_width=1 +axis_colorbar_right\axis_lines_offset=0 +axis_colorbar_right\min_ticks=5 +axis_colorbar_right\grid\enabled=true +axis_colorbar_right\grid\color=#616161 +axis_colorbar_right\grid\width=0.75 +axis_colorbar_right\axis_label\distance=5 +axis_colorbar_right\axis_label\font_size=8 +axis_colorbar_right\axis_label\position=center +axis_colorbar_right\axis_label\type=exponent +axis_colorbar_right\minor_grid\enabled=false +axis_colorbar_right\minor_grid\style=dot +axis_colorbar_right\minor_grid\width=0.5 +axis_colorbar_right\minor_tick\labels_enabled=false +axis_colorbar_right\minor_tick\inside_length=2 +axis_colorbar_right\minor_tick\label_font_size=6.4 +axis_colorbar_right\minor_tick\label_full_number=true +axis_colorbar_right\minor_tick\outside_length=2 +axis_colorbar_right\minor_tick\width=1 +axis_colorbar_right\minor_tick\count=1 +axis_colorbar_right\ticks\date_format=dd.MM.yyyy +axis_colorbar_right\ticks\datetime_format=dd.MM.yyyy HH:mm +axis_colorbar_right\ticks\inside_length=3 +axis_colorbar_right\ticks\label_distance=3 +axis_colorbar_right\ticks\label_font_size=8 +axis_colorbar_right\ticks\mode=lin_or_power +axis_colorbar_right\ticks\outside_length=3 +axis_colorbar_right\ticks\time_format=HH:mm +axis_colorbar_right\ticks\width=1 +axis_colorbar_right\zero_line\enabled=true +axis_colorbar_right\zero_line\line_width=1 +axis_colorbar_right\zero_line\color=#FAFAFA +axis_colorbar_right\zero_line\style=solid +axis_colorbar_top\color=#FAFAFA +axis_colorbar_top\draw_mode1=all +axis_colorbar_top\draw_mode2=line+ticks +axis_colorbar_top\line_width=1 +axis_colorbar_top\axis_lines_offset=0 +axis_colorbar_top\min_ticks=5 +axis_colorbar_top\grid\enabled=true +axis_colorbar_top\grid\color=#616161 +axis_colorbar_top\grid\width=0.75 +axis_colorbar_top\axis_label\distance=5 +axis_colorbar_top\axis_label\font_size=8 +axis_colorbar_top\axis_label\position=center +axis_colorbar_top\axis_label\type=exponent +axis_colorbar_top\minor_grid\enabled=false +axis_colorbar_top\minor_grid\style=dot +axis_colorbar_top\minor_grid\width=0.5 +axis_colorbar_top\minor_tick\labels_enabled=false +axis_colorbar_top\minor_tick\inside_length=2 +axis_colorbar_top\minor_tick\label_font_size=6.4 +axis_colorbar_top\minor_tick\label_full_number=true +axis_colorbar_top\minor_tick\outside_length=2 +axis_colorbar_top\minor_tick\width=1 +axis_colorbar_top\minor_tick\count=1 +axis_colorbar_top\ticks\date_format=dd.MM.yyyy +axis_colorbar_top\ticks\datetime_format=dd.MM.yyyy HH:mm +axis_colorbar_top\ticks\inside_length=3 +axis_colorbar_top\ticks\label_distance=3 +axis_colorbar_top\ticks\label_font_size=8 +axis_colorbar_top\ticks\mode=lin_or_power +axis_colorbar_top\ticks\outside_length=3 +axis_colorbar_top\ticks\time_format=HH:mm +axis_colorbar_top\ticks\width=1 +axis_colorbar_top\zero_line\enabled=true +axis_colorbar_top\zero_line\line_width=1 +axis_colorbar_top\zero_line\color=#FAFAFA +axis_colorbar_top\zero_line\style=solid +default_graph_styles\color0="#FF3D00,80%" +default_graph_styles\color1="#4CAF50,80%" +default_graph_styles\color2="#00BCD4,80%" +default_graph_styles\color3="#FFEB3B,80%" +default_graph_styles\color4="#FF9800,80%" +default_graph_styles\color5="#9C27B0,80%" +default_graph_styles\color6="#29B6F6,80%" +default_graph_styles\color7="blue,80%" +default_graph_styles\line_style0=solid +default_graph_styles\line_style1=dash +default_graph_styles\line_style2=dot +default_graph_styles\line_style3=dashdot +default_graph_styles\line_style4=dashdotdot +default_graph_styles\symbol0=symbol_cross +default_graph_styles\symbol1=symbol_plus +default_graph_styles\symbol2=symbol_circle +default_graph_styles\symbol3=symbol_filled_circle +default_graph_styles\symbol4=symbol_rect +default_graph_styles\symbol5=symbol_filled_rect +default_graph_styles\symbol6=symbol_triangle +default_graph_styles\symbol7=symbol_filled_triangle +default_graph_styles\symbol8=symbol_down_triangle +default_graph_styles\symbol9=symbol_filled_down_triangle +default_graph_styles\symbol10=symbol_diamond +default_graph_styles\symbol11=symbol_filled_diamond +default_graph_styles\symbol12=symbol_star +default_graph_styles\symbol13=symbol_filled_star +default_graph_styles\symbol14=symbol_pentagon +default_graph_styles\symbol15=symbol_filled_pentagon +default_graph_styles\symbol16=symbol_asterisc +default_graph_styles\symbol17=symbol_target +default_graph_styles\symbol18=symbol_rect_cross +default_graph_styles\symbol19=symbol_rect_plus diff --git a/lib/jkqtplotterressources/styles/default.ini b/lib/jkqtplotterressources/styles/default.ini new file mode 100644 index 0000000000..b5b9c50672 --- /dev/null +++ b/lib/jkqtplotterressources/styles/default.ini @@ -0,0 +1,262 @@ +[plot] +useraction_color=red +toolbar_enabled=true +toolbar_always_visible=false +toolbar_icon_size=16 +mouse_position_template="(%1; %2)" +display_mouse_position=true +use_palette_colors=true +actions\mouse_drag0\button=LEFT +actions\mouse_drag0\modifiers=CTRL +actions\mouse_drag0\action=PanOnMove +actions\mouse_drag1\button=LEFT +actions\mouse_drag1\modifiers=NONE +actions\mouse_drag1\action=ZoomRectangle +actions\mouse_doubleclick0\button=LEFT +actions\mouse_doubleclick0\modifiers=NONE +actions\mouse_doubleclick0\action=moveviewport +actions\mouse_wheel0\modifiers=NONE +actions\mouse_wheel0\action=zoom +csv_decimal_separator=. +csv_comment_initializer="# " +debug_show_region_boxes=false +debug_region_linewidth=3 +antialiase_system=true +antialiase_graphs=true +antialiase_text=true +widget_background_color=#f0f0f0 +widget_background_color_for_export=white +plot_background_color=white +plot_border_left=5 +plot_border_right=5 +plot_border_top=5 +plot_border_bottom=5 +graph_default_linewidth=2 +graph_default_symbolsize=10 +graph_default_symbol_linewidtht=1 +graph_default_palette=Matlab +graph_default_fill_color_mode=lighter +graph_default_error_color_mode=darker +graph_default_error_fill_color_mode=even_lighter +text_default_color=black +text_default_size=8 +text_default_font_name=MS Shell Dlg 2+XITS +plot_label_font_name=MS Shell Dlg 2+XITS +plot_label_font_size=12 +plot_frame_visible=false +plot_frame_color=black +plot_frame_width=2 +plot_frame_rounded=0 +key\xoffset=0.5 +key\yoffset=0.5 +key\xmargin=0.5 +key\ymargin=0.5 +key\xseparation=0.75 +key\yseparation=0.75 +key\frame_visible=true +key\frame_color=black +key\frame_width=1 +key\frame_rounding=0 +key\background_color=white +key\visible=true +key\position=inside_topright +key\layout=one_column +key\fontsize=8 +key\text_color=black +key\item_width=20 +key\item_height=2.2 +key\line_width=3 +key\autosize=true +axis_x\color=black +axis_x\draw_mode1=all +axis_x\draw_mode2=line+ticks +axis_x\line_width=1.5 +axis_x\axis_lines_offset=0 +axis_x\min_ticks=5 +axis_x\grid\enabled=true +axis_x\grid\color=gray +axis_x\grid\width=0.75 +axis_x\grid\style=dash +axis_x\axis_label\distance=5 +axis_x\axis_label\font_size=8 +axis_x\axis_label\position=center +axis_x\axis_label\type=exponent +axis_x\minor_grid\enabled=false +axis_x\minor_grid\color=gray +axis_x\minor_grid\style=dot +axis_x\minor_grid\width=0.5 +axis_x\minor_tick\labels_enabled=false +axis_x\minor_tick\inside_length=1.5 +axis_x\minor_tick\label_font_size=6.4 +axis_x\minor_tick\label_full_number=true +axis_x\minor_tick\outside_length=1.5 +axis_x\minor_tick\width=1 +axis_x\minor_tick\count=1 +axis_x\ticks\date_format=dd.MM.yyyy +axis_x\ticks\datetime_format=dd.MM.yyyy HH:mm +axis_x\ticks\inside_length=3 +axis_x\ticks\label_distance=3 +axis_x\ticks\label_font_size=8 +axis_x\ticks\mode=lin_or_power +axis_x\ticks\outside_length=3 +axis_x\ticks\time_format=HH:mm +axis_x\ticks\width=1.5 +axis_x\zero_line\enabled=true +axis_x\zero_line\line_width=1.5 +axis_x\zero_line\color=black +axis_x\zero_line\style=solid +axis_y\color=black +axis_y\draw_mode1=all +axis_y\draw_mode2=line+ticks +axis_y\line_width=1.5 +axis_y\axis_lines_offset=0 +axis_y\min_ticks=5 +axis_y\grid\enabled=true +axis_y\grid\color=gray +axis_y\grid\width=0.75 +axis_y\grid\style=dash +axis_y\axis_label\distance=5 +axis_y\axis_label\font_size=8 +axis_y\axis_label\position=center +axis_y\axis_label\type=exponent +axis_y\minor_grid\enabled=false +axis_y\minor_grid\color=gray +axis_y\minor_grid\style=dot +axis_y\minor_grid\width=0.5 +axis_y\minor_tick\labels_enabled=false +axis_y\minor_tick\inside_length=1.5 +axis_y\minor_tick\label_font_size=6.4 +axis_y\minor_tick\label_full_number=true +axis_y\minor_tick\outside_length=1.5 +axis_y\minor_tick\width=1 +axis_y\minor_tick\count=1 +axis_y\ticks\date_format=dd.MM.yyyy +axis_y\ticks\datetime_format=dd.MM.yyyy HH:mm +axis_y\ticks\inside_length=3 +axis_y\ticks\label_distance=3 +axis_y\ticks\label_font_size=8 +axis_y\ticks\mode=lin_or_power +axis_y\ticks\outside_length=3 +axis_y\ticks\time_format=HH:mm +axis_y\ticks\width=1.5 +axis_y\zero_line\enabled=true +axis_y\zero_line\line_width=1.5 +axis_y\zero_line\color=black +axis_y\zero_line\style=solid +axis_colorbar_right\color=black +axis_colorbar_right\draw_mode1=all +axis_colorbar_right\draw_mode2=line+ticks +axis_colorbar_right\line_width=1.5 +axis_colorbar_right\axis_lines_offset=0 +axis_colorbar_right\min_ticks=5 +axis_colorbar_right\grid\enabled=true +axis_colorbar_right\grid\color=gray +axis_colorbar_right\grid\width=0.75 +axis_colorbar_right\grid\style=dash +axis_colorbar_right\axis_label\distance=5 +axis_colorbar_right\axis_label\font_size=8 +axis_colorbar_right\axis_label\position=center +axis_colorbar_right\axis_label\type=exponent +axis_colorbar_right\minor_grid\enabled=false +axis_colorbar_right\minor_grid\color=gray +axis_colorbar_right\minor_grid\style=dot +axis_colorbar_right\minor_grid\width=0.5 +axis_colorbar_right\minor_tick\labels_enabled=false +axis_colorbar_right\minor_tick\inside_length=1.5 +axis_colorbar_right\minor_tick\label_font_size=6.4 +axis_colorbar_right\minor_tick\label_full_number=true +axis_colorbar_right\minor_tick\outside_length=1.5 +axis_colorbar_right\minor_tick\width=1 +axis_colorbar_right\minor_tick\count=1 +axis_colorbar_right\ticks\date_format=dd.MM.yyyy +axis_colorbar_right\ticks\datetime_format=dd.MM.yyyy HH:mm +axis_colorbar_right\ticks\inside_length=3 +axis_colorbar_right\ticks\label_distance=3 +axis_colorbar_right\ticks\label_font_size=8 +axis_colorbar_right\ticks\mode=lin_or_power +axis_colorbar_right\ticks\outside_length=3 +axis_colorbar_right\ticks\time_format=HH:mm +axis_colorbar_right\ticks\width=1.5 +axis_colorbar_right\zero_line\enabled=true +axis_colorbar_right\zero_line\line_width=1.5 +axis_colorbar_right\zero_line\color=black +axis_colorbar_right\zero_line\style=solid +axis_colorbar_top\color=black +axis_colorbar_top\draw_mode1=all +axis_colorbar_top\draw_mode2=line+ticks +axis_colorbar_top\line_width=1.5 +axis_colorbar_top\axis_lines_offset=0 +axis_colorbar_top\min_ticks=5 +axis_colorbar_top\grid\enabled=true +axis_colorbar_top\grid\color=gray +axis_colorbar_top\grid\width=0.75 +axis_colorbar_top\grid\style=dash +axis_colorbar_top\axis_label\distance=5 +axis_colorbar_top\axis_label\font_size=8 +axis_colorbar_top\axis_label\position=center +axis_colorbar_top\axis_label\type=exponent +axis_colorbar_top\minor_grid\enabled=false +axis_colorbar_top\minor_grid\color=gray +axis_colorbar_top\minor_grid\style=dot +axis_colorbar_top\minor_grid\width=0.5 +axis_colorbar_top\minor_tick\labels_enabled=false +axis_colorbar_top\minor_tick\inside_length=1.5 +axis_colorbar_top\minor_tick\label_font_size=6.4 +axis_colorbar_top\minor_tick\label_full_number=true +axis_colorbar_top\minor_tick\outside_length=1.5 +axis_colorbar_top\minor_tick\width=1 +axis_colorbar_top\minor_tick\count=1 +axis_colorbar_top\ticks\date_format=dd.MM.yyyy +axis_colorbar_top\ticks\datetime_format=dd.MM.yyyy HH:mm +axis_colorbar_top\ticks\inside_length=3 +axis_colorbar_top\ticks\label_distance=3 +axis_colorbar_top\ticks\label_font_size=8 +axis_colorbar_top\ticks\mode=lin_or_power +axis_colorbar_top\ticks\outside_length=3 +axis_colorbar_top\ticks\time_format=HH:mm +axis_colorbar_top\ticks\width=1.5 +axis_colorbar_top\zero_line\enabled=true +axis_colorbar_top\zero_line\line_width=1.5 +axis_colorbar_top\zero_line\color=black +axis_colorbar_top\zero_line\style=solid +default_graph_styles\color0=red +default_graph_styles\color1=green +default_graph_styles\color2=blue +default_graph_styles\color3=fuchsia +default_graph_styles\color4=darkorange +default_graph_styles\color5=navy +default_graph_styles\color6=firebrick +default_graph_styles\color7=darkgreen +default_graph_styles\color8=darkmagenta +default_graph_styles\color9=darkgreen +default_graph_styles\color10=darkslateblue +default_graph_styles\color11=maroon +default_graph_styles\color12=indianred +default_graph_styles\color13=darkolivegreen +default_graph_styles\color14=mediumpurple +default_graph_styles\color15=darkcyan +default_graph_styles\line_style0=solid +default_graph_styles\line_style1=dash +default_graph_styles\line_style2=dot +default_graph_styles\line_style3=dashdot +default_graph_styles\line_style4=dashdotdot +default_graph_styles\symbol0=symbol_cross +default_graph_styles\symbol1=symbol_plus +default_graph_styles\symbol2=symbol_circle +default_graph_styles\symbol3=symbol_filled_circle +default_graph_styles\symbol4=symbol_rect +default_graph_styles\symbol5=symbol_filled_rect +default_graph_styles\symbol6=symbol_triangle +default_graph_styles\symbol7=symbol_filled_triangle +default_graph_styles\symbol8=symbol_down_triangle +default_graph_styles\symbol9=symbol_filled_down_triangle +default_graph_styles\symbol10=symbol_diamond +default_graph_styles\symbol11=symbol_filled_diamond +default_graph_styles\symbol12=symbol_star +default_graph_styles\symbol13=symbol_filled_star +default_graph_styles\symbol14=symbol_pentagon +default_graph_styles\symbol15=symbol_filled_pentagon +default_graph_styles\symbol16=symbol_asterisc +default_graph_styles\symbol17=symbol_target +default_graph_styles\symbol18=symbol_rect_cross +default_graph_styles\symbol19=symbol_rect_plus diff --git a/lib/jkqtplotterressources/styles/simple_axesoffset.ini b/lib/jkqtplotterressources/styles/simple_axesoffset.ini new file mode 100644 index 0000000000..89b62cac84 --- /dev/null +++ b/lib/jkqtplotterressources/styles/simple_axesoffset.ini @@ -0,0 +1,250 @@ +[plot] +useraction_color=red +toolbar_enabled=true +toolbar_always_visible=false +toolbar_icon_size=16 +mouse_position_template="(%1; %2)" +display_mouse_position=true +use_palette_colors=true +actions\mouse_drag0\button=LEFT +actions\mouse_drag0\modifiers=NONE +actions\mouse_drag0\action=ZoomRectangle +actions\mouse_drag1\button=LEFT +actions\mouse_drag1\modifiers=CTRL +actions\mouse_drag1\action=PanOnMove +actions\mouse_doubleclick0\button=LEFT +actions\mouse_doubleclick0\modifiers=NONE +actions\mouse_doubleclick0\action=moveviewport +actions\mouse_wheel0\modifiers=NONE +actions\mouse_wheel0\action=zoom +csv_decimal_separator=. +csv_comment_initializer="# " +debug_show_region_boxes=false +debug_region_linewidth=3 +antialiase_system=true +antialiase_graphs=true +antialiase_text=true +widget_background_color=white +widget_background_color_for_export=white +plot_background_color=white +plot_border_left=5 +plot_border_right=5 +plot_border_top=5 +plot_border_bottom=5 +graph_default_linewidth=2 +graph_default_symbolsize=10 +graph_default_symbol_linewidtht=1 +graph_default_palette=Matlab +text_default_color=black +text_default_size=8 +text_default_font_name=MS Shell Dlg 2+XITS +plot_label_font_name=MS Shell Dlg 2+XITS +plot_label_font_size=12 +plot_frame_visible=false +plot_frame_color=black +plot_frame_width=1 +plot_frame_rounded=3 +key\xoffset=1 +key\yoffset=1 +key\xmargin=1 +key\ymargin=1 +key\xseparation=0.75 +key\yseparation=0.75 +key\frame_visible=true +key\frame_color=black +key\frame_width=1 +key\frame_rounding=2 +key\background_color=white +key\visible=true +key\position=inside_topright +key\layout=one_column +key\fontsize=8 +key\item_width=20 +key\item_height=2.2 +key\line_width=3 +key\autosize=true +axis_x\color=black +axis_x\draw_mode1=all +axis_x\draw_mode2=none +axis_x\line_width=1 +axis_x\axis_lines_offset=6 +axis_x\min_ticks=5 +axis_x\grid\enabled=true +axis_x\grid\color=gray +axis_x\grid\width=0.75 +axis_x\axis_label\distance=5 +axis_x\axis_label\font_size=8 +axis_x\axis_label\position=center +axis_x\axis_label\type=exponent +axis_x\minor_grid\enabled=false +axis_x\minor_grid\style=dot +axis_x\minor_grid\width=0.5 +axis_x\minor_tick\labels_enabled=false +axis_x\minor_tick\inside_length=1.5 +axis_x\minor_tick\label_font_size=6.4 +axis_x\minor_tick\label_full_number=true +axis_x\minor_tick\outside_length=2 +axis_x\minor_tick\width=1 +axis_x\minor_tick\count=1 +axis_x\ticks\date_format=dd.MM.yyyy +axis_x\ticks\datetime_format=dd.MM.yyyy HH:mm +axis_x\ticks\inside_length=0 +axis_x\ticks\label_distance=3 +axis_x\ticks\label_font_size=8 +axis_x\ticks\mode=lin_or_power +axis_x\ticks\outside_length=5 +axis_x\ticks\time_format=HH:mm +axis_x\ticks\width=1 +axis_x\zero_line\enabled=true +axis_x\zero_line\line_width=1 +axis_x\zero_line\color=@Variant(\0\0\0\x43\x1\xff\xff\0\0\0\0\0\0\0\0) +axis_x\zero_line\style=solid +axis_y\color=black +axis_y\draw_mode1=all +axis_y\draw_mode2=none +axis_y\line_width=1 +axis_y\axis_lines_offset=6 +axis_y\min_ticks=5 +axis_y\grid\enabled=true +axis_y\grid\color=gray +axis_y\grid\width=0.75 +axis_y\axis_label\distance=5 +axis_y\axis_label\font_size=8 +axis_y\axis_label\position=center +axis_y\axis_label\type=exponent +axis_y\minor_grid\enabled=false +axis_y\minor_grid\style=dot +axis_y\minor_grid\width=0.5 +axis_y\minor_tick\labels_enabled=false +axis_y\minor_tick\inside_length=1.5 +axis_y\minor_tick\label_font_size=6.4 +axis_y\minor_tick\label_full_number=true +axis_y\minor_tick\outside_length=2 +axis_y\minor_tick\width=1 +axis_y\minor_tick\count=1 +axis_y\ticks\date_format=dd.MM.yyyy +axis_y\ticks\datetime_format=dd.MM.yyyy HH:mm +axis_y\ticks\inside_length=0 +axis_y\ticks\label_distance=5 +axis_y\ticks\label_font_size=8 +axis_y\ticks\mode=lin_or_power +axis_y\ticks\outside_length=3 +axis_y\ticks\time_format=HH:mm +axis_y\ticks\width=1 +axis_y\zero_line\enabled=true +axis_y\zero_line\line_width=1 +axis_y\zero_line\color=@Variant(\0\0\0\x43\x1\xff\xff\0\0\0\0\0\0\0\0) +axis_y\zero_line\style=solid +axis_colorbar_right\color=black +axis_colorbar_right\draw_mode1=all +axis_colorbar_right\draw_mode2=line+ticks +axis_colorbar_right\line_width=1.5 +axis_colorbar_right\axis_lines_offset=0 +axis_colorbar_right\min_ticks=5 +axis_colorbar_right\grid\enabled=true +axis_colorbar_right\grid\color=gray +axis_colorbar_right\grid\width=0.75 +axis_colorbar_right\axis_label\distance=5 +axis_colorbar_right\axis_label\font_size=8 +axis_colorbar_right\axis_label\position=center +axis_colorbar_right\axis_label\type=exponent +axis_colorbar_right\minor_grid\enabled=false +axis_colorbar_right\minor_grid\style=dot +axis_colorbar_right\minor_grid\width=0.5 +axis_colorbar_right\minor_tick\labels_enabled=false +axis_colorbar_right\minor_tick\inside_length=1.5 +axis_colorbar_right\minor_tick\label_font_size=6.4 +axis_colorbar_right\minor_tick\label_full_number=true +axis_colorbar_right\minor_tick\outside_length=1.5 +axis_colorbar_right\minor_tick\width=1 +axis_colorbar_right\minor_tick\count=1 +axis_colorbar_right\ticks\date_format=dd.MM.yyyy +axis_colorbar_right\ticks\datetime_format=dd.MM.yyyy HH:mm +axis_colorbar_right\ticks\inside_length=3 +axis_colorbar_right\ticks\label_distance=3 +axis_colorbar_right\ticks\label_font_size=8 +axis_colorbar_right\ticks\mode=lin_or_power +axis_colorbar_right\ticks\outside_length=3 +axis_colorbar_right\ticks\time_format=HH:mm +axis_colorbar_right\ticks\width=1.5 +axis_colorbar_right\zero_line\enabled=true +axis_colorbar_right\zero_line\line_width=1.5 +axis_colorbar_right\zero_line\color=@Variant(\0\0\0\x43\x1\xff\xff\0\0\0\0\0\0\0\0) +axis_colorbar_right\zero_line\style=solid +axis_colorbar_top\color=black +axis_colorbar_top\draw_mode1=all +axis_colorbar_top\draw_mode2=line+ticks +axis_colorbar_top\line_width=1.5 +axis_colorbar_top\axis_lines_offset=0 +axis_colorbar_top\min_ticks=5 +axis_colorbar_top\grid\enabled=true +axis_colorbar_top\grid\color=gray +axis_colorbar_top\grid\width=0.75 +axis_colorbar_top\axis_label\distance=5 +axis_colorbar_top\axis_label\font_size=8 +axis_colorbar_top\axis_label\position=center +axis_colorbar_top\axis_label\type=exponent +axis_colorbar_top\minor_grid\enabled=false +axis_colorbar_top\minor_grid\style=dot +axis_colorbar_top\minor_grid\width=0.5 +axis_colorbar_top\minor_tick\labels_enabled=false +axis_colorbar_top\minor_tick\inside_length=1.5 +axis_colorbar_top\minor_tick\label_font_size=6.4 +axis_colorbar_top\minor_tick\label_full_number=true +axis_colorbar_top\minor_tick\outside_length=1.5 +axis_colorbar_top\minor_tick\width=1 +axis_colorbar_top\minor_tick\count=1 +axis_colorbar_top\ticks\date_format=dd.MM.yyyy +axis_colorbar_top\ticks\datetime_format=dd.MM.yyyy HH:mm +axis_colorbar_top\ticks\inside_length=3 +axis_colorbar_top\ticks\label_distance=3 +axis_colorbar_top\ticks\label_font_size=8 +axis_colorbar_top\ticks\mode=lin_or_power +axis_colorbar_top\ticks\outside_length=3 +axis_colorbar_top\ticks\time_format=HH:mm +axis_colorbar_top\ticks\width=1.5 +axis_colorbar_top\zero_line\enabled=true +axis_colorbar_top\zero_line\line_width=1.5 +axis_colorbar_top\zero_line\color=@Variant(\0\0\0\x43\x1\xff\xff\0\0\0\0\0\0\0\0) +axis_colorbar_top\zero_line\style=solid +default_graph_styles\color0=red +default_graph_styles\color1=green +default_graph_styles\color2=blue +default_graph_styles\color3=fuchsia +default_graph_styles\color4=darkorange +default_graph_styles\color5=navy +default_graph_styles\color6=firebrick +default_graph_styles\color7=darkgreen +default_graph_styles\color8=darkmagenta +default_graph_styles\color9=darkgreen +default_graph_styles\color10=darkslateblue +default_graph_styles\color11=maroon +default_graph_styles\color12=indianred +default_graph_styles\color13=darkolivegreen +default_graph_styles\color14=mediumpurple +default_graph_styles\color15=darkcyan +default_graph_styles\line_style0=solid +default_graph_styles\line_style1=dash +default_graph_styles\line_style2=dot +default_graph_styles\line_style3=dashdot +default_graph_styles\line_style4=dashdotdot +default_graph_styles\symbol0=symbol_cross +default_graph_styles\symbol1=symbol_plus +default_graph_styles\symbol2=symbol_circle +default_graph_styles\symbol3=symbol_filled_circle +default_graph_styles\symbol4=symbol_rect +default_graph_styles\symbol5=symbol_filled_rect +default_graph_styles\symbol6=symbol_triangle +default_graph_styles\symbol7=symbol_filled_triangle +default_graph_styles\symbol8=symbol_down_triangle +default_graph_styles\symbol9=symbol_filled_down_triangle +default_graph_styles\symbol10=symbol_diamond +default_graph_styles\symbol11=symbol_filled_diamond +default_graph_styles\symbol12=symbol_star +default_graph_styles\symbol13=symbol_filled_star +default_graph_styles\symbol14=symbol_pentagon +default_graph_styles\symbol15=symbol_filled_pentagon +default_graph_styles\symbol16=symbol_asterisc +default_graph_styles\symbol17=symbol_target +default_graph_styles\symbol18=symbol_rect_cross +default_graph_styles\symbol19=symbol_rect_plus diff --git a/lib/jkqtplotterressources/styles/simple_axesoffset_plotbox.ini b/lib/jkqtplotterressources/styles/simple_axesoffset_plotbox.ini new file mode 100644 index 0000000000..92a7470c94 --- /dev/null +++ b/lib/jkqtplotterressources/styles/simple_axesoffset_plotbox.ini @@ -0,0 +1,251 @@ +[plot] +useraction_color=red +toolbar_enabled=true +toolbar_always_visible=false +toolbar_icon_size=16 +mouse_position_template="(%1; %2)" +display_mouse_position=true +use_palette_colors=true +actions\mouse_drag0\button=LEFT +actions\mouse_drag0\modifiers=NONE +actions\mouse_drag0\action=ZoomRectangle +actions\mouse_drag1\button=LEFT +actions\mouse_drag1\modifiers=CTRL +actions\mouse_drag1\action=PanOnMove +actions\mouse_doubleclick0\button=LEFT +actions\mouse_doubleclick0\modifiers=NONE +actions\mouse_doubleclick0\action=moveviewport +actions\mouse_wheel0\modifiers=NONE +actions\mouse_wheel0\action=zoom +csv_decimal_separator=. +csv_comment_initializer="# " +debug_show_region_boxes=false +debug_region_linewidth=3 +antialiase_system=true +antialiase_system=true +antialiase_graphs=true +antialiase_text=true +widget_background_color=white +widget_background_color_for_export=white +plot_background_color=white +plot_border_left=5 +plot_border_right=5 +plot_border_top=5 +plot_border_bottom=5 +graph_default_linewidth=2 +graph_default_symbolsize=10 +graph_default_symbol_linewidtht=1 +graph_default_palette=Matlab +text_default_color=black +text_default_size=8 +text_default_font_name=MS Shell Dlg 2+XITS +plot_label_font_name=MS Shell Dlg 2+XITS +plot_label_font_size=12 +plot_frame_visible=true +plot_frame_color=black +plot_frame_width=1 +plot_frame_rounded=3 +key\xoffset=1 +key\yoffset=1 +key\xmargin=1 +key\ymargin=1 +key\xseparation=0.75 +key\yseparation=0.75 +key\frame_visible=true +key\frame_color=black +key\frame_width=1 +key\frame_rounding=2 +key\background_color=white +key\visible=true +key\position=inside_topright +key\layout=one_column +key\fontsize=8 +key\item_width=20 +key\item_height=2.2 +key\line_width=3 +key\autosize=true +axis_x\color=black +axis_x\draw_mode1=all +axis_x\draw_mode2=none +axis_x\line_width=1.5 +axis_x\axis_lines_offset=6 +axis_x\min_ticks=5 +axis_x\grid\enabled=true +axis_x\grid\color=gray +axis_x\grid\width=0.75 +axis_x\axis_label\distance=5 +axis_x\axis_label\font_size=8 +axis_x\axis_label\position=center +axis_x\axis_label\type=exponent +axis_x\minor_grid\enabled=false +axis_x\minor_grid\style=dot +axis_x\minor_grid\width=0.5 +axis_x\minor_tick\labels_enabled=false +axis_x\minor_tick\inside_length=1.5 +axis_x\minor_tick\label_font_size=6.4 +axis_x\minor_tick\label_full_number=true +axis_x\minor_tick\outside_length=2 +axis_x\minor_tick\width=1 +axis_x\minor_tick\count=1 +axis_x\ticks\date_format=dd.MM.yyyy +axis_x\ticks\datetime_format=dd.MM.yyyy HH:mm +axis_x\ticks\inside_length=0 +axis_x\ticks\label_distance=3 +axis_x\ticks\label_font_size=8 +axis_x\ticks\mode=lin_or_power +axis_x\ticks\outside_length=5 +axis_x\ticks\time_format=HH:mm +axis_x\ticks\width=1 +axis_x\zero_line\enabled=false +axis_x\zero_line\line_width=1 +axis_x\zero_line\color=@Variant(\0\0\0\x43\x1\xff\xff\0\0\0\0\0\0\0\0) +axis_x\zero_line\style=solid +axis_y\color=black +axis_y\draw_mode1=all +axis_y\draw_mode2=none +axis_y\line_width=1 +axis_y\axis_lines_offset=6 +axis_y\min_ticks=5 +axis_y\grid\enabled=true +axis_y\grid\color=gray +axis_y\grid\width=0.75 +axis_y\axis_label\distance=5 +axis_y\axis_label\font_size=8 +axis_y\axis_label\position=center +axis_y\axis_label\type=exponent +axis_y\minor_grid\enabled=false +axis_y\minor_grid\style=dot +axis_y\minor_grid\width=0.5 +axis_y\minor_tick\labels_enabled=false +axis_y\minor_tick\inside_length=1.5 +axis_y\minor_tick\label_font_size=6.4 +axis_y\minor_tick\label_full_number=true +axis_y\minor_tick\outside_length=2 +axis_y\minor_tick\width=1 +axis_y\minor_tick\count=1 +axis_y\ticks\date_format=dd.MM.yyyy +axis_y\ticks\datetime_format=dd.MM.yyyy HH:mm +axis_y\ticks\inside_length=0 +axis_y\ticks\label_distance=5 +axis_y\ticks\label_font_size=8 +axis_y\ticks\mode=lin_or_power +axis_y\ticks\outside_length=3 +axis_y\ticks\time_format=HH:mm +axis_y\ticks\width=1.5 +axis_y\zero_line\enabled=false +axis_y\zero_line\line_width=1 +axis_y\zero_line\color=@Variant(\0\0\0\x43\x1\xff\xff\0\0\0\0\0\0\0\0) +axis_y\zero_line\style=solid +axis_colorbar_right\color=black +axis_colorbar_right\draw_mode1=all +axis_colorbar_right\draw_mode2=line+ticks +axis_colorbar_right\line_width=1.5 +axis_colorbar_right\axis_lines_offset=0 +axis_colorbar_right\min_ticks=5 +axis_colorbar_right\grid\enabled=true +axis_colorbar_right\grid\color=gray +axis_colorbar_right\grid\width=0.75 +axis_colorbar_right\axis_label\distance=5 +axis_colorbar_right\axis_label\font_size=8 +axis_colorbar_right\axis_label\position=center +axis_colorbar_right\axis_label\type=exponent +axis_colorbar_right\minor_grid\enabled=false +axis_colorbar_right\minor_grid\style=dot +axis_colorbar_right\minor_grid\width=0.5 +axis_colorbar_right\minor_tick\labels_enabled=false +axis_colorbar_right\minor_tick\inside_length=1.5 +axis_colorbar_right\minor_tick\label_font_size=6.4 +axis_colorbar_right\minor_tick\label_full_number=true +axis_colorbar_right\minor_tick\outside_length=1.5 +axis_colorbar_right\minor_tick\width=1 +axis_colorbar_right\minor_tick\count=1 +axis_colorbar_right\ticks\date_format=dd.MM.yyyy +axis_colorbar_right\ticks\datetime_format=dd.MM.yyyy HH:mm +axis_colorbar_right\ticks\inside_length=3 +axis_colorbar_right\ticks\label_distance=3 +axis_colorbar_right\ticks\label_font_size=8 +axis_colorbar_right\ticks\mode=lin_or_power +axis_colorbar_right\ticks\outside_length=3 +axis_colorbar_right\ticks\time_format=HH:mm +axis_colorbar_right\ticks\width=1.5 +axis_colorbar_right\zero_line\enabled=true +axis_colorbar_right\zero_line\line_width=1.5 +axis_colorbar_right\zero_line\color=@Variant(\0\0\0\x43\x1\xff\xff\0\0\0\0\0\0\0\0) +axis_colorbar_right\zero_line\style=solid +axis_colorbar_top\color=black +axis_colorbar_top\draw_mode1=all +axis_colorbar_top\draw_mode2=line+ticks +axis_colorbar_top\line_width=1.5 +axis_colorbar_top\axis_lines_offset=0 +axis_colorbar_top\min_ticks=5 +axis_colorbar_top\grid\enabled=true +axis_colorbar_top\grid\color=gray +axis_colorbar_top\grid\width=0.75 +axis_colorbar_top\axis_label\distance=5 +axis_colorbar_top\axis_label\font_size=8 +axis_colorbar_top\axis_label\position=center +axis_colorbar_top\axis_label\type=exponent +axis_colorbar_top\minor_grid\enabled=false +axis_colorbar_top\minor_grid\style=dot +axis_colorbar_top\minor_grid\width=0.5 +axis_colorbar_top\minor_tick\labels_enabled=false +axis_colorbar_top\minor_tick\inside_length=1.5 +axis_colorbar_top\minor_tick\label_font_size=6.4 +axis_colorbar_top\minor_tick\label_full_number=true +axis_colorbar_top\minor_tick\outside_length=1.5 +axis_colorbar_top\minor_tick\width=1 +axis_colorbar_top\minor_tick\count=1 +axis_colorbar_top\ticks\date_format=dd.MM.yyyy +axis_colorbar_top\ticks\datetime_format=dd.MM.yyyy HH:mm +axis_colorbar_top\ticks\inside_length=3 +axis_colorbar_top\ticks\label_distance=3 +axis_colorbar_top\ticks\label_font_size=8 +axis_colorbar_top\ticks\mode=lin_or_power +axis_colorbar_top\ticks\outside_length=3 +axis_colorbar_top\ticks\time_format=HH:mm +axis_colorbar_top\ticks\width=1.5 +axis_colorbar_top\zero_line\enabled=true +axis_colorbar_top\zero_line\line_width=1.5 +axis_colorbar_top\zero_line\color=@Variant(\0\0\0\x43\x1\xff\xff\0\0\0\0\0\0\0\0) +axis_colorbar_top\zero_line\style=solid +default_graph_styles\color0=red +default_graph_styles\color1=green +default_graph_styles\color2=blue +default_graph_styles\color3=fuchsia +default_graph_styles\color4=darkorange +default_graph_styles\color5=navy +default_graph_styles\color6=firebrick +default_graph_styles\color7=darkgreen +default_graph_styles\color8=darkmagenta +default_graph_styles\color9=darkgreen +default_graph_styles\color10=darkslateblue +default_graph_styles\color11=maroon +default_graph_styles\color12=indianred +default_graph_styles\color13=darkolivegreen +default_graph_styles\color14=mediumpurple +default_graph_styles\color15=darkcyan +default_graph_styles\line_style0=solid +default_graph_styles\line_style1=dash +default_graph_styles\line_style2=dot +default_graph_styles\line_style3=dashdot +default_graph_styles\line_style4=dashdotdot +default_graph_styles\symbol0=symbol_cross +default_graph_styles\symbol1=symbol_plus +default_graph_styles\symbol2=symbol_circle +default_graph_styles\symbol3=symbol_filled_circle +default_graph_styles\symbol4=symbol_rect +default_graph_styles\symbol5=symbol_filled_rect +default_graph_styles\symbol6=symbol_triangle +default_graph_styles\symbol7=symbol_filled_triangle +default_graph_styles\symbol8=symbol_down_triangle +default_graph_styles\symbol9=symbol_filled_down_triangle +default_graph_styles\symbol10=symbol_diamond +default_graph_styles\symbol11=symbol_filled_diamond +default_graph_styles\symbol12=symbol_star +default_graph_styles\symbol13=symbol_filled_star +default_graph_styles\symbol14=symbol_pentagon +default_graph_styles\symbol15=symbol_filled_pentagon +default_graph_styles\symbol16=symbol_asterisc +default_graph_styles\symbol17=symbol_target +default_graph_styles\symbol18=symbol_rect_cross +default_graph_styles\symbol19=symbol_rect_plus diff --git a/lib/jkqtplotterressources/styles/simple_gridandticks.ini b/lib/jkqtplotterressources/styles/simple_gridandticks.ini new file mode 100644 index 0000000000..1ef669697f --- /dev/null +++ b/lib/jkqtplotterressources/styles/simple_gridandticks.ini @@ -0,0 +1,250 @@ +[plot] +useraction_color=red +toolbar_enabled=true +toolbar_always_visible=false +toolbar_icon_size=16 +mouse_position_template="(%1; %2)" +display_mouse_position=true +use_palette_colors=true +actions\mouse_drag0\button=LEFT +actions\mouse_drag0\modifiers=NONE +actions\mouse_drag0\action=ZoomRectangle +actions\mouse_drag1\button=LEFT +actions\mouse_drag1\modifiers=CTRL +actions\mouse_drag1\action=PanOnMove +actions\mouse_doubleclick0\button=LEFT +actions\mouse_doubleclick0\modifiers=NONE +actions\mouse_doubleclick0\action=moveviewport +actions\mouse_wheel0\modifiers=NONE +actions\mouse_wheel0\action=zoom +csv_decimal_separator=. +csv_comment_initializer="# " +debug_show_region_boxes=false +debug_region_linewidth=3 +antialiase_system=true +antialiase_graphs=true +antialiase_text=true +widget_background_color=white +widget_background_color_for_export=white +plot_background_color=white +plot_border_left=5 +plot_border_right=5 +plot_border_top=5 +plot_border_bottom=5 +graph_default_linewidth=2 +graph_default_symbolsize=10 +graph_default_symbol_linewidtht=1 +graph_default_palette=Matlab +text_default_color=black +text_default_size=8 +text_default_font_name=MS Shell Dlg 2+XITS +plot_label_font_name=MS Shell Dlg 2+XITS +plot_label_font_size=12 +plot_frame_visible=false +plot_frame_color=black +plot_frame_width=2 +plot_frame_rounded=0 +key\xoffset=0.5 +key\yoffset=0.5 +key\xmargin=0.5 +key\ymargin=0.5 +key\xseparation=0.75 +key\yseparation=0.75 +key\frame_visible=true +key\frame_color=black +key\frame_width=1 +key\frame_rounding=0 +key\background_color=white +key\visible=true +key\position=inside_topright +key\layout=one_column +key\fontsize=8 +key\item_width=20 +key\item_height=2.2 +key\line_width=3 +key\autosize=true +axis_x\color=black +axis_x\draw_mode1=ticks+labels+axislabel +axis_x\draw_mode2=none +axis_x\line_width=1.5 +axis_x\axis_lines_offset=0 +axis_x\min_ticks=5 +axis_x\grid\enabled=true +axis_x\grid\color=gray +axis_x\grid\width=0.75 +axis_x\axis_label\distance=5 +axis_x\axis_label\font_size=8 +axis_x\axis_label\position=center +axis_x\axis_label\type=exponent +axis_x\minor_grid\enabled=false +axis_x\minor_grid\style=dot +axis_x\minor_grid\width=0.5 +axis_x\minor_tick\labels_enabled=false +axis_x\minor_tick\inside_length=1.5 +axis_x\minor_tick\label_font_size=6.4 +axis_x\minor_tick\label_full_number=true +axis_x\minor_tick\outside_length=1.5 +axis_x\minor_tick\width=1 +axis_x\minor_tick\count=1 +axis_x\ticks\date_format=dd.MM.yyyy +axis_x\ticks\datetime_format=dd.MM.yyyy HH:mm +axis_x\ticks\inside_length=3 +axis_x\ticks\label_distance=3 +axis_x\ticks\label_font_size=8 +axis_x\ticks\mode=lin_or_power +axis_x\ticks\outside_length=3 +axis_x\ticks\time_format=HH:mm +axis_x\ticks\width=1.5 +axis_x\zero_line\enabled=false +axis_x\zero_line\line_width=1.5 +axis_x\zero_line\color=black +axis_x\zero_line\style=solid +axis_y\color=black +axis_y\draw_mode1=ticks+labels+axislabel +axis_y\draw_mode2=none +axis_y\line_width=1.5 +axis_y\axis_lines_offset=0 +axis_y\min_ticks=5 +axis_y\grid\enabled=true +axis_y\grid\color=gray +axis_y\grid\width=0.75 +axis_y\axis_label\distance=5 +axis_y\axis_label\font_size=8 +axis_y\axis_label\position=center +axis_y\axis_label\type=exponent +axis_y\minor_grid\enabled=false +axis_y\minor_grid\style=dot +axis_y\minor_grid\width=0.5 +axis_y\minor_tick\labels_enabled=false +axis_y\minor_tick\inside_length=1.5 +axis_y\minor_tick\label_font_size=6.4 +axis_y\minor_tick\label_full_number=true +axis_y\minor_tick\outside_length=1.5 +axis_y\minor_tick\width=1 +axis_y\minor_tick\count=1 +axis_y\ticks\date_format=dd.MM.yyyy +axis_y\ticks\datetime_format=dd.MM.yyyy HH:mm +axis_y\ticks\inside_length=3 +axis_y\ticks\label_distance=3 +axis_y\ticks\label_font_size=8 +axis_y\ticks\mode=lin_or_power +axis_y\ticks\outside_length=3 +axis_y\ticks\time_format=HH:mm +axis_y\ticks\width=1.5 +axis_y\zero_line\enabled=true +axis_y\zero_line\line_width=1.5 +axis_y\zero_line\color=black +axis_y\zero_line\style=solid +axis_colorbar_right\color=black +axis_colorbar_right\draw_mode1=none +axis_colorbar_right\draw_mode2=ticks+labels+axislabel +axis_colorbar_right\line_width=1.5 +axis_colorbar_right\axis_lines_offset=0 +axis_colorbar_right\min_ticks=5 +axis_colorbar_right\grid\enabled=true +axis_colorbar_right\grid\color=gray +axis_colorbar_right\grid\width=0.75 +axis_colorbar_right\axis_label\distance=5 +axis_colorbar_right\axis_label\font_size=8 +axis_colorbar_right\axis_label\position=center +axis_colorbar_right\axis_label\type=exponent +axis_colorbar_right\minor_grid\enabled=false +axis_colorbar_right\minor_grid\style=dot +axis_colorbar_right\minor_grid\width=0.5 +axis_colorbar_right\minor_tick\labels_enabled=false +axis_colorbar_right\minor_tick\inside_length=1.5 +axis_colorbar_right\minor_tick\label_font_size=6.4 +axis_colorbar_right\minor_tick\label_full_number=true +axis_colorbar_right\minor_tick\outside_length=1.5 +axis_colorbar_right\minor_tick\width=1 +axis_colorbar_right\minor_tick\count=1 +axis_colorbar_right\ticks\date_format=dd.MM.yyyy +axis_colorbar_right\ticks\datetime_format=dd.MM.yyyy HH:mm +axis_colorbar_right\ticks\inside_length=3 +axis_colorbar_right\ticks\label_distance=3 +axis_colorbar_right\ticks\label_font_size=8 +axis_colorbar_right\ticks\mode=lin_or_power +axis_colorbar_right\ticks\outside_length=3 +axis_colorbar_right\ticks\time_format=HH:mm +axis_colorbar_right\ticks\width=1.5 +axis_colorbar_right\zero_line\enabled=true +axis_colorbar_right\zero_line\line_width=1.5 +axis_colorbar_right\zero_line\color=black +axis_colorbar_right\zero_line\style=solid +axis_colorbar_top\color=black +axis_colorbar_top\draw_mode1=none +axis_colorbar_top\draw_mode2=ticks+labels+axislabel +axis_colorbar_top\line_width=1.5 +axis_colorbar_top\axis_lines_offset=0 +axis_colorbar_top\min_ticks=5 +axis_colorbar_top\grid\enabled=true +axis_colorbar_top\grid\color=gray +axis_colorbar_top\grid\width=0.75 +axis_colorbar_top\axis_label\distance=5 +axis_colorbar_top\axis_label\font_size=8 +axis_colorbar_top\axis_label\position=center +axis_colorbar_top\axis_label\type=exponent +axis_colorbar_top\minor_grid\enabled=false +axis_colorbar_top\minor_grid\style=dot +axis_colorbar_top\minor_grid\width=0.5 +axis_colorbar_top\minor_tick\labels_enabled=false +axis_colorbar_top\minor_tick\inside_length=1.5 +axis_colorbar_top\minor_tick\label_font_size=6.4 +axis_colorbar_top\minor_tick\label_full_number=true +axis_colorbar_top\minor_tick\outside_length=1.5 +axis_colorbar_top\minor_tick\width=1 +axis_colorbar_top\minor_tick\count=1 +axis_colorbar_top\ticks\date_format=dd.MM.yyyy +axis_colorbar_top\ticks\datetime_format=dd.MM.yyyy HH:mm +axis_colorbar_top\ticks\inside_length=3 +axis_colorbar_top\ticks\label_distance=3 +axis_colorbar_top\ticks\label_font_size=8 +axis_colorbar_top\ticks\mode=lin_or_power +axis_colorbar_top\ticks\outside_length=3 +axis_colorbar_top\ticks\time_format=HH:mm +axis_colorbar_top\ticks\width=1.5 +axis_colorbar_top\zero_line\enabled=true +axis_colorbar_top\zero_line\line_width=1.5 +axis_colorbar_top\zero_line\color=black +axis_colorbar_top\zero_line\style=solid +default_graph_styles\color0=red +default_graph_styles\color1=green +default_graph_styles\color2=blue +default_graph_styles\color3=fuchsia +default_graph_styles\color4=darkorange +default_graph_styles\color5=navy +default_graph_styles\color6=firebrick +default_graph_styles\color7=darkgreen +default_graph_styles\color8=darkmagenta +default_graph_styles\color9=darkgreen +default_graph_styles\color10=darkslateblue +default_graph_styles\color11=maroon +default_graph_styles\color12=indianred +default_graph_styles\color13=darkolivegreen +default_graph_styles\color14=mediumpurple +default_graph_styles\color15=darkcyan +default_graph_styles\line_style0=solid +default_graph_styles\line_style1=dash +default_graph_styles\line_style2=dot +default_graph_styles\line_style3=dashdot +default_graph_styles\line_style4=dashdotdot +default_graph_styles\symbol0=symbol_cross +default_graph_styles\symbol1=symbol_plus +default_graph_styles\symbol2=symbol_circle +default_graph_styles\symbol3=symbol_filled_circle +default_graph_styles\symbol4=symbol_rect +default_graph_styles\symbol5=symbol_filled_rect +default_graph_styles\symbol6=symbol_triangle +default_graph_styles\symbol7=symbol_filled_triangle +default_graph_styles\symbol8=symbol_down_triangle +default_graph_styles\symbol9=symbol_filled_down_triangle +default_graph_styles\symbol10=symbol_diamond +default_graph_styles\symbol11=symbol_filled_diamond +default_graph_styles\symbol12=symbol_star +default_graph_styles\symbol13=symbol_filled_star +default_graph_styles\symbol14=symbol_pentagon +default_graph_styles\symbol15=symbol_filled_pentagon +default_graph_styles\symbol16=symbol_asterisc +default_graph_styles\symbol17=symbol_target +default_graph_styles\symbol18=symbol_rect_cross +default_graph_styles\symbol19=symbol_rect_plus diff --git a/lib/jkqtplottertools/jkqtp_imexport.h b/lib/jkqtplottertools/jkqtp_imexport.h index 85bb70467e..d93bcb2b1b 100644 --- a/lib/jkqtplottertools/jkqtp_imexport.h +++ b/lib/jkqtplottertools/jkqtp_imexport.h @@ -9,7 +9,7 @@ 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 of the License, or + 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, diff --git a/lib/jkqtplottertools/jkqtpdrawingtools.cpp b/lib/jkqtplottertools/jkqtpdrawingtools.cpp index 52e76f327c..d1e751464a 100644 --- a/lib/jkqtplottertools/jkqtpdrawingtools.cpp +++ b/lib/jkqtplottertools/jkqtpdrawingtools.cpp @@ -7,7 +7,7 @@ Copyright (c) 2008-2019 Jan W. Krieger () 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 of the License, or + 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, @@ -26,7 +26,7 @@ Copyright (c) 2008-2019 Jan W. Krieger () #include "jkqtplottertools/jkqtpdrawingtools.h" #include "jkqtplottertools/jkqtpenhancedpainter.h" - +const double JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH= 0.02; void JKQTPPlotSymbol(QPaintDevice& paintDevice, double x, double y, JKQTPGraphSymbols symbol, double size, double symbolLineWidth, QColor color, QColor fillColor) { JKQTPEnhancedPainter p(&paintDevice); @@ -34,10 +34,10 @@ void JKQTPPlotSymbol(QPaintDevice& paintDevice, double x, double y, JKQTPGraphSy } void JKQTPPlotSymbol(JKQTPEnhancedPainter& painter, double x, double y, JKQTPGraphSymbols symbol, double symbolSize, double symbolLineWidth, QColor color, QColor fillColor) { - painter.save(); + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); QPen p=painter.pen(); p.setColor(color); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, symbolLineWidth)); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, symbolLineWidth)); p.setStyle(Qt::SolidLine); painter.setPen(p); QBrush b=painter.brush(); @@ -224,7 +224,7 @@ void JKQTPPlotSymbol(JKQTPEnhancedPainter& painter, double x, double y, JKQTPGra } break; default: break; } - painter.restore(); + }; diff --git a/lib/jkqtplottertools/jkqtpdrawingtools.h b/lib/jkqtplottertools/jkqtpdrawingtools.h index d3957f6edd..4cb3507410 100644 --- a/lib/jkqtplottertools/jkqtpdrawingtools.h +++ b/lib/jkqtplottertools/jkqtpdrawingtools.h @@ -4,16 +4,16 @@ This software is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or + it under the terms of the GNU Lesser General Public License 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 General Public License for more details. + GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License + You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ @@ -26,6 +26,16 @@ class JKQTPEnhancedPainter; // forward + +/*! \brief tool class with static values used by JKQTPlotter/JKQTBasePlotter + \ingroup jkqtptools_drawing + */ +JKQTP_LIB_EXPORT struct JKQTPlotterDrawinTools { + /** \brief smallest linewidth any line in JKQTPlotter/JKQTBasePlotter may have + */ + static const double ABS_MIN_LINEWIDTH; +}; + /*! \brief plot the specified symbol at pixel position x,y \ingroup jkqtptools_drawing diff --git a/lib/jkqtplottertools/jkqtpenhancedpainter.cpp b/lib/jkqtplottertools/jkqtpenhancedpainter.cpp index 78e0586623..7e1b18f763 100644 --- a/lib/jkqtplottertools/jkqtpenhancedpainter.cpp +++ b/lib/jkqtplottertools/jkqtpenhancedpainter.cpp @@ -7,7 +7,7 @@ Copyright (c) 2008-2019 Jan W. Krieger () 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 of the License, or + 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, diff --git a/lib/jkqtplottertools/jkqtpenhancedpainter.h b/lib/jkqtplottertools/jkqtpenhancedpainter.h index 44fcf07250..164a30f831 100644 --- a/lib/jkqtplottertools/jkqtpenhancedpainter.h +++ b/lib/jkqtplottertools/jkqtpenhancedpainter.h @@ -4,16 +4,16 @@ This software is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or + it under the terms of the GNU Lesser General Public License 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 General Public License for more details. + GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License + You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ diff --git a/lib/jkqtplottertools/jkqtphighrestimer.cpp b/lib/jkqtplottertools/jkqtphighrestimer.cpp index 745cf1694a..649bc21bb9 100644 --- a/lib/jkqtplottertools/jkqtphighrestimer.cpp +++ b/lib/jkqtplottertools/jkqtphighrestimer.cpp @@ -5,7 +5,7 @@ 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 of the License, or + 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, diff --git a/lib/jkqtplottertools/jkqtphighrestimer.h b/lib/jkqtplottertools/jkqtphighrestimer.h index 76a2a56f65..8cd914b6b2 100644 --- a/lib/jkqtplottertools/jkqtphighrestimer.h +++ b/lib/jkqtplottertools/jkqtphighrestimer.h @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -136,16 +136,16 @@ class JKQTPHighResTimer { #else struct timeval last; #endif - public: - /** \brief class constructor. */ + public: + /** \brief class constructor. */ JKQTPHighResTimer(); - /** \brief class destructor */ + /** \brief class destructor */ ~JKQTPHighResTimer(); - /** \brief start the timer */ - void start(); - /** \brief get the time since the last call of start() in microseconds */ - double getTime(); - /** \brief test the resolution + /** \brief start the timer */ + void start(); + /** \brief get the time since the last call of start() in microseconds */ + double getTime(); + /** \brief test the resolution * * mean value and standard deviation of 1000000 timer polls will be evaluated and returned in \c mean * and \c stddev. If you supply \c histogram with a pointer to a memory array with \c histogram_size @@ -163,7 +163,7 @@ for (unsigned long i=0; i. */ - - #include "jkqtplottertools/jkqtpimagetools.h" #include #include @@ -27,16 +25,19 @@ #ifndef NO_JKQTPLOTTER #include "jkqtplotter/jkqtpbaseelements.h" #include "jkqtplotter/jkqtpbaseplotter.h" +#include "jkqtplottertools/jkqtpdrawingtools.h" #endif #ifdef QT_XML_LIB # include #endif -#define jkqtp_PALETTE_ICON_WIDTH 64 -#define jkqtp_PALETTE_IMAGEICON_HEIGHT 64 +const int JKQTPImageTools::PALETTE_ICON_WIDTH = 64; +const int JKQTPImageTools::PALETTE_IMAGEICON_HEIGHT = 64; +const int JKQTPImageTools::LUTSIZE = 256; QList global_jkqtpimagetools_lutstore = QList(); + bool JKQTPImagePlot_buildDefinedPaletteLessThan(const QPair &s1, const QPair &s2) { return s1.first=items[j+1].first) j++; - } else { - r=double(qRed(items.last().second)); - g=double(qGreen(items.last().second)); - b=double(qBlue(items.last().second)); - } - if (i<=lut_size) lut[i]=qRgb(static_cast(r), static_cast(g), static_cast(b)); - i++; + double r=0; + double g=0; + double b=0; + if (j+1=items[j+1].first) j++; + } else { + r=double(qRed(items.last().second)); + g=double(qGreen(items.last().second)); + b=double(qBlue(items.last().second)); + } + if (i<=lut_size) lut[i]=qRgb(static_cast(r), static_cast(g), static_cast(b)); + i++; } } @@ -78,9 +79,9 @@ void JKQTPImagePlot_buildDefinedPaletteLinInterpolate(int* lut, int N, ...) { va_start(args, N); for (int i=0; i > it double dmin=items.first().first; double dmax=items.last().first; - double delta=(dmax-dmin)/double(JKQTPImagePlot_LUTSIZE); + double delta=(dmax-dmin)/double(JKQTPImageTools::LUTSIZE); int i=0; int j=0; for (double v=dmin; v<=dmax; v=v+delta) { - double r=0; - double g=0; - double b=0; - if (j+1=items[j+1].first) j++; - } - if (i<=JKQTPImagePlot_LUTSIZE) lut[i]=qRgb(static_cast(r), static_cast(g), static_cast(b)); - i++; + double r=0; + double g=0; + double b=0; + if (j+1=items[j+1].first) j++; + } + if (i<=JKQTPImageTools::LUTSIZE) lut[i]=qRgb(static_cast(r), static_cast(g), static_cast(b)); + i++; } } @@ -119,9 +120,9 @@ void JKQTPImagePlot_buildDefinedPalette(int* lut, int N, ...) { va_start(args, N); for (int i=0; i > pal; - 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); - // determine format - for (int i=slt.size()-1; i>=0; i--) { - slt[i]=slt[i].trimmed(); - if (rx4.indexIn(slt[i])>=0) { - 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; - } - } 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)); - if (r>1.0 || g>1.0 || b>1.0) { - rgb255=true; - } - } else { - slt.removeAt(i); - } - } - // read data - bool ok=true; - for (int i=0; i=0) { - x=JKQTPImagePlot_QStringToDouble(rx4.cap(1)); - r=JKQTPImagePlot_QStringToDouble(rx4.cap(3)); - g=JKQTPImagePlot_QStringToDouble(rx4.cap(4)); - b=JKQTPImagePlot_QStringToDouble(rx4.cap(5)); - } else if (!has4 && rx3.indexIn(slt[i])>=0) { - x=i; - r=JKQTPImagePlot_QStringToDouble(rx3.cap(1)); - g=JKQTPImagePlot_QStringToDouble(rx3.cap(3)); - b=JKQTPImagePlot_QStringToDouble(rx3.cap(4)); - //qDebug()<(round(255*r)), 255), qBound(0,static_cast(round(255*g)), 255), qBound(0,static_cast(round(255*b)), 255))); - } else { - pal<(round(r)), 255), qBound(0,static_cast(round(g)), 255), qBound(0,static_cast(round(b)), 255))); - } - } - } - //qDebug()<<"read: "< > pal; + 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); + // determine format + for (int i=slt.size()-1; i>=0; i--) { + slt[i]=slt[i].trimmed(); + if (rx4.indexIn(slt[i])>=0) { + 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; } + } 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)); + if (r>1.0 || g>1.0 || b>1.0) { + rgb255=true; + } + } else { + slt.removeAt(i); + } + } + // read data + bool ok=true; + for (int i=0; i=0) { + x=JKQTPImagePlot_QStringToDouble(rx4.cap(1)); + r=JKQTPImagePlot_QStringToDouble(rx4.cap(3)); + g=JKQTPImagePlot_QStringToDouble(rx4.cap(4)); + b=JKQTPImagePlot_QStringToDouble(rx4.cap(5)); + } else if (!has4 && rx3.indexIn(slt[i])>=0) { + x=i; + r=JKQTPImagePlot_QStringToDouble(rx3.cap(1)); + g=JKQTPImagePlot_QStringToDouble(rx3.cap(3)); + b=JKQTPImagePlot_QStringToDouble(rx3.cap(4)); + //qDebug()<(round(255*r)), 255), qBound(0,static_cast(round(255*g)), 255), qBound(0,static_cast(round(255*b)), 255))); + } else { + pal<(round(r)), 255), qBound(0,static_cast(round(g)), 255), qBound(0,static_cast(round(b)), 255))); + } + } + } + //qDebug()<<"read: "< > pal; - if (colorspace=="rgb"){ - QDomElement e = n.firstChildElement("Point"); - while(!e.isNull()) { - double x=JKQTPImagePlot_QStringToDouble(e.attribute("x", "0")); - //double o=JKQTPImagePlot_QStringToDouble(e.attribute("o", "0")); - double r=JKQTPImagePlot_QStringToDouble(e.attribute("r", "0")); - double g=JKQTPImagePlot_QStringToDouble(e.attribute("g", "0")); - double b=JKQTPImagePlot_QStringToDouble(e.attribute("b", "0")); - pal<(round(255*r)), 255), qBound(0,static_cast(round(255*g)), 255), qBound(0,static_cast(round(255*b)), 255))); - e = e.nextSiblingElement("Point"); - } - if (pal.size()>1) { - sl<); - JKQTPImagePlot_lutsFromFiles[sl.size()-1]=pal; - palID=sl.size(); - //qDebug()<<"read "< > pal; + if (colorspace=="rgb"){ + QDomElement e = n.firstChildElement("Point"); + while(!e.isNull()) { + double x=JKQTPImagePlot_QStringToDouble(e.attribute("x", "0")); + //double o=JKQTPImagePlot_QStringToDouble(e.attribute("o", "0")); + double r=JKQTPImagePlot_QStringToDouble(e.attribute("r", "0")); + double g=JKQTPImagePlot_QStringToDouble(e.attribute("g", "0")); + double b=JKQTPImagePlot_QStringToDouble(e.attribute("b", "0")); + pal<(round(255*r)), 255), qBound(0,static_cast(round(255*g)), 255), qBound(0,static_cast(round(255*b)), 255))); + e = e.nextSiblingElement("Point"); + } + if (pal.size()>1) { + sl<); + JKQTPImagePlot_lutsFromFiles[sl.size()-1]=pal; + palID=sl.size(); + //qDebug()<<"read "< &lutstore) { QList ls=lutstore; lutstore.clear(); for (int i=0; i& lutstore, JKQTPMathImageColorPalet if (palette == JKQTPMathImageRED) { - //int*& plut=lutstore[palette]; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTPImagePlot_LUTSIZE); - plut[l]=qRgb(static_cast(255.0*v), 0, 0); - } - plut[JKQTPImagePlot_LUTSIZE+1]=plut[JKQTPImagePlot_LUTSIZE]; - } - } - lut_used=lutstore[palette]; + //int*& plut=lutstore[palette]; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=l/static_cast(JKQTPImageTools::LUTSIZE); + plut[l]=qRgb(static_cast(255.0*v), 0, 0); + } + plut[JKQTPImageTools::LUTSIZE+1]=plut[JKQTPImageTools::LUTSIZE]; + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageGREEN) { - //int*& plut=&lut_green; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTPImagePlot_LUTSIZE); - plut[l]=qRgb(0, static_cast(255.0*v), 0); - } - plut[JKQTPImagePlot_LUTSIZE+1]=plut[JKQTPImagePlot_LUTSIZE]; - } - } - lut_used=lutstore[palette]; + //int*& plut=&lut_green; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=l/static_cast(JKQTPImageTools::LUTSIZE); + plut[l]=qRgb(0, static_cast(255.0*v), 0); + } + plut[JKQTPImageTools::LUTSIZE+1]=plut[JKQTPImageTools::LUTSIZE]; + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageBLUE) { - //int*& plut=&lut_blue; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTPImagePlot_LUTSIZE); - plut[l]=qRgb(0, 0, static_cast(255.0*v)); - } - plut[JKQTPImagePlot_LUTSIZE+1]=plut[JKQTPImagePlot_LUTSIZE]; - } - } - lut_used=lutstore[palette]; + //int*& plut=&lut_blue; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=l/static_cast(JKQTPImageTools::LUTSIZE); + plut[l]=qRgb(0, 0, static_cast(255.0*v)); + } + plut[JKQTPImageTools::LUTSIZE+1]=plut[JKQTPImageTools::LUTSIZE]; + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageGRAY) { - //int*& plut=&lut_gray; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTPImagePlot_LUTSIZE); - plut[l]=qRgb(static_cast(255.0*v), - static_cast(255.0*v), - static_cast(255.0*v)); - } - plut[JKQTPImagePlot_LUTSIZE+1]=plut[JKQTPImagePlot_LUTSIZE]; - } - } - lut_used=lutstore[palette]; + //int*& plut=&lut_gray; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=l/static_cast(JKQTPImageTools::LUTSIZE); + plut[l]=qRgb(static_cast(255.0*v), + static_cast(255.0*v), + static_cast(255.0*v)); + } + plut[JKQTPImageTools::LUTSIZE+1]=plut[JKQTPImageTools::LUTSIZE]; + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageALPHA) { - //int*& plut=&lut_gray; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTPImagePlot_LUTSIZE); - plut[l]=qRgba(255,255,255, - static_cast(255.0*v)); - } - plut[JKQTPImagePlot_LUTSIZE+1]=plut[JKQTPImagePlot_LUTSIZE]; - } - } - lut_used=lutstore[palette]; + //int*& plut=&lut_gray; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=l/static_cast(JKQTPImageTools::LUTSIZE); + plut[l]=qRgba(255,255,255, + static_cast(255.0*v)); + } + plut[JKQTPImageTools::LUTSIZE+1]=plut[JKQTPImageTools::LUTSIZE]; + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTED_ALPHA) { - //int*& plut=&lut_gray; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTPImagePlot_LUTSIZE); - plut[l]=qRgba(255,255,255, - static_cast(255.0*v)); - } - plut[JKQTPImagePlot_LUTSIZE+1]=plut[JKQTPImagePlot_LUTSIZE]; - } - } - lut_used=lutstore[palette]; + //int*& plut=&lut_gray; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=l/static_cast(JKQTPImageTools::LUTSIZE); + plut[l]=qRgba(255,255,255, + static_cast(255.0*v)); + } + plut[JKQTPImageTools::LUTSIZE+1]=plut[JKQTPImageTools::LUTSIZE]; + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTEDRED) { - //int*& plut=&lut_invred; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTPImagePlot_LUTSIZE); - plut[l]=qRgb(static_cast(255.0*(1.0-v)), 0, 0); - } - plut[JKQTPImagePlot_LUTSIZE+1]=plut[JKQTPImagePlot_LUTSIZE]; - } - } - lut_used=lutstore[palette]; + //int*& plut=&lut_invred; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=l/static_cast(JKQTPImageTools::LUTSIZE); + plut[l]=qRgb(static_cast(255.0*(1.0-v)), 0, 0); + } + plut[JKQTPImageTools::LUTSIZE+1]=plut[JKQTPImageTools::LUTSIZE]; + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTEDGREEN) { - //int*& plut=&lut_invgreen; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTPImagePlot_LUTSIZE); - plut[l]=qRgb(0, static_cast(255.0*(1.0-v)), 0); - } - plut[JKQTPImagePlot_LUTSIZE+1]=plut[JKQTPImagePlot_LUTSIZE]; - } - } - lut_used=lutstore[palette]; + //int*& plut=&lut_invgreen; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=l/static_cast(JKQTPImageTools::LUTSIZE); + plut[l]=qRgb(0, static_cast(255.0*(1.0-v)), 0); + } + plut[JKQTPImageTools::LUTSIZE+1]=plut[JKQTPImageTools::LUTSIZE]; + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTEDBLUE) { - //int*& plut=&lut_invblue; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTPImagePlot_LUTSIZE); - plut[l]=qRgb(0, 0, static_cast(255.0*(1.0-v))); - } - plut[JKQTPImagePlot_LUTSIZE+1]=plut[JKQTPImagePlot_LUTSIZE]; - } - } - lut_used=lutstore[palette]; + //int*& plut=&lut_invblue; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=l/static_cast(JKQTPImageTools::LUTSIZE); + plut[l]=qRgb(0, 0, static_cast(255.0*(1.0-v))); + } + plut[JKQTPImageTools::LUTSIZE+1]=plut[JKQTPImageTools::LUTSIZE]; + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTEDGRAY) { - //int*& plut=&lut_invgray; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=1.0-(l/static_cast(JKQTPImagePlot_LUTSIZE)); - plut[l]=qRgb(static_cast(255.0*v), - static_cast(255.0*v), - static_cast(255.0*v)); - } - plut[JKQTPImagePlot_LUTSIZE+1]=plut[JKQTPImagePlot_LUTSIZE]; - } - } - lut_used=lutstore[palette]; + //int*& plut=&lut_invgray; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=1.0-(l/static_cast(JKQTPImageTools::LUTSIZE)); + plut[l]=qRgb(static_cast(255.0*v), + static_cast(255.0*v), + static_cast(255.0*v)); + } + plut[JKQTPImageTools::LUTSIZE+1]=plut[JKQTPImageTools::LUTSIZE]; + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageMATLAB) { - //int*& plut=&lut_matlab; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTPImagePlot_LUTSIZE); - double r = 382.5 - 1020.0 * std::abs(v - 0.75); - if (r > 255.0) - r = 255.0; - else if (r < 0.0) - r = 0.0; + //int*& plut=&lut_matlab; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=l/static_cast(JKQTPImageTools::LUTSIZE); + double r = 382.5 - 1020.0 * std::abs(v - 0.75); + if (r > 255.0) + r = 255.0; + else if (r < 0.0) + r = 0.0; - double g = 382.5 - 1020.0 * std::abs(v - 0.5); - if (g > 255.0) - g = 255.0; - else if (g < 0.0) - g = 0.0; + double g = 382.5 - 1020.0 * std::abs(v - 0.5); + if (g > 255.0) + g = 255.0; + else if (g < 0.0) + g = 0.0; - double b = 382.5 - 1020.0 * std::abs(v - 0.25); - if (b > 255.0) - b = 255.0; - else if (b < 0.0) - b = 0.0; + double b = 382.5 - 1020.0 * std::abs(v - 0.25); + if (b > 255.0) + b = 255.0; + else if (b < 0.0) + b = 0.0; - plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); - } - } - } - lut_used=lutstore[palette]; + plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); + } + } + } + lut_used=lutstore[palette]; } - else if (palette == JKQTPMathImageINVERTED_MATLAB) - { - //int*& plut=&lut_matlab_inverted; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - if (plut!=nullptr) { - for (int l=JKQTPImagePlot_LUTSIZE; l>=0; l--) { - double v=(JKQTPImagePlot_LUTSIZE-l)/static_cast(JKQTPImagePlot_LUTSIZE); - double r = 382.5 - 1020.0 * std::abs(v - 0.75); - if (r > 255.0) - r = 255.0; - else if (r < 0.0) - r = 0.0; + else if (palette == JKQTPMathImageINVERTED_MATLAB) + { + //int*& plut=&lut_matlab_inverted; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + if (plut!=nullptr) { + for (int l=JKQTPImageTools::LUTSIZE; l>=0; l--) { + double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); + double r = 382.5 - 1020.0 * std::abs(v - 0.75); + if (r > 255.0) + r = 255.0; + else if (r < 0.0) + r = 0.0; - double g = 382.5 - 1020.0 * std::abs(v - 0.5); - if (g > 255.0) - g = 255.0; - else if (g < 0.0) - g = 0.0; + double g = 382.5 - 1020.0 * std::abs(v - 0.5); + if (g > 255.0) + g = 255.0; + else if (g < 0.0) + g = 0.0; - double b = 382.5 - 1020.0 * std::abs(v - 0.25); - if (b > 255.0) - b = 255.0; - else if (b < 0.0) - b = 0.0; + double b = 382.5 - 1020.0 * std::abs(v - 0.25); + if (b > 255.0) + b = 255.0; + else if (b < 0.0) + b = 0.0; - plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); - } - } - } - lut_used=lutstore[palette]; + plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); + } + } + } + lut_used=lutstore[palette]; } - else if (palette == JKQTPMathImageRYGB) //gnuplot: 30,-13,-23 - { - //int*& plut=&lut_rygb; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTPImagePlot_LUTSIZE); - double r = 796.875*v - 199.21875; - if (r > 255.0) - r = 255.0; - else if (r < 0.0) - r = 0.0; + else if (palette == JKQTPMathImageRYGB) //gnuplot: 30,-13,-23 + { + //int*& plut=&lut_rygb; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=l/static_cast(JKQTPImageTools::LUTSIZE); + double r = 796.875*v - 199.21875; + if (r > 255.0) + r = 255.0; + else if (r < 0.0) + r = 0.0; - double g = 255.0 * std::sin(M_PI*v); + double g = 255.0 * std::sin(M_PI*v); - double b = 255.0 - 765.0 * v; - if (b < 0.0) - b = 0.0; - plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); - } - } - } - lut_used=lutstore[palette]; + double b = 255.0 - 765.0 * v; + if (b < 0.0) + b = 0.0; + plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); + } + } + } + lut_used=lutstore[palette]; } - else if (palette == JKQTPMathImageINVERTED_RYGB) //gnuplot: 30,-13,-23 - { - //int*& plut=&lut_rygb_inverted; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - if (plut!=nullptr) { - for (int l=JKQTPImagePlot_LUTSIZE; l>=0; l--) { - double v=(JKQTPImagePlot_LUTSIZE-l)/static_cast(JKQTPImagePlot_LUTSIZE); - double r = 796.875*v - 199.21875; - if (r > 255.0) - r = 255.0; - else if (r < 0.0) - r = 0.0; + else if (palette == JKQTPMathImageINVERTED_RYGB) //gnuplot: 30,-13,-23 + { + //int*& plut=&lut_rygb_inverted; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + if (plut!=nullptr) { + for (int l=JKQTPImageTools::LUTSIZE; l>=0; l--) { + double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); + double r = 796.875*v - 199.21875; + if (r > 255.0) + r = 255.0; + else if (r < 0.0) + r = 0.0; - double g = 255.0 * std::sin(M_PI*v); + double g = 255.0 * std::sin(M_PI*v); - double b = 255.0 - 765.0 * v; - if (b < 0.0) - b = 0.0; - plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); - } - } - } - lut_used=lutstore[palette]; + double b = 255.0 - 765.0 * v; + if (b < 0.0) + b = 0.0; + plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); + } + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageHSV) { - //int*& plut=&lut_hsv; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTPImagePlot_LUTSIZE); - int h = static_cast(floor(6*v)); - double f = 6*v-double(h); + //int*& plut=&lut_hsv; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=l/static_cast(JKQTPImageTools::LUTSIZE); + int h = static_cast(floor(6*v)); + double f = 6*v-double(h); - switch (h) - { - case 0: plut[l]=qRgb(255, static_cast(255.0*f), 0); break; - case 1: plut[l]=qRgb(static_cast(255.0*(1-f)), 255, 0); break; - case 2: plut[l]=qRgb(0, 255, static_cast(255.0*f)); break; - case 3: plut[l]=qRgb(0, static_cast(255.0*(1-f)), 255); break; - case 4: plut[l]=qRgb(static_cast(255.0*f), 0, 255); break; - case 5: plut[l]=qRgb(255, 0, static_cast(255.0*(1-f))); break; - case 6: plut[l]=qRgb(255, static_cast(255.0*f), 0); break; - } - } - } - } - lut_used=lutstore[palette]; + switch (h) + { + case 0: plut[l]=qRgb(255, static_cast(255.0*f), 0); break; + case 1: plut[l]=qRgb(static_cast(255.0*(1-f)), 255, 0); break; + case 2: plut[l]=qRgb(0, 255, static_cast(255.0*f)); break; + case 3: plut[l]=qRgb(0, static_cast(255.0*(1-f)), 255); break; + case 4: plut[l]=qRgb(static_cast(255.0*f), 0, 255); break; + case 5: plut[l]=qRgb(255, 0, static_cast(255.0*(1-f))); break; + case 6: plut[l]=qRgb(255, static_cast(255.0*f), 0); break; + } + } + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTED_HSV) { - //int*& plut=&lut_invhsv; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTPImagePlot_LUTSIZE); - int h = static_cast(floor(6.0-6.0*v)); - double f = 6.0-6.0*v-double(h); + //int*& plut=&lut_invhsv; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=l/static_cast(JKQTPImageTools::LUTSIZE); + int h = static_cast(floor(6.0-6.0*v)); + double f = 6.0-6.0*v-double(h); - switch (h) - { - case 0: plut[l]=qRgb(255, static_cast(255.0*f), 0); break; - case 1: plut[l]=qRgb(static_cast(255.0*(1-f)), 255, 0); break; - case 2: plut[l]=qRgb(0, 255, static_cast(255.0*f)); break; - case 3: plut[l]=qRgb(0, static_cast(255.0*(1-f)), 255); break; - case 4: plut[l]=qRgb(static_cast(255.0*f), 0, 255); break; - case 5: plut[l]=qRgb(255, 0, static_cast(255.0*(1-f))); break; - case 6: plut[l]=qRgb(255, static_cast(255.0*f), 0); break; - } - } - } - } - lut_used=lutstore[palette]; + switch (h) + { + case 0: plut[l]=qRgb(255, static_cast(255.0*f), 0); break; + case 1: plut[l]=qRgb(static_cast(255.0*(1-f)), 255, 0); break; + case 2: plut[l]=qRgb(0, 255, static_cast(255.0*f)); break; + case 3: plut[l]=qRgb(0, static_cast(255.0*(1-f)), 255); break; + case 4: plut[l]=qRgb(static_cast(255.0*f), 0, 255); break; + case 5: plut[l]=qRgb(255, 0, static_cast(255.0*(1-f))); break; + case 6: plut[l]=qRgb(255, static_cast(255.0*f), 0); break; + } + } + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageRAINBOW) //gnuplot: 33,13,10 { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTPImagePlot_LUTSIZE); - double r = 255.0*std::abs(2.0*v-0.5); - if (r > 255.0) - r = 255.0; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=l/static_cast(JKQTPImageTools::LUTSIZE); + double r = 255.0*std::abs(2.0*v-0.5); + if (r > 255.0) + r = 255.0; - double g = 255.0*sin(M_PI*v); + double g = 255.0*sin(M_PI*v); - double b = 255.0*cos(0.5*M_PI*v); + double b = 255.0*cos(0.5*M_PI*v); - plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); - } - } - } - lut_used=lutstore[palette]; + plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); + } + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTED_RAINBOW) //gnuplot: 33,13,10 { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - for (int l=JKQTPImagePlot_LUTSIZE; l>=0; l--) { - double v=(JKQTPImagePlot_LUTSIZE-l)/static_cast(JKQTPImagePlot_LUTSIZE); - double r = 255.0*std::abs(2.0*v-0.5); - if (r > 255.0) - r = 255.0; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + for (int l=JKQTPImageTools::LUTSIZE; l>=0; l--) { + double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); + double r = 255.0*std::abs(2.0*v-0.5); + if (r > 255.0) + r = 255.0; - double g = 255.0*sin(M_PI*v); + double g = 255.0*sin(M_PI*v); - double b = 255.0*cos(0.5*M_PI*v); + double b = 255.0*cos(0.5*M_PI*v); - plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); - } - } - } - lut_used=lutstore[palette]; + plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); + } + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageHOT) //gnuplot: 21,22,23 { - //int*& plut=&lut_hot; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTPImagePlot_LUTSIZE); - double r = 765.0*v; - if (r > 255.0) - r = 255.0; + //int*& plut=&lut_hot; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=l/static_cast(JKQTPImageTools::LUTSIZE); + double r = 765.0*v; + if (r > 255.0) + r = 255.0; - double g = 765.0*v-255.0; - if (g > 255.0) - g = 255.0; - else if (g < 0.0) - g = 0.0; + double g = 765.0*v-255.0; + if (g > 255.0) + g = 255.0; + else if (g < 0.0) + g = 0.0; - double b = 765.0*v-510.0; - if (b < 0.0) - b = 0.0; - plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); - } - } - } - lut_used=lutstore[palette]; + double b = 765.0*v-510.0; + if (b < 0.0) + b = 0.0; + plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); + } + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTED_HOT) //gnuplot: 21,22,23 { - //int*& plut=&lut_hot_inverted; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - if (plut!=nullptr) { - for (int l=JKQTPImagePlot_LUTSIZE; l>=0; l--) { - double v=(JKQTPImagePlot_LUTSIZE-l)/static_cast(JKQTPImagePlot_LUTSIZE); - double r = 765.0*v; - if (r > 255.0) - r = 255.0; + //int*& plut=&lut_hot_inverted; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + if (plut!=nullptr) { + for (int l=JKQTPImageTools::LUTSIZE; l>=0; l--) { + double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); + double r = 765.0*v; + if (r > 255.0) + r = 255.0; - double g = 765.0*v-255.0; - if (g > 255.0) - g = 255.0; - else if (g < 0.0) - g = 0.0; + double g = 765.0*v-255.0; + if (g > 255.0) + g = 255.0; + else if (g < 0.0) + g = 0.0; - double b = 765.0*v-510.0; - if (b < 0.0) - b = 0.0; - plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); - } - } - } - lut_used=lutstore[palette]; + double b = 765.0*v-510.0; + if (b < 0.0) + b = 0.0; + plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); + } + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageOCEAN) //gnuplot: 23,28,3 { - //int*& plut=&lut_ocean; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTPImagePlot_LUTSIZE); - double r = 765.0*v-510.0; - if (r < 0.0) - r = 0.0; + //int*& plut=&lut_ocean; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=l/static_cast(JKQTPImageTools::LUTSIZE); + double r = 765.0*v-510.0; + if (r < 0.0) + r = 0.0; - double g = std::abs(382.5*v-127.5); + double g = std::abs(382.5*v-127.5); - double b = 255.0*v; - plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); - } - } - } - lut_used=lutstore[palette]; + double b = 255.0*v; + plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); + } + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTED_OCEAN) //gnuplot: 23,28,3 { - //int*& plut=&lut_ocean_inverted; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - if (plut!=nullptr) { - for (int l=JKQTPImagePlot_LUTSIZE; l>=0; l--) { - double v=(JKQTPImagePlot_LUTSIZE-l)/static_cast(JKQTPImagePlot_LUTSIZE); - double r = 765.0*v-510.0; - if (r < 0.0) - r = 0.0; + //int*& plut=&lut_ocean_inverted; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + if (plut!=nullptr) { + for (int l=JKQTPImageTools::LUTSIZE; l>=0; l--) { + double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); + double r = 765.0*v-510.0; + if (r < 0.0) + r = 0.0; - double g = std::abs(382.5*v-127.5); + double g = std::abs(382.5*v-127.5); - double b = 255.0*v; - plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); - } - } - } - lut_used=lutstore[palette]; + double b = 255.0*v; + plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); + } + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageBLUEMAGENTAYELLOW) //gnuplot: 30,31,32 { - //int*& plut=&lut_bluemagentayellow; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; + //int*& plut=&lut_bluemagentayellow; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=l/static_cast(JKQTPImageTools::LUTSIZE); + double r = (v/0.32-0.78125); + if (r < 0.0) r = 0.0; + if (r > 1.0) r = 1.0; + + double g = 2.0*v-0.84; + if (g < 0.0) g = 0.0; + if (g > 1.0) g = 1.0; + + double b = 4.0*v; + if (b>1 || b<0) b = -2.0*v+1.84; + if (b>1 || b<0) b = v/0.08-11.5; + if (b>1 || b<0) b=1; + + if (b < 0.0) b = 0.0; + if (b > 1.0) b = 1.0; + plut[l]=qRgb(static_cast(255.0*r), static_cast(255.0*g), static_cast(255.0*b)); + } + } + } + lut_used=lutstore[palette]; + } + else if (palette == JKQTPMathImageINVERTED_BLUEMAGENTAYELLOW) //gnuplot: 30,31,32 + { + //int*& plut=&lut_bluemagentayellow_inverted; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTPImagePlot_LUTSIZE); - double r = (v/0.32-0.78125); - if (r < 0.0) r = 0.0; - if (r > 1.0) r = 1.0; + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); + double r = (v/0.32-0.78125); + if (r < 0.0) r = 0.0; + if (r > 1.0) r = 1.0; - double g = 2.0*v-0.84; - if (g < 0.0) g = 0.0; - if (g > 1.0) g = 1.0; + double g = 2.0*v-0.84; + if (g < 0.0) g = 0.0; + if (g > 1.0) g = 1.0; - double b = 4.0*v; - if (b>1 || b<0) b = -2.0*v+1.84; - if (b>1 || b<0) b = v/0.08-11.5; - if (b>1 || b<0) b=1; + double b = 4.0*v; + if (b>1 || b<0) b = -2.0*v+1.84; + if (b>1 || b<0) b = v/0.08-11.5; + if (b>1 || b<0) b=1; - if (b < 0.0) b = 0.0; - if (b > 1.0) b = 1.0; - plut[l]=qRgb(static_cast(255.0*r), static_cast(255.0*g), static_cast(255.0*b)); - } + if (b < 0.0) b = 0.0; + if (b > 1.0) b = 1.0; + plut[l]=qRgb(static_cast(255.0*r), static_cast(255.0*g), static_cast(255.0*b)); + } } } lut_used=lutstore[palette]; - } - else if (palette == JKQTPMathImageINVERTED_BLUEMAGENTAYELLOW) //gnuplot: 30,31,32 - { - //int*& plut=&lut_bluemagentayellow_inverted; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=(JKQTPImagePlot_LUTSIZE-l)/static_cast(JKQTPImagePlot_LUTSIZE); - double r = (v/0.32-0.78125); - if (r < 0.0) r = 0.0; - if (r > 1.0) r = 1.0; - - double g = 2.0*v-0.84; - if (g < 0.0) g = 0.0; - if (g > 1.0) g = 1.0; - - double b = 4.0*v; - if (b>1 || b<0) b = -2.0*v+1.84; - if (b>1 || b<0) b = v/0.08-11.5; - if (b>1 || b<0) b=1; - - if (b < 0.0) b = 0.0; - if (b > 1.0) b = 1.0; - plut[l]=qRgb(static_cast(255.0*r), static_cast(255.0*g), static_cast(255.0*b)); - } - } - } - lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageBLUEYELLOW) //gnuplot: 8,9,10 { - //int*& plut=&lut_blueyellow; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTPImagePlot_LUTSIZE); - double r = sqrt(sqrt(v)); - if (r < 0.0) r = 0.0; - if (r > 1.0) r = 1.0; + //int*& plut=&lut_blueyellow; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=l/static_cast(JKQTPImageTools::LUTSIZE); + double r = sqrt(sqrt(v)); + if (r < 0.0) r = 0.0; + if (r > 1.0) r = 1.0; - double g = sin(M_PI/2.0*v); - if (g < 0.0) g = 0.0; - if (g > 1.0) g = 1.0; + double g = sin(M_PI/2.0*v); + if (g < 0.0) g = 0.0; + if (g > 1.0) g = 1.0; - double b = cos(M_PI/2.0*v); - if (b < 0.0) b = 0.0; - if (b > 1.0) b = 1.0; + double b = cos(M_PI/2.0*v); + if (b < 0.0) b = 0.0; + if (b > 1.0) b = 1.0; - plut[l]=qRgb(static_cast(255.0*r), static_cast(255.0*g), static_cast(255.0*b)); - } - } - } - lut_used=lutstore[palette]; + plut[l]=qRgb(static_cast(255.0*r), static_cast(255.0*g), static_cast(255.0*b)); + } + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTED_BLUEYELLOW) //gnuplot: 8,9,10 { - //int*& plut=&lut_blueyellow_inverted; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=(JKQTPImagePlot_LUTSIZE-l)/static_cast(JKQTPImagePlot_LUTSIZE); - double r = sqrt(sqrt(v)); - if (r < 0.0) r = 0.0; - if (r > 1.0) r = 1.0; + //int*& plut=&lut_blueyellow_inverted; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); + double r = sqrt(sqrt(v)); + if (r < 0.0) r = 0.0; + if (r > 1.0) r = 1.0; - double g = sin(M_PI/2.0*v); - if (g < 0.0) g = 0.0; - if (g > 1.0) g = 1.0; + double g = sin(M_PI/2.0*v); + if (g < 0.0) g = 0.0; + if (g > 1.0) g = 1.0; - double b = cos(M_PI/2.0*v); - if (b < 0.0) b = 0.0; - if (b > 1.0) b = 1.0; + double b = cos(M_PI/2.0*v); + if (b < 0.0) b = 0.0; + if (b > 1.0) b = 1.0; - plut[l]=qRgb(static_cast(255.0*r), static_cast(255.0*g), static_cast(255.0*b)); - } - } - } - lut_used=lutstore[palette]; + plut[l]=qRgb(static_cast(255.0*r), static_cast(255.0*g), static_cast(255.0*b)); + } + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageCYAN) { - //int*& plut=&lut_cyan; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTPImagePlot_LUTSIZE); - double r = v*0.5; - if (r < 0.0) r = 0.0; - if (r > 1.0) r = 1.0; + //int*& plut=&lut_cyan; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=l/static_cast(JKQTPImageTools::LUTSIZE); + double r = v*0.5; + if (r < 0.0) r = 0.0; + if (r > 1.0) r = 1.0; - double g = v; - if (g < 0.0) g = 0.0; - if (g > 1.0) g = 1.0; + double g = v; + if (g < 0.0) g = 0.0; + if (g > 1.0) g = 1.0; - double b = v; - if (b < 0.0) b = 0.0; - if (b > 1.0) b = 1.0; - plut[l]=qRgb(static_cast(255.0*r), static_cast(255.0*g), static_cast(255.0*b)); - } - } - } - lut_used=lutstore[palette]; + double b = v; + if (b < 0.0) b = 0.0; + if (b > 1.0) b = 1.0; + plut[l]=qRgb(static_cast(255.0*r), static_cast(255.0*g), static_cast(255.0*b)); + } + } + } + lut_used=lutstore[palette]; } - else if (palette == JKQTPMathImageINVERTED_CYAN) + else if (palette == JKQTPMathImageINVERTED_CYAN) { - //int*& plut=&lut_cyan_inverted; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=(JKQTPImagePlot_LUTSIZE-l)/static_cast(JKQTPImagePlot_LUTSIZE); - double r = v*0.5; - if (r < 0.0) r = 0.0; - if (r > 1.0) r = 1.0; + //int*& plut=&lut_cyan_inverted; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); + double r = v*0.5; + if (r < 0.0) r = 0.0; + if (r > 1.0) r = 1.0; - double g = v; - if (g < 0.0) g = 0.0; - if (g > 1.0) g = 1.0; + double g = v; + if (g < 0.0) g = 0.0; + if (g > 1.0) g = 1.0; - double b = v; - if (b < 0.0) b = 0.0; - if (b > 1.0) b = 1.0; - plut[l]=qRgb(static_cast(255.0*r), static_cast(255.0*g), static_cast(255.0*b)); - } - } - } - lut_used=lutstore[palette]; + double b = v; + if (b < 0.0) b = 0.0; + if (b > 1.0) b = 1.0; + plut[l]=qRgb(static_cast(255.0*r), static_cast(255.0*g), static_cast(255.0*b)); + } + } + } + lut_used=lutstore[palette]; } - else if (palette == JKQTPMathImageTRAFFICLIGHT) + else if (palette == JKQTPMathImageTRAFFICLIGHT) { - //int*& plut=&lut_trafficlight; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=l/static_cast(JKQTPImagePlot_LUTSIZE); - double r = (v < 0.5) ? 128.0*sin(M_PI*(2.0*v-0.5))+128.0 : 255.0; - if (r > 255.0) - r = 255.0; + //int*& plut=&lut_trafficlight; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=l/static_cast(JKQTPImageTools::LUTSIZE); + double r = (v < 0.5) ? 128.0*sin(M_PI*(2.0*v-0.5))+128.0 : 255.0; + if (r > 255.0) + r = 255.0; - double g = (v < 0.5) ? 512.0*v+128.0 : 512.0-512.0*v; - if (g > 255.0) - g = 255.0; - plut[l]=qRgb(static_cast(r), static_cast(g), 0); - } - } - } - lut_used=lutstore[palette]; + double g = (v < 0.5) ? 512.0*v+128.0 : 512.0-512.0*v; + if (g > 255.0) + g = 255.0; + plut[l]=qRgb(static_cast(r), static_cast(g), 0); + } + } + } + lut_used=lutstore[palette]; } - else if (palette == JKQTPMathImageINVERTED_TRAFFICLIGHT) + else if (palette == JKQTPMathImageINVERTED_TRAFFICLIGHT) { - //int*& plut=&lut_trafficlight_inverted; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=(JKQTPImagePlot_LUTSIZE-l)/static_cast(JKQTPImagePlot_LUTSIZE); - double r = (v < 0.5) ? 128.0*sin(M_PI*(2.0*v-0.5))+128.0 : 255.0; - if (r > 255.0) - r = 255.0; + //int*& plut=&lut_trafficlight_inverted; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); + double r = (v < 0.5) ? 128.0*sin(M_PI*(2.0*v-0.5))+128.0 : 255.0; + if (r > 255.0) + r = 255.0; - double g = (v < 0.5) ? 512.0*v+128.0 : 512.0-512.0*v; - if (g > 255.0) - g = 255.0; - plut[l]=qRgb(static_cast(r), static_cast(g), 0); - } - } - } - lut_used=lutstore[palette]; + double g = (v < 0.5) ? 512.0*v+128.0 : 512.0-512.0*v; + if (g > 255.0) + g = 255.0; + plut[l]=qRgb(static_cast(r), static_cast(g), 0); + } + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageBLUEWHITERED) //gnuplot: 34,13,-34 { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - QList > lst; - lst<(8.0, 0xFFB2182B); - lst<(7.0, 0xFFD6604D); - lst<(6.0, 0xFFF4A582); - lst<(5.0, 0xFFFDDBC7); - lst<(4.0, 0xFFD1E5F0); - lst<(3.0, 0xFF92C5DE); - lst<(2.0, 0xFF4393C3); - lst<(1.0, 0xFF2166AC); + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + QList > lst; + lst<(8.0, 0xFFB2182B); + lst<(7.0, 0xFFD6604D); + lst<(6.0, 0xFFF4A582); + lst<(5.0, 0xFFFDDBC7); + lst<(4.0, 0xFFD1E5F0); + lst<(3.0, 0xFF92C5DE); + lst<(2.0, 0xFF4393C3); + lst<(1.0, 0xFF2166AC); - JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); - } - } - lut_used=lutstore[palette]; + JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageREDWHITEBLUE) //gnuplot: https://github.com/aschn/gnuplot-colorbrewer/blob/master/diverging/RdBu.plt { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - QList > lst; - lst<(0.0, 0xFFB2182B); - lst<(1.0, 0xFFD6604D); - lst<(2.0, 0xFFF4A582); - lst<(3.0, 0xFFFDDBC7); - lst<(4.0, 0xFFD1E5F0); - lst<(5.0, 0xFF92C5DE); - lst<(6.0, 0xFF4393C3); - lst<(7.0, 0xFF2166AC); + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + QList > lst; + lst<(0.0, 0xFFB2182B); + lst<(1.0, 0xFFD6604D); + lst<(2.0, 0xFFF4A582); + lst<(3.0, 0xFFFDDBC7); + lst<(4.0, 0xFFD1E5F0); + lst<(5.0, 0xFF92C5DE); + lst<(6.0, 0xFF4393C3); + lst<(7.0, 0xFF2166AC); - JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); - } - } - lut_used=lutstore[palette]; + JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageBLACKBLUEREDYELLOW) //gnuplot: 7,5,15 - { -// int*& plut=&lut_BLACKBLUEREDYELLOW; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=(l)/static_cast(JKQTPImagePlot_LUTSIZE); - double r = 255.0*qBound(0.0,sqrt(v),1.0); - double g = 255.0*qBound(0.0,v*v*v,1.0); - double b = 255.0*qBound(0.0,sin(2.0*M_PI*v),1.0); + { +// int*& plut=&lut_BLACKBLUEREDYELLOW; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=(l)/static_cast(JKQTPImageTools::LUTSIZE); + double r = 255.0*qBound(0.0,sqrt(v),1.0); + double g = 255.0*qBound(0.0,v*v*v,1.0); + double b = 255.0*qBound(0.0,sin(2.0*M_PI*v),1.0); - plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); - } - } - } - lut_used=lutstore[palette]; + plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); + } + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageGREENREDVIOLET) //gnuplot: 3,11,6 { - //int*& plut=&lut_GREENREDVIOLET; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=(l)/static_cast(JKQTPImagePlot_LUTSIZE); - double r = 255.0*qBound(0.0,v,1.0); - double g = 255.0*qBound(0.0,fabs(v-0.5),1.0); - double b = 255.0*qBound(0.0,v*v*v*v,1.0); + //int*& plut=&lut_GREENREDVIOLET; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=(l)/static_cast(JKQTPImageTools::LUTSIZE); + double r = 255.0*qBound(0.0,v,1.0); + double g = 255.0*qBound(0.0,fabs(v-0.5),1.0); + double b = 255.0*qBound(0.0,v*v*v*v,1.0); - plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); - } - } - } - lut_used=lutstore[palette]; + plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); + } + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageBLACKBLUEWHITEYELLOWWHITE) //gnuplot: 30,31,32 { - //int*& plut=&lut_BLACKBLUEVIOLETYELLOWWHITE; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=(l)/static_cast(JKQTPImagePlot_LUTSIZE); - double r = 255.0*qBound(0.0,v/0.32-0.78125,1.0); - double g = 255.0*qBound(0.0,v/0.32-0.78125,1.0); - double b = 255.0*qBound(0.0,(v<0.25)?4*v:(v<0.42)?1.0:(v<0.92)?-2.0*v+1.84:v/0.08-11.5,1.0); + //int*& plut=&lut_BLACKBLUEVIOLETYELLOWWHITE; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=(l)/static_cast(JKQTPImageTools::LUTSIZE); + double r = 255.0*qBound(0.0,v/0.32-0.78125,1.0); + double g = 255.0*qBound(0.0,v/0.32-0.78125,1.0); + double b = 255.0*qBound(0.0,(v<0.25)?4*v:(v<0.42)?1.0:(v<0.92)?-2.0*v+1.84:v/0.08-11.5,1.0); - plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); - } - } - } - lut_used=lutstore[palette]; + plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); + } + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageWHITEYELLOWWHITEBLUEBLACK) //gnuplot: 30,31,32 { - //int*& plut=&lut_WHITEYELLOWVIOLETBLUEBLACK; - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=(JKQTPImagePlot_LUTSIZE-l)/static_cast(JKQTPImagePlot_LUTSIZE); - double r = 255.0*qBound(0.0,v/0.32-0.78125,1.0); - double g = 255.0*qBound(0.0,v/0.32-0.78125,1.0); - double b = 255.0*qBound(0.0,(v<0.25)?4*v:(v<0.42)?1.0:(v<0.92)?-2.0*v+1.84:v/0.08-11.5,1.0); + //int*& plut=&lut_WHITEYELLOWVIOLETBLUEBLACK; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); + double r = 255.0*qBound(0.0,v/0.32-0.78125,1.0); + double g = 255.0*qBound(0.0,v/0.32-0.78125,1.0); + double b = 255.0*qBound(0.0,(v<0.25)?4*v:(v<0.42)?1.0:(v<0.92)?-2.0*v+1.84:v/0.08-11.5,1.0); - plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); - } - } - } - lut_used=lutstore[palette]; + plut[l]=qRgb(static_cast(r), static_cast(g), static_cast(b)); + } + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageBR_GR) //https://github.com/aschn/gnuplot-colorbrewer/blob/master/diverging/BrBG.plt { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - QList > lst; - lst<(0.0, qRgb(0x8C, 0x51, 0x0A)); - lst<(1.0, qRgb(0xBF, 0x81, 0x2D)); - lst<(2.0, qRgb(0xDF, 0xC2, 0x7D)); - lst<(3.0, 0xFFF6E8C3); - lst<(4.0, 0xFFC7EAE5); - lst<(5.0, 0xFF80CDC1); - lst<(6.0, 0xFF35978F); - lst<(7.0, 0xFF01665E); + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + QList > lst; + lst<(0.0, qRgb(0x8C, 0x51, 0x0A)); + lst<(1.0, qRgb(0xBF, 0x81, 0x2D)); + lst<(2.0, qRgb(0xDF, 0xC2, 0x7D)); + lst<(3.0, 0xFFF6E8C3); + lst<(4.0, 0xFFC7EAE5); + lst<(5.0, 0xFF80CDC1); + lst<(6.0, 0xFF35978F); + lst<(7.0, 0xFF01665E); - JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); - } - } - lut_used=lutstore[palette]; + JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageBR_GR_STEP) //https://github.com/aschn/gnuplot-colorbrewer/blob/master/diverging/BrBG.plt { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - QList > lst; - lst<(0.0, qRgb(0x8C, 0x51, 0x0A)); - lst<(1.0, qRgb(0xBF, 0x81, 0x2D)); - lst<(2.0, qRgb(0xDF, 0xC2, 0x7D)); - lst<(3.0, 0xFFF6E8C3); - lst<(4.0, 0xFFC7EAE5); - lst<(5.0, 0xFF80CDC1); - lst<(6.0, 0xFF35978F); - lst<(7.0, 0xFF01665E); + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + QList > lst; + lst<(0.0, qRgb(0x8C, 0x51, 0x0A)); + lst<(1.0, qRgb(0xBF, 0x81, 0x2D)); + lst<(2.0, qRgb(0xDF, 0xC2, 0x7D)); + lst<(3.0, 0xFFF6E8C3); + lst<(4.0, 0xFFC7EAE5); + lst<(5.0, 0xFF80CDC1); + lst<(6.0, 0xFF35978F); + lst<(7.0, 0xFF01665E); - JKQTPImagePlot_buildDefinedPalette(plut, lst); - } - } - lut_used=lutstore[palette]; + JKQTPImagePlot_buildDefinedPalette(plut, lst); + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImagePU_OR) //https://github.com/aschn/gnuplot-colorbrewer/blob/master/diverging/PuOr.plt { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - QList > lst; - lst<(0.0, 0xFFB35806); - lst<(1.0, 0xFFE08214); - lst<(2.0, 0xFFFDB863); - lst<(3.0, 0xFFFEE0B6); - lst<(4.0, 0xFFF7F7F7); - lst<(5.0, 0xFFD8DAEB); - lst<(6.0, 0xFFB2ABD2); - lst<(7.0, 0xFF8073AC); - lst<(8.0, 0xFF542788); + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + QList > lst; + lst<(0.0, 0xFFB35806); + lst<(1.0, 0xFFE08214); + lst<(2.0, 0xFFFDB863); + lst<(3.0, 0xFFFEE0B6); + lst<(4.0, 0xFFF7F7F7); + lst<(5.0, 0xFFD8DAEB); + lst<(6.0, 0xFFB2ABD2); + lst<(7.0, 0xFF8073AC); + lst<(8.0, 0xFF542788); - JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); - } - } - lut_used=lutstore[palette]; + JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImagePU_OR_STEP) //https://github.com/aschn/gnuplot-colorbrewer/blob/master/diverging/PuOr.plt { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - QList > lst; - lst<(0.0, 0xFFB35806); - lst<(1.0, 0xFFE08214); - lst<(2.0, 0xFFFDB863); - lst<(3.0, 0xFFFEE0B6); - lst<(4.0, 0xFFF7F7F7); - lst<(5.0, 0xFFD8DAEB); - lst<(6.0, 0xFFB2ABD2); - lst<(7.0, 0xFF8073AC); - lst<(8.0, 0xFF542788); + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + QList > lst; + lst<(0.0, 0xFFB35806); + lst<(1.0, 0xFFE08214); + lst<(2.0, 0xFFFDB863); + lst<(3.0, 0xFFFEE0B6); + lst<(4.0, 0xFFF7F7F7); + lst<(5.0, 0xFFD8DAEB); + lst<(6.0, 0xFFB2ABD2); + lst<(7.0, 0xFF8073AC); + lst<(8.0, 0xFF542788); - JKQTPImagePlot_buildDefinedPalette(plut, lst); - } - } - lut_used=lutstore[palette]; + JKQTPImagePlot_buildDefinedPalette(plut, lst); + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageYL_GN_BU) //http://colorbrewer2.org/ { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - QList > lst; - lst<(0.0, 0xFFFFFFD9); - lst<(1.0, 0xFFEDF8B1); - lst<(2.0, 0xFFC7E9B4); - lst<(3.0, 0xFF7FCDBB); - lst<(4.0, 0xFF41B6C4); - lst<(5.0, 0xFF1D91C0); - lst<(6.0, 0xFF225EA8); - lst<(7.0, 0xFF253494); - lst<(8.0, 0xFF081D58); + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + QList > lst; + lst<(0.0, 0xFFFFFFD9); + lst<(1.0, 0xFFEDF8B1); + lst<(2.0, 0xFFC7E9B4); + lst<(3.0, 0xFF7FCDBB); + lst<(4.0, 0xFF41B6C4); + lst<(5.0, 0xFF1D91C0); + lst<(6.0, 0xFF225EA8); + lst<(7.0, 0xFF253494); + lst<(8.0, 0xFF081D58); - JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); - } - } - lut_used=lutstore[palette]; + JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageYL_GN_BU_STEP) //http://colorbrewer2.org/ { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - QList > lst; - lst<(0.0, 0xFFFFFFD9); - lst<(1.0, 0xFFEDF8B1); - lst<(2.0, 0xFFC7E9B4); - lst<(3.0, 0xFF7FCDBB); - lst<(4.0, 0xFF41B6C4); - lst<(5.0, 0xFF1D91C0); - lst<(6.0, 0xFF225EA8); - lst<(7.0, 0xFF253494); - lst<(8.0, 0xFF081D58); + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + QList > lst; + lst<(0.0, 0xFFFFFFD9); + lst<(1.0, 0xFFEDF8B1); + lst<(2.0, 0xFFC7E9B4); + lst<(3.0, 0xFF7FCDBB); + lst<(4.0, 0xFF41B6C4); + lst<(5.0, 0xFF1D91C0); + lst<(6.0, 0xFF225EA8); + lst<(7.0, 0xFF253494); + lst<(8.0, 0xFF081D58); - JKQTPImagePlot_buildDefinedPalette(plut, lst); - } - } - lut_used=lutstore[palette]; + JKQTPImagePlot_buildDefinedPalette(plut, lst); + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageGN_BU) //http://colorbrewer2.org/ { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - QList > lst; - lst<(0.0, 0xFFF7FCF0); - lst<(1.0, 0xFFE0F3DB); - lst<(2.0, 0xFFCCEBC5); - lst<(3.0, 0xFFA8DDB5); - lst<(4.0, 0xFF7BCCC4); - lst<(5.0, 0xFF4EB3D3); - lst<(6.0, 0xFF2B8CBE); - lst<(7.0, 0xFF0868AC); - lst<(8.0, 0xFF084081); + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + QList > lst; + lst<(0.0, 0xFFF7FCF0); + lst<(1.0, 0xFFE0F3DB); + lst<(2.0, 0xFFCCEBC5); + lst<(3.0, 0xFFA8DDB5); + lst<(4.0, 0xFF7BCCC4); + lst<(5.0, 0xFF4EB3D3); + lst<(6.0, 0xFF2B8CBE); + lst<(7.0, 0xFF0868AC); + lst<(8.0, 0xFF084081); - JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); - } - } - lut_used=lutstore[palette]; + JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageGN_BU_STEP) //http://colorbrewer2.org/ { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - QList > lst; - lst<(0.0, 0xFFF7FCF0); - lst<(1.0, 0xFFE0F3DB); - lst<(2.0, 0xFFCCEBC5); - lst<(3.0, 0xFFA8DDB5); - lst<(4.0, 0xFF7BCCC4); - lst<(5.0, 0xFF4EB3D3); - lst<(6.0, 0xFF2B8CBE); - lst<(7.0, 0xFF0868AC); - lst<(8.0, 0xFF084081); + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + QList > lst; + lst<(0.0, 0xFFF7FCF0); + lst<(1.0, 0xFFE0F3DB); + lst<(2.0, 0xFFCCEBC5); + lst<(3.0, 0xFFA8DDB5); + lst<(4.0, 0xFF7BCCC4); + lst<(5.0, 0xFF4EB3D3); + lst<(6.0, 0xFF2B8CBE); + lst<(7.0, 0xFF0868AC); + lst<(8.0, 0xFF084081); - JKQTPImagePlot_buildDefinedPalette(plut, lst); - } - } - lut_used=lutstore[palette]; + JKQTPImagePlot_buildDefinedPalette(plut, lst); + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageBU_GN) //http://colorbrewer2.org/ { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - QList > lst; - lst<(8.0, 0xFFF7FCF0); - lst<(7.0, 0xFFE0F3DB); - lst<(6.0, 0xFFCCEBC5); - lst<(5.0, 0xFFA8DDB5); - lst<(4.0, 0xFF7BCCC4); - lst<(3.0, 0xFF4EB3D3); - lst<(2.0, 0xFF2B8CBE); - lst<(1.0, 0xFF0868AC); - lst<(0.0, 0xFF084081); + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + QList > lst; + lst<(8.0, 0xFFF7FCF0); + lst<(7.0, 0xFFE0F3DB); + lst<(6.0, 0xFFCCEBC5); + lst<(5.0, 0xFFA8DDB5); + lst<(4.0, 0xFF7BCCC4); + lst<(3.0, 0xFF4EB3D3); + lst<(2.0, 0xFF2B8CBE); + lst<(1.0, 0xFF0868AC); + lst<(0.0, 0xFF084081); - JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); - } - } - lut_used=lutstore[palette]; + JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageBU_GN_STEP) //http://colorbrewer2.org/ { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - QList > lst; - lst<(8.0, 0xFFF7FCF0); - lst<(7.0, 0xFFE0F3DB); - lst<(6.0, 0xFFCCEBC5); - lst<(5.0, 0xFFA8DDB5); - lst<(4.0, 0xFF7BCCC4); - lst<(3.0, 0xFF4EB3D3); - lst<(2.0, 0xFF2B8CBE); - lst<(1.0, 0xFF0868AC); - lst<(0.0, 0xFF084081); + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + QList > lst; + lst<(8.0, 0xFFF7FCF0); + lst<(7.0, 0xFFE0F3DB); + lst<(6.0, 0xFFCCEBC5); + lst<(5.0, 0xFFA8DDB5); + lst<(4.0, 0xFF7BCCC4); + lst<(3.0, 0xFF4EB3D3); + lst<(2.0, 0xFF2B8CBE); + lst<(1.0, 0xFF0868AC); + lst<(0.0, 0xFF084081); - JKQTPImagePlot_buildDefinedPalette(plut, lst); - } - } - lut_used=lutstore[palette]; + JKQTPImagePlot_buildDefinedPalette(plut, lst); + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTED_MAGENTA) // from CMYK model { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=(l)/static_cast(JKQTPImagePlot_LUTSIZE); - plut[l]=QColor::fromCmykF(0,1,0,v).rgba(); - } + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=(l)/static_cast(JKQTPImageTools::LUTSIZE); + plut[l]=QColor::fromCmykF(0,1,0,v).rgba(); + } - } - } - lut_used=lutstore[palette]; + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageMAGENTA) // from CMYK model { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=(JKQTPImagePlot_LUTSIZE-l)/static_cast(JKQTPImagePlot_LUTSIZE); - plut[l]=QColor::fromCmykF(0,1,0,v).rgba(); - } + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); + plut[l]=QColor::fromCmykF(0,1,0,v).rgba(); + } - } - } - lut_used=lutstore[palette]; + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTED_YELLOW) // from CMYK model { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=(l)/static_cast(JKQTPImagePlot_LUTSIZE); - plut[l]=QColor::fromCmykF(0,0,1,v).rgba(); - } + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=(l)/static_cast(JKQTPImageTools::LUTSIZE); + plut[l]=QColor::fromCmykF(0,0,1,v).rgba(); + } - } - } - lut_used=lutstore[palette]; + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageYELLOW) // from CMYK model { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=(JKQTPImagePlot_LUTSIZE-l)/static_cast(JKQTPImagePlot_LUTSIZE); - plut[l]=QColor::fromCmykF(0,0,1,v).rgba(); - } + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); + plut[l]=QColor::fromCmykF(0,0,1,v).rgba(); + } - } - } - lut_used=lutstore[palette]; + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTED_MAGENTAWHITE) // from CMYK model { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=(l)/static_cast(JKQTPImagePlot_LUTSIZE); - plut[l]=QColor::fromCmykF(0,v,0,0).rgba(); - } + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=(l)/static_cast(JKQTPImageTools::LUTSIZE); + plut[l]=QColor::fromCmykF(0,v,0,0).rgba(); + } - } - } - lut_used=lutstore[palette]; + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageMAGENTAWHITE) // from CMYK model { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=(JKQTPImagePlot_LUTSIZE-l)/static_cast(JKQTPImagePlot_LUTSIZE); - plut[l]=QColor::fromCmykF(0,v,0,0).rgba(); - } + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); + plut[l]=QColor::fromCmykF(0,v,0,0).rgba(); + } - } - } - lut_used=lutstore[palette]; + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTED_YELLOWWHITE) // from CMYK model { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=(l)/static_cast(JKQTPImagePlot_LUTSIZE); - plut[l]=QColor::fromCmykF(0,0,v,0).rgba(); - } + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=(l)/static_cast(JKQTPImageTools::LUTSIZE); + plut[l]=QColor::fromCmykF(0,0,v,0).rgba(); + } - } - } - lut_used=lutstore[palette]; + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageYELLOWWHITE) // from CMYK model { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=(JKQTPImagePlot_LUTSIZE-l)/static_cast(JKQTPImagePlot_LUTSIZE); - plut[l]=QColor::fromCmykF(0,0,v,0).rgba(); - } + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); + plut[l]=QColor::fromCmykF(0,0,v,0).rgba(); + } - } - } - lut_used=lutstore[palette]; + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageINVERTED_CYANWHITE) // from CMYK model { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=(l)/static_cast(JKQTPImagePlot_LUTSIZE); - plut[l]=QColor::fromCmykF(v,0,0,0).rgba(); - } + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=(l)/static_cast(JKQTPImageTools::LUTSIZE); + plut[l]=QColor::fromCmykF(v,0,0,0).rgba(); + } - } - } - lut_used=lutstore[palette]; + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageCYANWHITE) // from CMYK model { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - for (int l=0; l<=JKQTPImagePlot_LUTSIZE; l++) { - double v=(JKQTPImagePlot_LUTSIZE-l)/static_cast(JKQTPImagePlot_LUTSIZE); - plut[l]=QColor::fromCmykF(v,0,0,0).rgba(); - } + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) { + double v=(JKQTPImageTools::LUTSIZE-l)/static_cast(JKQTPImageTools::LUTSIZE); + plut[l]=QColor::fromCmykF(v,0,0,0).rgba(); + } - } - } - lut_used=lutstore[palette]; + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageBlueGreenRed) { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - QList > lst; - lst<(1.0, QColor("blue").rgb()); - lst<(2.0, QColor("green").rgb()); - lst<(3.0, QColor("red").rgb()); + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + QList > lst; + lst<(1.0, QColor("blue").rgb()); + lst<(2.0, QColor("green").rgb()); + lst<(3.0, QColor("red").rgb()); - JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); - } - } - lut_used=lutstore[palette]; + JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImageRedGreenBlue) { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - QList > lst; - lst<(1.0, QColor("red").rgb()); - lst<(2.0, QColor("green").rgb()); - lst<(3.0, QColor("blue").rgb()); + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + QList > lst; + lst<(1.0, QColor("red").rgb()); + lst<(2.0, QColor("green").rgb()); + lst<(3.0, QColor("blue").rgb()); - JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); - } - } - lut_used=lutstore[palette]; + JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImagePREDEFINED_PALETTES_COUNT) { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - QList > lst; - lst<(1.0, QColor("magenta").rgb()); - lst<(2.0, QColor("yellow").rgb()); + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + QList > lst; + lst<(1.0, QColor("magenta").rgb()); + lst<(2.0, QColor("yellow").rgb()); - JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); - } - } - lut_used=lutstore[palette]; + JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImagePREDEFINED_PALETTES_COUNT+1) { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - QList > lst; - lst<(1.0, QColor("yellow").rgb()); - lst<(2.0, QColor("magenta").rgb()); + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + QList > lst; + lst<(1.0, QColor("yellow").rgb()); + lst<(2.0, QColor("magenta").rgb()); - JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); - } - } - lut_used=lutstore[palette]; + JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImagePREDEFINED_PALETTES_COUNT+2) { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - QList > lst; - lst<(1.0, QColor("red").rgb()); - lst<(2.0, QColor("blue").rgb()); + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + QList > lst; + lst<(1.0, QColor("red").rgb()); + lst<(2.0, QColor("blue").rgb()); - JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); - } - } - lut_used=lutstore[palette]; + JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); + } + } + lut_used=lutstore[palette]; } else if (palette == JKQTPMathImagePREDEFINED_PALETTES_COUNT+3) { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - QList > lst; - lst<(1.0, QColor("blue").rgb()); - lst<(2.0, QColor("red").rgb()); + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + QList > lst; + lst<(1.0, QColor("blue").rgb()); + lst<(2.0, QColor("red").rgb()); - JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); - } - } - lut_used=lutstore[palette]; + JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, lst); + } + } + lut_used=lutstore[palette]; - /* + /* } else if (palette == JKQTPMathImagePU_OR) //https://github.com/aschn/gnuplot-colorbrewer/blob/master/diverging/PuOr.plt { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - QList > lst; - lst<(0.0, 0xFF); - lst<(1.0, 0xFF); - lst<(2.0, 0xFF); - lst<(3.0, 0xFF); - lst<(4.0, 0xFF); - lst<(5.0, 0xFF); - lst<(6.0, 0xFF); - lst<(7.0, 0xFF); - lst<(8.0, 0xFF); + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + QList > lst; + lst<(0.0, 0xFF); + lst<(1.0, 0xFF); + lst<(2.0, 0xFF); + lst<(3.0, 0xFF); + lst<(4.0, 0xFF); + lst<(5.0, 0xFF); + lst<(6.0, 0xFF); + lst<(7.0, 0xFF); + lst<(8.0, 0xFF); - JKQTPImagePlot_buildDefinedPalette(plut, lst); - } - } - lut_used=lutstore[palette]; + JKQTPImagePlot_buildDefinedPalette(plut, lst); + } + } + lut_used=lutstore[palette]; */ } else if (JKQTPImagePlot_lutsFromFiles.contains(palette)) // LUTs read from files in JKQTPImagePlot_lutsFromFiles { - if (lutstore[palette]==nullptr) { - lutstore[palette]=(int*)malloc((JKQTPImagePlot_LUTSIZE+2)*sizeof(int)); - int* plut=lutstore[palette]; - //std::cout<<"!!! creating rainbow lut\n"; - if (plut!=nullptr) { - if (JKQTPImagePlot_lutsFromFiles[palette].size()>220) JKQTPImagePlot_buildDefinedPalette(plut, JKQTPImagePlot_lutsFromFiles[palette]); - else JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, JKQTPImagePlot_lutsFromFiles[palette]); - } - } - lut_used=lutstore[palette]; + if (lutstore[palette]==nullptr) { + lutstore[palette]=(int*)malloc((JKQTPImageTools::LUTSIZE+2)*sizeof(int)); + int* plut=lutstore[palette]; + //std::cout<<"!!! creating rainbow lut\n"; + if (plut!=nullptr) { + if (JKQTPImagePlot_lutsFromFiles[palette].size()>220) JKQTPImagePlot_buildDefinedPalette(plut, JKQTPImagePlot_lutsFromFiles[palette]); + else JKQTPImagePlot_buildDefinedPaletteLinInterpolate(plut, JKQTPImagePlot_lutsFromFiles[palette]); + } + } + lut_used=lutstore[palette]; } return lut_used; } @@ -1725,7 +1726,7 @@ QImage JKQTPMathImageGetPaletteImage(int i, int width, int height) QImage img; double* pic=static_cast(malloc(width*height*sizeof(double))); for (int j=0; j(pic, width, height, img, (JKQTPMathImageColorPalette)i, Qt::black, Qt::black); free(pic); @@ -1749,7 +1750,7 @@ QImage JKQTPMathImageGetPaletteImage(int *lut, int lut_size, int width) QImage img; double* pic=static_cast(malloc(width*sizeof(double))); for (int j=0; j(pic, width, 1, img, lut, lut_size, Qt::black, Qt::black); free(pic); @@ -1759,9 +1760,9 @@ QImage JKQTPMathImageGetPaletteImage(int *lut, int lut_size, int width) QIcon JKQTPMathImageGetPaletteIcon(int i) { - QImage img=JKQTPMathImageGetPaletteImage(i, jkqtp_PALETTE_ICON_WIDTH); - QPixmap pix(jkqtp_PALETTE_ICON_WIDTH,8); - QRect r(0,0,jkqtp_PALETTE_ICON_WIDTH-1,7); + QImage img=JKQTPMathImageGetPaletteImage(i, JKQTPImageTools::PALETTE_ICON_WIDTH); + QPixmap pix(JKQTPImageTools::PALETTE_ICON_WIDTH,8); + QRect r(0,0,JKQTPImageTools::PALETTE_ICON_WIDTH-1,7); QPainter p(&pix); p.drawImage(r, img); p.setPen(QPen(QColor("black"))); @@ -1787,21 +1788,21 @@ QImage JKQTPMathImageGetAlphaPaletteImage(int *lut, int lut_size, int width, int if (!lut || lut_size<=0 || width<=0 || height<=0) return img; double* pic=static_cast(malloc(width*sizeof(double))); for (int j=0; j l1(lut_size, QColor("white").rgba()); for (int i=0; i(pic, width, 1, img, l1.data(), lut_size, Qt::black, Qt::black); free(pic); @@ -1828,8 +1829,7 @@ JKQTPColorPaletteTools::JKQTPColorPaletteTools(JKQTBasePlotter *parent) { cbParent=parent; colorBarRightAxis=new JKQTPVerticalIndependentAxis(0, 100, 0, 100, parent); - if (parent) colorBarRightAxis->loadSettings(parent->getYAxis()); - colorBarRightAxis->setDrawMode1(JKQTPCADMline); + colorBarRightAxis->setDrawMode1(JKQTPCADMLine); colorBarRightAxis->setDrawMode2(JKQTPCADMcomplete); colorBarRightAxis->setAxisLabel(""); colorBarRightAxis->setMinTicks(3); @@ -1838,8 +1838,7 @@ JKQTPColorPaletteTools::JKQTPColorPaletteTools(JKQTBasePlotter *parent) colorBarRightAxis->setTickOutsideLength(0); colorBarRightAxis->setMinorTickOutsideLength(0); colorBarTopAxis=new JKQTPHorizontalIndependentAxis(0, 100, 0, 100, parent); - if (parent) colorBarTopAxis->loadSettings(parent->getXAxis()); - colorBarTopAxis->setDrawMode1(JKQTPCADMline); + colorBarTopAxis->setDrawMode1(JKQTPCADMLine); colorBarTopAxis->setDrawMode2(JKQTPCADMcomplete); colorBarTopAxis->setAxisLabel(""); colorBarTopAxis->setMinTicks(3); @@ -1850,8 +1849,8 @@ JKQTPColorPaletteTools::JKQTPColorPaletteTools(JKQTBasePlotter *parent) this->palette=JKQTPMathImageMATLAB; - this->imageNameFontName=parent->getKeyFont(); - this->imageNameFontSize=parent->getKeyFontSize(); + this->imageNameFontName=parent->getDefaultTextFontName(); + this->imageNameFontSize=parent->getDefaultTextSize(); this->imageName=""; this->showColorBar=true; this->colorBarWidth=14; @@ -1868,6 +1867,9 @@ JKQTPColorPaletteTools::JKQTPColorPaletteTools(JKQTBasePlotter *parent) this->infColor=QColor("black"); this->colorBarTopVisible=false; this->colorBarRightVisible=true; + + if (parent) this->palette=parent->getCurrentPlotterStyle().defaultPalette; + } JKQTPColorPaletteTools::~JKQTPColorPaletteTools() @@ -1877,33 +1879,27 @@ void JKQTPColorPaletteTools::cbGetOutsideSize(JKQTPEnhancedPainter& painter, int Q_UNUSED(leftSpace); Q_UNUSED(bottomSpace); if (showColorBar) { - double internalDataMin=getInternalDataMin(); - double internalDataMax=getInternalDataMax(); - cbGetDataMinMax(internalDataMin, internalDataMax); - if (colorBarRightVisible) { - rightSpace+=cbParent->pt2px(painter, colorBarWidth+colorBarOffset); - colorBarRightAxis->setRange(internalDataMin, internalDataMax); - colorBarRightAxis->setAxisWidth(colorBarRelativeHeight*cbParent->getPlotHeight()); - QSize s=colorBarRightAxis->getSize2(painter); - /*cbParent->getMathText()->setFontSize(imageNameFontSize*cbParent->getFontSizeMultiplier()); - cbParent->getMathText()->setFontRoman(imageNameFontName); - cbParent->getMathText()->parse(imageName); - QSizeF names=cbParent->getMathText()->getSize(painter);*/ - QSizeF names=cbParent->getTextSizeSize(imageNameFontName, imageNameFontSize*cbParent->getFontSizeMultiplier(), imageName, painter); - rightSpace+=cbParent->pt2px(painter, colorBarWidth+colorBarOffset)+qMax(static_cast(s.width()), static_cast(names.width())); - } - if (colorBarTopVisible) { - //topSpace+=cbParent->pt2px(painter, colorBarWidth+colorBarOffset); - colorBarTopAxis->setRange(internalDataMin, internalDataMax); - colorBarTopAxis->setAxisWidth(colorBarRelativeHeight*cbParent->getPlotWidth()); - QSize s=colorBarTopAxis->getSize2(painter); - /*cbParent->getMathText()->setFontSize(imageNameFontSize*cbParent->getFontSizeMultiplier()); - cbParent->getMathText()->setFontRoman(imageNameFontName); - cbParent->getMathText()->parse(imageName); - QSizeF names=cbParent->getMathText()->getSize(painter);*/ - QSizeF names=cbParent->getTextSizeSize(imageNameFontName, imageNameFontSize*cbParent->getFontSizeMultiplier(), imageName, painter); - topSpace+=cbParent->pt2px(painter, colorBarWidth+colorBarOffset)+qMax(static_cast(s.height()), static_cast(names.height())); - } + double internalDataMin=getInternalDataMin(); + double internalDataMax=getInternalDataMax(); + cbGetDataMinMax(internalDataMin, internalDataMax); + if (colorBarRightVisible) { + rightSpace+=cbParent->pt2px(painter, colorBarWidth+colorBarOffset); + colorBarRightAxis->setRange(internalDataMin, internalDataMax); + colorBarRightAxis->setAxisWidth(colorBarRelativeHeight*cbParent->getPlotHeight()); + QSizeF s1=colorBarRightAxis->getSize2(painter); + QSizeF s2=colorBarRightAxis->getSize1(painter); + QSizeF names=cbParent->getTextSizeSize(imageNameFontName, imageNameFontSize*cbParent->getFontSizeMultiplier(), imageName, painter); + rightSpace+=qMax(static_cast(s1.width()+s2.width()), static_cast(names.width())); + } + if (colorBarTopVisible) { + //topSpace+=cbParent->pt2px(painter, colorBarWidth+colorBarOffset); + colorBarTopAxis->setRange(internalDataMin, internalDataMax); + colorBarTopAxis->setAxisWidth(colorBarRelativeHeight*cbParent->getPlotWidth()); + QSizeF s1=colorBarTopAxis->getSize2(painter); + QSizeF s2=colorBarTopAxis->getSize1(painter); + QSizeF names=cbParent->getTextSizeSize(imageNameFontName, imageNameFontSize*cbParent->getFontSizeMultiplier(), imageName, painter); + topSpace+=cbParent->pt2px(painter, colorBarWidth+colorBarOffset)+qMax(static_cast(s1.height()+s2.height()), static_cast(names.height())); + } } } @@ -1911,133 +1907,115 @@ void JKQTPColorPaletteTools::cbDrawOutside(JKQTPEnhancedPainter& painter, QRect Q_UNUSED(leftSpace); Q_UNUSED(bottomSpace); if (showColorBar) { - double internalDataMin=getInternalDataMin(); - double internalDataMax=getInternalDataMax(); - cbGetDataMinMax(internalDataMin, internalDataMax); - if (colorBarRightVisible) { - painter.save(); + double internalDataMin=getInternalDataMin(); + double internalDataMax=getInternalDataMax(); + cbGetDataMinMax(internalDataMin, internalDataMax); + if (colorBarRightVisible) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); - static const uint8_t h=1; - static const uint8_t dSize = 200*h; - uint8_t d[dSize];//, dd[200*h]; - for (int i=0; i<200; i++) { - for (int j=0; j(d, h, 200, b, palette, 0, 199); + static const uint8_t h=1; + static const uint8_t dSize = 200*h; + uint8_t d[dSize];//, dd[200*h]; + for (int i=0; i<200; i++) { + for (int j=0; j(d, h, 200, b, palette, 0, 199); - /*cbParent->getMathText()->setFontSize(imageNameFontSize*cbParent->getFontSizeMultiplier()); - cbParent->getMathText()->setFontRoman(imageNameFontName); - cbParent->getMathText()->parse(imageName); - QSizeF names=cbParent->getMathText()->getSize(painter);*/ - QSizeF names=cbParent->getTextSizeSize(imageNameFontName, imageNameFontSize*cbParent->getFontSizeMultiplier(), imageName, painter); + QSizeF names=cbParent->getTextSizeSize(imageNameFontName, imageNameFontSize*cbParent->getFontSizeMultiplier(), imageName, painter); - double icolorBarRelativeHeight=colorBarRelativeHeight; - int barHeight=rightSpace.height()*icolorBarRelativeHeight; - if (barHeight<1) barHeight=1; - // find a height for the bar that allows to show the image name - while ((barHeight>1) && ((rightSpace.height()-barHeight)/21) && ((rightSpace.height()-barHeight)/2pt2px(painter, colorBarOffset), rightSpace.top()+(rightSpace.height()-barHeight)/2, cbParent->pt2px(painter, colorBarWidth), barHeight); - painter.drawImage(cb, b.mirrored(true, false)); - QPen p=painter.pen(); - p.setColor(colorBarRightAxis->getAxisColor()); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, cbParent->pt2px(painter, colorBarRightAxis->getLineWidth()*cbParent->getLineWidthMultiplier()))); - painter.setPen(p); - painter.drawRect(cb); + QRect cb(rightSpace.x()+cbParent->pt2px(painter, colorBarOffset), rightSpace.top()+(rightSpace.height()-barHeight)/2, cbParent->pt2px(painter, colorBarWidth), barHeight); + painter.drawImage(cb, b.mirrored(true, false)); + QPen p=painter.pen(); + p.setColor(colorBarRightAxis->getAxisColor()); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, cbParent->pt2px(painter, colorBarRightAxis->getLineWidth()*cbParent->getLineWidthMultiplier()))); + painter.setPen(p); + painter.drawRect(cb); - colorBarRightAxis->setRange(internalDataMin, internalDataMax); - colorBarRightAxis->setAxisWidth(cb.height()); - colorBarRightAxis->setAxisOffset(cb.top()); - colorBarRightAxis->setOtherAxisOffset(cb.left()); - colorBarRightAxis->setOtherAxisWidth(cb.width()); - colorBarRightAxis->drawAxes(painter); + colorBarRightAxis->setRange(internalDataMin, internalDataMax); + colorBarRightAxis->setAxisWidth(cb.height()); + colorBarRightAxis->setAxisOffset(cb.top()); + colorBarRightAxis->setOtherAxisOffset(cb.left()); + colorBarRightAxis->setOtherAxisWidth(cb.width()); + colorBarRightAxis->drawAxes(painter); - cbParent->getMathText()->setFontSize(imageNameFontSize*cbParent->getFontSizeMultiplier()); - cbParent->getMathText()->setFontRoman(imageNameFontName); - cbParent->getMathText()->parse(imageName); - cbParent->getMathText()->draw(painter, Qt::AlignHCenter|Qt::AlignVCenter, QRect(rightSpace.x(), rightSpace.y(), rightSpace.width(), (rightSpace.height()-barHeight)/2)); - - painter.restore(); - } - if (colorBarTopVisible) { - painter.save(); - - /*uint8_t d[200]; - for (int i=0; i<200; i++) d[i]=i; - QImage b(200,1, QImage::Format_ARGB32); - JKQTPImagePlot_array2image(d, 200, 1, b, palette, 0, 199);*/ + cbParent->getMathText()->setFontSize(imageNameFontSize*cbParent->getFontSizeMultiplier()); + cbParent->getMathText()->setFontRomanOrSpecial(imageNameFontName); + cbParent->getMathText()->parse(imageName); + cbParent->getMathText()->draw(painter, Qt::AlignHCenter|Qt::AlignVCenter, QRect(rightSpace.x(), rightSpace.y(), rightSpace.width(), (rightSpace.height()-barHeight)/2)); - static const uint8_t h=1; - static const uint8_t dSize = 200*h; - uint8_t d[dSize];//, dd[200*h]; - for (int i=0; i<200; i++) { - for (int j=0; j(d,h,200, b, palette, 0, 199); + } + if (colorBarTopVisible) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + + static const uint8_t h=1; + static const uint8_t dSize = 200*h; + uint8_t d[dSize];//, dd[200*h]; + for (int i=0; i<200; i++) { + for (int j=0; j(d,h,200, b, palette, 0, 199); + + QSizeF names=cbParent->getTextSizeSize(imageNameFontName, imageNameFontSize*cbParent->getFontSizeMultiplier(), imageName, painter); + + double icolorBarRelativeHeight=colorBarRelativeHeight; + int barWidth=topSpace.width()*icolorBarRelativeHeight; + if (barWidth<1) barWidth=1; + // find a height for the bar that allows to show the image name + while ((barWidth>1) && ((topSpace.width()-barWidth)/2pt2px(painter, colorBarOffset+(colorBarWidth)), barWidth, cbParent->pt2px(painter, colorBarWidth)); + //qDebug()<<"t: "<getAxisColor()); + p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, cbParent->pt2px(painter, colorBarTopAxis->getLineWidth()*cbParent->getLineWidthMultiplier()))); + painter.setPen(p); + painter.drawRect(cb); + + + colorBarTopAxis->setRange(internalDataMin, internalDataMax); + colorBarTopAxis->setAxisWidth(cb.width()); + colorBarTopAxis->setAxisOffset(cb.left()); + colorBarTopAxis->setOtherAxisOffset(cb.top()); + colorBarTopAxis->setOtherAxisWidth(cb.height()); + colorBarTopAxis->drawAxes(painter); + cbParent->getMathText()->setFontSize(imageNameFontSize*cbParent->getFontSizeMultiplier()); + cbParent->getMathText()->setFontRomanOrSpecial(imageNameFontName); + cbParent->getMathText()->parse(imageName); + cbParent->getMathText()->draw(painter, Qt::AlignHCenter|Qt::AlignVCenter, QRect(topSpace.right()-(topSpace.width()-barWidth)/2, topSpace.y(), (topSpace.width()-barWidth)/2, topSpace.height())); - /*cbParent->getMathText()->setFontSize(imageNameFontSize*cbParent->getFontSizeMultiplier()); - cbParent->getMathText()->setFontRoman(imageNameFontName); - cbParent->getMathText()->parse(imageName); - QSizeF names=cbParent->getMathText()->getSize(painter);*/ - QSizeF names=cbParent->getTextSizeSize(imageNameFontName, imageNameFontSize*cbParent->getFontSizeMultiplier(), imageName, painter); - - double icolorBarRelativeHeight=colorBarRelativeHeight; - int barWidth=topSpace.width()*icolorBarRelativeHeight; - if (barWidth<1) barWidth=1; - // find a height for the bar that allows to show the image name - while ((barWidth>1) && ((topSpace.width()-barWidth)/2pt2px(painter, colorBarOffset+(colorBarWidth)), barWidth, cbParent->pt2px(painter, colorBarWidth)); - //qDebug()<<"t: "<getAxisColor()); - p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, cbParent->pt2px(painter, colorBarTopAxis->getLineWidth()*cbParent->getLineWidthMultiplier()))); - painter.setPen(p); - painter.drawRect(cb); - - - colorBarTopAxis->setRange(internalDataMin, internalDataMax); - colorBarTopAxis->setAxisWidth(cb.width()); - colorBarTopAxis->setAxisOffset(cb.left()); - colorBarTopAxis->setOtherAxisOffset(cb.top()); - colorBarTopAxis->setOtherAxisWidth(cb.height()); - colorBarTopAxis->drawAxes(painter); - - - - cbParent->getMathText()->setFontSize(imageNameFontSize*cbParent->getFontSizeMultiplier()); - cbParent->getMathText()->setFontRoman(imageNameFontName); - cbParent->getMathText()->parse(imageName); - cbParent->getMathText()->draw(painter, Qt::AlignHCenter|Qt::AlignVCenter, QRect(topSpace.right()-(topSpace.width()-barWidth)/2, topSpace.y(), (topSpace.width()-barWidth)/2, topSpace.height())); - - painter.restore(); - } + } } } @@ -2052,9 +2030,9 @@ int JKQTPColorPaletteTools::getPalettesCount() } QIcon JKQTPColorPaletteTools::getPaletteIcon(int i) { - QImage img=getPaletteImage(i, jkqtp_PALETTE_ICON_WIDTH); - QPixmap pix(jkqtp_PALETTE_ICON_WIDTH,8); - QRect r(0,0,jkqtp_PALETTE_ICON_WIDTH-1,7); + QImage img=getPaletteImage(i, JKQTPImageTools::PALETTE_ICON_WIDTH); + QPixmap pix(JKQTPImageTools::PALETTE_ICON_WIDTH,8); + QRect r(0,0,JKQTPImageTools::PALETTE_ICON_WIDTH-1,7); QPainter p(&pix); p.drawImage(r, img); p.setPen(QPen(QColor("black"))); @@ -2073,7 +2051,7 @@ QImage JKQTPColorPaletteTools::getPaletteImage(int i, int width) QImage img; double* pic=static_cast(malloc(width*sizeof(double))); for (int j=0; j(pic, width, 1, img, (JKQTPMathImageColorPalette)i, 0, width-1); free(pic); @@ -2087,9 +2065,9 @@ QImage JKQTPColorPaletteTools::getPaletteImage(JKQTPMathImageColorPalette palett QIcon JKQTPColorPaletteTools::getPaletteKeyIcon(int i) { - QImage img=getPaletteKeyImage(i, jkqtp_PALETTE_ICON_WIDTH, jkqtp_PALETTE_IMAGEICON_HEIGHT); - QPixmap pix(jkqtp_PALETTE_ICON_WIDTH,jkqtp_PALETTE_IMAGEICON_HEIGHT); - QRect r(0,0,jkqtp_PALETTE_ICON_WIDTH-1,jkqtp_PALETTE_IMAGEICON_HEIGHT-1); + QImage img=getPaletteKeyImage(i, JKQTPImageTools::PALETTE_ICON_WIDTH, JKQTPImageTools::PALETTE_IMAGEICON_HEIGHT); + QPixmap pix(JKQTPImageTools::PALETTE_ICON_WIDTH,JKQTPImageTools::PALETTE_IMAGEICON_HEIGHT); + QRect r(0,0,JKQTPImageTools::PALETTE_ICON_WIDTH-1,JKQTPImageTools::PALETTE_IMAGEICON_HEIGHT-1); QPainter p(&pix); p.drawImage(r, img); p.setPen(QPen(QColor("black"))); @@ -2119,10 +2097,10 @@ QImage JKQTPColorPaletteTools::getPaletteKeyImage(int i, int width, int height) double* pic=static_cast(malloc(width*height*sizeof(double))); double mmax=0; for (int j=0; jmmax) mmax=pic[j]; + const int x=j%width; + const int y=j/width; + pic[j]=exp(-0.5*(double((x-x01)*double(x-x01))/w1x+double((y-y01)*double(y-y01))/w1y))+0.7*exp(-0.5*(double((x-x02)*double(x-x02))/w2x+double((y-y02)*double(y-y02))/w2y)); + if (pic[j]>mmax) mmax=pic[j]; } JKQTPImagePlot_array2image(pic, width, height, img, (JKQTPMathImageColorPalette)i, 0, mmax); free(pic); @@ -2160,3 +2138,151 @@ double JKQTPColorPaletteTools::getInternalDataMax() const + +QString JKQTPMathImageColorPalette2String(JKQTPMathImageColorPalette p) +{ + switch (p) { + case JKQTPMathImageGRAY: return QString("gray"); + case JKQTPMathImageINVERTEDGRAY: return QString("invgray"); + case JKQTPMathImageRED: return QString("red"); + case JKQTPMathImageINVERTEDRED: return QString("invred"); + case JKQTPMathImageGREEN: return QString("green"); + case JKQTPMathImageINVERTEDGREEN: return QString("invgreen"); + case JKQTPMathImageBLUE: return QString("blue"); + case JKQTPMathImageINVERTEDBLUE: return QString("invblue"); + case JKQTPMathImageCYAN: return QString("cyan"); + case JKQTPMathImageINVERTED_CYAN: return QString("invcyan"); + case JKQTPMathImageYELLOW: return QString("yellow"); + case JKQTPMathImageINVERTED_YELLOW: return QString("invyellow"); + case JKQTPMathImageMAGENTA: return QString("magenta"); + case JKQTPMathImageINVERTED_MAGENTA: return QString("invmagenta"); + + + case JKQTPMathImageMATLAB: return QString("Matlab"); + case JKQTPMathImageINVERTED_MATLAB: return QString("invMatlab"); + case JKQTPMathImageRYGB: return QString("RYGB"); + case JKQTPMathImageINVERTED_RYGB: return QString("invRYGB"); + case JKQTPMathImageHSV: return QString("HSV"); + case JKQTPMathImageINVERTED_HSV: return QString("invHSV"); + case JKQTPMathImageRAINBOW: return QString("rainbow"); + case JKQTPMathImageINVERTED_RAINBOW: return QString("invrainbow"); + case JKQTPMathImageHOT: return QString("AFMhot"); + case JKQTPMathImageINVERTED_HOT: return QString("invAFMhot"); + case JKQTPMathImageOCEAN: return QString("ocean"); + case JKQTPMathImageINVERTED_OCEAN: return QString("invocean"); + case JKQTPMathImageTRAFFICLIGHT: return QString("trafficlight"); + case JKQTPMathImageINVERTED_TRAFFICLIGHT: return QString("invtrafficlight"); + case JKQTPMathImageBLUEMAGENTAYELLOW: return QString("BlMaYe"); + case JKQTPMathImageINVERTED_BLUEMAGENTAYELLOW: return QString("YeMaBl"); + case JKQTPMathImageBLUEYELLOW: return QString("BlYe"); + case JKQTPMathImageINVERTED_BLUEYELLOW: return QString("YeBl"); + + case JKQTPMathImageBLUEWHITERED: return QString("bluewhitered"); + case JKQTPMathImageREDWHITEBLUE: return QString("redwhiteblue"); + + case JKQTPMathImageBLACKBLUEREDYELLOW: return QString("BBlRdYe"); + case JKQTPMathImageGREENREDVIOLET: return QString("GnRdVi"); + case JKQTPMathImageBLACKBLUEWHITEYELLOWWHITE: return QString("BWprint"); + case JKQTPMathImageWHITEYELLOWWHITEBLUEBLACK: return QString("invBWprint"); + case JKQTPMathImageBR_GR: return QString("BrBG"); + case JKQTPMathImagePU_OR: return QString("PuOr"); + case JKQTPMathImageGN_BU: return QString("greenblue"); + case JKQTPMathImageBU_GN: return QString("bluegreen"); + case JKQTPMathImageYL_GN_BU: return QString("YeGnBu"); + + case JKQTPMathImageBR_GR_STEP: return QString("stepsBrBG"); + case JKQTPMathImagePU_OR_STEP: return QString("stepsPuOr"); + case JKQTPMathImageGN_BU_STEP: return QString("stepsGnBl"); + case JKQTPMathImageBU_GN_STEP: return QString("stepsBlGn"); + case JKQTPMathImageYL_GN_BU_STEP: return QString("stepsYeGnBu"); + + + case JKQTPMathImageCYANWHITE: return QString("cyanwhite"); + case JKQTPMathImageINVERTED_CYANWHITE: return QString("whitecyan"); + case JKQTPMathImageYELLOWWHITE: return QString("yellowwhite"); + case JKQTPMathImageINVERTED_YELLOWWHITE: return QString("whiteyellow"); + case JKQTPMathImageMAGENTAWHITE: return QString("magentawhite"); + case JKQTPMathImageINVERTED_MAGENTAWHITE: return QString("whitemagenta"); + case JKQTPMathImageBlueGreenRed: return QString("bluegreenred"); + case JKQTPMathImageRedGreenBlue: return QString("redgreenblue"); + case JKQTPMathImageALPHA: return QString("alpha"); + case JKQTPMathImageINVERTED_ALPHA: return QString("invAlpha"); + default: + return QString::number(static_cast(p)); + } +} + +JKQTPMathImageColorPalette String2JKQTPMathImageColorPalette(const QString &p) +{ + if (QString::compare(p, "gray", Qt::CaseInsensitive)==0) return JKQTPMathImageGRAY; + if (QString::compare(p, "invgray", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTEDGRAY; + if (QString::compare(p, "red", Qt::CaseInsensitive)==0) return JKQTPMathImageRED; + if (QString::compare(p, "invred", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTEDRED; + if (QString::compare(p, "green", Qt::CaseInsensitive)==0) return JKQTPMathImageGREEN; + if (QString::compare(p, "invgreen", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTEDGREEN; + if (QString::compare(p, "blue", Qt::CaseInsensitive)==0) return JKQTPMathImageBLUE; + if (QString::compare(p, "invblue", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTEDBLUE; + if (QString::compare(p, "cyan", Qt::CaseInsensitive)==0) return JKQTPMathImageCYAN; + if (QString::compare(p, "invcyan", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_CYAN; + if (QString::compare(p, "yellow", Qt::CaseInsensitive)==0) return JKQTPMathImageYELLOW; + if (QString::compare(p, "invyellow", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_YELLOW; + if (QString::compare(p, "magenta", Qt::CaseInsensitive)==0) return JKQTPMathImageMAGENTA; + if (QString::compare(p, "invmagenta", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_MAGENTA; + + + if (QString::compare(p, "Matlab", Qt::CaseInsensitive)==0) return JKQTPMathImageMATLAB; + if (QString::compare(p, "invMatlab", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_MATLAB; + if (QString::compare(p, "RYGB", Qt::CaseInsensitive)==0) return JKQTPMathImageRYGB; + if (QString::compare(p, "invRYGB", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_RYGB; + if (QString::compare(p, "HSV", Qt::CaseInsensitive)==0) return JKQTPMathImageHSV; + if (QString::compare(p, "invHSV", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_HSV; + if (QString::compare(p, "rainbow", Qt::CaseInsensitive)==0) return JKQTPMathImageRAINBOW; + if (QString::compare(p, "invrainbow", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_RAINBOW; + if (QString::compare(p, "AFMhot", Qt::CaseInsensitive)==0) return JKQTPMathImageHOT; + if (QString::compare(p, "invAFMhot", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_HOT; + if (QString::compare(p, "ocean", Qt::CaseInsensitive)==0) return JKQTPMathImageOCEAN; + if (QString::compare(p, "invocean", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_OCEAN; + if (QString::compare(p, "trafficlight", Qt::CaseInsensitive)==0) return JKQTPMathImageTRAFFICLIGHT; + if (QString::compare(p, "invtrafficlight", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_TRAFFICLIGHT; + if (QString::compare(p, "BlMaYe", Qt::CaseInsensitive)==0) return JKQTPMathImageBLUEMAGENTAYELLOW; + if (QString::compare(p, "YeMaBl", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_BLUEMAGENTAYELLOW; + if (QString::compare(p, "BlYe", Qt::CaseInsensitive)==0) return JKQTPMathImageBLUEYELLOW; + if (QString::compare(p, "YeBl", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_BLUEYELLOW; + + if (QString::compare(p, "bluewhitered", Qt::CaseInsensitive)==0) return JKQTPMathImageBLUEWHITERED; + if (QString::compare(p, "redwhiteblue", Qt::CaseInsensitive)==0) return JKQTPMathImageREDWHITEBLUE; + + if (QString::compare(p, "BBlRdYe", Qt::CaseInsensitive)==0) return JKQTPMathImageBLACKBLUEREDYELLOW; + if (QString::compare(p, "GnRdVi", Qt::CaseInsensitive)==0) return JKQTPMathImageGREENREDVIOLET; + if (QString::compare(p, "BWprint", Qt::CaseInsensitive)==0) return JKQTPMathImageBLACKBLUEWHITEYELLOWWHITE; + if (QString::compare(p, "invBWprint", Qt::CaseInsensitive)==0) return JKQTPMathImageWHITEYELLOWWHITEBLUEBLACK; + if (QString::compare(p, "BrBG", Qt::CaseInsensitive)==0) return JKQTPMathImageBR_GR; + if (QString::compare(p, "PuOr", Qt::CaseInsensitive)==0) return JKQTPMathImagePU_OR; + if (QString::compare(p, "greenblue", Qt::CaseInsensitive)==0) return JKQTPMathImageGN_BU; + if (QString::compare(p, "bluegreen", Qt::CaseInsensitive)==0) return JKQTPMathImageBU_GN; + if (QString::compare(p, "YeGnBu", Qt::CaseInsensitive)==0) return JKQTPMathImageYL_GN_BU; + + if (QString::compare(p, "stepsBrBG", Qt::CaseInsensitive)==0) return JKQTPMathImageBR_GR_STEP; + if (QString::compare(p, "stepsPuOr", Qt::CaseInsensitive)==0) return JKQTPMathImagePU_OR_STEP; + if (QString::compare(p, "stepsGnBl", Qt::CaseInsensitive)==0) return JKQTPMathImageGN_BU_STEP; + if (QString::compare(p, "stepsBlGn", Qt::CaseInsensitive)==0) return JKQTPMathImageBU_GN_STEP; + if (QString::compare(p, "stepsYeGnBu", Qt::CaseInsensitive)==0) return JKQTPMathImageYL_GN_BU_STEP; + + + if (QString::compare(p, "cyanwhite", Qt::CaseInsensitive)==0) return JKQTPMathImageCYANWHITE; + if (QString::compare(p, "whitecyan", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_CYANWHITE; + if (QString::compare(p, "yellowwhite", Qt::CaseInsensitive)==0) return JKQTPMathImageYELLOWWHITE; + if (QString::compare(p, "whiteyellow", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_YELLOWWHITE; + if (QString::compare(p, "magentawhite", Qt::CaseInsensitive)==0) return JKQTPMathImageMAGENTAWHITE; + if (QString::compare(p, "whitemagenta", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_MAGENTAWHITE; + if (QString::compare(p, "bluegreenred", Qt::CaseInsensitive)==0) return JKQTPMathImageBlueGreenRed; + if (QString::compare(p, "redgreenblue", Qt::CaseInsensitive)==0) return JKQTPMathImageRedGreenBlue; + if (QString::compare(p, "alpha", Qt::CaseInsensitive)==0) return JKQTPMathImageALPHA; + if (QString::compare(p, "invAlpha", Qt::CaseInsensitive)==0) return JKQTPMathImageINVERTED_ALPHA; + + bool ok=false; + JKQTPMathImageColorPalette res = static_cast(p.toInt(&ok)); + if (!ok) return JKQTPMathImageMATLAB; + else return res; + +} diff --git a/lib/jkqtplottertools/jkqtpimagetools.h b/lib/jkqtplottertools/jkqtpimagetools.h index 23aa83d324..f030022ac6 100644 --- a/lib/jkqtplottertools/jkqtpimagetools.h +++ b/lib/jkqtplottertools/jkqtpimagetools.h @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -39,12 +39,24 @@ class JKQTPHorizontalIndependentAxis; // forward class JKQTBasePlotter; // forward #endif -/*! \brief Width of the Palette-Icons, generated e.g. by JKQTPMathImageGetPaletteIcon() - \ingroup jkqtptools_qt */ -#define jkqtp_PALETTE_ICON_WIDTH 64 -/*! \brief Height of the Palette-Icons, generated e.g. by JKQTPMathImageGetPaletteIcon() - \ingroup jkqtptools_qt */ -#define jkqtp_PALETTE_IMAGEICON_HEIGHT 64 +/*! \brief tool structure that summarizes several static properties + \ingroup jkqtptools_qt + \internal +*/ +struct JKQTP_LIB_EXPORT JKQTPImageTools { + + /*! \brief Width of the Palette-Icons, generated e.g. by JKQTPMathImageGetPaletteIcon() + \ingroup jkqtptools_qt */ + static const int PALETTE_ICON_WIDTH; + /*! \brief Height of the Palette-Icons, generated e.g. by JKQTPMathImageGetPaletteIcon() + \ingroup jkqtptools_qt */ + static const int PALETTE_IMAGEICON_HEIGHT; + + /*! \brief size of the lookup tables used by JKQTFPimagePlot_array2image() + \ingroup jkqtplotter_imagelots_tools + */ + static const int LUTSIZE; +}; /*! \brief available palettes for coloring an image @@ -126,8 +138,17 @@ enum JKQTPMathImageColorPalette { +/*! \brief convert the palette \a p to a string + \ingroup jkqtplotter_imagelots_tools + \see String2JKQTPMathImageColorPalette() + */ +QString JKQTPMathImageColorPalette2String(JKQTPMathImageColorPalette p); - +/*! \brief convert the palette name \a p to JKQTPMathImageColorPalette (compatible with String2JKQTPMathImageColorPalette() ) + \ingroup jkqtplotter_imagelots_tools + \see JKQTPMathImageColorPalette2String() + */ +JKQTPMathImageColorPalette String2JKQTPMathImageColorPalette(const QString& p); @@ -527,10 +548,6 @@ inline QList JKQTPImagePlot_makeQList(const T& defaultVal, int N=1) { -/*! \brief size of the lookup tables used by JKQTFPimagePlot_array2image() - \ingroup jkqtplotter_imagelots_tools -*/ -#define JKQTPImagePlot_LUTSIZE 256 /*! \brief build a linearly interpolated palette in \a lut with \a N entries that are provided in \a items \ingroup jkqtplotter_imagelots_tools @@ -540,7 +557,7 @@ inline QList JKQTPImagePlot_makeQList(const T& defaultVal, int N=1) { \a lut needs to have \c lut_size) entries */ -void JKQTP_LIB_EXPORT JKQTPImagePlot_buildDefinedPaletteLinInterpolate(int* lut, QList > items, int lut_size=JKQTPImagePlot_LUTSIZE); +void JKQTP_LIB_EXPORT JKQTPImagePlot_buildDefinedPaletteLinInterpolate(int* lut, QList > items, int lut_size=JKQTPImageTools::LUTSIZE); /*! \brief build a linearly interpolated palette in \a lut with \a N entries that are provided as (double, QRgb) value pairss in the variable arguments \ingroup jkqtplotter_imagelots_tools @@ -556,9 +573,9 @@ void JKQTP_LIB_EXPORT JKQTPImagePlot_buildDefinedPaletteLinInterpolate(int* lut, \ingroup jkqtplotter_imagelots_tools The entries in \a items are sorted by the first (double) argument and the full range is distributed - over 0 ... JKQTPImagePlot_LUTSIZE. + over 0 ... JKQTPImageTools::LUTSIZE. - \a lut needs to have \c JKQTPImagePlot_LUTSIZE) entries + \a lut needs to have \c JKQTPImageTools::LUTSIZE) entries */ void JKQTP_LIB_EXPORT JKQTPImagePlot_buildDefinedPalette(int* lut, QList > items); @@ -575,20 +592,20 @@ QStringList JKQTP_LIB_EXPORT JKQTPImagePlot_getPredefinedPalettes(); /*! \brief create a LUT for a given JKQTPMathImageColorPalette, store it in \a lutstore and return it \ingroup jkqtplotter_imagelots_tools - \internal - */ + \internal + */ JKQTP_LIB_EXPORT int* JKQTPImagePlot_getCreateLUT(QList &lutstore, JKQTPMathImageColorPalette palette); /*! \brief frees a list of LUTs \ingroup jkqtplotter_imagelots_tools - \internal - */ + \internal + */ void JKQTP_LIB_EXPORT JKQTPImagePlot_freeLUTs(QList &lutstore); /*! \brief internal global storage object for lookup-tables \ingroup jkqtplotter_imagelots_tools - \internal - */ + \internal + */ extern JKQTP_LIB_EXPORT QList global_jkqtpimagetools_lutstore; /*! \brief convert a 2D image (as 1D array) into a QImage with given palette (see JKQTFPColorPalette) @@ -596,7 +613,7 @@ extern JKQTP_LIB_EXPORT QList global_jkqtpimagetools_lutstore; This method uses lookup tables which are saved as static variables to convert the 2D array into an image. The luts are only created once, and stored then, so mor CPU time is saved. The precompiler define - JKQTPImagePlot_LUTSIZE sets the size of the LUTs. Note that if you don't use a specific color palette, + JKQTPImageTools::LUTSIZE sets the size of the LUTs. Note that if you don't use a specific color palette, the according LUT won't be calculated and stored! \param dbl_in pointer to a 1D array of template type \c T representing the image to plot. This array has to be of size \a width * \a height @@ -661,7 +678,7 @@ inline void JKQTPImagePlot_array2image(const T* dbl_in, int width, int height, Q const int* lut_used=nullptr; - int lutSize=JKQTPImagePlot_LUTSIZE; + int lutSize=JKQTPImageTools::LUTSIZE; if (global_jkqtpimagetools_lutstore.size()<=0) global_jkqtpimagetools_lutstore=JKQTPImagePlot_makeQList(nullptr, JKQTPImagePlot_getPredefinedPalettes().size()+2); @@ -722,7 +739,7 @@ inline void JKQTPImagePlot_array2image(const T* dbl_in, int width, int height, Q This method uses lookup tables which are saved as static variables to convert the 2D array into an image. The luts are only created once, and stored then, so mor CPU time is saved. The precompiler define - JKQTPImagePlot_LUTSIZE sets the size of the LUTs. Note that if you don't use a specific color palette, + JKQTPImageTools::LUTSIZE sets the size of the LUTs. Note that if you don't use a specific color palette, the according LUT won't be calculated and stored! \param dbl_in pointer to a 1D array of template type \c T representing the image to plot. This array has to be of size \a width * \a height @@ -730,7 +747,7 @@ inline void JKQTPImagePlot_array2image(const T* dbl_in, int width, int height, Q \param height height of the array in \a dbl \param[out] im the QImage object to draw to (should be initialized as \c QImage::Format_ARGB32 ) \param lutUser user-defined lookup-table - \param lutUserSize number of entries in \a lutUser + \param lutUserSize number of entries in \a lutUser \param minColor lower boundary of color range in \a dbl pixels, if \a minColor == \a maxColor then this function will extract the image min and image max. \param maxColor upper boundary of color range in \a dbl pixels, if \a minColor == \a maxColor then this function will extract the image min and image max. \param paletteMinFail specifies what shell happen, when a value in \a dbl is below \a minColor @@ -1139,16 +1156,28 @@ class JKQTP_LIB_EXPORT JKQTPColorPaletteTools { /*! \brief returns the property colorBarRightAxis ( \copybrief colorBarRightAxis ). \details Description of the parameter colorBarRightAxis is:
    \copydoc colorBarRightAxis
    . \see colorBarRightAxis for more information */ - inline JKQTPVerticalIndependentAxis* getColorBarRightAxis() const { + inline JKQTPVerticalIndependentAxis* getColorBarRightAxis() { return this->colorBarRightAxis; } /*! \brief returns the property colorBarTopAxis ( \copybrief colorBarTopAxis ). \details Description of the parameter colorBarTopAxis is:
    \copydoc colorBarTopAxis
    . \see colorBarTopAxis for more information */ - inline JKQTPHorizontalIndependentAxis* getColorBarTopAxis() const { + inline JKQTPHorizontalIndependentAxis* getColorBarTopAxis() { return this->colorBarTopAxis; } - /*! \brief sets the property colorBarTopVisible ( \copybrief colorBarTopVisible ) to the specified \a __value. + /*! \brief returns the property colorBarRightAxis ( \copybrief colorBarRightAxis ). + \details Description of the parameter colorBarRightAxis is:
    \copydoc colorBarRightAxis
    . + \see colorBarRightAxis for more information */ + inline const JKQTPVerticalIndependentAxis* getColorBarRightAxis() const { + return this->colorBarRightAxis; + } + /*! \brief returns the property colorBarTopAxis ( \copybrief colorBarTopAxis ). + \details Description of the parameter colorBarTopAxis is:
    \copydoc colorBarTopAxis
    . + \see colorBarTopAxis for more information */ + inline const JKQTPHorizontalIndependentAxis* getColorBarTopAxis() const { + return this->colorBarTopAxis; + } + /*! \brief sets the property colorBarTopVisible ( \copybrief colorBarTopVisible ) to the specified \a __value. \details Description of the parameter colorBarTopVisible is:
    \copydoc colorBarTopVisible
    \see colorBarTopVisible for more information */ inline virtual void setColorBarTopVisible(bool __value) diff --git a/lib/jkqtplottertools/jkqtpmathparser.cpp b/lib/jkqtplottertools/jkqtpmathparser.cpp index 8afdbe3d20..d236a63be9 100644 --- a/lib/jkqtplottertools/jkqtpmathparser.cpp +++ b/lib/jkqtplottertools/jkqtpmathparser.cpp @@ -4,16 +4,16 @@ This software is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or + it under the terms of the GNU Lesser General Public License 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 General Public License for more details. + GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License + You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ diff --git a/lib/jkqtplottertools/jkqtpmathparser.h b/lib/jkqtplottertools/jkqtpmathparser.h index 0b922fe1e0..ed8a5a72be 100644 --- a/lib/jkqtplottertools/jkqtpmathparser.h +++ b/lib/jkqtplottertools/jkqtpmathparser.h @@ -5,7 +5,7 @@ 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 of the License, or + 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, diff --git a/lib/jkqtplottertools/jkqtptools.cpp b/lib/jkqtplottertools/jkqtptools.cpp index d3c0edf268..a3c115d426 100644 --- a/lib/jkqtplottertools/jkqtptools.cpp +++ b/lib/jkqtplottertools/jkqtptools.cpp @@ -7,7 +7,7 @@ Copyright (c) 2008-2019 Jan W. Krieger () 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 of the License, or + 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, @@ -45,6 +45,7 @@ Copyright (c) 2008-2019 Jan W. Krieger () #include #include + std::string jkqtp_tolower(const std::string& s){ std::string d; d=""; @@ -330,20 +331,33 @@ Qt::BrushStyle jkqtp_String2QBrushStyle(const QString& style) { QString JKQTPCADrawMode2String(JKQTPCADrawMode pos) { switch(pos) { case JKQTPCADMcomplete: return "all"; - case JKQTPCADMticksAndLabels: return "ticks+labels"; - case JKQTPCADMticks: return "ticks"; - case JKQTPCADMline: return "line"; + case JKQTPCADMTicksTickLabelsAxisLabel: return "ticks+labels+axislabel"; + case JKQTPCADMTicksTickLabels: return "ticks+labels"; + case JKQTPCADMTicks: return "ticks"; + case JKQTPCADMLineTicksTickLabels: return "line+ticks+labels"; + case JKQTPCADMTickLabelsAxisLabel: return "ticks+labels"; + case JKQTPCADMTickLabels: return "labels"; + case JKQTPCADMLineTicks: return "line+ticks"; + case JKQTPCADMLine: return "line"; case JKQTPCADMnone: return "none"; } return ""; } + + JKQTPCADrawMode String2JKQTPCADrawMode(const QString& pos) { QString s=pos.trimmed().toLower(); - if (s=="all") return JKQTPCADMcomplete; - if (s=="ticks+labels") return JKQTPCADMticksAndLabels; - if (s=="ticks") return JKQTPCADMticks; - if (s=="line") return JKQTPCADMline; + if (s=="all" || s=="complete" || s=="line+ticks+labels+axislabel") return JKQTPCADMcomplete; + if (s=="ticks+labels") return JKQTPCADMLineTicksTickLabels; + if (s=="ticks+labels+axislabel") return JKQTPCADMTicksTickLabelsAxisLabel; + if (s=="labels+axislabel") return JKQTPCADMTickLabelsAxisLabel; + if (s=="ticks+labels") return JKQTPCADMTicksTickLabels; + if (s=="line+ticks+labels") return JKQTPCADMLineTicksTickLabels; + if (s=="labels") return JKQTPCADMTickLabels; + if (s=="line+ticks") return JKQTPCADMLineTicks; + if (s=="ticks") return JKQTPCADMTicks; + if (s=="line") return JKQTPCADMLine; if (s=="none") return JKQTPCADMnone; return JKQTPCADMnone; } @@ -768,17 +782,51 @@ static const struct RGBData { static const int rgbTblSize = sizeof(rgbTbl) / sizeof(RGBData); -std::string jkqtp_rgbtostring(unsigned char r, unsigned char g, unsigned char b, unsigned char a) { +QString jkqtp_rgbtostring(unsigned char r, unsigned char g, unsigned char b, unsigned char a, bool useSpecialTransparencySyntax) { if (a==255) {// only for non-transparent colors for (int i=0; i(r), static_cast(g), static_cast(b)); + return QString("#%1%2%3").arg(static_cast(r), 2,16,QLatin1Char('0')).arg(static_cast(g), 2,16,QLatin1Char('0')).arg(static_cast(b), 2,16,QLatin1Char('0')); } // if we reach this, we have an unnamed transparent color - return jkqtp_format("#%02X%02X%02X%02X", static_cast(r), static_cast(g), static_cast(b), static_cast(a)); + if (useSpecialTransparencySyntax) { + QString col=jkqtp_rgbtostring(r,g,b,255,false); + return QString("%1,%2").arg(col).arg(static_cast(a), 0, 10); + //return QString("%1,%2%%").arg(col).arg(static_cast(a)*100/255, 0, 10); + } else { + return QString("#%1%2%3%4").arg(static_cast(r), 2,16,QLatin1Char('0')).arg(static_cast(g), 2,16,QLatin1Char('0')).arg(static_cast(b), 2,16,QLatin1Char('0')).arg(static_cast(a), 2,16,QLatin1Char('0')); + } +} + + +QString jkqtp_QColor2String(QColor color, bool useSpecialTransparencySyntax) { + return jkqtp_rgbtostring(static_cast((color).red()), + static_cast((color).green()), + static_cast((color).blue()), + static_cast((color).alpha()), + useSpecialTransparencySyntax); +} + +QColor jkqtp_String2QColor(const QString &color) +{ + QRegExp rxP("(.+)\\s*,\\s*(\\d+\\.?\\d+)\\%"); + QRegExp rxNP("(.+)\\s*,\\s*([\\d]+)"); + if (rxP.exactMatch(color)) { + QColor col(rxP.cap(1)); + double a=QLocale::c().toDouble(rxP.cap(2)); + col.setAlphaF(a/100.0); + return col; + } + if (rxNP.exactMatch(color)) { + QColor col(rxNP.cap(1)); + double a=QLocale::c().toInt(rxNP.cap(2)); + col.setAlphaF(a/255.0); + return col; + } + return QColor(color); } std::string jkqtp_to_valid_variable_name(const std::string& input) { @@ -857,3 +905,161 @@ JKQTPStepType String2JKQTPStepType(const QString& pos) return JKQTPStepLeft; } + +QString JKQTPContextMenuModes2String(JKQTPContextMenuModes act) +{ + if (act==jkqtpcmmStandardContextMenu) return "standard"; + if (act==jkqtpcmmSpecialContextMenu) return "special"; + if (act==jkqtpcmmStandardAndSpecialContextMenu) return "both"; + if (act==jkqtpcmmNoContextMenu) return "none"; + return "none"; +} + +JKQTPContextMenuModes String2JKQTPContextMenuModes(const QString &act) +{ + QString s=act.trimmed().toLower(); + if (s=="jkqtpcmmstandardcontextmenu"||s=="standardcontextmenu" ||s=="standard") return jkqtpcmmStandardContextMenu; + if (s=="jkqtpcmmspecialcontextmenu"||s=="specialcontextmenu"||s=="special") return jkqtpcmmSpecialContextMenu; + if (s=="jkqtpcmmstandardandspecialcontextmenu"||s=="standardandspecialcontextmenu"||s=="standardandspecial"||s=="standard+special"||s=="both") return jkqtpcmmStandardAndSpecialContextMenu; + + return jkqtpcmmNoContextMenu; +} + +JKQTPMouseWheelActions String2JKQTPMouseWheelActions(const QString &act) +{ + QString s=act.trimmed().toLower(); + if (s=="jkqtpmwazoombywheel"||s=="zoombywheel" ||s=="zoom") return jkqtpmwaZoomByWheel; + if (s=="jkqtpmwapanbywheel"||s=="panbywheel"||s=="pan") return jkqtpmwaPanByWheel; + return jkqtpmwaZoomByWheel; + +} + +QString JKQTPMouseWheelActions2String(JKQTPMouseWheelActions act) +{ + if (act==jkqtpmwaZoomByWheel) return "zoom"; + if (act==jkqtpmwaPanByWheel) return "pan"; + return "unknown"; +} + +JKQTPMouseDoubleClickActions String2JKQTPMouseDoubleClickActions(const QString &act) +{ + QString s=act.trimmed().toLower(); + if (s=="jkqtpdcaclickzoomsin"||s=="clickzoomsin" ||s=="zoomsin" ||s=="zoomin") return jkqtpdcaClickZoomsIn; + if (s=="jkqtpdcaclickzoomsout"||s=="clickzoomsout" ||s=="zoomsout" ||s=="zoomout") return jkqtpdcaClickZoomsOut; + if (s=="jkqtpdcaclickopenscontextmenu"||s=="openscontextmenu"||s=="opencontextmenu"||s=="contextmenu") return jkqtpdcaClickOpensContextMenu; + if (s=="jkqtpdcaclickopensspecialcontextmenu"||s=="opensspecialcontextmenu"||s=="openspecialcontextmenu"||s=="specialcontextmenu") return jkqtpdcaClickOpensSpecialContextMenu; + if (s=="jkqtpdcaclickmovesviewport"||s=="clickmovesviewport"||s=="movesviewport"||s=="moveviewport"||s=="moveview") return jkqtpdcaClickMovesViewport; + + return jkqtpdcaClickZoomsIn; +} + +QString JKQTPMouseDoubleClickActions2String(JKQTPMouseDoubleClickActions act) +{ + if (act==jkqtpdcaClickZoomsIn) return "zoomin"; + if (act==jkqtpdcaClickZoomsOut) return "zoomout"; + if (act==jkqtpdcaClickOpensContextMenu) return "contextmenu"; + if (act==jkqtpdcaClickOpensSpecialContextMenu) return "specialcontextmenu"; + if (act==jkqtpdcaClickMovesViewport) return "moveviewport"; + return "unknown"; + +} + +JKQTPMouseDragActions String2JKQTPMouseDragActions(const QString &act) +{ + QString s=act.trimmed().toLower(); + if (s=="jkqtpmdapanonmove"||s=="panonmove" ||s=="panmove") return jkqtpmdaPanPlotOnMove; + if (s=="jkqtpmdapanonrelease"||s=="panonrelease" ||s=="panrelease") return jkqtpmdaPanPlotOnRelease; + if (s=="jkqtpmdazoombyrectangle"||s=="zoomrectangle"||s=="zoomrect"||s=="zoombyrectangle"||s=="zoombyrect") return jkqtpmdaZoomByRectangle; + if (s=="jkqtpmdadrawrectforevent"||s=="drawrectangle"||s=="drawrect"||s=="rectangle"||s=="rect") return jkqtpmdaDrawRectangleForEvent; + if (s=="jkqtpmdadrawrectforevent"||s=="drawcircle"||s=="circle") return jkqtpmdaDrawCircleForEvent; + if (s=="jkqtpmdadrawrectforevent"||s=="drawellipse"||s=="ellipse") return jkqtpmdaDrawEllipseForEvent; + if (s=="jkqtpmdadrawrectforevent"||s=="drawline"||s=="line") return jkqtpmdaDrawLineForEvent; + if (s=="jkqtpmdascribbleforevents"||s=="scribble") return jkqtpmdaScribbleForEvents; + + return jkqtpmdaZoomByRectangle; + +} + +QString JKQTPMouseDragActions2String(JKQTPMouseDragActions act) +{ + if (act==jkqtpmdaPanPlotOnMove) return "PanOnMove"; + if (act==jkqtpmdaPanPlotOnRelease) return "PanOnRelease"; + if (act==jkqtpmdaZoomByRectangle) return "ZoomRectangle"; + if (act==jkqtpmdaDrawRectangleForEvent) return "DrawRectangle"; + if (act==jkqtpmdaDrawCircleForEvent) return "DrawCircle"; + if (act==jkqtpmdaDrawEllipseForEvent) return "DrawEllipse"; + if (act==jkqtpmdaDrawLineForEvent) return "DrawLine"; + if (act==jkqtpmdaScribbleForEvents) return "Scribble"; + return "unknown"; +} + + +bool JKQTPCADrawModeHasLine(JKQTPCADrawMode pos) +{ + return (pos==JKQTPCADMcomplete) || (pos==JKQTPCADMLineTicksTickLabels) || (pos==JKQTPCADMLineTicks) || (pos==JKQTPCADMLine); +} + +bool JKQTPCADrawModeHasTicks(JKQTPCADrawMode pos) +{ + return (pos==JKQTPCADMcomplete) || (pos==JKQTPCADMTicksTickLabelsAxisLabel) || (pos==JKQTPCADMLineTicks) || (pos==JKQTPCADMLineTicksTickLabels) || (pos==JKQTPCADMTicksTickLabels)|| (pos==JKQTPCADMTicks); +} + +bool JKQTPCADrawModeHasTickLabels(JKQTPCADrawMode pos) +{ + return (pos==JKQTPCADMcomplete) || (pos==JKQTPCADMTicksTickLabelsAxisLabel) || (pos==JKQTPCADMLineTicksTickLabels) || (pos==JKQTPCADMTicksTickLabels) || (pos==JKQTPCADMTickLabels) || (pos==JKQTPCADMTickLabelsAxisLabel); +} + +bool JKQTPCADrawModeHasAxisLabel(JKQTPCADrawMode pos) +{ + return (pos==JKQTPCADMcomplete) || (pos==JKQTPCADMTicksTickLabelsAxisLabel) || (pos==JKQTPCADMTickLabelsAxisLabel); +} + +QString JKQTPColorDerivationMode2String(JKQTPColorDerivationMode mode) +{ + switch(mode) { + case JKQTPFFCMSameColor: return "same"; + case JKQTPFFCMInvertedColor: return "inverted"; + case JKQTPFFCMLighterColor: return "lighter"; + case JKQTPFFCMEvenLighterColor: return "even_lighter"; + case JKQTPFFCMDarkerColor: return "darker"; + case JKQTPFFCMEvenDarkerColor: return "even_darker"; + case JKQTPFFCMMoreTransparentColor: return "more_transparent"; + case JKQTPFFCMEvenMoreTransparentColor: return "even_more_transparent"; + case JKQTPFFCMLessTransparentColor: return "less_transparent"; + case JKQTPFFCMEvenLessTransparentColor: return "even_less_transparent"; + } + return "same"; +} + +JKQTPColorDerivationMode String2JKQTPColorDerivationMode(const QString &mode) +{ + QString m=mode.trimmed().toLower(); + if (m=="same") return JKQTPFFCMSameColor; + if (m=="inverted") return JKQTPFFCMInvertedColor; + if (m=="lighter") return JKQTPFFCMLighterColor; + if (m=="even_lighter") return JKQTPFFCMEvenLighterColor; + if (m=="darker") return JKQTPFFCMDarkerColor; + if (m=="even_darker") return JKQTPFFCMEvenDarkerColor; + if (m=="more_transparent") return JKQTPFFCMMoreTransparentColor; + if (m=="even_more_transparent") return JKQTPFFCMEvenMoreTransparentColor; + if (m=="less_transparent") return JKQTPFFCMLessTransparentColor; + if (m=="even_less_transparent") return JKQTPFFCMEvenLessTransparentColor; + return JKQTPFFCMSameColor; +} + +QColor JKQTPGetDerivedColor(JKQTPColorDerivationMode mode, const QColor &col) +{ + switch(mode) { + case JKQTPFFCMSameColor: return col; + case JKQTPFFCMInvertedColor: return QColor(255-col.red(), 255-col.green(), 255-col.blue(), col.alpha()); + case JKQTPFFCMLighterColor: return col.lighter(); + case JKQTPFFCMEvenLighterColor: return col.lighter().lighter(); + case JKQTPFFCMDarkerColor: return col.darker(); + case JKQTPFFCMEvenDarkerColor: return col.darker().darker(); + case JKQTPFFCMMoreTransparentColor: { QColor c=col; c.setAlphaF(0.66*c.alphaF()); return c; } + case JKQTPFFCMEvenMoreTransparentColor: { QColor c=col; c.setAlphaF(0.33*c.alphaF()); return c; } + case JKQTPFFCMLessTransparentColor: { QColor c=col; c.setAlphaF(c.alphaF()+(1.0-c.alphaF())*0.33); return c; } + case JKQTPFFCMEvenLessTransparentColor: { QColor c=col; c.setAlphaF(c.alphaF()+(1.0-c.alphaF())*0.66); return c; } + } + return col; +} diff --git a/lib/jkqtplottertools/jkqtptools.h b/lib/jkqtplottertools/jkqtptools.h index 51d24e3e0b..c926481b34 100644 --- a/lib/jkqtplottertools/jkqtptools.h +++ b/lib/jkqtplottertools/jkqtptools.h @@ -4,16 +4,16 @@ This software is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by + it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 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 General Public License for more details. + GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License + You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ @@ -74,10 +74,59 @@ class JKQTPEnhancedPainter; // forward class JKQTBasePlotter; // forward declaration -/** \brief smallest linewidth any line in JKQTPlotter may have + + +/** \brief C++11 finally construct * \ingroup jkqtptools + * + * \see JKQTPFinally() */ -#define JKQTPLOTTER_ABS_MIN_LINEWIDTH 0.02 +template +class JKQTPFinalAct +{ +public: + explicit JKQTPFinalAct(F f) noexcept + : f_(std::move(f)), invoke_(true) {} + + JKQTPFinalAct(JKQTPFinalAct&& other) noexcept + : f_(std::move(other.f_)), + invoke_(other.invoke_) + { + other.invoke_ = false; + } + + JKQTPFinalAct(const JKQTPFinalAct&) = delete; + JKQTPFinalAct& operator=(const JKQTPFinalAct&) = delete; + + ~JKQTPFinalAct() noexcept + { + if (invoke_) f_(); + } + +private: + F f_; + bool invoke_; +}; + +/** \brief C++11 finally construct + * \ingroup jkqtptools + * \see JKQTPFinalAct + */ +template +inline JKQTPFinalAct JKQTPFinally(const F& f) noexcept +{ + return JKQTPFinalAct(f); +} + +/** \brief C++11 finally construct + * \ingroup jkqtptools + * \see JKQTPFinalAct + */ +template +inline JKQTPFinalAct JKQTPFinally(F&& f) noexcept +{ + return JKQTPFinalAct(std::forward(f)); +} /** \brief check whether the dlotaing point number is OK (i.e. non-inf, non-NAN) * \ingroup jkqtptools @@ -87,7 +136,111 @@ inline bool JKQTPIsOKFloat(T v) { return std::isfinite(v)&&(!std::isinf(v))&&(!std::isnan(v)); } +/** \brief Availble action this JKQtPlotter can perform when mouse events occur. + * This allows you to e.g. draw rectangles or lines over the plot and receive a signal, when the drawing finishes + * \ingroup jkqtptools + */ +enum JKQTPMouseDragActions { + jkqtpmdaPanPlotOnMove=0, /*!< \brief the user can drag the current plot window while keeping the left mouse-button pushed down (=panning), the new widow is applied/displayed whenever the mouse moves \image html drag_viewport.gif "Drag the Plot Viewport" */ + jkqtpmdaPanPlotOnRelease, /*!< \brief the user can drag the current plot window while keeping the left mouse-button pushed down (=panning), the new widow is applied/displayed when the left mouse button is released */ + jkqtpmdaZoomByRectangle, /*!< \brief draw a rectangle and when finish zoom to that rectangle */ + jkqtpmdaDrawRectangleForEvent, /*!< \brief draw a rectangle and when finished execute the signal JKQTPlotter::userRectangleFinished() \image html draw_rectangle.gif "Draw Rectangle User-Action" */ + jkqtpmdaDrawCircleForEvent, /*!< \brief draw a circle and when finished execute the signal JKQTPlotter::userCircleFinished() \image html draw_circle.gif "Draw Circle User-Action" */ + jkqtpmdaDrawEllipseForEvent, /*!< \brief draw an ellipse and when finished execute the signal JKQTPlotter::userEllipseFinished() \image html draw_ellipse.gif "Draw Ellipse User-Action" */ + jkqtpmdaDrawLineForEvent, /*!< \brief draw a line and when finished execute the signal JKQTPlotter::userLineFinished() \image html draw_line.gif "Draw Lines User-Action" */ + jkqtpmdaScribbleForEvents, /*!< \brief let the user scribble on the plot (left mouse button is kept pressed) and call JKQTPlotter::userScribbleClick() for each new position */ +}; + +/** \brief convert a JKQTPMouseDragActions to a QString + * \ingroup jkqtptools + * + * \see String2JKQTPMouseDragActions(), JKQTPMouseDragActions + */ +JKQTP_LIB_EXPORT QString JKQTPMouseDragActions2String(JKQTPMouseDragActions act); +/** \brief convert a QString (created by JKQTPMouseDragActions2String() ) to JKQTPMouseDragActions + * \ingroup jkqtptools + * + * \see JKQTPMouseDragActions2String(), JKQTPMouseDragActions + */ +JKQTP_LIB_EXPORT JKQTPMouseDragActions String2JKQTPMouseDragActions(const QString &button); + +/** \brief actions that can be bound to a double-click of the mouse + * \ingroup jkqtptools + */ +enum JKQTPMouseDoubleClickActions { + jkqtpdcaClickZoomsIn=0, /*!< \brief a double-click zooms into the plot at the current mouse location */ + jkqtpdcaClickZoomsOut, /*!< \brief a double-click zooms out of the plot at the current mouse location */ + jkqtpdcaClickOpensContextMenu, /*!< \brief a double-click opens the context menu */ + jkqtpdcaClickOpensSpecialContextMenu, /*!< \brief a double-click opens the special context menu \see setSpecialContextMenu() */ + jkqtpdcaClickMovesViewport, /*!< \brief a double-click centers the x/y-range around the clicked position */ +}; + +/** \brief convert a JKQTPMouseDoubleClickActions to a QString + * \ingroup jkqtptools + * + * \see String2JKQTPMouseDoubleClickActions(), JKQTPMouseDoubleClickActions + */ +JKQTP_LIB_EXPORT QString JKQTPMouseDoubleClickActions2String(JKQTPMouseDoubleClickActions act); +/** \brief convert a QString (created by JKQTPMouseDoubleClickActions2String() ) to JKQTPMouseDoubleClickActions + * \ingroup jkqtptools + * + * \see JKQTPMouseDoubleClickActions2String(), JKQTPMouseDoubleClickActions + */ +JKQTP_LIB_EXPORT JKQTPMouseDoubleClickActions String2JKQTPMouseDoubleClickActions(const QString &act); + +/** \brief actions that can be bound to a mouse wheel event + * \ingroup jkqtptools + */ +enum JKQTPMouseWheelActions { + jkqtpmwaZoomByWheel=0, /*!< \brief use the mouse-wheel for zooming */ + jkqtpmwaPanByWheel, /*!< \brief use the mouse-wheel for panning the plot */ +}; + +/** \brief convert a JKQTPMouseWheelActions to a QString + * \ingroup jkqtptools + * + * \see String2JKQTPMouseWheelActions(), JKQTPMouseWheelActions + */ +JKQTP_LIB_EXPORT QString JKQTPMouseWheelActions2String(JKQTPMouseWheelActions act); +/** \brief convert a QString (created by JKQTPMouseWheelActions2String() ) to JKQTPMouseWheelActions + * \ingroup jkqtptools + * + * \see JKQTPMouseWheelActions2String(), JKQTPMouseWheelActions + */ +JKQTP_LIB_EXPORT JKQTPMouseWheelActions String2JKQTPMouseWheelActions(const QString &act); + +/** \brief modes for the context menu + * \ingroup jkqtptools + */ +enum JKQTPContextMenuModes { + jkqtpcmmStandardContextMenu=0, /*!< \brief only show the standard context menu \image html zoomin_mouse_contextmenu.gif "Zooming with the mouse" */ + jkqtpcmmSpecialContextMenu, /*!< \brief only show the special context menu \see setSpecialContextMenu() */ + jkqtpcmmStandardAndSpecialContextMenu, /*!< \brief show the standard context menu, with the special context menu incorporated \see setSpecialContextMenu() */ + jkqtpcmmNoContextMenu, /*!< \brief don't show a context menu at all */ +}; + +/** \brief convert a JKQTPContextMenuModes to a QString + * \ingroup jkqtptools + * + * \see String2JKQTPContextMenuModes(), JKQTPContextMenuModes + */ +JKQTP_LIB_EXPORT QString JKQTPContextMenuModes2String(JKQTPContextMenuModes act); +/** \brief convert a QString (created by JKQTPContextMenuModes2String() ) to JKQTPContextMenuModes + * \ingroup jkqtptools + * + * \see JKQTPContextMenuModes2String(), JKQTPContextMenuModes + */ +JKQTP_LIB_EXPORT JKQTPContextMenuModes String2JKQTPContextMenuModes(const QString &act); + +typedef QHash, JKQTPMouseDragActions> JKQTPMouseDragActionsHashMap; +typedef JKQTPMouseDragActionsHashMap::const_iterator JKQTPMouseDragActionsHashMapIterator; + +typedef QHash JKQTPMouseWheelActionsHashMap; +typedef JKQTPMouseWheelActionsHashMap::const_iterator JKQTPMouseWheelActionsHashMapIterator; + +typedef QHash, JKQTPMouseDoubleClickActions> JKQTPMouseDoubleClickActionsHashMap; +typedef JKQTPMouseDoubleClickActionsHashMap::const_iterator JKQTPMouseDoubleClickActionsHashMapIterator; /** \brief converts a QT::PenStyle into a string * \ingroup jkqtptools @@ -110,17 +263,81 @@ JKQTP_LIB_EXPORT Qt::BrushStyle jkqtp_String2QBrushStyle(const QString& style); +/** \brief Specifies how a fill-color is derived from a given color + * \ingroup jkqtptools + + */ +enum JKQTPColorDerivationMode { + JKQTPFFCMSameColor, /*!< \brief fill with the same color */ + JKQTPFFCMInvertedColor, /*!< \brief fill with the inverted color */ + JKQTPFFCMLighterColor, /*!< \brief fill with the a lighter color */ + JKQTPFFCMEvenLighterColor, /*!< \brief fill with the an even lighter color than JKQTPFFCMLighterColor */ + JKQTPFFCMDarkerColor, /*!< \brief fill with the a darker color */ + JKQTPFFCMEvenDarkerColor, /*!< \brief fill with the an even darker color than JKQTPFFCMDarkerColor */ + JKQTPFFCMMoreTransparentColor, /*!< \brief fill with the a partly transparent color */ + JKQTPFFCMEvenMoreTransparentColor, /*!< \brief fill with the a more transparent color than JKQTPFFCMMoreTransparentColor */ + JKQTPFFCMLessTransparentColor, /*!< \brief fill with the a partly transparent color */ + JKQTPFFCMEvenLessTransparentColor, /*!< \brief fill with the a more transparent color than JKQTPFFCMLessTransparentColor*/ +}; + +/** \brief use a JKQTPColorDerivationMode to derive a color from \a col as specified + * \ingroup jkqtptools + * + * \see JKQTPColorDerivationMode + */ +JKQTP_LIB_EXPORT QColor JKQTPGetDerivedColor(JKQTPColorDerivationMode mode, const QColor& col); + +/** \brief convert a JKQTPColorDerivationMode to a QString + * \ingroup jkqtptools + * + * \see String2JKQTPColorDerivationMode(), JKQTPColorDerivationMode + */ +JKQTP_LIB_EXPORT QString JKQTPColorDerivationMode2String(JKQTPColorDerivationMode mode); +/** \brief convert a QString (created by JKQTPColorDerivationMode2String() ) to JKQTPColorDerivationMode + * \ingroup jkqtptools + * + * \see JKQTPColorDerivationMode2String(), JKQTPColorDerivationMode + */ +JKQTP_LIB_EXPORT JKQTPColorDerivationMode String2JKQTPColorDerivationMode(const QString &mode); + /** \brief display mode for an axis * \ingroup jkqtptools */ enum JKQTPCADrawMode { JKQTPCADMcomplete=0, /*!< \brief draw axis with ticks, ticklabels and axis label */ - JKQTPCADMticksAndLabels, /*!< \brief draw axis with ticks and tick labels */ - JKQTPCADMticks, /*!< \brief draw axis with ticks */ - JKQTPCADMline, /*!< \brief draw axis as thick line */ + JKQTPCADMLineTicksTickLabels, /*!< \brief draw axis with ticks, line and tick labels */ + JKQTPCADMLineTicks, /*!< \brief draw axis with ticks and line */ + JKQTPCADMLine, /*!< \brief draw axis as thick line */ + JKQTPCADMTicksTickLabelsAxisLabel, /*!< \brief draw axis with ticks, tick labels and axisLabel */ + JKQTPCADMTicksTickLabels, /*!< \brief draw axis with ticks and tick labels */ + JKQTPCADMTickLabelsAxisLabel, /*!< \brief draw axis tick labels and axisLabel */ + JKQTPCADMTickLabels, /*!< \brief draw axis tick labels */ + JKQTPCADMTicks, /*!< \brief draw axis with ticks */ JKQTPCADMnone /*!< \brief draw no axis */ }; +/** \brief determines whether JKQTPCADrawMode has the line + * \ingroup jkqtptools + */ +JKQTP_LIB_EXPORT bool JKQTPCADrawModeHasLine(JKQTPCADrawMode pos); + +/** \brief determines whether JKQTPCADrawMode has ticks + * \ingroup jkqtptools + */ +JKQTP_LIB_EXPORT bool JKQTPCADrawModeHasTicks(JKQTPCADrawMode pos); + +/** \brief determines whether JKQTPCADrawMode has tick labels + * \ingroup jkqtptools + */ +JKQTP_LIB_EXPORT bool JKQTPCADrawModeHasTickLabels(JKQTPCADrawMode pos); + +/** \brief determines whether JKQTPCADrawMode has the axis label + * \ingroup jkqtptools + */ +JKQTP_LIB_EXPORT bool JKQTPCADrawModeHasAxisLabel(JKQTPCADrawMode pos); + + + /** \brief converts a JKQTPCADrawMode variable into a human-readable string * \ingroup jkqtptools */ @@ -179,8 +396,8 @@ JKQTP_LIB_EXPORT JKQTPCALabelType String2JKQTPCALabelType(const QString& pos); */ enum JKQTPLabelPosition { JKQTPLabelMin=0, /*!< \brief the axis label is near the min value of the axis (left/bottom) */ - JKQTPLabelMax, /*!< \brief the axis label is near the max value of the axis (right/top) */ - JKQTPLabelCenter /*!< \brief the label is at the center of the axis */ + JKQTPLabelMax, /*!< \brief the axis label is near the max value of the axis (right/top) */ + JKQTPLabelCenter /*!< \brief the label is at the center of the axis */ }; @@ -259,19 +476,6 @@ struct JKQTPGridPrintingItem { }; -/** - * \brief saves the given property (for which also a default_property exists) into the given settings object - * \ingroup jkqtptools - */ -#define JKQTPPROPERTYsave(settings, group, var, varname) \ - if (var!=default_##var) settings.setValue(group+varname, var); -/** - * \brief loads the given property from the given settings object - * \ingroup jkqtptools - */ -#define JKQTPPROPERTYload(settings, group, var, varname, varconvert) \ - var=settings.value(group+varname, var).varconvert; - /** \brief plot styles for the error information * \ingroup jkqtptools @@ -307,15 +511,15 @@ JKQTP_LIB_EXPORT JKQTPErrorPlotstyle String2JKQTPErrorPlotstyle(const QString& p * \ingroup jkqtptools */ enum JKQTPGraphPlotstyle { - JKQTPLines, /*!< \brief plot y=f(x), connect the datapoints by straight lines */ - JKQTPFilledCurveX, /*!< \brief plot y=f(x), as filled curve (filled until the y=0/x-axis) */ - JKQTPFilledCurveY, /*!< \brief plot x=f(y), as filled curve (filled until the x=0/y-axis) */ - JKQTPPoints, /*!< \brief plot y=f(x), plot each datapoint with a symbol */ - JKQTPLinesPoints, /*!< \brief plot y=f(x), plot each datapoint with a symbol and connect them by straight lines */ - JKQTPImpulsesHorizontal, /*!< \brief plot y=f(x), plot each datapoint as a line from (x,0) to (x,f(x)) */ - JKQTPImpulsesVertical, /*!< \brief plot x=f(y), plot each datapoint as a line from (0,f(x)) to (x,f(x)) */ - JKQTPStepsX, /*!< \brief plot y=f(x), as a step curve */ - JKQTPStepsY /*!< \brief plot x=f(y), as a step curve */ + JKQTPLines, /*!< \brief plot y=f(x), connect the datapoints by straight lines */ + JKQTPFilledCurveX, /*!< \brief plot y=f(x), as filled curve (filled until the y=0/x-axis) */ + JKQTPFilledCurveY, /*!< \brief plot x=f(y), as filled curve (filled until the x=0/y-axis) */ + JKQTPPoints, /*!< \brief plot y=f(x), plot each datapoint with a symbol */ + JKQTPLinesPoints, /*!< \brief plot y=f(x), plot each datapoint with a symbol and connect them by straight lines */ + JKQTPImpulsesHorizontal, /*!< \brief plot y=f(x), plot each datapoint as a line from (x,0) to (x,f(x)) */ + JKQTPImpulsesVertical, /*!< \brief plot x=f(y), plot each datapoint as a line from (0,f(x)) to (x,f(x)) */ + JKQTPStepsX, /*!< \brief plot y=f(x), as a step curve */ + JKQTPStepsY /*!< \brief plot x=f(y), as a step curve */ }; /** \brief symbols that can be used to plot a datapoint for a graph @@ -565,17 +769,28 @@ JKQTP_LIB_EXPORT std::string jkqtp_booltostr(bool data); * \ingroup jkqtptools_string * * This returns a QString which contains the name of named colors and the RGBA values in a QT readable form othertwise. + * + * \param r red value of the color to convert + * \param g green value of the color to convert + * \param b blue value of the color to convert + * \param a alpha value of the color to convert + * \param useSpecialTransparencySyntax is set (\c true ), the function uses a special syntax to denote color and transparency: \c color,trans */ -JKQTP_LIB_EXPORT std::string jkqtp_rgbtostring(unsigned char r, unsigned char g, unsigned char b, unsigned char a=255); +JKQTP_LIB_EXPORT QString jkqtp_rgbtostring(unsigned char r, unsigned char g, unsigned char b, unsigned char a=255, bool useSpecialTransparencySyntax=true); /** \brief converts a QColor into a string using the jkqtp_rgbtostring() method. * \ingroup jkqtptools_string * * This returns a QString which contains the name of named colors and the RGBA values in a QT readable form othertwise. */ -inline QString jkqtp_QColor2String(QColor color) { - return QString(jkqtp_rgbtostring(static_cast((color).red()), static_cast((color).green()), static_cast((color).blue()), static_cast((color).alpha())).c_str()); -} +JKQTP_LIB_EXPORT QString jkqtp_QColor2String(QColor color, bool useSpecialTransparencySyntax=true); + +/** \brief converts a QString into a QColor, compatible with jkqtp_QColor2String(QColor color); + * \ingroup jkqtptools_string + * + * This returns a QString which contains the name of named colors and the RGBA values in a QT readable form othertwise. + */ +JKQTP_LIB_EXPORT QColor jkqtp_String2QColor(const QString& color); /** \brief clean a string to be usable as a variable name, e.g. in an expression parser, or a C++-expression * \ingroup jkqtptools_string diff --git a/lib/jkqtplottertools/jkqttools.cpp b/lib/jkqtplottertools/jkqttools.cpp index 32c1954d21..cdf0d07c6e 100644 --- a/lib/jkqtplottertools/jkqttools.cpp +++ b/lib/jkqtplottertools/jkqttools.cpp @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -120,3 +120,110 @@ QString jkqtp_toValidVariableName(const QString& input) { } return out; } + +QString jkqtp_KeyboardModifiers2String(Qt::KeyboardModifiers modifiers, bool useNONE) +{ + if (modifiers==Qt::NoModifier) { + if (useNONE) return "NONE"; + else return ""; + } + QString ret=""; + auto append=[](QString& ret, const QString & appending, const QString& separator="+") { + if (appending.size()<=0) return; + if (ret.size()>0) ret+=separator; + ret+=appending; + }; + if ((modifiers&Qt::ShiftModifier)==Qt::ShiftModifier) append(ret, "SHIFT", "+"); + if ((modifiers&Qt::ControlModifier)==Qt::ControlModifier) append(ret, "CTRL", "+"); + if ((modifiers&Qt::AltModifier)==Qt::AltModifier) append(ret, "ALT", "+"); + if ((modifiers&Qt::MetaModifier)==Qt::MetaModifier) append(ret, "META", "+"); + if ((modifiers&Qt::KeypadModifier)==Qt::KeypadModifier) append(ret, "KEYPAD", "+"); + if ((modifiers&Qt::GroupSwitchModifier)==Qt::GroupSwitchModifier) append(ret, "GROUP", "+"); + return ret; +} + +Qt::KeyboardModifiers jkqtp_String2KeyboardModifiers(const QString &modifiers) +{ + auto mods=modifiers.toUpper().split("+"); + Qt::KeyboardModifiers ret=Qt::NoModifier; + + for (const auto& m: mods) { + if (m.trimmed()=="SHIFT") ret |= Qt::ShiftModifier; + else if (m.trimmed()=="CTRL") ret |= Qt::ControlModifier; + else if (m.trimmed()=="ALT") ret |= Qt::AltModifier; + else if (m.trimmed()=="META") ret |= Qt::MetaModifier; + else if (m.trimmed()=="KEYPAD") ret |= Qt::KeypadModifier; + else if (m.trimmed()=="GROUP") ret |= Qt::GroupSwitchModifier; + } + + return ret; +} + +QString jkqtp_MouseButton2String(Qt::MouseButton button, bool useNONE) +{ + if (button==Qt::NoButton) { + if (useNONE) return "NONE"; + else return ""; + } + if (button==Qt::LeftButton) return "LEFT"; + if (button==Qt::RightButton) return "RIGHT"; + if (button==Qt::MidButton) return "MIDDLE"; + if (button==Qt::BackButton) return "BACK"; + if (button==Qt::ForwardButton) return "FORWARD"; + if (button==Qt::TaskButton) return "TASK"; + if (button==Qt::ExtraButton4) return "EXTRA4"; + if (button==Qt::ExtraButton5) return "EXTRA5"; + if (button==Qt::ExtraButton6) return "EXTRA6"; + if (button==Qt::ExtraButton7) return "EXTRA7"; + if (button==Qt::ExtraButton8) return "EXTRA8"; + if (button==Qt::ExtraButton9) return "EXTRA9"; + if (button==Qt::ExtraButton10) return "EXTRA10"; + if (button==Qt::ExtraButton11) return "EXTRA11"; + if (button==Qt::ExtraButton12) return "EXTRA12"; + if (button==Qt::ExtraButton13) return "EXTRA13"; + if (button==Qt::ExtraButton14) return "EXTRA14"; + if (button==Qt::ExtraButton15) return "EXTRA15"; + if (button==Qt::ExtraButton16) return "EXTRA16"; + if (button==Qt::ExtraButton17) return "EXTRA17"; + if (button==Qt::ExtraButton18) return "EXTRA18"; + if (button==Qt::ExtraButton19) return "EXTRA19"; + if (button==Qt::ExtraButton20) return "EXTRA20"; + if (button==Qt::ExtraButton21) return "EXTRA21"; + if (button==Qt::ExtraButton22) return "EXTRA22"; + if (button==Qt::ExtraButton23) return "EXTRA23"; + if (button==Qt::ExtraButton24) return "EXTRA24"; + return "UNKNOWN"; +} + +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 (but=="MIDDLE") return Qt::MidButton; + if (but=="BACK") return Qt::BackButton; + if (but=="FORWARD") return Qt::ForwardButton; + if (but=="TASK") return Qt::TaskButton; + if (but=="EXTRA4") return Qt::ExtraButton4; + if (but=="EXTRA5") return Qt::ExtraButton5; + if (but=="EXTRA6") return Qt::ExtraButton6; + if (but=="EXTRA7") return Qt::ExtraButton7; + if (but=="EXTRA8") return Qt::ExtraButton8; + if (but=="EXTRA9") return Qt::ExtraButton9; + if (but=="EXTRA10") return Qt::ExtraButton10; + if (but=="EXTRA11") return Qt::ExtraButton11; + if (but=="EXTRA12") return Qt::ExtraButton12; + if (but=="EXTRA13") return Qt::ExtraButton13; + if (but=="EXTRA14") return Qt::ExtraButton14; + if (but=="EXTRA15") return Qt::ExtraButton15; + if (but=="EXTRA16") return Qt::ExtraButton16; + if (but=="EXTRA17") return Qt::ExtraButton17; + if (but=="EXTRA18") return Qt::ExtraButton18; + if (but=="EXTRA19") return Qt::ExtraButton19; + if (but=="EXTRA20") return Qt::ExtraButton20; + if (but=="EXTRA21") return Qt::ExtraButton21; + if (but=="EXTRA22") return Qt::ExtraButton22; + if (but=="EXTRA23") return Qt::ExtraButton23; + if (but=="EXTRA24") return Qt::ExtraButton24; + return Qt::NoButton; +} diff --git a/lib/jkqtplottertools/jkqttools.h b/lib/jkqtplottertools/jkqttools.h index 9474ebfe02..0651e6f1a8 100644 --- a/lib/jkqtplottertools/jkqttools.h +++ b/lib/jkqtplottertools/jkqttools.h @@ -5,7 +5,7 @@ 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 of the License, or + 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, @@ -100,6 +100,40 @@ JKQTP_LIB_EXPORT QString jkVariantListToString(const QList& data, cons JKQTP_LIB_EXPORT QString jkqtp_filenameize(const QString& data); /** \brief create a valid variable name from the string, i.e. a string with only characters and digits and \c '_'. ALso the first character has to be a charcter. - \ingroup tools */ + * \ingroup tools */ JKQTP_LIB_EXPORT QString jkqtp_toValidVariableName(const QString& input); + +/** \brief convert a Qt::KeyboardModifiers to a QString + * \ingroup tools + * + * \param modifiers the object to convert + * \param useNONE if \c true the function will return \C "NONE" if \c modifiers==Qt::NoMofifiers. Otherwise the function will return an empty string ( jkqtp_String2KeyboardModifiers() can cope with both variants) + * + * \see jkqtp_String2KeyboardModifiers() + */ +JKQTP_LIB_EXPORT QString jkqtp_KeyboardModifiers2String(Qt::KeyboardModifiers modifiers, bool useNONE=true); + +/** \brief convert a QString (created by jkqtp_KeyboardModifiers2String() ) to Qt::KeyboardModifiers + * \ingroup tools + * + * \see jkqtp_KeyboardModifiers2String() + */ +JKQTP_LIB_EXPORT Qt::KeyboardModifiers jkqtp_String2KeyboardModifiers(const QString& modifiers); +/** \brief convert a Qt::MouseButton to a QString + * \ingroup tools + * + * \param button the object to convert + * \param useNONE if \c true the function will return \C "NONE" if \c button==Qt::NoButton. Otherwise the function will return an empty string ( jkqtp_String2MouseButton() can cope with both variants) + * + * \see jkqtp_MouseButton2String() + */ +JKQTP_LIB_EXPORT QString jkqtp_MouseButton2String(Qt::MouseButton button, bool useNONE=true); +/** \brief convert a QString (created by jkqtp_MouseButton2String() ) to Qt::MouseButton + * \ingroup tools + * + * \see jkqtp_MouseButton2String() + */ +JKQTP_LIB_EXPORT Qt::MouseButton jkqtp_String2MouseButton(const QString &button); + + #endif // JKQTTOOLS_H diff --git a/screenshots/jkqtplotter_fastresizing.gif b/screenshots/jkqtplotter_fastresizing.gif new file mode 100644 index 0000000000..509ef15fe5 Binary files /dev/null and b/screenshots/jkqtplotter_fastresizing.gif differ diff --git a/screenshots/style_blackandwhite.png b/screenshots/style_blackandwhite.png new file mode 100644 index 0000000000..1176f736e3 Binary files /dev/null and b/screenshots/style_blackandwhite.png differ diff --git a/screenshots/style_blueprint.png b/screenshots/style_blueprint.png new file mode 100644 index 0000000000..904c71777e Binary files /dev/null and b/screenshots/style_blueprint.png differ diff --git a/screenshots/style_dark.png b/screenshots/style_dark.png new file mode 100644 index 0000000000..e3952124f5 Binary files /dev/null and b/screenshots/style_dark.png differ diff --git a/screenshots/style_default.png b/screenshots/style_default.png new file mode 100644 index 0000000000..c1b0fe5258 Binary files /dev/null and b/screenshots/style_default.png differ diff --git a/screenshots/style_simple_axesoffset.png b/screenshots/style_simple_axesoffset.png new file mode 100644 index 0000000000..501a9fd8ac Binary files /dev/null and b/screenshots/style_simple_axesoffset.png differ diff --git a/screenshots/style_simple_axesoffset_plotbox.png b/screenshots/style_simple_axesoffset_plotbox.png new file mode 100644 index 0000000000..e4657c72f0 Binary files /dev/null and b/screenshots/style_simple_axesoffset_plotbox.png differ diff --git a/screenshots/style_simple_gridandticks.png b/screenshots/style_simple_gridandticks.png new file mode 100644 index 0000000000..189814d295 Binary files /dev/null and b/screenshots/style_simple_gridandticks.png differ diff --git a/screenshots/stylesbanner.png b/screenshots/stylesbanner.png new file mode 100644 index 0000000000..28e55d0cf5 Binary files /dev/null and b/screenshots/stylesbanner.png differ diff --git a/screenshots/test_styling.png b/screenshots/test_styling.png new file mode 100644 index 0000000000..4ddcf3dca3 Binary files /dev/null and b/screenshots/test_styling.png differ diff --git a/screenshots/test_styling_small.png b/screenshots/test_styling_small.png new file mode 100644 index 0000000000..827751bdb7 Binary files /dev/null and b/screenshots/test_styling_small.png differ diff --git a/sharedlib/README.md b/sharedlib/README.md index ef2986c17a..2eb5bc62f5 100644 --- a/sharedlib/README.md +++ b/sharedlib/README.md @@ -9,7 +9,7 @@ There are several `.PRO`-files, that can be used to build the full library, or a ```.qmake # include JKQTPlotter library -DEPENDPATH += /lib +DEPENDPATH += /lib /sharedlib INCLUDEPATH += /lib CONFIG (debug, debug|release) { # ensure that DLLs are copied to the output directory diff --git a/sharedlib/jkqtfastplotterlib_sharedlib.pro b/sharedlib/jkqtfastplotterlib_sharedlib.pro index 8362a2626f..6744c58027 100644 --- a/sharedlib/jkqtfastplotterlib_sharedlib.pro +++ b/sharedlib/jkqtfastplotterlib_sharedlib.pro @@ -1,3 +1,5 @@ +# uncomment this line to prevent linking in of the XITS fonts +#DEFINES += NO_XITS_FONTS TARGET = jkqtfastplotterlib CONFIG (debug, debug|release): TARGET = jkqtfastplotterlib_debug diff --git a/sharedlib/jkqtmathtextlib_sharedlib.pro b/sharedlib/jkqtmathtextlib_sharedlib.pro index 07e75339cb..385d8542b9 100644 --- a/sharedlib/jkqtmathtextlib_sharedlib.pro +++ b/sharedlib/jkqtmathtextlib_sharedlib.pro @@ -1,3 +1,5 @@ +# uncomment this line to prevent linking in of the XITS fonts +#DEFINES += NO_XITS_FONTS TARGET = jkqtmathtextlib CONFIG (debug, debug|release): TARGET = jkqtmathtextlib_debug diff --git a/sharedlib/jkqtplotterlib_sharedlib.pro b/sharedlib/jkqtplotterlib_sharedlib.pro index 46f7111e8e..62067fdc06 100644 --- a/sharedlib/jkqtplotterlib_sharedlib.pro +++ b/sharedlib/jkqtplotterlib_sharedlib.pro @@ -1,3 +1,5 @@ +# uncomment this line to prevent linking in of the XITS fonts +#DEFINES += NO_XITS_FONTS TARGET = jkqtplotterlib CONFIG (debug, debug|release): TARGET = jkqtplotterlib_debug diff --git a/staticlib/README.md b/staticlib/README.md index 6594f24e20..777670a38a 100644 --- a/staticlib/README.md +++ b/staticlib/README.md @@ -9,7 +9,7 @@ There are several `.PRO`-files, that can be used to build the full library, or a ```.qmake # include JKQTPlotter library -DEPENDPATH += /lib +DEPENDPATH += /staticlib /lib INCLUDEPATH += /lib CONFIG (debug, debug|release) { LIBS += -L/staticlib/debug -ljkqtplotterlib_debug diff --git a/staticlib/jkqtfastplotterlib.pro b/staticlib/jkqtfastplotterlib.pro index f9fd673a08..56ae5b8199 100644 --- a/staticlib/jkqtfastplotterlib.pro +++ b/staticlib/jkqtfastplotterlib.pro @@ -1,3 +1,5 @@ +# uncomment this line to prevent linking in of the XITS fonts +#DEFINES += NO_XITS_FONTS TARGET = jkqtfastplotterlib CONFIG (debug, debug|release): TARGET = jkqtfastplotterlib_debug diff --git a/staticlib/jkqtmathtextlib.pro b/staticlib/jkqtmathtextlib.pro index c7d4ee783d..48e9e85708 100644 --- a/staticlib/jkqtmathtextlib.pro +++ b/staticlib/jkqtmathtextlib.pro @@ -1,3 +1,5 @@ +# uncomment this line to prevent linking in of the XITS fonts +#DEFINES += NO_XITS_FONTS TARGET = jkqtmathtextlib CONFIG (debug, debug|release): TARGET = jkqtmathtextlib_debug diff --git a/staticlib/jkqtplotterlib.pro b/staticlib/jkqtplotterlib.pro index e275a7fa7b..e52c7ce564 100644 --- a/staticlib/jkqtplotterlib.pro +++ b/staticlib/jkqtplotterlib.pro @@ -1,3 +1,5 @@ +# uncomment this line to prevent linking in of the XITS fonts +#DEFINES += NO_XITS_FONTS TARGET = jkqtplotterlib CONFIG (debug, debug|release): TARGET = jkqtplotterlib_debug @@ -5,4 +7,6 @@ TEMPLATE = lib CONFIG += staticlib CONFIG += create_prl +#DEFINES += JKQTBP_AUTOTIMER + include(../lib/jkqtplotter.pri)