diff -Nru qcustomplot-1.1.0/changelog.txt qcustomplot-1.2.0/changelog.txt --- qcustomplot-1.1.0/changelog.txt 2013-11-04 21:49:26.000000000 +0000 +++ qcustomplot-1.2.0/changelog.txt 2014-03-14 21:07:49.000000000 +0000 @@ -1,3 +1,47 @@ +#### Version 1.2.0 released on 14.03.14 #### + + Bugfixes: + - Fixed bug that caused crash if clicked-on legend item is removed in mousePressEvent. + - On some systems, font size defaults to -1, which used to cause a debug output in QCPAxisPainterPrivate::TickLabelDataQCP. Now it's checked before setting values based on the default font size. + - When using multiple axes on one side, setting one to invisible didn't properly compress the freed space. + - Fixed bug that allowed selection of plottables when clicking in the bottom or top margin of a QCPAxisRect (outside the inner rect) + +#### Version 1.2.0-beta released on 28.01.14 #### + + Added features: + - Adaptive Sampling for QCPGraph greatly improves performance for high data densities (see QCPGraph::setAdaptiveSampling) + - QCPColorMap plottable with QCPColorScale layout element allows plotting of 2D color maps + - QCustomPlot::savePdf now has additional optional parameters pdfCreator and pdfTitle to set according PDF metadata fields + - QCustomPlot::replot now allows specifying whether the widget update is immediate (repaint) or queued (update) + - QCPRange operators +, -, *, / with double operand for range shifting and scaling, and ==, != for range comparison + - Layers now have a visibility property (QCPLayer::setVisible) + - static functions QCPAxis::opposite and QCPAxis::orientation now offer more convenience when handling axis types + - added notification signals for selectability change (selectableChanged) on all objects that have a selected/selectable property + - added notification signal for QCPAxis scaleType property + - added notification signal QCPLayerable::layerChanged + + Bugfixes: + - Fixed assert halt, when QCPAxis auto tick labels not disabled but nevertheless a custom non-number tick label ending in "e" given + - Fixed painting glitches when QCustomPlot resized inside a QMdiArea or under certain conditions inside a QLayout + - If changing QCPAxis::scaleType and thus causing range sanitizing and a range modification, rangeChanged wouldn't be emitted + - Fixed documentation bug that caused indentation to be lost in code examples + + Other: + - In method QCPAbstractPlottable::getKeyRange/getValueRange, renamed parameter "validRange" to "foundRange", to better reflect its meaning (and contrast it from QCPRange::validRange) + - QCPAxis low-level axis painting methods exported to QCPAxisPainterPrivate + +#### Version 1.1.1 released on 09.12.13 #### + + Bugfixes: + - Fixed bug causing legends blocking input events from reaching underlying axis rect even if legend is invisible + - Added missing Q_PROPERTY for QCPAxis::setDateTimeSpec + - Fixed behaviour of QCPAxisRect::setupFullAxesBox (now transfers more properties from bottom/left to top/right axes and sets visibility of bottom/left axes to true) + - Made sure PDF export doesn't default to grayscale output on some systems + + Other: + - Plotting hint QCP::phForceRepaint is now enabled on all systems (and not only on windows) by default + - Documentation improvements + #### Version 1.1.0 released on 04.11.13 #### Added features: @@ -177,7 +221,7 @@ - on Windows, a repaint used to be delayed during dragging/zooming of a complex plot, until the drag operation was done. This was fixed, i.e. repaints are forced after a replot() call. See QCP::phForceRepaint and setPlottingHints. - when using the raster paintengine and exporting to scaled PNG, pen widths are now scaled correctly (QPainter bug workaround via QCPPainter) - - PDF export now respects QCustomPlot background color (QCustomPlot::setColor), also Qt::transparent + - PDF export now respects QCustomPlot background color (QCustomPlot::setColor), also Qt::transparent - fixed a bug on QCPBars and QCPStatisticalBox where auto-rescaling of axis would fail when all data is very small (< 1e-11) - fixed mouse event propagation bug that prevented range dragging from working on KDE (GNU/Linux) - fixed a compiler warning on 64-bit systems due to pointer cast to int instead of quintptr in a qDebug output @@ -255,7 +299,7 @@ A simple search and replace on all code files should make your code run again, e.g. consider the regex "QCustomPlot(?=[AGRDL])" -> "QCP". Make sure not to just replace "QCustomPlot" with "QCP" because the main class QCustomPlot hasn't changed to QCP. This change was necessary because class names became unhandy, pardon my bad naming decision in the beginning. - - QCPAxis::tickLength() and QCPAxis::subTickLength() now each split into two functions for inward and outward ticks (tickLengthIn/tickLengthOut). + - QCPAxis::tickLength() and QCPAxis::subTickLength() now each split into two functions for inward and outward ticks (tickLengthIn/tickLengthOut). - QCPLegend now uses QCPAbstractLegendItem to carry item data (before, the legend was passed QCPGraphs directly) - QCustomPlot::addGraph() now doesn't return the index of the created graph anymore, but a pointer to the created QCPGraph. - QCustomPlot::setAutoAddGraphToLegend is replaced by setAutoAddPlottableToLegend @@ -278,7 +322,7 @@ Bugfixes: - Fixed QCustomPlot::removeGraph(int) not being able to remove graph index 0 - made QCustomPlot::replot() abort painting when painter initialization fails (e.g. because width/height of QCustomPlot is zero) - - The distance of the axis label from the axis ignored the tick label padding, this could have caused overlapping axis labels and tick labels + - The distance of the axis label from the axis ignored the tick label padding, this could have caused overlapping axis labels and tick labels - fixed memory leak in QCustomPlot (dtor didn't delete legend) - fixed bug that prevented QCPAxis::setRangeLower/Upper from setting the value to exactly 0. diff -Nru qcustomplot-1.1.0/debian/changelog qcustomplot-1.2.0/debian/changelog --- qcustomplot-1.1.0/debian/changelog 2013-11-08 17:12:36.000000000 +0000 +++ qcustomplot-1.2.0/debian/changelog 2014-04-08 12:07:19.000000000 +0000 @@ -1,3 +1,13 @@ +qcustomplot (1.2.0-1~trusty1) trusty; urgency=medium + + * [b820dfc] Imported Upstream version 1.2.0 + * [d6daa9b] Refresh cmake-patch. + Use qt5 for building the library. + * [af0b882] Update so-number. + * [f1912e1] Ignore quilt dir + + -- Anton Gladky Thu, 03 Apr 2014 22:35:45 +0200 + qcustomplot (1.1.0-1) unstable; urgency=low * Initial packaging. (Closes: #729075). diff -Nru qcustomplot-1.1.0/debian/control qcustomplot-1.2.0/debian/control --- qcustomplot-1.1.0/debian/control 2013-11-08 17:30:12.000000000 +0000 +++ qcustomplot-1.2.0/debian/control 2014-04-03 19:34:37.000000000 +0000 @@ -4,15 +4,15 @@ Maintainer: Debian Science Maintainers Uploaders: Anton Gladky Homepage: http://www.qcustomplot.com -Standards-Version: 3.9.4 -Build-Depends: cmake, debhelper (>= 9), libqt4-dev +Standards-Version: 3.9.5 +Build-Depends: cmake, debhelper (>= 9), qt5-default Vcs-Git: git://anonscm.debian.org/debian-science/packages/qcustomplot.git Vcs-Browser: http://anonscm.debian.org/gitweb/?p=debian-science/packages/qcustomplot.git Package: libqcustomplot-dev Section: libdevel Architecture: any -Depends: libqcustomplot1.1 (= ${binary:Version}), libqt4-dev, ${misc:Depends} +Depends: libqcustomplot1.2 (= ${binary:Version}), qt5-default, ${misc:Depends} Conflicts: libqcustomplot-dev Description: Qt C++ widget for plotting. Header QCustomPlot plotting library focuses on making good looking, publication @@ -29,7 +29,7 @@ realtime visualization applications. The package contains examples and documentation. -Package: libqcustomplot1.1 +Package: libqcustomplot1.2 Architecture: any Multi-Arch: same Pre-Depends: ${misc:Pre-Depends} @@ -39,13 +39,13 @@ quality 2D plots, graphs and charts, as well as offering high performance for realtime visualization applications. -Package: libqcustomplot1.1-dbg +Package: libqcustomplot1.2-dbg Architecture: any Section: debug Priority: extra Multi-Arch: same Pre-Depends: ${misc:Pre-Depends} -Depends: libqcustomplot1.1 (= ${binary:Version}), +Depends: libqcustomplot1.2 (= ${binary:Version}), ${misc:Depends}, ${shlibs:Depends} Description: Qt C++ widget for plotting. Debugging symbols diff -Nru qcustomplot-1.1.0/debian/libqcustomplot1.1.install qcustomplot-1.2.0/debian/libqcustomplot1.1.install --- qcustomplot-1.1.0/debian/libqcustomplot1.1.install 2013-11-08 17:30:12.000000000 +0000 +++ qcustomplot-1.2.0/debian/libqcustomplot1.1.install 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -usr/lib/*/libqcustomplot.so.* diff -Nru qcustomplot-1.1.0/debian/libqcustomplot1.2.install qcustomplot-1.2.0/debian/libqcustomplot1.2.install --- qcustomplot-1.1.0/debian/libqcustomplot1.2.install 1970-01-01 00:00:00.000000000 +0000 +++ qcustomplot-1.2.0/debian/libqcustomplot1.2.install 2014-04-03 19:14:11.000000000 +0000 @@ -0,0 +1 @@ +usr/lib/*/libqcustomplot.so.* diff -Nru qcustomplot-1.1.0/debian/patches/01_Add_CMakeLists.patch qcustomplot-1.2.0/debian/patches/01_Add_CMakeLists.patch --- qcustomplot-1.1.0/debian/patches/01_Add_CMakeLists.patch 2013-11-08 14:27:38.000000000 +0000 +++ qcustomplot-1.2.0/debian/patches/01_Add_CMakeLists.patch 2014-04-03 20:27:39.000000000 +0000 @@ -1,36 +1,35 @@ Description: Add CMakeLists files for building of shared library and to examples Author: Anton Gladky -Last-Update: 2013-11-08 +Last-Update: 2014-04-03 --- /dev/null +++ b/CMakeLists.txt -@@ -0,0 +1,30 @@ +@@ -0,0 +1,29 @@ +PROJECT(qcustomplot CXX) +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +SET(Q_MAJOR_VERSION "1") -+SET(Q_MINOR_VERSION "1") ++SET(Q_MINOR_VERSION "2") +SET(Q_PATCH_VERSION "0") + -+ +INCLUDE(GNUInstallDirs) -+INCLUDE(FindQt4) -+FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui REQUIRED) -+INCLUDE_DIRECTORIES(${QT_INCLUDES}) -+INCLUDE(${QT_USE_FILE}) ++FIND_PACKAGE(Qt5Widgets REQUIRED) ++FIND_PACKAGE(Qt5PrintSupport REQUIRED) ++INCLUDE_DIRECTORIES(${Qt5Widgets_INCLUDE_DIRS} /usr/include/qt5/QtPrintSupport) ++ADD_DEFINITIONS(${Qt5Widgets_DEFINITIONS} -DQCUSTOMPLOT_COMPILE_LIBRARY) ++SET(CMAKE_AUTOMOC ON) ++ + +set(Q_VERSION "${Q_MAJOR_VERSION}.${Q_MINOR_VERSION}.${Q_PATCH_VERSION}") +set(Q_SOVERSION "${Q_MAJOR_VERSION}.${Q_MINOR_VERSION}") + -+ -+QT4_WRAP_CPP(Q_MOC_OUTFILES qcustomplot.h) -+ -+ADD_LIBRARY(qcustomplot SHARED qcustomplot.cpp ${Q_MOC_OUTFILES}) ++ADD_LIBRARY(qcustomplot SHARED qcustomplot.cpp) ++QT5_USE_MODULES(qcustomplot Widgets) + +SET_TARGET_PROPERTIES(qcustomplot PROPERTIES + VERSION ${Q_VERSION} + SOVERSION ${Q_SOVERSION}) -+TARGET_LINK_LIBRARIES(qcustomplot ${QT_LIBRARIES}) ++TARGET_LINK_LIBRARIES(qcustomplot ${Qt5Widgets_LIBRARIES} Qt5::PrintSupport) + +INSTALL(TARGETS qcustomplot DESTINATION "${CMAKE_INSTALL_LIBDIR}") +INSTALL(FILES qcustomplot.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") @@ -59,105 +58,93 @@ +FIND_PACKAGE_HANDLE_STANDARD_ARGS(QCustomPlot DEFAULT_MSG QCustomPlot_INCLUDE_DIR QCustomPlot_LIBRARIES) --- /dev/null +++ b/examples/interactions/CMakeLists.txt -@@ -0,0 +1,23 @@ +@@ -0,0 +1,20 @@ +project(interactions CXX) +cmake_minimum_required(VERSION 2.8) + ++FIND_PACKAGE(QCustomPlot REQUIRED) ++FIND_PACKAGE(Qt5PrintSupport REQUIRED) +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cMake") + +INCLUDE(GNUInstallDirs) ++FIND_PACKAGE(Qt5Widgets REQUIRED) ++INCLUDE_DIRECTORIES(${Qt5Widgets_INCLUDE_DIRS}) ++INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${QCustomPlot_INCLUDE_DIR}) ++ADD_DEFINITIONS(${Qt5Widgets_DEFINITIONS} -DQCUSTOMPLOT_USE_LIBRARY) ++SET(CMAKE_AUTOMOC ON) ++ ++QT5_WRAP_UI(UI_HEADERS mainwindow.ui) ++ADD_EXECUTABLE(interactions main.cpp mainwindow.cpp ${UI_HEADERS}) ++QT5_USE_MODULES(interactions Widgets) + -+ -+FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui REQUIRED) -+FIND_PACKAGE(QCustomPlot REQUIRED) -+ -+INCLUDE_DIRECTORIES(${QT_INCLUDES}) -+INCLUDE_DIRECTORIES(${QCustomPlot_INCLUDE_DIR}) -+INCLUDE(${QT_USE_FILE}) -+ -+QT4_WRAP_CPP(TEST_MOC_OUTFILES mainwindow.h) -+QT4_WRAP_UI(TEST_FORMS_HEADERS mainwindow.ui) -+ -+ADD_EXECUTABLE(interactions main.cpp mainwindow.cpp ${TEST_MOC_OUTFILES} ${TEST_FORMS_HEADERS} ${TEST_MOC_OUTFILES}) -+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) -+ -+TARGET_LINK_LIBRARIES(interactions ${QT_LIBRARIES} ${QCustomPlot_LIBRARIES}) ++TARGET_LINK_LIBRARIES(interactions ${Qt5Widgets_LIBRARIES} ${QCustomPlot_LIBRARIES} Qt5::PrintSupport) +INSTALL(TARGETS interactions DESTINATION ${CMAKE_INSTALL_BINDIR}) --- /dev/null +++ b/examples/plots/CMakeLists.txt -@@ -0,0 +1,23 @@ +@@ -0,0 +1,20 @@ +project(plots CXX) +cmake_minimum_required(VERSION 2.8) + ++FIND_PACKAGE(QCustomPlot REQUIRED) ++FIND_PACKAGE(Qt5PrintSupport REQUIRED) +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cMake") + +INCLUDE(GNUInstallDirs) ++FIND_PACKAGE(Qt5Widgets REQUIRED) ++INCLUDE_DIRECTORIES(${Qt5Widgets_INCLUDE_DIRS}) ++INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${QCustomPlot_INCLUDE_DIR}) ++ADD_DEFINITIONS(${Qt5Widgets_DEFINITIONS} -DQCUSTOMPLOT_USE_LIBRARY) ++SET(CMAKE_AUTOMOC ON) ++ ++QT5_WRAP_UI(UI_HEADERS mainwindow.ui) ++ADD_EXECUTABLE(plots main.cpp mainwindow.cpp ${UI_HEADERS}) ++QT5_USE_MODULES(plots Widgets) + -+ -+FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui REQUIRED) -+FIND_PACKAGE(QCustomPlot REQUIRED) -+ -+INCLUDE_DIRECTORIES(${QT_INCLUDES}) -+INCLUDE_DIRECTORIES(${QCustomPlot_INCLUDE_DIR}) -+INCLUDE(${QT_USE_FILE}) -+ -+QT4_WRAP_CPP(TEST_MOC_OUTFILES mainwindow.h) -+QT4_WRAP_UI(TEST_FORMS_HEADERS mainwindow.ui) -+ -+ADD_EXECUTABLE(plots main.cpp mainwindow.cpp ${TEST_MOC_OUTFILES} ${TEST_FORMS_HEADERS} ${TEST_MOC_OUTFILES}) -+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) -+ -+TARGET_LINK_LIBRARIES(plots ${QT_LIBRARIES} ${QCustomPlot_LIBRARIES}) ++TARGET_LINK_LIBRARIES(plots ${Qt5Widgets_LIBRARIES} ${QCustomPlot_LIBRARIES} Qt5::PrintSupport) +INSTALL(TARGETS plots DESTINATION ${CMAKE_INSTALL_BINDIR}) --- /dev/null +++ b/examples/scrollbar-axis-range-control/CMakeLists.txt -@@ -0,0 +1,23 @@ +@@ -0,0 +1,20 @@ +project(scrollbar CXX) +cmake_minimum_required(VERSION 2.8) + ++FIND_PACKAGE(QCustomPlot REQUIRED) ++FIND_PACKAGE(Qt5PrintSupport REQUIRED) +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cMake") + +INCLUDE(GNUInstallDirs) ++FIND_PACKAGE(Qt5Widgets REQUIRED) ++INCLUDE_DIRECTORIES(${Qt5Widgets_INCLUDE_DIRS}) ++INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${QCustomPlot_INCLUDE_DIR}) ++ADD_DEFINITIONS(${Qt5Widgets_DEFINITIONS} -DQCUSTOMPLOT_USE_LIBRARY) ++SET(CMAKE_AUTOMOC ON) ++ ++QT5_WRAP_UI(UI_HEADERS mainwindow.ui) ++ADD_EXECUTABLE(scrollbar main.cpp mainwindow.cpp ${UI_HEADERS}) ++QT5_USE_MODULES(scrollbar Widgets) + -+ -+FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui REQUIRED) -+FIND_PACKAGE(QCustomPlot REQUIRED) -+ -+INCLUDE_DIRECTORIES(${QT_INCLUDES}) -+INCLUDE_DIRECTORIES(${QCustomPlot_INCLUDE_DIR}) -+INCLUDE(${QT_USE_FILE}) -+ -+QT4_WRAP_CPP(TEST_MOC_OUTFILES mainwindow.h) -+QT4_WRAP_UI(TEST_FORMS_HEADERS mainwindow.ui) -+ -+ADD_EXECUTABLE(scrollbar main.cpp mainwindow.cpp ${TEST_MOC_OUTFILES} ${TEST_FORMS_HEADERS} ${TEST_MOC_OUTFILES}) -+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) -+ -+TARGET_LINK_LIBRARIES(scrollbar ${QT_LIBRARIES} ${QCustomPlot_LIBRARIES}) ++TARGET_LINK_LIBRARIES(scrollbar ${Qt5Widgets_LIBRARIES} ${QCustomPlot_LIBRARIES} Qt5::PrintSupport) +INSTALL(TARGETS scrollbar DESTINATION ${CMAKE_INSTALL_BINDIR}) --- /dev/null +++ b/examples/text-document-integration/CMakeLists.txt -@@ -0,0 +1,23 @@ +@@ -0,0 +1,20 @@ +project(text CXX) +cmake_minimum_required(VERSION 2.8) + ++FIND_PACKAGE(QCustomPlot REQUIRED) ++FIND_PACKAGE(Qt5PrintSupport REQUIRED) +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cMake") + +INCLUDE(GNUInstallDirs) ++FIND_PACKAGE(Qt5Widgets REQUIRED) ++INCLUDE_DIRECTORIES(${Qt5Widgets_INCLUDE_DIRS}) ++INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${QCustomPlot_INCLUDE_DIR}) ++ADD_DEFINITIONS(${Qt5Widgets_DEFINITIONS} -DQCUSTOMPLOT_USE_LIBRARY) ++SET(CMAKE_AUTOMOC ON) ++ ++QT5_WRAP_UI(UI_HEADERS mainwindow.ui) ++ADD_EXECUTABLE(text main.cpp mainwindow.cpp qcpdocumentobject.cpp ${UI_HEADERS}) ++QT5_USE_MODULES(text Widgets) + -+ -+FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui REQUIRED) -+FIND_PACKAGE(QCustomPlot REQUIRED) -+ -+INCLUDE_DIRECTORIES(${QT_INCLUDES}) -+INCLUDE_DIRECTORIES(${QCustomPlot_INCLUDE_DIR}) -+INCLUDE(${QT_USE_FILE}) -+ -+QT4_WRAP_CPP(TEST_MOC_OUTFILES mainwindow.h qcpdocumentobject.h) -+QT4_WRAP_UI(TEST_FORMS_HEADERS mainwindow.ui) -+ -+ADD_EXECUTABLE(text main.cpp mainwindow.cpp qcpdocumentobject.cpp ${TEST_MOC_OUTFILES} ${TEST_FORMS_HEADERS} ${TEST_MOC_OUTFILES}) -+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) -+ -+TARGET_LINK_LIBRARIES(text ${QT_LIBRARIES} ${QCustomPlot_LIBRARIES}) ++TARGET_LINK_LIBRARIES(text ${Qt5Widgets_LIBRARIES} ${QCustomPlot_LIBRARIES} Qt5::PrintSupport) +INSTALL(TARGETS text DESTINATION ${CMAKE_INSTALL_BINDIR}) diff -Nru qcustomplot-1.1.0/debian/rules qcustomplot-1.2.0/debian/rules --- qcustomplot-1.1.0/debian/rules 2013-11-08 17:13:50.000000000 +0000 +++ qcustomplot-1.2.0/debian/rules 2014-04-03 19:34:43.000000000 +0000 @@ -4,4 +4,4 @@ dh $@ --parallel override_dh_strip: - dh_strip --dbg-package=libqcustomplot1.1-dbg + dh_strip --dbg-package=libqcustomplot1.2-dbg Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/adaptive-sampling-line.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/adaptive-sampling-line.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/adaptive-sampling-scatter.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/adaptive-sampling-scatter.png differ diff -Nru qcustomplot-1.1.0/documentation/html/annotated.html qcustomplot-1.2.0/documentation/html/annotated.html --- qcustomplot-1.1.0/documentation/html/annotated.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/annotated.html 2014-03-14 21:11:26.000000000 +0000 @@ -29,38 +29,42 @@ oCQCPAxisRectHolds multiple axes and arranges them in a rectangular shape oCQCPBarDataHolds the data of one single data point (one bar) for QCPBars oCQCPBarsA plottable representing a bar chart in a plot -oCQCPCurveA plottable representing a parametric curve in a plot -oCQCPCurveDataHolds the data of one single data point for QCPCurve -oCQCPDataHolds the data of one single data point for QCPGraph -oCQCPGraphA plottable representing a graph in a plot -oCQCPGridResponsible for drawing the grid of a QCPAxis -oCQCPItemAnchorAn anchor of an item to which positions can be attached to -oCQCPItemBracketA bracket for referencing/highlighting certain parts in the plot -oCQCPItemCurveA curved line from one point to another -oCQCPItemEllipseAn ellipse -oCQCPItemLineA line from one point to another -oCQCPItemPixmapAn arbitrary pixmap -oCQCPItemPositionManages the position of an item -oCQCPItemRectA rectangle -oCQCPItemStraightLineA straight line that spans infinitely in both directions -oCQCPItemTextA text label -oCQCPItemTracerItem that sticks to QCPGraph data points -oCQCPLayerA layer that may contain objects, to control the rendering order -oCQCPLayerableBase class for all drawable objects -oCQCPLayoutThe abstract base class for layouts -oCQCPLayoutElementThe abstract base class for all objects that form the layout system -oCQCPLayoutGridA layout that arranges child elements in a grid -oCQCPLayoutInsetA layout that places child elements aligned to the border or arbitrarily positioned -oCQCPLegendManages a legend inside a QCustomPlot -oCQCPLineEndingHandles the different ending decorations for line-like items -oCQCPMarginGroupA margin group allows synchronization of margin sides if working with multiple layout elements -oCQCPPainterQPainter subclass used internally -oCQCPPlottableLegendItemA legend item representing a plottable with an icon and the plottable name -oCQCPPlotTitleA layout element displaying a plot title text -oCQCPRangeRepresents the range an axis is encompassing -oCQCPScatterStyleRepresents the visual appearance of scatter points -oCQCPStatisticalBoxA plottable representing a single statistical box in a plot -\CQCustomPlotThe central class of the library. This is the QWidget which displays the plot and interacts with the user +oCQCPColorGradientDefines a color gradient for use with e.g. QCPColorMap +oCQCPColorMapA plottable representing a two-dimensional color map in a plot +oCQCPColorMapDataHolds the two-dimensional data of a QCPColorMap plottable +oCQCPColorScaleA color scale for use with color coding data such as QCPColorMap +oCQCPCurveA plottable representing a parametric curve in a plot +oCQCPCurveDataHolds the data of one single data point for QCPCurve +oCQCPDataHolds the data of one single data point for QCPGraph +oCQCPGraphA plottable representing a graph in a plot +oCQCPGridResponsible for drawing the grid of a QCPAxis +oCQCPItemAnchorAn anchor of an item to which positions can be attached to +oCQCPItemBracketA bracket for referencing/highlighting certain parts in the plot +oCQCPItemCurveA curved line from one point to another +oCQCPItemEllipseAn ellipse +oCQCPItemLineA line from one point to another +oCQCPItemPixmapAn arbitrary pixmap +oCQCPItemPositionManages the position of an item +oCQCPItemRectA rectangle +oCQCPItemStraightLineA straight line that spans infinitely in both directions +oCQCPItemTextA text label +oCQCPItemTracerItem that sticks to QCPGraph data points +oCQCPLayerA layer that may contain objects, to control the rendering order +oCQCPLayerableBase class for all drawable objects +oCQCPLayoutThe abstract base class for layouts +oCQCPLayoutElementThe abstract base class for all objects that form the layout system +oCQCPLayoutGridA layout that arranges child elements in a grid +oCQCPLayoutInsetA layout that places child elements aligned to the border or arbitrarily positioned +oCQCPLegendManages a legend inside a QCustomPlot +oCQCPLineEndingHandles the different ending decorations for line-like items +oCQCPMarginGroupA margin group allows synchronization of margin sides if working with multiple layout elements +oCQCPPainterQPainter subclass used internally +oCQCPPlottableLegendItemA legend item representing a plottable with an icon and the plottable name +oCQCPPlotTitleA layout element displaying a plot title text +oCQCPRangeRepresents the range an axis is encompassing +oCQCPScatterStyleRepresents the visual appearance of scatter points +oCQCPStatisticalBoxA plottable representing a single statistical box in a plot +\CQCustomPlotThe central class of the library. This is the QWidget which displays the plot and interacts with the user diff -Nru qcustomplot-1.1.0/documentation/html/axis_8h_source.html qcustomplot-1.2.0/documentation/html/axis_8h_source.html --- qcustomplot-1.1.0/documentation/html/axis_8h_source.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/axis_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -26,7 +26,7 @@
1 /***************************************************************************
2 ** **
3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
-
4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
+
4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
5 ** **
6 ** This program is free software: you can redistribute it and/or modify **
7 ** it under the terms of the GNU General Public License as published by **
@@ -44,8 +44,8 @@
19 ****************************************************************************
20 ** Author: Emanuel Eichhammer **
21 ** Website/Contact: http://www.qcustomplot.com/ **
-
22 ** Date: 04.11.13 **
-
23 ** Version: 1.1.0 **
+
22 ** Date: 14.03.14 **
+
23 ** Version: 1.2.0 **
24 ****************************************************************************/
25 
26 #ifndef QCP_AXIS_H
@@ -61,380 +61,434 @@
36 class QCustomPlot;
37 class QCPAxis;
38 class QCPAxisRect;
- -
40 class QCPGraph;
-
41 class QCPAbstractItem;
-
42 
-
43 class QCP_LIB_DECL QCPGrid :public QCPLayerable
-
44 {
-
45  Q_OBJECT
-
47  Q_PROPERTY(bool subGridVisible READ subGridVisible WRITE setSubGridVisible)
-
48  Q_PROPERTY(bool antialiasedSubGrid READ antialiasedSubGrid WRITE setAntialiasedSubGrid)
-
49  Q_PROPERTY(bool antialiasedZeroLine READ antialiasedZeroLine WRITE setAntialiasedZeroLine)
-
50  Q_PROPERTY(QPen pen READ pen WRITE setPen)
-
51  Q_PROPERTY(QPen subGridPen READ subGridPen WRITE setSubGridPen)
-
52  Q_PROPERTY(QPen zeroLinePen READ zeroLinePen WRITE setZeroLinePen)
-
54 public:
-
55  QCPGrid(QCPAxis *parentAxis);
-
56 
-
57  // getters:
-
58  bool subGridVisible() const { return mSubGridVisible; }
-
59  bool antialiasedSubGrid() const { return mAntialiasedSubGrid; }
-
60  bool antialiasedZeroLine() const { return mAntialiasedZeroLine; }
-
61  QPen pen() const { return mPen; }
-
62  QPen subGridPen() const { return mSubGridPen; }
-
63  QPen zeroLinePen() const { return mZeroLinePen; }
-
64 
-
65  // setters:
-
66  void setSubGridVisible(bool visible);
-
67  void setAntialiasedSubGrid(bool enabled);
-
68  void setAntialiasedZeroLine(bool enabled);
-
69  void setPen(const QPen &pen);
-
70  void setSubGridPen(const QPen &pen);
-
71  void setZeroLinePen(const QPen &pen);
-
72 
-
73 protected:
-
74  // property members:
-
75  bool mSubGridVisible;
-
76  bool mAntialiasedSubGrid, mAntialiasedZeroLine;
-
77  QPen mPen, mSubGridPen, mZeroLinePen;
-
78  // non-property members:
-
79  QCPAxis *mParentAxis;
-
80 
-
81  // reimplemented virtual methods:
-
82  virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
-
83  virtual void draw(QCPPainter *painter);
-
84 
-
85  // non-virtual methods:
-
86  void drawGridLines(QCPPainter *painter) const;
-
87  void drawSubGridLines(QCPPainter *painter) const;
-
88 
-
89  friend class QCPAxis;
-
90 };
-
91 
+
39 class QCPAxisPainterPrivate;
+ +
41 class QCPGraph;
+
42 class QCPAbstractItem;
+
43 
+
44 class QCP_LIB_DECL QCPGrid :public QCPLayerable
+
45 {
+
46  Q_OBJECT
+
48  Q_PROPERTY(bool subGridVisible READ subGridVisible WRITE setSubGridVisible)
+
49  Q_PROPERTY(bool antialiasedSubGrid READ antialiasedSubGrid WRITE setAntialiasedSubGrid)
+
50  Q_PROPERTY(bool antialiasedZeroLine READ antialiasedZeroLine WRITE setAntialiasedZeroLine)
+
51  Q_PROPERTY(QPen pen READ pen WRITE setPen)
+
52  Q_PROPERTY(QPen subGridPen READ subGridPen WRITE setSubGridPen)
+
53  Q_PROPERTY(QPen zeroLinePen READ zeroLinePen WRITE setZeroLinePen)
+
55 public:
+
56  QCPGrid(QCPAxis *parentAxis);
+
57 
+
58  // getters:
+
59  bool subGridVisible() const { return mSubGridVisible; }
+
60  bool antialiasedSubGrid() const { return mAntialiasedSubGrid; }
+
61  bool antialiasedZeroLine() const { return mAntialiasedZeroLine; }
+
62  QPen pen() const { return mPen; }
+
63  QPen subGridPen() const { return mSubGridPen; }
+
64  QPen zeroLinePen() const { return mZeroLinePen; }
+
65 
+
66  // setters:
+
67  void setSubGridVisible(bool visible);
+
68  void setAntialiasedSubGrid(bool enabled);
+
69  void setAntialiasedZeroLine(bool enabled);
+
70  void setPen(const QPen &pen);
+
71  void setSubGridPen(const QPen &pen);
+
72  void setZeroLinePen(const QPen &pen);
+
73 
+
74 protected:
+
75  // property members:
+
76  bool mSubGridVisible;
+
77  bool mAntialiasedSubGrid, mAntialiasedZeroLine;
+
78  QPen mPen, mSubGridPen, mZeroLinePen;
+
79  // non-property members:
+
80  QCPAxis *mParentAxis;
+
81 
+
82  // reimplemented virtual methods:
+
83  virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
+
84  virtual void draw(QCPPainter *painter);
+
85 
+
86  // non-virtual methods:
+
87  void drawGridLines(QCPPainter *painter) const;
+
88  void drawSubGridLines(QCPPainter *painter) const;
+
89 
+
90  friend class QCPAxis;
+
91 };
92 
-
93 class QCP_LIB_DECL QCPAxis : public QCPLayerable
-
94 {
-
95  Q_OBJECT
-
97  Q_PROPERTY(AxisType axisType READ axisType)
-
98  Q_PROPERTY(QCPAxisRect* axisRect READ axisRect)
-
99  Q_PROPERTY(ScaleType scaleType READ scaleType WRITE setScaleType)
-
100  Q_PROPERTY(double scaleLogBase READ scaleLogBase WRITE setScaleLogBase)
-
101  Q_PROPERTY(QCPRange range READ range WRITE setRange)
-
102  Q_PROPERTY(bool rangeReversed READ rangeReversed WRITE setRangeReversed)
-
103  Q_PROPERTY(bool autoTicks READ autoTicks WRITE setAutoTicks)
-
104  Q_PROPERTY(int autoTickCount READ autoTickCount WRITE setAutoTickCount)
-
105  Q_PROPERTY(bool autoTickLabels READ autoTickLabels WRITE setAutoTickLabels)
-
106  Q_PROPERTY(bool autoTickStep READ autoTickStep WRITE setAutoTickStep)
-
107  Q_PROPERTY(bool autoSubTicks READ autoSubTicks WRITE setAutoSubTicks)
-
108  Q_PROPERTY(bool ticks READ ticks WRITE setTicks)
-
109  Q_PROPERTY(bool tickLabels READ tickLabels WRITE setTickLabels)
-
110  Q_PROPERTY(int tickLabelPadding READ tickLabelPadding WRITE setTickLabelPadding)
-
111  Q_PROPERTY(LabelType tickLabelType READ tickLabelType WRITE setTickLabelType)
-
112  Q_PROPERTY(QFont tickLabelFont READ tickLabelFont WRITE setTickLabelFont)
-
113  Q_PROPERTY(QColor tickLabelColor READ tickLabelColor WRITE setTickLabelColor)
-
114  Q_PROPERTY(double tickLabelRotation READ tickLabelRotation WRITE setTickLabelRotation)
-
115  Q_PROPERTY(QString dateTimeFormat READ dateTimeFormat WRITE setDateTimeFormat)
-
116  Q_PROPERTY(QString numberFormat READ numberFormat WRITE setNumberFormat)
-
117  Q_PROPERTY(int numberPrecision READ numberPrecision WRITE setNumberPrecision)
-
118  Q_PROPERTY(double tickStep READ tickStep WRITE setTickStep)
-
119  Q_PROPERTY(QVector<double> tickVector READ tickVector WRITE setTickVector)
-
120  Q_PROPERTY(QVector<QString> tickVectorLabels READ tickVectorLabels WRITE setTickVectorLabels)
-
121  Q_PROPERTY(int tickLengthIn READ tickLengthIn WRITE setTickLengthIn)
-
122  Q_PROPERTY(int tickLengthOut READ tickLengthOut WRITE setTickLengthOut)
-
123  Q_PROPERTY(int subTickCount READ subTickCount WRITE setSubTickCount)
-
124  Q_PROPERTY(int subTickLengthIn READ subTickLengthIn WRITE setSubTickLengthIn)
-
125  Q_PROPERTY(int subTickLengthOut READ subTickLengthOut WRITE setSubTickLengthOut)
-
126  Q_PROPERTY(QPen basePen READ basePen WRITE setBasePen)
-
127  Q_PROPERTY(QPen tickPen READ tickPen WRITE setTickPen)
-
128  Q_PROPERTY(QPen subTickPen READ subTickPen WRITE setSubTickPen)
-
129  Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont)
-
130  Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor)
-
131  Q_PROPERTY(QString label READ label WRITE setLabel)
-
132  Q_PROPERTY(int labelPadding READ labelPadding WRITE setLabelPadding)
-
133  Q_PROPERTY(int padding READ padding WRITE setPadding)
-
134  Q_PROPERTY(int offset READ offset WRITE setOffset)
-
135  Q_PROPERTY(SelectableParts selectedParts READ selectedParts WRITE setSelectedParts)
-
136  Q_PROPERTY(SelectableParts selectableParts READ selectableParts WRITE setSelectableParts)
-
137  Q_PROPERTY(QFont selectedTickLabelFont READ selectedTickLabelFont WRITE setSelectedTickLabelFont)
-
138  Q_PROPERTY(QFont selectedLabelFont READ selectedLabelFont WRITE setSelectedLabelFont)
-
139  Q_PROPERTY(QColor selectedTickLabelColor READ selectedTickLabelColor WRITE setSelectedTickLabelColor)
-
140  Q_PROPERTY(QColor selectedLabelColor READ selectedLabelColor WRITE setSelectedLabelColor)
-
141  Q_PROPERTY(QPen selectedBasePen READ selectedBasePen WRITE setSelectedBasePen)
-
142  Q_PROPERTY(QPen selectedTickPen READ selectedTickPen WRITE setSelectedTickPen)
-
143  Q_PROPERTY(QPen selectedSubTickPen READ selectedSubTickPen WRITE setSelectedSubTickPen)
-
144  Q_PROPERTY(QCPLineEnding lowerEnding READ lowerEnding WRITE setLowerEnding)
-
145  Q_PROPERTY(QCPLineEnding upperEnding READ upperEnding WRITE setUpperEnding)
-
146  Q_PROPERTY(QCPGrid* grid READ grid)
-
148 public:
-
153  enum AxisType { atLeft = 0x01
-
154  ,atRight = 0x02
-
155  ,atTop = 0x04
-
156  ,atBottom = 0x08
-
157  };
-
158  Q_FLAGS(AxisType AxisTypes)
-
159  Q_DECLARE_FLAGS(AxisTypes, AxisType)
-
166  enum LabelType { ltNumber
-
167  ,ltDateTime
-
168  };
-
169  Q_ENUMS(LabelType)
-
174  enum ScaleType { stLinear
-
175  ,stLogarithmic
-
176  };
-
177  Q_ENUMS(ScaleType)
-
182  enum SelectablePart { spNone = 0
-
183  ,spAxis = 0x001
-
184  ,spTickLabels = 0x002
-
185  ,spAxisLabel = 0x004
-
186  };
-
187  Q_FLAGS(SelectablePart SelectableParts)
-
188  Q_DECLARE_FLAGS(SelectableParts, SelectablePart)
-
189 
-
190  explicit QCPAxis(QCPAxisRect *parent, AxisType type);
-
191 
-
192  // getters:
-
193  AxisType axisType() const { return mAxisType; }
-
194  QCPAxisRect *axisRect() const { return mAxisRect; }
-
195  ScaleType scaleType() const { return mScaleType; }
-
196  double scaleLogBase() const { return mScaleLogBase; }
-
197  const QCPRange range() const { return mRange; }
-
198  bool rangeReversed() const { return mRangeReversed; }
-
199  bool autoTicks() const { return mAutoTicks; }
-
200  int autoTickCount() const { return mAutoTickCount; }
-
201  bool autoTickLabels() const { return mAutoTickLabels; }
-
202  bool autoTickStep() const { return mAutoTickStep; }
-
203  bool autoSubTicks() const { return mAutoSubTicks; }
-
204  bool ticks() const { return mTicks; }
-
205  bool tickLabels() const { return mTickLabels; }
-
206  int tickLabelPadding() const { return mTickLabelPadding; }
-
207  LabelType tickLabelType() const { return mTickLabelType; }
-
208  QFont tickLabelFont() const { return mTickLabelFont; }
-
209  QColor tickLabelColor() const { return mTickLabelColor; }
-
210  double tickLabelRotation() const { return mTickLabelRotation; }
-
211  QString dateTimeFormat() const { return mDateTimeFormat; }
-
212  Qt::TimeSpec dateTimeSpec() const { return mDateTimeSpec; }
-
213  QString numberFormat() const;
-
214  int numberPrecision() const { return mNumberPrecision; }
-
215  double tickStep() const { return mTickStep; }
-
216  QVector<double> tickVector() const { return mTickVector; }
-
217  QVector<QString> tickVectorLabels() const { return mTickVectorLabels; }
-
218  int tickLengthIn() const { return mTickLengthIn; }
-
219  int tickLengthOut() const { return mTickLengthOut; }
-
220  int subTickCount() const { return mSubTickCount; }
-
221  int subTickLengthIn() const { return mSubTickLengthIn; }
-
222  int subTickLengthOut() const { return mSubTickLengthOut; }
-
223  QPen basePen() const { return mBasePen; }
-
224  QPen tickPen() const { return mTickPen; }
-
225  QPen subTickPen() const { return mSubTickPen; }
-
226  QFont labelFont() const { return mLabelFont; }
-
227  QColor labelColor() const { return mLabelColor; }
-
228  QString label() const { return mLabel; }
-
229  int labelPadding() const { return mLabelPadding; }
-
230  int padding() const { return mPadding; }
-
231  int offset() const { return mOffset; }
-
232  SelectableParts selectedParts() const { return mSelectedParts; }
-
233  SelectableParts selectableParts() const { return mSelectableParts; }
-
234  QFont selectedTickLabelFont() const { return mSelectedTickLabelFont; }
-
235  QFont selectedLabelFont() const { return mSelectedLabelFont; }
-
236  QColor selectedTickLabelColor() const { return mSelectedTickLabelColor; }
-
237  QColor selectedLabelColor() const { return mSelectedLabelColor; }
-
238  QPen selectedBasePen() const { return mSelectedBasePen; }
-
239  QPen selectedTickPen() const { return mSelectedTickPen; }
-
240  QPen selectedSubTickPen() const { return mSelectedSubTickPen; }
-
241  QCPLineEnding lowerEnding() const { return mLowerEnding; }
-
242  QCPLineEnding upperEnding() const { return mUpperEnding; }
-
243  QCPGrid *grid() const { return mGrid; }
-
244 
-
245  // setters:
-
246  void setScaleType(ScaleType type);
-
247  void setScaleLogBase(double base);
-
248  Q_SLOT void setRange(const QCPRange &range);
-
249  void setRange(double lower, double upper);
-
250  void setRange(double position, double size, Qt::AlignmentFlag alignment);
-
251  void setRangeLower(double lower);
-
252  void setRangeUpper(double upper);
-
253  void setRangeReversed(bool reversed);
-
254  void setAutoTicks(bool on);
-
255  void setAutoTickCount(int approximateCount);
-
256  void setAutoTickLabels(bool on);
-
257  void setAutoTickStep(bool on);
-
258  void setAutoSubTicks(bool on);
-
259  void setTicks(bool show);
-
260  void setTickLabels(bool show);
-
261  void setTickLabelPadding(int padding);
-
262  void setTickLabelType(LabelType type);
-
263  void setTickLabelFont(const QFont &font);
-
264  void setTickLabelColor(const QColor &color);
-
265  void setTickLabelRotation(double degrees);
-
266  void setDateTimeFormat(const QString &format);
-
267  void setDateTimeSpec(const Qt::TimeSpec &timeSpec);
-
268  void setNumberFormat(const QString &formatCode);
-
269  void setNumberPrecision(int precision);
-
270  void setTickStep(double step);
-
271  void setTickVector(const QVector<double> &vec);
-
272  void setTickVectorLabels(const QVector<QString> &vec);
-
273  void setTickLength(int inside, int outside=0);
-
274  void setTickLengthIn(int inside);
-
275  void setTickLengthOut(int outside);
-
276  void setSubTickCount(int count);
-
277  void setSubTickLength(int inside, int outside=0);
-
278  void setSubTickLengthIn(int inside);
-
279  void setSubTickLengthOut(int outside);
-
280  void setBasePen(const QPen &pen);
-
281  void setTickPen(const QPen &pen);
-
282  void setSubTickPen(const QPen &pen);
-
283  void setLabelFont(const QFont &font);
-
284  void setLabelColor(const QColor &color);
-
285  void setLabel(const QString &str);
-
286  void setLabelPadding(int padding);
-
287  void setPadding(int padding);
-
288  void setOffset(int offset);
-
289  void setSelectedTickLabelFont(const QFont &font);
-
290  void setSelectedLabelFont(const QFont &font);
-
291  void setSelectedTickLabelColor(const QColor &color);
-
292  void setSelectedLabelColor(const QColor &color);
-
293  void setSelectedBasePen(const QPen &pen);
-
294  void setSelectedTickPen(const QPen &pen);
-
295  void setSelectedSubTickPen(const QPen &pen);
-
296  Q_SLOT void setSelectableParts(const QCPAxis::SelectableParts &selectableParts);
-
297  Q_SLOT void setSelectedParts(const QCPAxis::SelectableParts &selectedParts);
-
298  void setLowerEnding(const QCPLineEnding &ending);
-
299  void setUpperEnding(const QCPLineEnding &ending);
-
300 
-
301  // reimplemented virtual methods:
-
302  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
+
93 
+
94 class QCP_LIB_DECL QCPAxis : public QCPLayerable
+
95 {
+
96  Q_OBJECT
+
98  Q_PROPERTY(AxisType axisType READ axisType)
+
99  Q_PROPERTY(QCPAxisRect* axisRect READ axisRect)
+
100  Q_PROPERTY(ScaleType scaleType READ scaleType WRITE setScaleType NOTIFY scaleTypeChanged)
+
101  Q_PROPERTY(double scaleLogBase READ scaleLogBase WRITE setScaleLogBase)
+
102  Q_PROPERTY(QCPRange range READ range WRITE setRange NOTIFY rangeChanged)
+
103  Q_PROPERTY(bool rangeReversed READ rangeReversed WRITE setRangeReversed)
+
104  Q_PROPERTY(bool autoTicks READ autoTicks WRITE setAutoTicks)
+
105  Q_PROPERTY(int autoTickCount READ autoTickCount WRITE setAutoTickCount)
+
106  Q_PROPERTY(bool autoTickLabels READ autoTickLabels WRITE setAutoTickLabels)
+
107  Q_PROPERTY(bool autoTickStep READ autoTickStep WRITE setAutoTickStep)
+
108  Q_PROPERTY(bool autoSubTicks READ autoSubTicks WRITE setAutoSubTicks)
+
109  Q_PROPERTY(bool ticks READ ticks WRITE setTicks)
+
110  Q_PROPERTY(bool tickLabels READ tickLabels WRITE setTickLabels)
+
111  Q_PROPERTY(int tickLabelPadding READ tickLabelPadding WRITE setTickLabelPadding)
+
112  Q_PROPERTY(LabelType tickLabelType READ tickLabelType WRITE setTickLabelType)
+
113  Q_PROPERTY(QFont tickLabelFont READ tickLabelFont WRITE setTickLabelFont)
+
114  Q_PROPERTY(QColor tickLabelColor READ tickLabelColor WRITE setTickLabelColor)
+
115  Q_PROPERTY(double tickLabelRotation READ tickLabelRotation WRITE setTickLabelRotation)
+
116  Q_PROPERTY(QString dateTimeFormat READ dateTimeFormat WRITE setDateTimeFormat)
+
117  Q_PROPERTY(Qt::TimeSpec dateTimeSpec READ dateTimeSpec WRITE setDateTimeSpec)
+
118  Q_PROPERTY(QString numberFormat READ numberFormat WRITE setNumberFormat)
+
119  Q_PROPERTY(int numberPrecision READ numberPrecision WRITE setNumberPrecision)
+
120  Q_PROPERTY(double tickStep READ tickStep WRITE setTickStep)
+
121  Q_PROPERTY(QVector<double> tickVector READ tickVector WRITE setTickVector)
+
122  Q_PROPERTY(QVector<QString> tickVectorLabels READ tickVectorLabels WRITE setTickVectorLabels)
+
123  Q_PROPERTY(int tickLengthIn READ tickLengthIn WRITE setTickLengthIn)
+
124  Q_PROPERTY(int tickLengthOut READ tickLengthOut WRITE setTickLengthOut)
+
125  Q_PROPERTY(int subTickCount READ subTickCount WRITE setSubTickCount)
+
126  Q_PROPERTY(int subTickLengthIn READ subTickLengthIn WRITE setSubTickLengthIn)
+
127  Q_PROPERTY(int subTickLengthOut READ subTickLengthOut WRITE setSubTickLengthOut)
+
128  Q_PROPERTY(QPen basePen READ basePen WRITE setBasePen)
+
129  Q_PROPERTY(QPen tickPen READ tickPen WRITE setTickPen)
+
130  Q_PROPERTY(QPen subTickPen READ subTickPen WRITE setSubTickPen)
+
131  Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont)
+
132  Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor)
+
133  Q_PROPERTY(QString label READ label WRITE setLabel)
+
134  Q_PROPERTY(int labelPadding READ labelPadding WRITE setLabelPadding)
+
135  Q_PROPERTY(int padding READ padding WRITE setPadding)
+
136  Q_PROPERTY(int offset READ offset WRITE setOffset)
+
137  Q_PROPERTY(SelectableParts selectedParts READ selectedParts WRITE setSelectedParts NOTIFY selectionChanged)
+
138  Q_PROPERTY(SelectableParts selectableParts READ selectableParts WRITE setSelectableParts NOTIFY selectableChanged)
+
139  Q_PROPERTY(QFont selectedTickLabelFont READ selectedTickLabelFont WRITE setSelectedTickLabelFont)
+
140  Q_PROPERTY(QFont selectedLabelFont READ selectedLabelFont WRITE setSelectedLabelFont)
+
141  Q_PROPERTY(QColor selectedTickLabelColor READ selectedTickLabelColor WRITE setSelectedTickLabelColor)
+
142  Q_PROPERTY(QColor selectedLabelColor READ selectedLabelColor WRITE setSelectedLabelColor)
+
143  Q_PROPERTY(QPen selectedBasePen READ selectedBasePen WRITE setSelectedBasePen)
+
144  Q_PROPERTY(QPen selectedTickPen READ selectedTickPen WRITE setSelectedTickPen)
+
145  Q_PROPERTY(QPen selectedSubTickPen READ selectedSubTickPen WRITE setSelectedSubTickPen)
+
146  Q_PROPERTY(QCPLineEnding lowerEnding READ lowerEnding WRITE setLowerEnding)
+
147  Q_PROPERTY(QCPLineEnding upperEnding READ upperEnding WRITE setUpperEnding)
+
148  Q_PROPERTY(QCPGrid* grid READ grid)
+
150 public:
+
155  enum AxisType { atLeft = 0x01
+
156  ,atRight = 0x02
+
157  ,atTop = 0x04
+
158  ,atBottom = 0x08
+
159  };
+
160  Q_FLAGS(AxisType AxisTypes)
+
161  Q_DECLARE_FLAGS(AxisTypes, AxisType)
+
168  enum LabelType { ltNumber
+
169  ,ltDateTime
+
170  };
+
171  Q_ENUMS(LabelType)
+
176  enum ScaleType { stLinear
+
177  ,stLogarithmic
+
178  };
+
179  Q_ENUMS(ScaleType)
+
184  enum SelectablePart { spNone = 0
+
185  ,spAxis = 0x001
+
186  ,spTickLabels = 0x002
+
187  ,spAxisLabel = 0x004
+
188  };
+
189  Q_FLAGS(SelectablePart SelectableParts)
+
190  Q_DECLARE_FLAGS(SelectableParts, SelectablePart)
+
191 
+
192  explicit QCPAxis(QCPAxisRect *parent, AxisType type);
+
193  virtual ~QCPAxis();
+
194 
+
195  // getters:
+
196  AxisType axisType() const { return mAxisType; }
+
197  QCPAxisRect *axisRect() const { return mAxisRect; }
+
198  ScaleType scaleType() const { return mScaleType; }
+
199  double scaleLogBase() const { return mScaleLogBase; }
+
200  const QCPRange range() const { return mRange; }
+
201  bool rangeReversed() const { return mRangeReversed; }
+
202  bool autoTicks() const { return mAutoTicks; }
+
203  int autoTickCount() const { return mAutoTickCount; }
+
204  bool autoTickLabels() const { return mAutoTickLabels; }
+
205  bool autoTickStep() const { return mAutoTickStep; }
+
206  bool autoSubTicks() const { return mAutoSubTicks; }
+
207  bool ticks() const { return mTicks; }
+
208  bool tickLabels() const { return mTickLabels; }
+
209  int tickLabelPadding() const;
+
210  LabelType tickLabelType() const { return mTickLabelType; }
+
211  QFont tickLabelFont() const { return mTickLabelFont; }
+
212  QColor tickLabelColor() const { return mTickLabelColor; }
+
213  double tickLabelRotation() const;
+
214  QString dateTimeFormat() const { return mDateTimeFormat; }
+
215  Qt::TimeSpec dateTimeSpec() const { return mDateTimeSpec; }
+
216  QString numberFormat() const;
+
217  int numberPrecision() const { return mNumberPrecision; }
+
218  double tickStep() const { return mTickStep; }
+
219  QVector<double> tickVector() const { return mTickVector; }
+
220  QVector<QString> tickVectorLabels() const { return mTickVectorLabels; }
+
221  int tickLengthIn() const;
+
222  int tickLengthOut() const;
+
223  int subTickCount() const { return mSubTickCount; }
+
224  int subTickLengthIn() const;
+
225  int subTickLengthOut() const;
+
226  QPen basePen() const { return mBasePen; }
+
227  QPen tickPen() const { return mTickPen; }
+
228  QPen subTickPen() const { return mSubTickPen; }
+
229  QFont labelFont() const { return mLabelFont; }
+
230  QColor labelColor() const { return mLabelColor; }
+
231  QString label() const { return mLabel; }
+
232  int labelPadding() const;
+
233  int padding() const { return mPadding; }
+
234  int offset() const;
+
235  SelectableParts selectedParts() const { return mSelectedParts; }
+
236  SelectableParts selectableParts() const { return mSelectableParts; }
+
237  QFont selectedTickLabelFont() const { return mSelectedTickLabelFont; }
+
238  QFont selectedLabelFont() const { return mSelectedLabelFont; }
+
239  QColor selectedTickLabelColor() const { return mSelectedTickLabelColor; }
+
240  QColor selectedLabelColor() const { return mSelectedLabelColor; }
+
241  QPen selectedBasePen() const { return mSelectedBasePen; }
+
242  QPen selectedTickPen() const { return mSelectedTickPen; }
+
243  QPen selectedSubTickPen() const { return mSelectedSubTickPen; }
+
244  QCPLineEnding lowerEnding() const;
+
245  QCPLineEnding upperEnding() const;
+
246  QCPGrid *grid() const { return mGrid; }
+
247 
+
248  // setters:
+
249  Q_SLOT void setScaleType(QCPAxis::ScaleType type);
+
250  void setScaleLogBase(double base);
+
251  Q_SLOT void setRange(const QCPRange &range);
+
252  void setRange(double lower, double upper);
+
253  void setRange(double position, double size, Qt::AlignmentFlag alignment);
+
254  void setRangeLower(double lower);
+
255  void setRangeUpper(double upper);
+
256  void setRangeReversed(bool reversed);
+
257  void setAutoTicks(bool on);
+
258  void setAutoTickCount(int approximateCount);
+
259  void setAutoTickLabels(bool on);
+
260  void setAutoTickStep(bool on);
+
261  void setAutoSubTicks(bool on);
+
262  void setTicks(bool show);
+
263  void setTickLabels(bool show);
+
264  void setTickLabelPadding(int padding);
+
265  void setTickLabelType(LabelType type);
+
266  void setTickLabelFont(const QFont &font);
+
267  void setTickLabelColor(const QColor &color);
+
268  void setTickLabelRotation(double degrees);
+
269  void setDateTimeFormat(const QString &format);
+
270  void setDateTimeSpec(const Qt::TimeSpec &timeSpec);
+
271  void setNumberFormat(const QString &formatCode);
+
272  void setNumberPrecision(int precision);
+
273  void setTickStep(double step);
+
274  void setTickVector(const QVector<double> &vec);
+
275  void setTickVectorLabels(const QVector<QString> &vec);
+
276  void setTickLength(int inside, int outside=0);
+
277  void setTickLengthIn(int inside);
+
278  void setTickLengthOut(int outside);
+
279  void setSubTickCount(int count);
+
280  void setSubTickLength(int inside, int outside=0);
+
281  void setSubTickLengthIn(int inside);
+
282  void setSubTickLengthOut(int outside);
+
283  void setBasePen(const QPen &pen);
+
284  void setTickPen(const QPen &pen);
+
285  void setSubTickPen(const QPen &pen);
+
286  void setLabelFont(const QFont &font);
+
287  void setLabelColor(const QColor &color);
+
288  void setLabel(const QString &str);
+
289  void setLabelPadding(int padding);
+
290  void setPadding(int padding);
+
291  void setOffset(int offset);
+
292  void setSelectedTickLabelFont(const QFont &font);
+
293  void setSelectedLabelFont(const QFont &font);
+
294  void setSelectedTickLabelColor(const QColor &color);
+
295  void setSelectedLabelColor(const QColor &color);
+
296  void setSelectedBasePen(const QPen &pen);
+
297  void setSelectedTickPen(const QPen &pen);
+
298  void setSelectedSubTickPen(const QPen &pen);
+
299  Q_SLOT void setSelectableParts(const QCPAxis::SelectableParts &selectableParts);
+
300  Q_SLOT void setSelectedParts(const QCPAxis::SelectableParts &selectedParts);
+
301  void setLowerEnding(const QCPLineEnding &ending);
+
302  void setUpperEnding(const QCPLineEnding &ending);
303 
-
304  // non-virtual methods:
-
305  Qt::Orientation orientation() const { return mOrientation; }
-
306  void moveRange(double diff);
-
307  void scaleRange(double factor, double center);
-
308  void setScaleRatio(const QCPAxis *otherAxis, double ratio=1.0);
-
309  void rescale(bool onlyVisiblePlottables=false);
-
310  double pixelToCoord(double value) const;
-
311  double coordToPixel(double value) const;
-
312  SelectablePart getPartAt(const QPointF &pos) const;
-
313  QList<QCPAbstractPlottable*> plottables() const;
-
314  QList<QCPGraph*> graphs() const;
-
315  QList<QCPAbstractItem*> items() const;
-
316 
-
317  static AxisType marginSideToAxisType(QCP::MarginSide side);
-
318 
-
319 signals:
-
320  void ticksRequest();
-
321  void rangeChanged(const QCPRange &newRange);
-
322  void rangeChanged(const QCPRange &newRange, const QCPRange &oldRange);
-
323  void selectionChanged(const QCPAxis::SelectableParts &parts);
-
324 
-
325 protected:
-
326  struct CachedLabel
-
327  {
-
328  QPointF offset;
-
329  QPixmap pixmap;
-
330  };
-
331  struct TickLabelData
-
332  {
-
333  QString basePart, expPart;
-
334  QRect baseBounds, expBounds, totalBounds, rotatedTotalBounds;
-
335  QFont baseFont, expFont;
-
336  };
-
337 
-
338  // property members:
-
339  // axis base:
-
340  AxisType mAxisType;
-
341  QCPAxisRect *mAxisRect;
-
342  int mOffset, mPadding;
-
343  Qt::Orientation mOrientation;
-
344  SelectableParts mSelectableParts, mSelectedParts;
-
345  QPen mBasePen, mSelectedBasePen;
-
346  QCPLineEnding mLowerEnding, mUpperEnding;
-
347  // axis label:
-
348  int mLabelPadding;
-
349  QString mLabel;
-
350  QFont mLabelFont, mSelectedLabelFont;
-
351  QColor mLabelColor, mSelectedLabelColor;
-
352  // tick labels:
-
353  int mTickLabelPadding;
-
354  bool mTickLabels, mAutoTickLabels;
-
355  double mTickLabelRotation;
-
356  LabelType mTickLabelType;
-
357  QFont mTickLabelFont, mSelectedTickLabelFont;
-
358  QColor mTickLabelColor, mSelectedTickLabelColor;
-
359  QString mDateTimeFormat;
-
360  Qt::TimeSpec mDateTimeSpec;
-
361  int mNumberPrecision;
-
362  char mNumberFormatChar;
-
363  bool mNumberBeautifulPowers;
-
364  bool mNumberMultiplyCross;
-
365  // ticks and subticks:
-
366  bool mTicks;
-
367  double mTickStep;
-
368  int mSubTickCount, mAutoTickCount;
-
369  bool mAutoTicks, mAutoTickStep, mAutoSubTicks;
-
370  int mTickLengthIn, mTickLengthOut, mSubTickLengthIn, mSubTickLengthOut;
-
371  QPen mTickPen, mSelectedTickPen;
-
372  QPen mSubTickPen, mSelectedSubTickPen;
-
373  // scale and range:
-
374  QCPRange mRange;
-
375  bool mRangeReversed;
-
376  ScaleType mScaleType;
-
377  double mScaleLogBase, mScaleLogBaseLogInv;
-
378 
-
379  // non-property members:
-
380  QCPGrid *mGrid;
-
381  QCache<QString, CachedLabel> mLabelCache;
-
382  int mLowestVisibleTick, mHighestVisibleTick;
-
383  QChar mExponentialChar, mPositiveSignChar;
-
384  QVector<double> mTickVector;
-
385  QVector<QString> mTickVectorLabels;
-
386  QVector<double> mSubTickVector;
-
387  QRect mAxisSelectionBox, mTickLabelsSelectionBox, mLabelSelectionBox;
-
388  bool mCachedMarginValid;
-
389  int mCachedMargin;
+
304  // reimplemented virtual methods:
+
305  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
+
306 
+
307  // non-property methods:
+
308  Qt::Orientation orientation() const { return mOrientation; }
+
309  void moveRange(double diff);
+
310  void scaleRange(double factor, double center);
+
311  void setScaleRatio(const QCPAxis *otherAxis, double ratio=1.0);
+
312  void rescale(bool onlyVisiblePlottables=false);
+
313  double pixelToCoord(double value) const;
+
314  double coordToPixel(double value) const;
+
315  SelectablePart getPartAt(const QPointF &pos) const;
+
316  QList<QCPAbstractPlottable*> plottables() const;
+
317  QList<QCPGraph*> graphs() const;
+
318  QList<QCPAbstractItem*> items() const;
+
319 
+
320  static AxisType marginSideToAxisType(QCP::MarginSide side);
+
321  static Qt::Orientation orientation(AxisType type) { return type==atBottom||type==atTop ? Qt::Horizontal : Qt::Vertical; }
+
322  static AxisType opposite(AxisType type);
+
323 
+
324 signals:
+
325  void ticksRequest();
+
326  void rangeChanged(const QCPRange &newRange);
+
327  void rangeChanged(const QCPRange &newRange, const QCPRange &oldRange);
+
328  void scaleTypeChanged(QCPAxis::ScaleType scaleType);
+
329  void selectionChanged(const QCPAxis::SelectableParts &parts);
+
330  void selectableChanged(const QCPAxis::SelectableParts &parts);
+
331 
+
332 protected:
+
333  // property members:
+
334  // axis base:
+
335  AxisType mAxisType;
+
336  QCPAxisRect *mAxisRect;
+
337  //int mOffset; // in QCPAxisPainter
+
338  int mPadding;
+
339  Qt::Orientation mOrientation;
+
340  SelectableParts mSelectableParts, mSelectedParts;
+
341  QPen mBasePen, mSelectedBasePen;
+
342  //QCPLineEnding mLowerEnding, mUpperEnding; // in QCPAxisPainter
+
343  // axis label:
+
344  //int mLabelPadding; // in QCPAxisPainter
+
345  QString mLabel;
+
346  QFont mLabelFont, mSelectedLabelFont;
+
347  QColor mLabelColor, mSelectedLabelColor;
+
348  // tick labels:
+
349  //int mTickLabelPadding; // in QCPAxisPainter
+
350  bool mTickLabels, mAutoTickLabels;
+
351  //double mTickLabelRotation; // in QCPAxisPainter
+
352  LabelType mTickLabelType;
+
353  QFont mTickLabelFont, mSelectedTickLabelFont;
+
354  QColor mTickLabelColor, mSelectedTickLabelColor;
+
355  QString mDateTimeFormat;
+
356  Qt::TimeSpec mDateTimeSpec;
+
357  int mNumberPrecision;
+
358  char mNumberFormatChar;
+
359  bool mNumberBeautifulPowers;
+
360  //bool mNumberMultiplyCross; // QCPAxisPainter
+
361  // ticks and subticks:
+
362  bool mTicks;
+
363  double mTickStep;
+
364  int mSubTickCount, mAutoTickCount;
+
365  bool mAutoTicks, mAutoTickStep, mAutoSubTicks;
+
366  //int mTickLengthIn, mTickLengthOut, mSubTickLengthIn, mSubTickLengthOut; // QCPAxisPainter
+
367  QPen mTickPen, mSelectedTickPen;
+
368  QPen mSubTickPen, mSelectedSubTickPen;
+
369  // scale and range:
+
370  QCPRange mRange;
+
371  bool mRangeReversed;
+
372  ScaleType mScaleType;
+
373  double mScaleLogBase, mScaleLogBaseLogInv;
+
374 
+
375  // non-property members:
+
376  QCPGrid *mGrid;
+
377  QCPAxisPainterPrivate *mAxisPainter;
+
378  int mLowestVisibleTick, mHighestVisibleTick;
+
379  QVector<double> mTickVector;
+
380  QVector<QString> mTickVectorLabels;
+
381  QVector<double> mSubTickVector;
+
382  bool mCachedMarginValid;
+
383  int mCachedMargin;
+
384 
+
385  // introduced virtual methods:
+
386  virtual void setupTickVectors();
+
387  virtual void generateAutoTicks();
+
388  virtual int calculateAutoSubTickCount(double tickStep) const;
+
389  virtual int calculateMargin();
390 
-
391  // introduced virtual methods:
-
392  virtual void setupTickVectors();
-
393  virtual void generateAutoTicks();
-
394  virtual int calculateAutoSubTickCount(double tickStep) const;
-
395  virtual int calculateMargin();
-
396  // tick label drawing/caching:
-
397  virtual void placeTickLabel(QCPPainter *painter, double position, int distanceToAxis, const QString &text, QSize *tickLabelsSize);
-
398  virtual void drawTickLabel(QCPPainter *painter, double x, double y, const TickLabelData &labelData) const;
-
399  virtual TickLabelData getTickLabelData(const QFont &font, const QString &text) const;
-
400  virtual QPointF getTickLabelDrawOffset(const TickLabelData &labelData) const;
-
401  virtual void getMaxTickLabelSize(const QFont &font, const QString &text, QSize *tickLabelsSize) const;
-
402 
-
403  // reimplemented virtual methods:
-
404  virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
-
405  virtual void draw(QCPPainter *painter);
-
406  virtual QCP::Interaction selectionCategory() const;
-
407  // events:
-
408  virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
-
409  virtual void deselectEvent(bool *selectionStateChanged);
+
391  // reimplemented virtual methods:
+
392  virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
+
393  virtual void draw(QCPPainter *painter);
+
394  virtual QCP::Interaction selectionCategory() const;
+
395  // events:
+
396  virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
+
397  virtual void deselectEvent(bool *selectionStateChanged);
+
398 
+
399  // non-virtual methods:
+
400  void visibleTickBounds(int &lowIndex, int &highIndex) const;
+
401  double baseLog(double value) const;
+
402  double basePow(double value) const;
+
403  QPen getBasePen() const;
+
404  QPen getTickPen() const;
+
405  QPen getSubTickPen() const;
+
406  QFont getTickLabelFont() const;
+
407  QFont getLabelFont() const;
+
408  QColor getTickLabelColor() const;
+
409  QColor getLabelColor() const;
410 
-
411  // non-virtual methods:
-
412  void visibleTickBounds(int &lowIndex, int &highIndex) const;
-
413  double baseLog(double value) const;
-
414  double basePow(double value) const;
-
415  QPen getBasePen() const;
-
416  QPen getTickPen() const;
-
417  QPen getSubTickPen() const;
-
418  QFont getTickLabelFont() const;
-
419  QFont getLabelFont() const;
-
420  QColor getTickLabelColor() const;
-
421  QColor getLabelColor() const;
-
422 
-
423 private:
-
424  Q_DISABLE_COPY(QCPAxis)
-
425 
-
426  friend class QCustomPlot;
-
427  friend class QCPGrid;
-
428  friend class QCPAxisRect;
-
429 };
-
430 Q_DECLARE_OPERATORS_FOR_FLAGS(QCPAxis::SelectableParts)
-
431 Q_DECLARE_OPERATORS_FOR_FLAGS(QCPAxis::AxisTypes)
-
432 Q_DECLARE_METATYPE(QCPAxis::SelectablePart)
-
433 
-
434 #endif // QCP_AXIS_H
+
411 private:
+
412  Q_DISABLE_COPY(QCPAxis)
+
413 
+
414  friend class QCustomPlot;
+
415  friend class QCPGrid;
+
416  friend class QCPAxisRect;
+
417 };
+
418 Q_DECLARE_OPERATORS_FOR_FLAGS(QCPAxis::SelectableParts)
+
419 Q_DECLARE_OPERATORS_FOR_FLAGS(QCPAxis::AxisTypes)
+
420 Q_DECLARE_METATYPE(QCPAxis::SelectablePart)
+
421 
+
422 
+
423 class QCPAxisPainterPrivate
+
424 {
+
425 public:
+
426  explicit QCPAxisPainterPrivate(QCustomPlot *parentPlot);
+
427  virtual ~QCPAxisPainterPrivate();
+
428 
+
429  virtual void draw(QCPPainter *painter);
+
430  virtual int size() const;
+
431  void clearCache();
+
432 
+
433  QRect axisSelectionBox() const { return mAxisSelectionBox; }
+
434  QRect tickLabelsSelectionBox() const { return mTickLabelsSelectionBox; }
+
435  QRect labelSelectionBox() const { return mLabelSelectionBox; }
+
436 
+
437  // public property members:
+
438  QCPAxis::AxisType type;
+
439  QPen basePen;
+
440  QCPLineEnding lowerEnding, upperEnding; // directly accessed by QCPAxis setters/getters
+
441  int labelPadding; // directly accessed by QCPAxis setters/getters
+
442  QFont labelFont;
+
443  QColor labelColor;
+
444  QString label;
+
445  int tickLabelPadding; // directly accessed by QCPAxis setters/getters
+
446  double tickLabelRotation; // directly accessed by QCPAxis setters/getters
+
447  bool substituteExponent;
+
448  bool numberMultiplyCross; // directly accessed by QCPAxis setters/getters
+
449  int tickLengthIn, tickLengthOut, subTickLengthIn, subTickLengthOut; // directly accessed by QCPAxis setters/getters
+
450  QPen tickPen, subTickPen;
+
451  QFont tickLabelFont;
+
452  QColor tickLabelColor;
+
453  QRect alignmentRect, viewportRect;
+
454  double offset; // directly accessed by QCPAxis setters/getters
+
455  bool abbreviateDecimalPowers;
+
456  bool reversedEndings;
+
457 
+
458  QVector<double> subTickPositions;
+
459  QVector<double> tickPositions;
+
460  QVector<QString> tickLabels;
+
461 
+
462 protected:
+
463  struct CachedLabel
+
464  {
+
465  QPointF offset;
+
466  QPixmap pixmap;
+
467  };
+
468  struct TickLabelData
+
469  {
+
470  QString basePart, expPart;
+
471  QRect baseBounds, expBounds, totalBounds, rotatedTotalBounds;
+
472  QFont baseFont, expFont;
+
473  };
+
474  QCustomPlot *mParentPlot;
+
475  QByteArray mLabelParameterHash; // to determine whether mLabelCache needs to be cleared due to changed parameters
+
476  QCache<QString, CachedLabel> mLabelCache;
+
477  QRect mAxisSelectionBox, mTickLabelsSelectionBox, mLabelSelectionBox;
+
478 
+
479  virtual QByteArray generateLabelParameterHash() const;
+
480 
+
481  virtual void placeTickLabel(QCPPainter *painter, double position, int distanceToAxis, const QString &text, QSize *tickLabelsSize);
+
482  virtual void drawTickLabel(QCPPainter *painter, double x, double y, const TickLabelData &labelData) const;
+
483  virtual TickLabelData getTickLabelData(const QFont &font, const QString &text) const;
+
484  virtual QPointF getTickLabelDrawOffset(const TickLabelData &labelData) const;
+
485  virtual void getMaxTickLabelSize(const QFont &font, const QString &text, QSize *tickLabelsSize) const;
+
486 };
+
487 
+
488 #endif // QCP_AXIS_H
Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/AxisNamesOverview.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/AxisNamesOverview.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/AxisRectSpacingOverview.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/AxisRectSpacingOverview.png differ diff -Nru qcustomplot-1.1.0/documentation/html/classes.html qcustomplot-1.2.0/documentation/html/classes.html --- qcustomplot-1.1.0/documentation/html/classes.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classes.html 2014-03-14 21:11:26.000000000 +0000 @@ -22,27 +22,29 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + +
  Q  
-
QCPItemRect   
QCPItemStraightLine   
QCPAbstractItem   QCPItemText   
QCPAbstractLegendItem   QCPItemTracer   
QCPAbstractPlottable   QCPLayer   
QCPAxis   QCPLayerable   
QCPAxisRect   QCPLayout   
QCPBarData   QCPLayoutElement   
QCPBars   QCPLayoutGrid   
QCPCurve   QCPLayoutInset   
QCPCurveData   QCPLegend   
QCPData   QCPLineEnding   
QCPGraph   QCPMarginGroup   
QCPGrid   QCPPainter   
QCPItemAnchor   QCPPlottableLegendItem   
QCPItemBracket   QCPPlotTitle   
QCPItemCurve   QCPRange   
QCPItemEllipse   QCPScatterStyle   
QCPItemLine   QCPStatisticalBox   
QCPItemPixmap   QCustomPlot   
QCPItemPosition   
QCPItemPixmap   
QCPItemPosition   
QCPAbstractItem   QCPItemRect   
QCPAbstractLegendItem   QCPItemStraightLine   
QCPAbstractPlottable   QCPItemText   
QCPAxis   QCPItemTracer   
QCPAxisRect   QCPLayer   
QCPBarData   QCPLayerable   
QCPBars   QCPLayout   
QCPColorGradient   QCPLayoutElement   
QCPColorMap   QCPLayoutGrid   
QCPColorMapData   QCPLayoutInset   
QCPColorScale   QCPLegend   
QCPCurve   QCPLineEnding   
QCPCurveData   QCPMarginGroup   
QCPData   QCPPainter   
QCPGraph   QCPPlottableLegendItem   
QCPGrid   QCPPlotTitle   
QCPItemAnchor   QCPRange   
QCPItemBracket   QCPScatterStyle   
QCPItemCurve   QCPStatisticalBox   
QCPItemEllipse   QCustomPlot   
QCPItemLine   
diff -Nru qcustomplot-1.1.0/documentation/html/classQCPAbstractItem.html qcustomplot-1.2.0/documentation/html/classQCPAbstractItem.html --- qcustomplot-1.1.0/documentation/html/classQCPAbstractItem.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPAbstractItem.html 2014-03-14 21:11:26.000000000 +0000 @@ -47,32 +47,38 @@ bool selected () const void setClipToAxisRect (bool clip) void setClipAxisRect (QCPAxisRect *rect) -void setSelectable (bool selectable) -void setSelected (bool selected) +Q_SLOT void setSelectable (bool selectable) +Q_SLOT void setSelected (bool selected) virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const =0 QList< QCPItemPosition * > positions () const QList< QCPItemAnchor * > anchors () const QCPItemPositionposition (const QString &name) const QCPItemAnchoranchor (const QString &name) const bool hasAnchor (const QString &name) const - +- Public Functions inherited from QCPLayerableQCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0) + bool visible () const - + QCustomPlotparentPlot () const -QCPLayerableparentLayerable () const - +QCPLayerableparentLayerable () const + QCPLayerlayer () const - + bool antialiased () const -void setVisible (bool on) -bool setLayer (QCPLayer *layer) -bool setLayer (const QString &layerName) -void setAntialiased (bool enabled) -bool realVisibility () const +void setVisible (bool on) +Q_SLOT bool setLayer (QCPLayer *layer) +bool setLayer (const QString &layerName) +void setAntialiased (bool enabled) +bool realVisibility () const + + +

Signals

void selectionChanged (bool selected)
+void selectableChanged (bool selectable)
- Signals inherited from QCPLayerable
void layerChanged (QCPLayer *newLayer)
@@ -87,11 +93,12 @@ - - - - - + + + + + +

Protected Functions

double rectSelectTest (const QRectF &rect, const QPointF &pos, bool filledRect) const
QCPItemPositioncreatePosition (const QString &name)
QCPItemAnchorcreateAnchor (const QString &name, int anchorId)
virtual void parentPlotInitialized (QCustomPlot *parentPlot)
void initializeParentPlot (QCustomPlot *parentPlot)
void setParentLayerable (QCPLayerable *parentLayerable)
bool moveToLayer (QCPLayer *layer, bool prepend)
void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
- Protected Functions inherited from QCPLayerable
virtual void parentPlotInitialized (QCustomPlot *parentPlot)
void initializeParentPlot (QCustomPlot *parentPlot)
void setParentLayerable (QCPLayerable *parentLayerable)
bool moveToLayer (QCPLayer *layer, bool prepend)
void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const

Detailed Description

The abstract base class for all items in a plot.

@@ -605,7 +612,7 @@

This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

-

Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

+

Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is fed back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

See Also
selectTest, deselectEvent
@@ -826,324 +833,6 @@
- -
-
- - - - - -
- - - - - - - -
QCPLayerable * QCPLayerable::parentLayerable () const
-
-inlineinherited
-
-

Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.

-

Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.

-

A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.

- -
-
- -
-
- - - - - -
- - - - - - - - -
void QCPLayerable::setVisible (bool on)
-
-inherited
-
-

Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.

- -
-
- -
-
- - - - - -
- - - - - - - - -
bool QCPLayerable::setLayer (QCPLayerlayer)
-
-inherited
-
-

Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.

-

Returns true on success, i.e. if layer is a valid layer.

- -
-
- -
-
- - - - - -
- - - - - - - - -
bool QCPLayerable::setLayer (const QString & layerName)
-
-inherited
-
-

This is an overloaded function.

-

Sets the layer of this layerable object by name

-

Returns true on success, i.e. if layerName is a valid layer name.

- -
-
- -
-
- - - - - -
- - - - - - - - -
void QCPLayerable::setAntialiased (bool enabled)
-
-inherited
-
-

Sets whether this object will be drawn antialiased or not.

-

Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

- -
-
- -
-
- - - - - -
- - - - - - - -
bool QCPLayerable::realVisibility () const
-
-inherited
-
-

Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.

-

If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.

-

If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.

- -
-
- -
-
- - - - - -
- - - - - - - - -
void QCPLayerable::parentPlotInitialized (QCustomPlotparentPlot)
-
-protectedvirtualinherited
-
-

This function is called by initializeParentPlot, to allow subclasses to react on the setting of a parent plot. This is the case when 0 was passed as parent plot in the constructor, and the parent plot is set at a later time.

-

For example, QCPLayoutElement/QCPLayout hierarchies may be created independently of any QCustomPlot at first. When they are then added to a layout inside the QCustomPlot, the top level element of the hierarchy gets its parent plot initialized with initializeParentPlot. To propagate the parent plot to all the children of the hierarchy, the top level element then uses this function to pass the parent plot on to its child elements.

-

The default implementation does nothing.

-
See Also
initializeParentPlot
- -

Reimplemented in QCPLegend, and QCPLayoutElement.

- -
-
- -
-
- - - - - -
- - - - - - - - -
void QCPLayerable::initializeParentPlot (QCustomPlotparentPlot)
-
-protectedinherited
-
-

Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.

-

Note that, unlike when passing a non-null parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.

-

Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.

-

The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).

- -
-
- -
-
- - - - - -
- - - - - - - - -
void QCPLayerable::setParentLayerable (QCPLayerableparentLayerable)
-
-protectedinherited
-
-

Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.

-

The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.

-
See Also
realVisibility
- -
-
- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - -
bool QCPLayerable::moveToLayer (QCPLayerlayer,
bool prepend 
)
-
-protectedinherited
-
-

Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.

-

Returns true on success, i.e. if layer is a valid layer.

- -
-
- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
void QCPLayerable::applyAntialiasingHint (QCPPainterpainter,
bool localAntialiased,
QCP::AntialiasedElement overrideElement 
) const
-
-protectedinherited
-
-

Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.

- -
-

The documentation for this class was generated from the following files:
  • src/item.h
  • src/item.cpp
  • diff -Nru qcustomplot-1.1.0/documentation/html/classQCPAbstractLegendItem.html qcustomplot-1.2.0/documentation/html/classQCPAbstractLegendItem.html --- qcustomplot-1.1.0/documentation/html/classQCPAbstractLegendItem.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPAbstractLegendItem.html 2014-03-14 21:11:26.000000000 +0000 @@ -55,59 +55,65 @@ void setTextColor (const QColor &color) void setSelectedFont (const QFont &font) void setSelectedTextColor (const QColor &color) -void setSelectable (bool selectable) -void setSelected (bool selected) +Q_SLOT void setSelectable (bool selectable) +Q_SLOT void setSelected (bool selected) virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const -QCPLayoutlayout () const -QRect rect () const - +- Public Functions inherited from QCPLayoutElementQCPLayoutElement (QCustomPlot *parentPlot=0) +QCPLayoutlayout () const +QRect rect () const + QRect outerRect () const - + QMargins margins () const - + QMargins minimumMargins () const - + QCP::MarginSides autoMargins () const - + QSize minimumSize () const - + QSize maximumSize () const - + QCPMarginGroupmarginGroup (QCP::MarginSide side) const - + QHash< QCP::MarginSide,
    QCPMarginGroup * > marginGroups () const -void setOuterRect (const QRect &rect) -void setMargins (const QMargins &margins) -void setMinimumMargins (const QMargins &margins) -void setAutoMargins (QCP::MarginSides sides) -void setMinimumSize (const QSize &size) -void setMinimumSize (int width, int height) -void setMaximumSize (const QSize &size) -void setMaximumSize (int width, int height) -void setMarginGroup (QCP::MarginSides sides, QCPMarginGroup *group) -virtual void update () -virtual QSize minimumSizeHint () const -virtual QSize maximumSizeHint () const -virtual QList< QCPLayoutElement * > elements (bool recursive) const - +void setOuterRect (const QRect &rect) +void setMargins (const QMargins &margins) +void setMinimumMargins (const QMargins &margins) +void setAutoMargins (QCP::MarginSides sides) +void setMinimumSize (const QSize &size) +void setMinimumSize (int width, int height) +void setMaximumSize (const QSize &size) +void setMaximumSize (int width, int height) +void setMarginGroup (QCP::MarginSides sides, QCPMarginGroup *group) +virtual void update (UpdatePhase phase) +virtual QSize minimumSizeHint () const +virtual QSize maximumSizeHint () const +virtual QList< QCPLayoutElement * > elements (bool recursive) const +- Public Functions inherited from QCPLayerableQCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0) + bool visible () const - + QCustomPlotparentPlot () const -QCPLayerableparentLayerable () const - +QCPLayerableparentLayerable () const + QCPLayerlayer () const - + bool antialiased () const -void setVisible (bool on) -bool setLayer (QCPLayer *layer) -bool setLayer (const QString &layerName) -void setAntialiased (bool enabled) -bool realVisibility () const +void setVisible (bool on) +Q_SLOT bool setLayer (QCPLayer *layer) +bool setLayer (const QString &layerName) +void setAntialiased (bool enabled) +bool realVisibility () const +

    Signals

    void selectionChanged (bool selected)
    +void selectableChanged (bool selectable)
    @@ -117,17 +123,24 @@ - - - - - - - - - - - + + + + + + + + + + + + + +

    Protected Functions

    virtual void draw (QCPPainter *painter)=0
    virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
    virtual void deselectEvent (bool *selectionStateChanged)
    virtual int calculateAutoMargin (QCP::MarginSide side)
    virtual void mousePressEvent (QMouseEvent *event)
    virtual void mouseMoveEvent (QMouseEvent *event)
    virtual void mouseReleaseEvent (QMouseEvent *event)
    virtual void mouseDoubleClickEvent (QMouseEvent *event)
    virtual void wheelEvent (QWheelEvent *event)
    virtual void parentPlotInitialized (QCustomPlot *parentPlot)
    void initializeParentPlot (QCustomPlot *parentPlot)
    void setParentLayerable (QCPLayerable *parentLayerable)
    bool moveToLayer (QCPLayer *layer, bool prepend)
    void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
    - Protected Functions inherited from QCPLayoutElement
    virtual int calculateAutoMargin (QCP::MarginSide side)
    virtual void mousePressEvent (QMouseEvent *event)
    virtual void mouseMoveEvent (QMouseEvent *event)
    virtual void mouseReleaseEvent (QMouseEvent *event)
    virtual void mouseDoubleClickEvent (QMouseEvent *event)
    virtual void wheelEvent (QWheelEvent *event)
    virtual void parentPlotInitialized (QCustomPlot *parentPlot)
    - Protected Functions inherited from QCPLayerable
    void initializeParentPlot (QCustomPlot *parentPlot)
    void setParentLayerable (QCPLayerable *parentLayerable)
    bool moveToLayer (QCPLayer *layer, bool prepend)
    void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
    + + +

    +Additional Inherited Members

    - Public Types inherited from QCPLayoutElement
    enum  UpdatePhase

    Detailed Description

    The abstract base class for all entries in a QCPLegend.

    @@ -509,7 +522,7 @@

    This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

    event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

    -

    Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

    +

    Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is fed back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

    selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

    See Also
    selectTest, deselectEvent
    @@ -546,913 +559,6 @@
    - -
    -
    - - - - - -
    - - - - - - - -
    QCPLayout * QCPLayoutElement::layout () const
    -
    -inlineinherited
    -
    -

    Returns the parent layout of this layout element.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - -
    QRect QCPLayoutElement::rect () const
    -
    -inlineinherited
    -
    -

    Returns the inner rect of this layout element. The inner rect is the outer rect (setOuterRect) shrinked by the margins (setMargins, setAutoMargins).

    -

    In some cases, the area between outer and inner rect is left blank. In other cases the margin area is used to display peripheral graphics while the main content is in the inner rect. This is where automatic margin calculation becomes interesting because it allows the layout element to adapt the margins to the peripheral graphics it wants to draw. For example, QCPAxisRect draws the axis labels and tick labels in the margin area, thus needs to adjust the margins (if setAutoMargins is enabled) according to the space required by the labels of the axes.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - -
    void QCPLayoutElement::setOuterRect (const QRect & rect)
    -
    -inherited
    -
    -

    Sets the outer rect of this layout element. If the layout element is inside a layout, the layout sets the position and size of this layout element using this function.

    -

    Calling this function externally has no effect, since the layout will overwrite any changes to the outer rect upon the next replot.

    -

    The layout element will adapt its inner rect by applying the margins inward to the outer rect.

    -
    See Also
    rect
    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - -
    void QCPLayoutElement::setMargins (const QMargins & margins)
    -
    -inherited
    -
    -

    Sets the margins of this layout element. If setAutoMargins is disabled for some or all sides, this function is used to manually set the margin on those sides. Sides that are still set to be handled automatically are ignored and may have any value in margins.

    -

    The margin is the distance between the outer rect (controlled by the parent layout via setOuterRect) and the inner rect (which usually contains the main content of this layout element).

    -
    See Also
    setAutoMargins
    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - -
    void QCPLayoutElement::setMinimumMargins (const QMargins & margins)
    -
    -inherited
    -
    -

    If setAutoMargins is enabled on some or all margins, this function is used to provide minimum values for those margins.

    -

    The minimum values are not enforced on margin sides that were set to be under manual control via setAutoMargins.

    -
    See Also
    setAutoMargins
    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - -
    void QCPLayoutElement::setAutoMargins (QCP::MarginSides sides)
    -
    -inherited
    -
    -

    Sets on which sides the margin shall be calculated automatically. If a side is calculated automatically, a minimum margin value may be provided with setMinimumMargins. If a side is set to be controlled manually, the value may be specified with setMargins.

    -

    Margin sides that are under automatic control may participate in a QCPMarginGroup (see setMarginGroup), to synchronize (align) it with other layout elements in the plot.

    -
    See Also
    setMinimumMargins, setMargins
    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - -
    void QCPLayoutElement::setMinimumSize (const QSize & size)
    -
    -inherited
    -
    -

    Sets the minimum size for the inner rect of this layout element. A parent layout tries to respect the size here by changing row/column sizes in the layout accordingly.

    -

    If the parent layout size is not sufficient to satisfy all minimum size constraints of its child layout elements, the layout may set a size that is actually smaller than size. QCustomPlot propagates the layout's size constraints to the outside by setting its own minimum QWidget size accordingly, so violations of size should be exceptions.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - - - - - - - - - - - -
    void QCPLayoutElement::setMinimumSize (int width,
    int height 
    )
    -
    -inherited
    -
    -

    This is an overloaded function.

    -

    Sets the minimum size for the inner rect of this layout element.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - -
    void QCPLayoutElement::setMaximumSize (const QSize & size)
    -
    -inherited
    -
    -

    Sets the maximum size for the inner rect of this layout element. A parent layout tries to respect the size here by changing row/column sizes in the layout accordingly.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - - - - - - - - - - - -
    void QCPLayoutElement::setMaximumSize (int width,
    int height 
    )
    -
    -inherited
    -
    -

    This is an overloaded function.

    -

    Sets the maximum size for the inner rect of this layout element.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - - - - - - - - - - - -
    void QCPLayoutElement::setMarginGroup (QCP::MarginSides sides,
    QCPMarginGroupgroup 
    )
    -
    -inherited
    -
    -

    Sets the margin group of the specified margin sides.

    -

    Margin groups allow synchronizing specified margins across layout elements, see the documentation of QCPMarginGroup.

    -

    To unset the margin group of sides, set group to 0.

    -

    Note that margin groups only work for margin sides that are set to automatic (setAutoMargins).

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - -
    void QCPLayoutElement::update ()
    -
    -virtualinherited
    -
    -

    Updates the layout element and sub-elements. This function is automatically called upon replot by the parent layout element.

    -

    Layout elements that have child elements should call the update method of their child elements.

    -

    The default implementation executes the automatic margin mechanism, so subclasses should make sure to call the base class implementation.

    - -

    Reimplemented in QCPLayout, and QCPAxisRect.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - -
    QSize QCPLayoutElement::minimumSizeHint () const
    -
    -virtualinherited
    -
    -

    Returns the minimum size this layout element (the inner rect) may be compressed to.

    -

    if a minimum size (setMinimumSize) was not set manually, parent layouts consult this function to determine the minimum allowed size of this layout element. (A manual minimum size is considered set if it is non-zero.)

    - -

    Reimplemented in QCPLayoutGrid, QCPPlottableLegendItem, and QCPPlotTitle.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - -
    QSize QCPLayoutElement::maximumSizeHint () const
    -
    -virtualinherited
    -
    -

    Returns the maximum size this layout element (the inner rect) may be expanded to.

    -

    if a maximum size (setMaximumSize) was not set manually, parent layouts consult this function to determine the maximum allowed size of this layout element. (A manual maximum size is considered set if it is smaller than Qt's QWIDGETSIZE_MAX.)

    - -

    Reimplemented in QCPLayoutGrid, and QCPPlotTitle.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - -
    QList< QCPLayoutElement * > QCPLayoutElement::elements (bool recursive) const
    -
    -virtualinherited
    -
    -

    Returns a list of all child elements in this layout element. If recursive is true, all sub-child elements are included in the list, too.

    -

    Note that there may be entries with value 0 in the returned list. (For example, QCPLayoutGrid may have empty cells which yield 0 at the respective index.)

    - -

    Reimplemented in QCPLayoutGrid, QCPLayout, and QCPAxisRect.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - -
    int QCPLayoutElement::calculateAutoMargin (QCP::MarginSide side)
    -
    -protectedvirtualinherited
    -
    -

    Returns the margin size for this side. It is used if automatic margins is enabled for this side (see setAutoMargins). If a minimum margin was set with setMinimumMargins, the returned value will not be smaller than the specified minimum margin.

    -

    The default implementation just returns the respective manual margin (setMargins) or the minimum margin, whichever is larger.

    - -

    Reimplemented in QCPAxisRect.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - -
    void QCPLayoutElement::mousePressEvent (QMouseEvent * event)
    -
    -inlineprotectedvirtualinherited
    -
    -

    This event is called, if the mouse was pressed while being inside the outer rect of this layout element.

    - -

    Reimplemented in QCPAxisRect.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - -
    void QCPLayoutElement::mouseMoveEvent (QMouseEvent * event)
    -
    -inlineprotectedvirtualinherited
    -
    -

    This event is called, if the mouse is moved inside the outer rect of this layout element.

    - -

    Reimplemented in QCPAxisRect.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - -
    void QCPLayoutElement::mouseReleaseEvent (QMouseEvent * event)
    -
    -inlineprotectedvirtualinherited
    -
    -

    This event is called, if the mouse was previously pressed inside the outer rect of this layout element and is now released.

    - -

    Reimplemented in QCPAxisRect.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - -
    void QCPLayoutElement::mouseDoubleClickEvent (QMouseEvent * event)
    -
    -inlineprotectedvirtualinherited
    -
    -

    This event is called, if the mouse is double-clicked inside the outer rect of this layout element.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - -
    void QCPLayoutElement::wheelEvent (QWheelEvent * event)
    -
    -inlineprotectedvirtualinherited
    -
    -

    This event is called, if the mouse wheel is scrolled while the cursor is inside the rect of this layout element.

    - -

    Reimplemented in QCPAxisRect.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - -
    void QCPLayoutElement::parentPlotInitialized (QCustomPlotparentPlot)
    -
    -protectedvirtualinherited
    -
    -

    propagates the parent plot initialization to all child elements, by calling QCPLayerable::initializeParentPlot on them.

    - -

    Reimplemented from QCPLayerable.

    - -

    Reimplemented in QCPLegend.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - -
    QCPLayerable * QCPLayerable::parentLayerable () const
    -
    -inlineinherited
    -
    -

    Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.

    -

    Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.

    -

    A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - -
    void QCPLayerable::setVisible (bool on)
    -
    -inherited
    -
    -

    Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - -
    bool QCPLayerable::setLayer (QCPLayerlayer)
    -
    -inherited
    -
    -

    Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.

    -

    Returns true on success, i.e. if layer is a valid layer.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - -
    bool QCPLayerable::setLayer (const QString & layerName)
    -
    -inherited
    -
    -

    This is an overloaded function.

    -

    Sets the layer of this layerable object by name

    -

    Returns true on success, i.e. if layerName is a valid layer name.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - -
    void QCPLayerable::setAntialiased (bool enabled)
    -
    -inherited
    -
    -

    Sets whether this object will be drawn antialiased or not.

    -

    Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - -
    bool QCPLayerable::realVisibility () const
    -
    -inherited
    -
    -

    Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.

    -

    If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.

    -

    If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - -
    void QCPLayerable::initializeParentPlot (QCustomPlotparentPlot)
    -
    -protectedinherited
    -
    -

    Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.

    -

    Note that, unlike when passing a non-null parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.

    -

    Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.

    -

    The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - -
    void QCPLayerable::setParentLayerable (QCPLayerableparentLayerable)
    -
    -protectedinherited
    -
    -

    Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.

    -

    The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.

    -
    See Also
    realVisibility
    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - - - - - - - - - - - -
    bool QCPLayerable::moveToLayer (QCPLayerlayer,
    bool prepend 
    )
    -
    -protectedinherited
    -
    -

    Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.

    -

    Returns true on success, i.e. if layer is a valid layer.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - -
    void QCPLayerable::applyAntialiasingHint (QCPPainterpainter,
    bool localAntialiased,
    QCP::AntialiasedElement overrideElement 
    ) const
    -
    -protectedinherited
    -
    -

    Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.

    - -
    -

    The documentation for this class was generated from the following files:

    See the documentation of those functions for what they need to do.

    For drawing your plot, you can use the coordsToPixels functions to translate a point in plot coordinates to pixel coordinates. This function is quite convenient, because it takes the orientation of the key and value axes into account for you (x and y are swapped when the key axis is vertical and the value axis horizontal). If you are worried about performance (i.e. you need to translate many points in a loop like QCPGraph), you can directly use QCPAxis::coordToPixel. However, you must then take care about the orientation of the axis yourself.

    @@ -169,7 +175,7 @@ QBrush mSelectedBrush The generic brush that should be used when the plottable is selected (hint: mainBrush gives you the right brush, depending on selection state). -QPointer<QCPAxis>mKeyAxis, mValueAxis The key and value axes this plottable is attached to. Call their QCPAxis::coordToPixel functions to translate coordinates to pixels in either the key or value dimension. Make sure to check whether the weak pointer is null before using it. If one of the axes is null, don't draw the plottable. +QPointer<QCPAxis>mKeyAxis, mValueAxis The key and value axes this plottable is attached to. Call their QCPAxis::coordToPixel functions to translate coordinates to pixels in either the key or value dimension. Make sure to check whether the pointer is null before using it. If one of the axes is null, don't draw the plottable. bool mSelected indicates whether the plottable is selected or not. @@ -191,7 +197,7 @@
    -

    Represents negative and positive sign domain for passing to getKeyRange and getValueRange.

    +

    Represents negative and positive sign domain for passing to getKeyRange and getValueRange.

    Enumerator:
    sdNegative 

    The negative sign domain, i.e. numbers smaller than zero.

    @@ -397,7 +403,7 @@
    -

    The key axis of a plottable can be set to any axis of a QCustomPlot, as long as it is orthogonal to the plottable's value axis. This function performs no checks to make sure this is the case. The typical mathematical choice is to use the x-axis (QCustomPlot::xAxis) as key axis and the y-axis (QCustomPlot::yAxis) as value axis.

    +

    The key axis of a plottable can be set to any axis of a QCustomPlot, as long as it is orthogonal to the plottable's value axis. This function performs no checks to make sure this is the case. The typical mathematical choice is to use the x-axis (QCustomPlot::xAxis) as key axis and the y-axis (QCustomPlot::yAxis) as value axis.

    Normally, the key and value axes are set in the constructor of the plottable (or QCustomPlot::addGraph when working with QCPGraphs through the dedicated graph interface).

    See Also
    setValueAxis
    @@ -416,7 +422,7 @@
    -

    The value axis of a plottable can be set to any axis of a QCustomPlot, as long as it is orthogonal to the plottable's key axis. This function performs no checks to make sure this is the case. The typical mathematical choice is to use the x-axis (QCustomPlot::xAxis) as key axis and the y-axis (QCustomPlot::yAxis) as value axis.

    +

    The value axis of a plottable can be set to any axis of a QCustomPlot, as long as it is orthogonal to the plottable's key axis. This function performs no checks to make sure this is the case. The typical mathematical choice is to use the x-axis (QCustomPlot::xAxis) as key axis and the y-axis (QCustomPlot::yAxis) as value axis.

    Normally, the key and value axes are set in the constructor of the plottable (or QCustomPlot::addGraph when working with QCPGraphs through the dedicated graph interface).

    See Also
    setKeyAxis
    @@ -484,7 +490,7 @@

    Clears all data in the plottable.

    -

    Implemented in QCPGraph, QCPCurve, QCPBars, and QCPStatisticalBox.

    +

    Implemented in QCPGraph, QCPColorMap, QCPCurve, QCPBars, and QCPStatisticalBox.

    @@ -536,7 +542,7 @@

    Reimplemented from QCPLayerable.

    -

    Implemented in QCPGraph, QCPCurve, QCPBars, and QCPStatisticalBox.

    +

    Implemented in QCPGraph, QCPColorMap, QCPCurve, QCPBars, and QCPStatisticalBox.

    @@ -560,7 +566,7 @@
    -

    Adds this plottable to the legend of the parent QCustomPlot (QCustomPlot::legend).

    +

    Adds this plottable to the legend of the parent QCustomPlot (QCustomPlot::legend).

    Normally, a QCPPlottableLegendItem is created and inserted into the legend. If the plottable needs a more specialized representation in the legend, this function will take this into account and instead create the specialized subclass of QCPAbstractLegendItem.

    Returns true on success, i.e. when the legend exists and a legend item associated with this plottable isn't already in the legend.

    See Also
    removeFromLegend, QCPLegend::addItem
    @@ -670,7 +676,33 @@
    -

    This signal is emitted when the selection state of this plottable has changed to selected, either by user interaction or by a direct call to setSelected.

    +

    This signal is emitted when the selection state of this plottable has changed, either by user interaction or by a direct call to setSelected.

    + +
    + + +
    +
    + + + + + +
    + + + + + + + + +
    void QCPAbstractPlottable::selectableChanged (bool selectable)
    +
    +signal
    +
    +

    This signal is emitted when the selectability of this plottable has changed.

    +
    See Also
    setSelectable
    @@ -727,7 +759,7 @@

    Implements QCPLayerable.

    -

    Implemented in QCPGraph, QCPCurve, QCPBars, and QCPStatisticalBox.

    +

    Implemented in QCPGraph, QCPColorMap, QCPCurve, QCPBars, and QCPStatisticalBox.

    @@ -834,7 +866,7 @@

    This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

    event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

    -

    Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

    +

    Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is fed back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

    selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

    See Also
    selectTest, deselectEvent
    @@ -904,11 +936,11 @@

    called by QCPLegend::draw (via QCPPlottableLegendItem::draw) to create a graphical representation of this plottable inside rect, next to the plottable name.

    -

    Implemented in QCPGraph, QCPCurve, QCPBars, and QCPStatisticalBox.

    +

    Implemented in QCPGraph, QCPColorMap, QCPCurve, QCPBars, and QCPStatisticalBox.

    - +
    @@ -919,7 +951,7 @@ - + @@ -939,14 +971,15 @@
    QCPRange QCPAbstractPlottable::getKeyRange ( bool & validRange, foundRange,
    -

    called by rescaleAxes functions to get the full data key bounds. For logarithmic plots, one can set inSignDomain to either sdNegative or sdPositive in order to restrict the returned range to that sign domain. E.g. when only negative range is wanted, set inSignDomain to sdNegative and all positive points will be ignored for range calculation. For no restriction, just set inSignDomain to sdBoth (default). validRange is an output parameter that indicates whether a proper range could be found or not. If this is false, you shouldn't use the returned range (e.g. no points in data).

    -
    See Also
    rescaleAxes, getValueRange
    +

    called by rescaleAxes functions to get the full data key bounds. For logarithmic plots, one can set inSignDomain to either sdNegative or sdPositive in order to restrict the returned range to that sign domain. E.g. when only negative range is wanted, set inSignDomain to sdNegative and all positive points will be ignored for range calculation. For no restriction, just set inSignDomain to sdBoth (default). foundRange is an output parameter that indicates whether a range could be found or not. If this is false, you shouldn't use the returned range (e.g. no points in data).

    +

    Note that foundRange is not the same as QCPRange::validRange, since the range returned by this function may have size zero, which wouldn't count as a valid range.

    +
    See Also
    rescaleAxes, getValueRange
    -

    Implemented in QCPGraph, QCPCurve, QCPBars, and QCPStatisticalBox.

    +

    Implemented in QCPGraph, QCPColorMap, QCPCurve, QCPBars, and QCPStatisticalBox.

    - +
    @@ -957,7 +990,7 @@ - + @@ -977,10 +1010,11 @@
    QCPRange QCPAbstractPlottable::getValueRange ( bool & validRange, foundRange,
    -

    called by rescaleAxes functions to get the full data value bounds. For logarithmic plots, one can set inSignDomain to either sdNegative or sdPositive in order to restrict the returned range to that sign domain. E.g. when only negative range is wanted, set inSignDomain to sdNegative and all positive points will be ignored for range calculation. For no restriction, just set inSignDomain to sdBoth (default). validRange is an output parameter that indicates whether a proper range could be found or not. If this is false, you shouldn't use the returned range (e.g. no points in data).

    -
    See Also
    rescaleAxes, getKeyRange
    +

    called by rescaleAxes functions to get the full data value bounds. For logarithmic plots, one can set inSignDomain to either sdNegative or sdPositive in order to restrict the returned range to that sign domain. E.g. when only negative range is wanted, set inSignDomain to sdNegative and all positive points will be ignored for range calculation. For no restriction, just set inSignDomain to sdBoth (default). foundRange is an output parameter that indicates whether a range could be found or not. If this is false, you shouldn't use the returned range (e.g. no points in data).

    +

    Note that foundRange is not the same as QCPRange::validRange, since the range returned by this function may have size zero, which wouldn't count as a valid range.

    +
    See Also
    rescaleAxes, getKeyRange
    -

    Implemented in QCPGraph, QCPCurve, QCPBars, and QCPStatisticalBox.

    +

    Implemented in QCPGraph, QCPColorMap, QCPCurve, QCPBars, and QCPStatisticalBox.

    @@ -1332,324 +1366,6 @@ - -
    -
    - - - - - -
    - - - - - - - -
    QCPLayerable * QCPLayerable::parentLayerable () const
    -
    -inlineinherited
    -
    -

    Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.

    -

    Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.

    -

    A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - -
    void QCPLayerable::setVisible (bool on)
    -
    -inherited
    -
    -

    Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - -
    bool QCPLayerable::setLayer (QCPLayerlayer)
    -
    -inherited
    -
    -

    Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.

    -

    Returns true on success, i.e. if layer is a valid layer.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - -
    bool QCPLayerable::setLayer (const QString & layerName)
    -
    -inherited
    -
    -

    This is an overloaded function.

    -

    Sets the layer of this layerable object by name

    -

    Returns true on success, i.e. if layerName is a valid layer name.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - -
    void QCPLayerable::setAntialiased (bool enabled)
    -
    -inherited
    -
    -

    Sets whether this object will be drawn antialiased or not.

    -

    Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - -
    bool QCPLayerable::realVisibility () const
    -
    -inherited
    -
    -

    Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.

    -

    If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.

    -

    If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - -
    void QCPLayerable::parentPlotInitialized (QCustomPlotparentPlot)
    -
    -protectedvirtualinherited
    -
    -

    This function is called by initializeParentPlot, to allow subclasses to react on the setting of a parent plot. This is the case when 0 was passed as parent plot in the constructor, and the parent plot is set at a later time.

    -

    For example, QCPLayoutElement/QCPLayout hierarchies may be created independently of any QCustomPlot at first. When they are then added to a layout inside the QCustomPlot, the top level element of the hierarchy gets its parent plot initialized with initializeParentPlot. To propagate the parent plot to all the children of the hierarchy, the top level element then uses this function to pass the parent plot on to its child elements.

    -

    The default implementation does nothing.

    -
    See Also
    initializeParentPlot
    - -

    Reimplemented in QCPLegend, and QCPLayoutElement.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - -
    void QCPLayerable::initializeParentPlot (QCustomPlotparentPlot)
    -
    -protectedinherited
    -
    -

    Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.

    -

    Note that, unlike when passing a non-null parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.

    -

    Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.

    -

    The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - -
    void QCPLayerable::setParentLayerable (QCPLayerableparentLayerable)
    -
    -protectedinherited
    -
    -

    Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.

    -

    The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.

    -
    See Also
    realVisibility
    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - - - - - - - - - - - -
    bool QCPLayerable::moveToLayer (QCPLayerlayer,
    bool prepend 
    )
    -
    -protectedinherited
    -
    -

    Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.

    -

    Returns true on success, i.e. if layer is a valid layer.

    - -
    -
    - -
    -
    - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - -
    void QCPLayerable::applyAntialiasingHint (QCPPainterpainter,
    bool localAntialiased,
    QCP::AntialiasedElement overrideElement 
    ) const
    -
    -protectedinherited
    -
    -

    Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.

    - -
    -

    The documentation for this class was generated from the following files:
    • src/plottable.h
    • src/plottable.cpp
    • Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/classQCPAbstractPlottable__inherit__graph.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/classQCPAbstractPlottable__inherit__graph.png differ diff -Nru qcustomplot-1.1.0/documentation/html/classQCPAxis.html qcustomplot-1.2.0/documentation/html/classQCPAxis.html --- qcustomplot-1.1.0/documentation/html/classQCPAxis.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPAxis.html 2014-03-14 21:11:27.000000000 +0000 @@ -147,7 +147,7 @@ QCPLineEnding upperEnding () const QCPGridgrid () const -void setScaleType (ScaleType type) +Q_SLOT void setScaleType (QCPAxis::ScaleType type) void setScaleLogBase (double base) Q_SLOT void setRange (const QCPRange &range) void setRange (double lower, double upper) @@ -213,31 +213,39 @@ QList< QCPAbstractPlottable * > plottables () const QList< QCPGraph * > graphs () const QList< QCPAbstractItem * > items () const - +- Public Functions inherited from QCPLayerableQCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0) + bool visible () const - + QCustomPlotparentPlot () const -QCPLayerableparentLayerable () const - +QCPLayerableparentLayerable () const + QCPLayerlayer () const - + bool antialiased () const -void setVisible (bool on) -bool setLayer (QCPLayer *layer) -bool setLayer (const QString &layerName) -void setAntialiased (bool enabled) -bool realVisibility () const +void setVisible (bool on) +Q_SLOT bool setLayer (QCPLayer *layer) +bool setLayer (const QString &layerName) +void setAntialiased (bool enabled) +bool realVisibility () const + + + +

      Signals

      void ticksRequest ()
      void rangeChanged (const QCPRange &newRange)
      void rangeChanged (const QCPRange &newRange, const QCPRange &oldRange)
      void scaleTypeChanged (QCPAxis::ScaleType scaleType)
      void selectionChanged (const QCPAxis::SelectableParts &parts)
      void selectableChanged (const QCPAxis::SelectableParts &parts)
      - Signals inherited from QCPLayerable
      void layerChanged (QCPLayer *newLayer)
      + +

      Static Public Functions

      static AxisType marginSideToAxisType (QCP::MarginSide side)
      static Qt::Orientation orientation (AxisType type)
      static AxisType opposite (AxisType type)
      @@ -245,11 +253,6 @@ - - - - - @@ -265,16 +268,17 @@ - - - - - - + + + + + + +

      Protected Functions

      virtual void generateAutoTicks ()
      virtual int calculateAutoSubTickCount (double tickStep) const
      virtual int calculateMargin ()
      virtual void placeTickLabel (QCPPainter *painter, double position, int distanceToAxis, const QString &text, QSize *tickLabelsSize)
      virtual void drawTickLabel (QCPPainter *painter, double x, double y, const TickLabelData &labelData) const
      virtual TickLabelData getTickLabelData (const QFont &font, const QString &text) const
      virtual QPointF getTickLabelDrawOffset (const TickLabelData &labelData) const
      virtual void getMaxTickLabelSize (const QFont &font, const QString &text, QSize *tickLabelsSize) const
      virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
      virtual void draw (QCPPainter *painter)
      virtual QCP::Interaction selectionCategory () const
      QFont getLabelFont () const
      QColor getTickLabelColor () const
      QColor getLabelColor () const
      virtual void parentPlotInitialized (QCustomPlot *parentPlot)
      virtual QRect clipRect () const
      void initializeParentPlot (QCustomPlot *parentPlot)
      void setParentLayerable (QCPLayerable *parentLayerable)
      bool moveToLayer (QCPLayer *layer, bool prepend)
      void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
      - Protected Functions inherited from QCPLayerable
      virtual void parentPlotInitialized (QCustomPlot *parentPlot)
      virtual QRect clipRect () const
      void initializeParentPlot (QCustomPlot *parentPlot)
      void setParentLayerable (QCPLayerable *parentLayerable)
      bool moveToLayer (QCPLayer *layer, bool prepend)
      void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const

      Detailed Description

      Manages a single axis inside a QCustomPlot.

      -

      Usually doesn't need to be instantiated externally. Access QCustomPlot's default four axes via QCustomPlot::xAxis (bottom), QCustomPlot::yAxis (left), QCustomPlot::xAxis2 (top) and QCustomPlot::yAxis2 (right).

      +

      Usually doesn't need to be instantiated externally. Access QCustomPlot's default four axes via QCustomPlot::xAxis (bottom), QCustomPlot::yAxis (left), QCustomPlot::xAxis2 (top) and QCustomPlot::yAxis2 (right).

      Axes are always part of an axis rect, see QCPAxisRect.

      AxisNamesOverview.png @@ -348,7 +352,7 @@

      Defines the scale of an axis.

      -
      See Also
      setScaleType
      +
      See Also
      setScaleType
      Enumerator:
      stLinear 

      Linear scaling.

      @@ -453,14 +457,14 @@ - +
      - + @@ -485,7 +489,7 @@
      void QCPAxis::setScaleType (ScaleType QCPAxis::ScaleType  type)
      -

      If setScaleType is set to stLogarithmic, base will be the logarithm base of the scaling. In logarithmic axis scaling, major tick marks appear at all powers of base.

      +

      If setScaleType is set to stLogarithmic, base will be the logarithm base of the scaling. In logarithmic axis scaling, major tick marks appear at all powers of base.

      Properties like tick step (setTickStep) don't apply in logarithmic scaling. If you wish a decimal base but less major ticks, consider choosing base 100, 1000 or even higher.

      @@ -643,7 +647,8 @@

      Sets whether the tick positions should be calculated automatically (either from an automatically generated tick step or a tick step provided manually via setTickStep, see setAutoTickStep).

      If on is set to false, you must provide the tick positions manually via setTickVector. For these manual ticks you may let QCPAxis generate the appropriate labels automatically by leaving setAutoTickLabels set to true. If you also wish to control the displayed labels manually, set setAutoTickLabels to false and provide the label strings with setTickVectorLabels.

      -

      If you need dynamically calculated tick vectors (and possibly tick label vectors), set the vectors in a slot connected to the ticksRequest signal.

      +

      If you need dynamically calculated tick vectors (and possibly tick label vectors), set the vectors in a slot connected to the ticksRequest signal.

      +
      See Also
      setAutoTickLabels, setAutoSubTicks, setAutoTickCount, setAutoTickStep
      @@ -662,7 +667,8 @@

      When setAutoTickStep is true, approximateCount determines how many ticks should be generated in the visible range, approximately.

      It's not guaranteed that this number of ticks is met exactly, but approximately within a tolerance of about two.

      -

      Only values greater than zero are accepted as approximateCount.

      +

      Only values greater than zero are accepted as approximateCount.

      +
      See Also
      setAutoTickStep, setAutoTicks, setAutoSubTicks
      @@ -681,7 +687,8 @@

      Sets whether the tick labels are generated automatically. Depending on the tick label type (ltNumber or ltDateTime), the labels will either show the coordinate as floating point number (setNumberFormat), or a date/time formatted according to setDateTimeFormat.

      If on is set to false, you should provide the tick labels via setTickVectorLabels. This is usually used in a combination with setAutoTicks set to false for complete control over tick positions and labels, e.g. when the ticks should be at multiples of pi and show "2pi", "3pi" etc. as tick labels.

      -

      If you need dynamically calculated tick vectors (and possibly tick label vectors), set the vectors in a slot connected to the ticksRequest signal.

      +

      If you need dynamically calculated tick vectors (and possibly tick label vectors), set the vectors in a slot connected to the ticksRequest signal.

      +
      See Also
      setAutoTicks
      @@ -699,8 +706,9 @@

      Sets whether the tick step, i.e. the interval between two (major) ticks, is calculated automatically. If on is set to true, the axis finds a tick step that is reasonable for human readable plots.

      -

      The number of ticks the algorithm aims for within the visible range can be set with setAutoTickCount.

      -

      If on is set to false, you may set the tick step manually with setTickStep.

      +

      The number of ticks the algorithm aims for within the visible range can be specified with setAutoTickCount.

      +

      If on is set to false, you may set the tick step manually with setTickStep.

      +
      See Also
      setAutoTicks, setAutoSubTicks, setAutoTickCount
      @@ -718,7 +726,8 @@

      Sets whether the number of sub ticks in one tick interval is determined automatically. This works, as long as the tick step mantissa is a multiple of 0.5. When setAutoTickStep is enabled, this is always the case.

      -

      When on is set to false, you may set the sub tick count with setSubTickCount manually.

      +

      When on is set to false, you may set the sub tick count with setSubTickCount manually.

      +
      See Also
      setAutoTickCount, setAutoTicks, setAutoTickStep
      @@ -906,7 +915,7 @@

      The second and third characters are optional and specific to QCustomPlot:
      If the first char was 'e' or 'g', numbers are/might be displayed in the scientific format, e.g. "5.5e9", which is ugly in a plot. So when the second char of formatCode is set to 'b' (for "beautiful"), those exponential numbers are formatted in a more natural way, i.e. "5.5 [multiplication sign] 10 [superscript] 9". By default, the multiplication sign is a centered dot. If instead a cross should be shown (as is usual in the USA), the third char of formatCode can be set to 'c'. The inserted multiplication signs are the UTF-8 characters 215 (0xD7) for the cross and 183 (0xB7) for the dot.

      -

      If the scale type (setScaleType) is stLogarithmic and the formatCode uses the 'b' option (beautifully typeset decimal powers), the display usually is "1 [multiplication sign] 10 +

      If the scale type (setScaleType) is stLogarithmic and the formatCode uses the 'b' option (beautifully typeset decimal powers), the display usually is "1 [multiplication sign] 10 [superscript] n", which looks unnatural for logarithmic scaling (the "1 [multiplication sign]" part). To only display the decimal power, set the number precision to zero with setNumberPrecision.

      Examples for formatCode:

        @@ -933,7 +942,7 @@

        Sets the precision of the tick label numbers. See QLocale::toString(double i, char f, int prec) for details. The effect of precisions are most notably for number Formats starting with 'e', see setNumberFormat

        -

        If the scale type (setScaleType) is stLogarithmic and the number format (setNumberFormat) uses the 'b' format code (beautifully typeset decimal powers), the display usually is "1 [multiplication sign] 10 [superscript] n", which looks unnatural for logarithmic scaling (the redundant "1 [multiplication sign]" part). To only display the decimal power "10 +

        If the scale type (setScaleType) is stLogarithmic and the number format (setNumberFormat) uses the 'b' format code (beautifully typeset decimal powers), the display usually is "1 [multiplication sign] 10 [superscript] n", which looks unnatural for logarithmic scaling (the redundant "1 [multiplication sign]" part). To only display the decimal power "10 [superscript] n", set precision to zero.

        @@ -1019,7 +1028,7 @@

        Sets the length of the ticks in pixels. inside is the length the ticks will reach inside the plot and outside is the length they will reach outside the plot. If outside is greater than zero, the tick labels and axis label will increase their distance to the axis accordingly, so they won't collide with the ticks.

        -
        See Also
        setSubTickLength
        +
        See Also
        setSubTickLength, setTickLengthIn, setTickLengthOut
        @@ -1037,7 +1046,7 @@

        Sets the length of the inward ticks in pixels. inside is the length the ticks will reach inside the plot.

        -
        See Also
        setTickLengthOut, setSubTickLength
        +
        See Also
        setTickLengthOut, setTickLength, setSubTickLength
        @@ -1055,7 +1064,7 @@

        Sets the length of the outward ticks in pixels. outside is the length the ticks will reach outside the plot. If outside is greater than zero, the tick labels and axis label will increase their distance to the axis accordingly, so they won't collide with the ticks.

        -
        See Also
        setTickLengthIn, setSubTickLength
        +
        See Also
        setTickLengthIn, setTickLength, setSubTickLength
        @@ -1101,7 +1110,8 @@
        -

        Sets the length of the subticks in pixels. inside is the length the subticks will reach inside the plot and outside is the length they will reach outside the plot. If outside is greater than zero, the tick labels and axis label will increase their distance to the axis accordingly, so they won't collide with the ticks.

        +

        Sets the length of the subticks in pixels. inside is the length the subticks will reach inside the plot and outside is the length they will reach outside the plot. If outside is greater than zero, the tick labels and axis label will increase their distance to the axis accordingly, so they won't collide with the ticks.

        +
        See Also
        setTickLength, setSubTickLengthIn, setSubTickLengthOut
        @@ -1119,7 +1129,7 @@

        Sets the length of the inward subticks in pixels. inside is the length the subticks will reach inside the plot.

        -
        See Also
        setSubTickLengthOut, setTickLength
        +
        See Also
        setSubTickLengthOut, setSubTickLength, setTickLength
        @@ -1137,7 +1147,7 @@

        Sets the length of the outward subticks in pixels. outside is the length the subticks will reach outside the plot. If outside is greater than zero, the tick labels will increase their distance to the axis accordingly, so they won't collide with the ticks.

        -
        See Also
        setSubTickLengthIn, setTickLength
        +
        See Also
        setSubTickLengthIn, setSubTickLength, setTickLength
        @@ -1300,7 +1310,7 @@

        Sets the offset the axis has to its axis rect side.

        -

        If an axis rect side has multiple axes, only the offset of the inner most axis has meaning. The offset of the other axes is controlled automatically, to place the axes at appropriate positions to prevent them from overlapping.

        +

        If an axis rect side has multiple axes and automatic margin calculation is enabled for that side, only the offset of the inner most axis has meaning (even if it is set to be invisible). The offset of the other, outer axes is controlled automatically, to place them at appropriate positions.

        @@ -1578,7 +1588,8 @@
        -

        Returns the orientation of the axis. The axis orientation (horizontal or vertical) is deduced from the axis type (left, top, right or bottom).

        +

        Returns the orientation of this axis. The axis orientation (horizontal or vertical) is deduced from the axis type (left, top, right or bottom).

        +
        See Also
        orientation(AxisType type)
        @@ -1595,7 +1606,7 @@
        -

        If the scale type (setScaleType) is stLinear, diff is added to the lower and upper bounds of the range. The range is simply moved by diff.

        +

        If the scale type (setScaleType) is stLinear, diff is added to the lower and upper bounds of the range. The range is simply moved by diff.

        If the scale type is stLogarithmic, the range bounds are multiplied by diff. This corresponds to an apparent "linear" move in logarithmic scaling by a distance of log(diff).

        @@ -1804,7 +1815,7 @@ - +
        @@ -1812,25 +1823,25 @@ +inlinestatic
        - + - + +
        void QCPAxis::ticksRequest static Qt::Orientation QCPAxis::orientation ()AxisType type)
        -signal
        -

        This signal is emitted when setAutoTicks is false and the axis is about to generate tick labels for a replot.

        -

        Modifying the tick positions can be done with setTickVector. If you also want to control the tick labels, set setAutoTickLabels to false and also provide the labels with setTickVectorLabels.

        -

        If you only want static ticks you probably don't need this signal, since you can just set the tick vector (and possibly tick label vector) once. However, if you want to provide ticks (and maybe labels) dynamically, e.g. depending on the current axis range, connect a slot to this signal and set the vector/vectors there.

        +

        Returns the orientation of the specified axis type

        +
        See Also
        orientation()
        - +
        @@ -1838,24 +1849,24 @@ +static
        - + - - + +
        void QCPAxis::rangeChanged QCPAxis::AxisType QCPAxis::opposite (const QCPRangenewRange)QCPAxis::AxisType type)
        -signal
        -

        This signal is emitted when the range of this axis has changed. You can connect it to the setRange slot of another axis to communicate the new range to the other axis, in order for it to be synchronized.

        +

        Returns the axis type that describes the opposite axis of an axis with the specified type.

        - +
        @@ -1863,21 +1874,10 @@ @@ -1886,12 +1886,13 @@
        - + - - - - - - - - - - + - -
        void QCPAxis::rangeChanged void QCPAxis::ticksRequest (const QCPRangenewRange,
        const QCPRangeoldRange 
        ) )
        -

        This is an overloaded function.

        -

        Additionally to the new range, this signal also provides the previous range held by the axis as oldRange.

        +

        This signal is emitted when setAutoTicks is false and the axis is about to generate tick labels for a replot.

        +

        Modifying the tick positions can be done with setTickVector. If you also want to control the tick labels, set setAutoTickLabels to false and also provide the labels with setTickVectorLabels.

        +

        If you only want static ticks you probably don't need this signal, since you can just set the tick vector (and possibly tick label vector) once. However, if you want to provide ticks (and maybe labels) dynamically, e.g. depending on the current axis range, connect a slot to this signal and set the vector/vectors there.

        - +
        @@ -1899,10 +1900,10 @@
        - + - - + +
        void QCPAxis::selectionChanged void QCPAxis::rangeChanged (const QCPAxis::SelectableParts & parts)const QCPRangenewRange)
        @@ -1912,11 +1913,11 @@
        -

        This signal is emitted when the selection state of this axis has changed, either by user interaction or by a direct call to setSelectedParts.

        +

        This signal is emitted when the range of this axis has changed. You can connect it to the setRange slot of another axis to communicate the new range to the other axis, in order for it to be synchronized.

        - +
        @@ -1924,48 +1925,35 @@ - - -
        - + - + + + + + + + -
        void QCPAxis::setupTickVectors void QCPAxis::rangeChanged ()const QCPRangenewRange,
        const QCPRangeoldRange 
        -
        -protectedvirtual
        -
        -

        This function is called to prepare the tick vector, sub tick vector and tick label vector. If setAutoTicks is set to true, appropriate tick values are determined automatically via generateAutoTicks. If it's set to false, the signal ticksRequest is emitted, which can be used to provide external tick positions. Then the sub tick vectors and tick label vectors are created.

        - -
        -
        - -
        -
        - - - +signal
        - - - - + +
        void QCPAxis::generateAutoTicks () )
        -protectedvirtual
        -

        If setAutoTicks is set to true, this function is called by setupTickVectors to generate reasonable tick positions (and subtick count). The algorithm tries to create approximately mAutoTickCount ticks (set via setAutoTickCount).

        -

        If the scale is logarithmic, setAutoTickCount is ignored, and one tick is generated at every power of the current logarithm base, set via setScaleLogBase.

        +

        This is an overloaded function.

        +

        Additionally to the new range, this signal also provides the previous range held by the axis as oldRange.

        - +
        @@ -1973,25 +1961,24 @@ +signal
        - + - - - + + +
        int QCPAxis::calculateAutoSubTickCount void QCPAxis::scaleTypeChanged (double tickStep) constQCPAxis::ScaleType scaleType)
        -protectedvirtual
        -

        Called by generateAutoTicks when setAutoSubTicks is set to true. Depending on the tickStep between two major ticks on the axis, a different number of sub ticks is appropriate. For Example taking 4 sub ticks for a tickStep of 1 makes more sense than taking 5 sub ticks, because this corresponds to a sub tick step of 0.2, instead of the less intuitive 0.16667. Note that a subtick count of 4 means dividing the major tick step into 5 sections.

        -

        This is implemented by a hand made lookup for integer tick steps as well as fractional tick steps with a fractional part of (approximately) 0.5. If a tick step is different (i.e. has no fractional part close to 0.5), the currently set sub tick count (setSubTickCount) is returned.

        +

        This signal is emitted when the scale type changes, by calls to setScaleType

        - +
        @@ -1999,25 +1986,24 @@ +signal
        - + - + +
        int QCPAxis::calculateMargin void QCPAxis::selectionChanged ()const QCPAxis::SelectableParts & parts)
        -protectedvirtual
        -

        Returns the appropriate outward margin for this axis. It is needed if QCPAxisRect::setAutoMargins is set to true on the parent axis rect. An axis with axis type atLeft will return an appropriate left margin, atBottom will return an appropriate bottom margin and so forth. For the calculation, this function goes through similar steps as draw, so changing one function likely requires the modification of the other one as well.

        -

        The margin consists of the outward tick length, tick label padding, tick label size, label padding, label size, and padding.

        -

        The margin is cached internally, so repeated calls while leaving the axis range, fonts, etc. unchanged are very fast.

        +

        This signal is emitted when the selection state of this axis has changed, either by user interaction or by a direct call to setSelectedParts.

        - +
        @@ -2025,54 +2011,24 @@ +signal
        - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - -
        void QCPAxis::placeTickLabel void QCPAxis::selectableChanged (QCPPainterpainter,
        double position,
        int distanceToAxis,
        const QString & text,
        QSize * tickLabelsSize 
        const QCPAxis::SelectableParts & parts) )
        -protectedvirtual
        -

        Draws a single tick label with the provided painter, utilizing the internal label cache to significantly speed up drawing of labels that were drawn in previous calls. The tick label is always bound to an axis, the distance to the axis is controllable via distanceToAxis in pixels. The pixel position in the axis direction is passed in the position parameter. Hence for the bottom axis, position would indicate the horizontal pixel position (not coordinate), at which the label should be drawn.

        -

        In order to later draw the axis label in a place that doesn't overlap with the tick labels, the largest tick label size is needed. This is acquired by passing a tickLabelsSize to the drawTickLabel calls during the process of drawing all tick labels of one axis. In every call, tickLabelsSize is expanded, if the drawn label exceeds the value tickLabelsSize currently holds.

        -

        The label is drawn with the font and pen that are currently set on the painter. To draw superscripted powers, the font is temporarily made smaller by a fixed factor (see getTickLabelData).

        +

        This signal is emitted when the selectability changes, by calls to setSelectableParts

        - +
        @@ -2080,33 +2036,10 @@ @@ -2115,12 +2048,11 @@
        - + - - - - - - - - - - - - - - - - - + - - - - - - -
        void QCPAxis::drawTickLabel void QCPAxis::setupTickVectors (QCPPainterpainter,
        double x,
        double y,
        ) const TickLabelData & labelData 
        ) const
        -

        This is a placeTickLabel helper function.

        -

        Draws the tick label specified in labelData with painter at the pixel positions x and y. This function is used by placeTickLabel to create new tick labels for the cache, or to directly draw the labels on the QCustomPlot surface when label caching is disabled, i.e. when QCP::phCacheLabels plotting hint is not set.

        +

        This function is called to prepare the tick vector, sub tick vector and tick label vector. If setAutoTicks is set to true, appropriate tick values are determined automatically via generateAutoTicks. If it's set to false, the signal ticksRequest is emitted, which can be used to provide external tick positions. Then the sub tick vectors and tick label vectors are created.

        - +
        @@ -2128,21 +2060,10 @@ @@ -2151,12 +2072,12 @@
        - + - - - - - + - - - - - - -
        QCPAxis::TickLabelData QCPAxis::getTickLabelData void QCPAxis::generateAutoTicks (const QFont & font,
        ) const QString & text 
        ) const
        -

        This is a placeTickLabel helper function.

        -

        Transforms the passed text and font to a tickLabelData structure that can then be further processed by getTickLabelDrawOffset and drawTickLabel. It splits the text into base and exponent if necessary (see setNumberFormat) and calculates appropriate bounding boxes.

        +

        If setAutoTicks is set to true, this function is called by setupTickVectors to generate reasonable tick positions (and subtick count). The algorithm tries to create approximately mAutoTickCount ticks (set via setAutoTickCount).

        +

        If the scale is logarithmic, setAutoTickCount is ignored, and one tick is generated at every power of the current logarithm base, set via setScaleLogBase.

        - +
        @@ -2164,10 +2085,10 @@
        - + - - + +
        QPointF QCPAxis::getTickLabelDrawOffset int QCPAxis::calculateAutoSubTickCount (const TickLabelData & labelData)double tickStep) const
        @@ -2177,13 +2098,12 @@
        -

        This is a placeTickLabel helper function.

        -

        Calculates the offset at which the top left corner of the specified tick label shall be drawn. The offset is relative to a point right next to the tick the label belongs to.

        -

        This function is thus responsible for e.g. centering tick labels under ticks and positioning them appropriately when they are rotated.

        +

        Called by generateAutoTicks when setAutoSubTicks is set to true. Depending on the tickStep between two major ticks on the axis, a different number of sub ticks is appropriate. For Example taking 4 sub ticks for a tickStep of 1 makes more sense than taking 5 sub ticks, because this corresponds to a sub tick step of 0.2, instead of the less intuitive 0.16667. Note that a subtick count of 4 means dividing the major tick step into 5 sections.

        +

        This is implemented by a hand made lookup for integer tick steps as well as fractional tick steps with a fractional part of (approximately) 0.5. If a tick step is different (i.e. has no fractional part close to 0.5), the currently set sub tick count (setSubTickCount) is returned.

        - +
        @@ -2191,27 +2111,10 @@ @@ -2220,7 +2123,9 @@
        - + - - - - - - - - - - - - - - - - + - -
        void QCPAxis::getMaxTickLabelSize int QCPAxis::calculateMargin (const QFont & font,
        const QString & text,
        QSize * tickLabelsSize 
        ) ) const
        -

        Simulates the steps done by placeTickLabel by calculating bounding boxes of the text label to be drawn, depending on number format etc. Since only the largest tick label is wanted for the margin calculation, the passed tickLabelsSize is only expanded, if it's currently set to a smaller width/height.

        +

        Returns the appropriate outward margin for this axis. It is needed if QCPAxisRect::setAutoMargins is set to true on the parent axis rect. An axis with axis type atLeft will return an appropriate left margin, atBottom will return an appropriate bottom margin and so forth. For the calculation, this function goes through similar steps as draw, so changing one function likely requires the modification of the other one as well.

        +

        The margin consists of the outward tick length, tick label padding, tick label size, label padding, label size, and padding.

        +

        The margin is cached internally, so repeated calls while leaving the axis range, fonts, etc. unchanged are very fast.

        @@ -2275,8 +2180,7 @@
        -

        Draws the axis with the specified painter.

        -

        The selection boxes (mAxisSelectionBox, mTickLabelsSelectionBox, mLabelSelectionBox) are set here, too.

        +

        Draws the axis with the specified painter, using the internal QCPAxisPainterPrivate instance.

        Implements QCPLayerable.

        @@ -2355,7 +2259,7 @@

        This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

        event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

        -

        Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

        +

        Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is fed back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

        selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

        See Also
        selectTest, deselectEvent
        @@ -2451,7 +2355,7 @@

        A log function with the base mScaleLogBase, used mostly for coordinate transforms in logarithmic scales with arbitrary log base. Uses the buffered mScaleLogBaseLogInv for faster calculation. This is set to 1.0/qLn(mScaleLogBase) in setScaleLogBase.

        -
        See Also
        basePow, setScaleLogBase, setScaleType
        +
        See Also
        basePow, setScaleLogBase, setScaleType
        @@ -2477,7 +2381,7 @@

        A power function with the base mScaleLogBase, used mostly for coordinate transforms in logarithmic scales with arbitrary log base.

        -
        See Also
        baseLog, setScaleLogBase, setScaleType
        +
        See Also
        baseLog, setScaleLogBase, setScaleType
        @@ -2649,351 +2553,6 @@ - -
        -
        - - - - - -
        - - - - - - - -
        QCPLayerable * QCPLayerable::parentLayerable () const
        -
        -inlineinherited
        -
        -

        Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.

        -

        Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.

        -

        A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.

        - -
        -
        - -
        -
        - - - - - -
        - - - - - - - - -
        void QCPLayerable::setVisible (bool on)
        -
        -inherited
        -
        -

        Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.

        - -
        -
        - -
        -
        - - - - - -
        - - - - - - - - -
        bool QCPLayerable::setLayer (QCPLayerlayer)
        -
        -inherited
        -
        -

        Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.

        -

        Returns true on success, i.e. if layer is a valid layer.

        - -
        -
        - -
        -
        - - - - - -
        - - - - - - - - -
        bool QCPLayerable::setLayer (const QString & layerName)
        -
        -inherited
        -
        -

        This is an overloaded function.

        -

        Sets the layer of this layerable object by name

        -

        Returns true on success, i.e. if layerName is a valid layer name.

        - -
        -
        - -
        -
        - - - - - -
        - - - - - - - - -
        void QCPLayerable::setAntialiased (bool enabled)
        -
        -inherited
        -
        -

        Sets whether this object will be drawn antialiased or not.

        -

        Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

        - -
        -
        - -
        -
        - - - - - -
        - - - - - - - -
        bool QCPLayerable::realVisibility () const
        -
        -inherited
        -
        -

        Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.

        -

        If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.

        -

        If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.

        - -
        -
        - -
        -
        - - - - - -
        - - - - - - - - -
        void QCPLayerable::parentPlotInitialized (QCustomPlotparentPlot)
        -
        -protectedvirtualinherited
        -
        -

        This function is called by initializeParentPlot, to allow subclasses to react on the setting of a parent plot. This is the case when 0 was passed as parent plot in the constructor, and the parent plot is set at a later time.

        -

        For example, QCPLayoutElement/QCPLayout hierarchies may be created independently of any QCustomPlot at first. When they are then added to a layout inside the QCustomPlot, the top level element of the hierarchy gets its parent plot initialized with initializeParentPlot. To propagate the parent plot to all the children of the hierarchy, the top level element then uses this function to pass the parent plot on to its child elements.

        -

        The default implementation does nothing.

        -
        See Also
        initializeParentPlot
        - -

        Reimplemented in QCPLegend, and QCPLayoutElement.

        - -
        -
        - -
        -
        - - - - - -
        - - - - - - - -
        QRect QCPLayerable::clipRect () const
        -
        -protectedvirtualinherited
        -
        -

        Returns the clipping rectangle of this layerable object. By default, this is the viewport of the parent QCustomPlot. Specific subclasses may reimplement this function to provide different clipping rects.

        -

        The returned clipping rect is set on the painter before the draw function of the respective object is called.

        - -

        Reimplemented in QCPAbstractItem, QCPAbstractPlottable, and QCPAbstractLegendItem.

        - -
        -
        - -
        -
        - - - - - -
        - - - - - - - - -
        void QCPLayerable::initializeParentPlot (QCustomPlotparentPlot)
        -
        -protectedinherited
        -
        -

        Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.

        -

        Note that, unlike when passing a non-null parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.

        -

        Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.

        -

        The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).

        - -
        -
        - -
        -
        - - - - - -
        - - - - - - - - -
        void QCPLayerable::setParentLayerable (QCPLayerableparentLayerable)
        -
        -protectedinherited
        -
        -

        Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.

        -

        The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.

        -
        See Also
        realVisibility
        - -
        -
        - -
        -
        - - - - - -
        - - - - - - - - - - - - - - - - - - -
        bool QCPLayerable::moveToLayer (QCPLayerlayer,
        bool prepend 
        )
        -
        -protectedinherited
        -
        -

        Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.

        -

        Returns true on success, i.e. if layer is a valid layer.

        - -
        -
        - -
        -
        - - - - - -
        - - - - - - - - - - - - - - - - - - - - - - - - -
        void QCPLayerable::applyAntialiasingHint (QCPPainterpainter,
        bool localAntialiased,
        QCP::AntialiasedElement overrideElement 
        ) const
        -
        -protectedinherited
        -
        -

        Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.

        - -
        -

        The documentation for this class was generated from the following files:
        • src/axis.h
        • src/axis.cpp
        • diff -Nru qcustomplot-1.1.0/documentation/html/classQCPAxisRect.html qcustomplot-1.2.0/documentation/html/classQCPAxisRect.html --- qcustomplot-1.1.0/documentation/html/classQCPAxisRect.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPAxisRect.html 2014-03-14 21:11:27.000000000 +0000 @@ -84,53 +84,57 @@ QPoint bottomLeft () const QPoint bottomRight () const QPoint center () const -virtual void update () +virtual void update (UpdatePhase phase) virtual QList< QCPLayoutElement * > elements (bool recursive) const -QCPLayoutlayout () const -QRect rect () const - +- Public Functions inherited from QCPLayoutElementQCPLayoutElement (QCustomPlot *parentPlot=0) +QCPLayoutlayout () const +QRect rect () const + QRect outerRect () const - + QMargins margins () const - + QMargins minimumMargins () const - + QCP::MarginSides autoMargins () const - + QSize minimumSize () const - + QSize maximumSize () const - + QCPMarginGroupmarginGroup (QCP::MarginSide side) const - + QHash< QCP::MarginSide,
          QCPMarginGroup * > marginGroups () const -void setOuterRect (const QRect &rect) -void setMargins (const QMargins &margins) -void setMinimumMargins (const QMargins &margins) -void setAutoMargins (QCP::MarginSides sides) -void setMinimumSize (const QSize &size) -void setMinimumSize (int width, int height) -void setMaximumSize (const QSize &size) -void setMaximumSize (int width, int height) -void setMarginGroup (QCP::MarginSides sides, QCPMarginGroup *group) -virtual QSize minimumSizeHint () const -virtual QSize maximumSizeHint () const -virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const - +void setOuterRect (const QRect &rect) +void setMargins (const QMargins &margins) +void setMinimumMargins (const QMargins &margins) +void setAutoMargins (QCP::MarginSides sides) +void setMinimumSize (const QSize &size) +void setMinimumSize (int width, int height) +void setMaximumSize (const QSize &size) +void setMaximumSize (int width, int height) +void setMarginGroup (QCP::MarginSides sides, QCPMarginGroup *group) +virtual QSize minimumSizeHint () const +virtual QSize maximumSizeHint () const +virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const +- Public Functions inherited from QCPLayerableQCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0) + bool visible () const - + QCustomPlotparentPlot () const -QCPLayerableparentLayerable () const - +QCPLayerableparentLayerable () const + QCPLayerlayer () const - + bool antialiased () const -void setVisible (bool on) -bool setLayer (QCPLayer *layer) -bool setLayer (const QString &layerName) -void setAntialiased (bool enabled) -bool realVisibility () const +void setVisible (bool on) +Q_SLOT bool setLayer (QCPLayer *layer) +bool setLayer (const QString &layerName) +void setAntialiased (bool enabled) +bool realVisibility () const @@ -143,16 +147,25 @@ - - - - - - - - - - + + + + + + + + + + + + +

          Protected Functions

          virtual void wheelEvent (QWheelEvent *event)
          void drawBackground (QCPPainter *painter)
          void updateAxesOffset (QCPAxis::AxisType type)
          virtual void mouseDoubleClickEvent (QMouseEvent *event)
          virtual void parentPlotInitialized (QCustomPlot *parentPlot)
          virtual QCP::Interaction selectionCategory () const
          virtual QRect clipRect () const
          virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
          virtual void deselectEvent (bool *selectionStateChanged)
          void initializeParentPlot (QCustomPlot *parentPlot)
          void setParentLayerable (QCPLayerable *parentLayerable)
          bool moveToLayer (QCPLayer *layer, bool prepend)
          void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
          - Protected Functions inherited from QCPLayoutElement
          virtual void mouseDoubleClickEvent (QMouseEvent *event)
          virtual void parentPlotInitialized (QCustomPlot *parentPlot)
          - Protected Functions inherited from QCPLayerable
          virtual QCP::Interaction selectionCategory () const
          virtual QRect clipRect () const
          virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
          virtual void deselectEvent (bool *selectionStateChanged)
          void initializeParentPlot (QCustomPlot *parentPlot)
          void setParentLayerable (QCPLayerable *parentLayerable)
          bool moveToLayer (QCPLayer *layer, bool prepend)
          void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
          + + + + +

          +Additional Inherited Members

          - Public Types inherited from QCPLayoutElement
          enum  UpdatePhase
          - Signals inherited from QCPLayerable
          void layerChanged (QCPLayer *newLayer)

          Detailed Description

          Holds multiple axes and arranges them in a rectangular shape.

          @@ -688,21 +701,26 @@
          -

          Convenience function to create an axis on each side that doesn't have any axes yet, and assign the top/right axes the following properties of the bottom/left axes (even if they already existed and weren't created by this function):

          +

          Convenience function to create an axis on each side that doesn't have any axes yet and set their visibility to true. Further, the top/right axes are assigned the following properties of the bottom/left axes:

          Tick labels (QCPAxis::setTickLabels) of the right and top axes are set to false.

          -

          If connectRanges is true, the rangeChanged signals of the bottom and left axes are connected to the QCPAxis::setRange slots of the top and right axes.

          +

          If connectRanges is true, the rangeChanged signals of the bottom and left axes are connected to the QCPAxis::setRange slots of the top and right axes.

          @@ -1048,7 +1066,7 @@ - +
          @@ -1058,7 +1076,8 @@ - + +
          void QCPAxisRect::update ()UpdatePhase phase)
          @@ -1069,9 +1088,9 @@

          This method is called automatically upon replot and doesn't need to be called by users of QCPAxisRect.

          -

          Calls the base class implementation to update the margins (see QCPLayoutElement::update), and finally passes the rect to the inset layout (insetLayout) and calls its QCPInsetLayout::update function.

          +

          Calls the base class implementation to update the margins (see QCPLayoutElement::update), and finally passes the rect to the inset layout (insetLayout) and calls its QCPInsetLayout::update function.

          -

          Reimplemented from QCPLayoutElement.

          +

          Reimplemented from QCPLayoutElement.

          @@ -1097,7 +1116,7 @@

          Returns a list of all child elements in this layout element. If recursive is true, all sub-child elements are included in the list, too.

          -

          Note that there may be entries with value 0 in the returned list. (For example, QCPLayoutGrid may have empty cells which yield 0 at the respective index.)

          +
          Warning
          There may be entries with value 0 in the returned list. (For example, QCPLayoutGrid may have empty cells which yield 0 at the respective index.)

          Reimplemented from QCPLayoutElement.

          @@ -1355,905 +1374,6 @@
          - -
          -
          - - - - - -
          - - - - - - - -
          QCPLayout * QCPLayoutElement::layout () const
          -
          -inlineinherited
          -
          -

          Returns the parent layout of this layout element.

          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - -
          QRect QCPLayoutElement::rect () const
          -
          -inlineinherited
          -
          -

          Returns the inner rect of this layout element. The inner rect is the outer rect (setOuterRect) shrinked by the margins (setMargins, setAutoMargins).

          -

          In some cases, the area between outer and inner rect is left blank. In other cases the margin area is used to display peripheral graphics while the main content is in the inner rect. This is where automatic margin calculation becomes interesting because it allows the layout element to adapt the margins to the peripheral graphics it wants to draw. For example, QCPAxisRect draws the axis labels and tick labels in the margin area, thus needs to adjust the margins (if setAutoMargins is enabled) according to the space required by the labels of the axes.

          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - - -
          void QCPLayoutElement::setOuterRect (const QRect & rect)
          -
          -inherited
          -
          -

          Sets the outer rect of this layout element. If the layout element is inside a layout, the layout sets the position and size of this layout element using this function.

          -

          Calling this function externally has no effect, since the layout will overwrite any changes to the outer rect upon the next replot.

          -

          The layout element will adapt its inner rect by applying the margins inward to the outer rect.

          -
          See Also
          rect
          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - - -
          void QCPLayoutElement::setMargins (const QMargins & margins)
          -
          -inherited
          -
          -

          Sets the margins of this layout element. If setAutoMargins is disabled for some or all sides, this function is used to manually set the margin on those sides. Sides that are still set to be handled automatically are ignored and may have any value in margins.

          -

          The margin is the distance between the outer rect (controlled by the parent layout via setOuterRect) and the inner rect (which usually contains the main content of this layout element).

          -
          See Also
          setAutoMargins
          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - - -
          void QCPLayoutElement::setMinimumMargins (const QMargins & margins)
          -
          -inherited
          -
          -

          If setAutoMargins is enabled on some or all margins, this function is used to provide minimum values for those margins.

          -

          The minimum values are not enforced on margin sides that were set to be under manual control via setAutoMargins.

          -
          See Also
          setAutoMargins
          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - - -
          void QCPLayoutElement::setAutoMargins (QCP::MarginSides sides)
          -
          -inherited
          -
          -

          Sets on which sides the margin shall be calculated automatically. If a side is calculated automatically, a minimum margin value may be provided with setMinimumMargins. If a side is set to be controlled manually, the value may be specified with setMargins.

          -

          Margin sides that are under automatic control may participate in a QCPMarginGroup (see setMarginGroup), to synchronize (align) it with other layout elements in the plot.

          -
          See Also
          setMinimumMargins, setMargins
          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - - -
          void QCPLayoutElement::setMinimumSize (const QSize & size)
          -
          -inherited
          -
          -

          Sets the minimum size for the inner rect of this layout element. A parent layout tries to respect the size here by changing row/column sizes in the layout accordingly.

          -

          If the parent layout size is not sufficient to satisfy all minimum size constraints of its child layout elements, the layout may set a size that is actually smaller than size. QCustomPlot propagates the layout's size constraints to the outside by setting its own minimum QWidget size accordingly, so violations of size should be exceptions.

          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - - - - - - - - - - - - -
          void QCPLayoutElement::setMinimumSize (int width,
          int height 
          )
          -
          -inherited
          -
          -

          This is an overloaded function.

          -

          Sets the minimum size for the inner rect of this layout element.

          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - - -
          void QCPLayoutElement::setMaximumSize (const QSize & size)
          -
          -inherited
          -
          -

          Sets the maximum size for the inner rect of this layout element. A parent layout tries to respect the size here by changing row/column sizes in the layout accordingly.

          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - - - - - - - - - - - - -
          void QCPLayoutElement::setMaximumSize (int width,
          int height 
          )
          -
          -inherited
          -
          -

          This is an overloaded function.

          -

          Sets the maximum size for the inner rect of this layout element.

          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - - - - - - - - - - - - -
          void QCPLayoutElement::setMarginGroup (QCP::MarginSides sides,
          QCPMarginGroupgroup 
          )
          -
          -inherited
          -
          -

          Sets the margin group of the specified margin sides.

          -

          Margin groups allow synchronizing specified margins across layout elements, see the documentation of QCPMarginGroup.

          -

          To unset the margin group of sides, set group to 0.

          -

          Note that margin groups only work for margin sides that are set to automatic (setAutoMargins).

          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - -
          QSize QCPLayoutElement::minimumSizeHint () const
          -
          -virtualinherited
          -
          -

          Returns the minimum size this layout element (the inner rect) may be compressed to.

          -

          if a minimum size (setMinimumSize) was not set manually, parent layouts consult this function to determine the minimum allowed size of this layout element. (A manual minimum size is considered set if it is non-zero.)

          - -

          Reimplemented in QCPLayoutGrid, QCPPlottableLegendItem, and QCPPlotTitle.

          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - -
          QSize QCPLayoutElement::maximumSizeHint () const
          -
          -virtualinherited
          -
          -

          Returns the maximum size this layout element (the inner rect) may be expanded to.

          -

          if a maximum size (setMaximumSize) was not set manually, parent layouts consult this function to determine the maximum allowed size of this layout element. (A manual maximum size is considered set if it is smaller than Qt's QWIDGETSIZE_MAX.)

          - -

          Reimplemented in QCPLayoutGrid, and QCPPlotTitle.

          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - - - - - - - - - - - - - - - - - - -
          double QCPLayoutElement::selectTest (const QPointF & pos,
          bool onlySelectable,
          QVariant * details = 0 
          ) const
          -
          -virtualinherited
          -
          -

          Layout elements are sensitive to events inside their outer rect. If pos is within the outer rect, this method returns a value corresponding to 0.99 times the parent plot's selection tolerance. However, layout elements are not selectable by default. So if onlySelectable is true, -1.0 is returned.

          -

          See QCPLayerable::selectTest for a general explanation of this virtual method.

          -

          QCPLayoutElement subclasses may reimplement this method to provide more specific selection test behaviour.

          - -

          Reimplemented from QCPLayerable.

          - -

          Reimplemented in QCPLayoutInset, QCPLegend, QCPAbstractLegendItem, and QCPPlotTitle.

          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - - -
          void QCPLayoutElement::mouseDoubleClickEvent (QMouseEvent * event)
          -
          -inlineprotectedvirtualinherited
          -
          -

          This event is called, if the mouse is double-clicked inside the outer rect of this layout element.

          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - - -
          void QCPLayoutElement::parentPlotInitialized (QCustomPlotparentPlot)
          -
          -protectedvirtualinherited
          -
          -

          propagates the parent plot initialization to all child elements, by calling QCPLayerable::initializeParentPlot on them.

          - -

          Reimplemented from QCPLayerable.

          - -

          Reimplemented in QCPLegend.

          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - -
          QCPLayerable * QCPLayerable::parentLayerable () const
          -
          -inlineinherited
          -
          -

          Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.

          -

          Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.

          -

          A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.

          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - - -
          void QCPLayerable::setVisible (bool on)
          -
          -inherited
          -
          -

          Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.

          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - - -
          bool QCPLayerable::setLayer (QCPLayerlayer)
          -
          -inherited
          -
          -

          Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.

          -

          Returns true on success, i.e. if layer is a valid layer.

          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - - -
          bool QCPLayerable::setLayer (const QString & layerName)
          -
          -inherited
          -
          -

          This is an overloaded function.

          -

          Sets the layer of this layerable object by name

          -

          Returns true on success, i.e. if layerName is a valid layer name.

          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - - -
          void QCPLayerable::setAntialiased (bool enabled)
          -
          -inherited
          -
          -

          Sets whether this object will be drawn antialiased or not.

          -

          Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - -
          bool QCPLayerable::realVisibility () const
          -
          -inherited
          -
          -

          Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.

          -

          If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.

          -

          If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.

          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - -
          QCP::Interaction QCPLayerable::selectionCategory () const
          -
          -protectedvirtualinherited
          -
          -

          Returns the selection category this layerable shall belong to. The selection category is used in conjunction with QCustomPlot::setInteractions to control which objects are selectable and which aren't.

          -

          Subclasses that don't fit any of the normal QCP::Interaction values can use QCP::iSelectOther. This is what the default implementation returns.

          -
          See Also
          QCustomPlot::setInteractions
          - -

          Reimplemented in QCPAxis, QCPLegend, QCPAbstractItem, QCPAbstractPlottable, and QCPAbstractLegendItem.

          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - -
          QRect QCPLayerable::clipRect () const
          -
          -protectedvirtualinherited
          -
          -

          Returns the clipping rectangle of this layerable object. By default, this is the viewport of the parent QCustomPlot. Specific subclasses may reimplement this function to provide different clipping rects.

          -

          The returned clipping rect is set on the painter before the draw function of the respective object is called.

          - -

          Reimplemented in QCPAbstractItem, QCPAbstractPlottable, and QCPAbstractLegendItem.

          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
          void QCPLayerable::selectEvent (QMouseEvent * event,
          bool additive,
          const QVariant & details,
          bool * selectionStateChanged 
          )
          -
          -protectedvirtualinherited
          -
          -

          This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

          -

          event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

          -

          Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

          -

          selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

          -
          See Also
          selectTest, deselectEvent
          - -

          Reimplemented in QCPAxis, QCPLegend, QCPAbstractItem, QCPAbstractPlottable, QCPPlotTitle, and QCPAbstractLegendItem.

          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - - -
          void QCPLayerable::deselectEvent (bool * selectionStateChanged)
          -
          -protectedvirtualinherited
          -
          -

          This event is called when the layerable shall be deselected, either as consequence of a user interaction or a call to QCustomPlot::deselectAll. Subclasses should react to it by unsetting their selection appropriately.

          -

          just as in selectEvent, the output parameter selectionStateChanged (if non-null), must return true or false when the selection state of this layerable has changed or not changed, respectively.

          -
          See Also
          selectTest, selectEvent
          - -

          Reimplemented in QCPAxis, QCPLegend, QCPAbstractItem, QCPAbstractPlottable, QCPPlotTitle, and QCPAbstractLegendItem.

          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - - -
          void QCPLayerable::initializeParentPlot (QCustomPlotparentPlot)
          -
          -protectedinherited
          -
          -

          Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.

          -

          Note that, unlike when passing a non-null parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.

          -

          Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.

          -

          The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).

          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - - -
          void QCPLayerable::setParentLayerable (QCPLayerableparentLayerable)
          -
          -protectedinherited
          -
          -

          Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.

          -

          The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.

          -
          See Also
          realVisibility
          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - - - - - - - - - - - - -
          bool QCPLayerable::moveToLayer (QCPLayerlayer,
          bool prepend 
          )
          -
          -protectedinherited
          -
          -

          Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.

          -

          Returns true on success, i.e. if layer is a valid layer.

          - -
          -
          - -
          -
          - - - - - -
          - - - - - - - - - - - - - - - - - - - - - - - - -
          void QCPLayerable::applyAntialiasingHint (QCPPainterpainter,
          bool localAntialiased,
          QCP::AntialiasedElement overrideElement 
          ) const
          -
          -protectedinherited
          -
          -

          Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.

          - -
          -

          The documentation for this class was generated from the following files:
          • src/layoutelements/layoutelement-axisrect.h
          • src/layoutelements/layoutelement-axisrect.cpp
          • diff -Nru qcustomplot-1.1.0/documentation/html/classQCPBars.html qcustomplot-1.2.0/documentation/html/classQCPBars.html --- qcustomplot-1.1.0/documentation/html/classQCPBars.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPBars.html 2014-03-14 21:11:27.000000000 +0000 @@ -17,8 +17,6 @@
            @@ -60,102 +58,108 @@ void removeData (double key) virtual void clearData () virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const - +- Public Functions inherited from QCPAbstractPlottableQCPAbstractPlottable (QCPAxis *keyAxis, QCPAxis *valueAxis) + QString name () const - + bool antialiasedFill () const - + bool antialiasedScatters () const - + bool antialiasedErrorBars () const - + QPen pen () const - + QPen selectedPen () const - + QBrush brush () const - + QBrush selectedBrush () const - + QCPAxiskeyAxis () const - + QCPAxisvalueAxis () const - + bool selectable () const - + bool selected () const -void setName (const QString &name) -void setAntialiasedFill (bool enabled) -void setAntialiasedScatters (bool enabled) -void setAntialiasedErrorBars (bool enabled) -void setPen (const QPen &pen) -void setSelectedPen (const QPen &pen) -void setBrush (const QBrush &brush) -void setSelectedBrush (const QBrush &brush) -void setKeyAxis (QCPAxis *axis) -void setValueAxis (QCPAxis *axis) -Q_SLOT void setSelectable (bool selectable) -Q_SLOT void setSelected (bool selected) -virtual bool addToLegend () -virtual bool removeFromLegend () const -void rescaleAxes (bool onlyEnlarge=false) const -void rescaleKeyAxis (bool onlyEnlarge=false) const -void rescaleValueAxis (bool onlyEnlarge=false) const - +void setName (const QString &name) +void setAntialiasedFill (bool enabled) +void setAntialiasedScatters (bool enabled) +void setAntialiasedErrorBars (bool enabled) +void setPen (const QPen &pen) +void setSelectedPen (const QPen &pen) +void setBrush (const QBrush &brush) +void setSelectedBrush (const QBrush &brush) +void setKeyAxis (QCPAxis *axis) +void setValueAxis (QCPAxis *axis) +Q_SLOT void setSelectable (bool selectable) +Q_SLOT void setSelected (bool selected) +virtual bool addToLegend () +virtual bool removeFromLegend () const +void rescaleAxes (bool onlyEnlarge=false) const +void rescaleKeyAxis (bool onlyEnlarge=false) const +void rescaleValueAxis (bool onlyEnlarge=false) const +- Public Functions inherited from QCPLayerableQCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0) + bool visible () const - + QCustomPlotparentPlot () const -QCPLayerableparentLayerable () const - +QCPLayerableparentLayerable () const + QCPLayerlayer () const - + bool antialiased () const -void setVisible (bool on) -bool setLayer (QCPLayer *layer) -bool setLayer (const QString &layerName) -void setAntialiased (bool enabled) -bool realVisibility () const - - - -

            -Signals

            void selectionChanged (bool selected)
            - - + + + + +

            -Protected Types

            enum  SignDomain
            void setVisible (bool on)
            Q_SLOT bool setLayer (QCPLayer *layer)
            bool setLayer (const QString &layerName)
            void setAntialiased (bool enabled)
            bool realVisibility () const
            - - + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + +

            Protected Functions

            virtual void draw (QCPPainter *painter)
            virtual void drawLegendIcon (QCPPainter *painter, const QRectF &rect) const
            virtual QCPRange getKeyRange (bool &validRange, SignDomain inSignDomain=sdBoth) const
            virtual QCPRange getValueRange (bool &validRange, SignDomain inSignDomain=sdBoth) const
            virtual QCPRange getKeyRange (bool &foundRange, SignDomain inSignDomain=sdBoth) const
            virtual QCPRange getValueRange (bool &foundRange, SignDomain inSignDomain=sdBoth) const
            QPolygonF getBarPolygon (double key, double value) const
            double getBaseValue (double key, bool positive) const
            virtual QRect clipRect () const
            virtual QCP::Interaction selectionCategory () const
            void applyDefaultAntialiasingHint (QCPPainter *painter) const
            virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
            virtual void deselectEvent (bool *selectionStateChanged)
            void coordsToPixels (double key, double value, double &x, double &y) const
            const QPointF coordsToPixels (double key, double value) const
            void pixelsToCoords (double x, double y, double &key, double &value) const
            void pixelsToCoords (const QPointF &pixelPos, double &key, double &value) const
            QPen mainPen () const
            QBrush mainBrush () const
            void applyFillAntialiasingHint (QCPPainter *painter) const
            void applyScattersAntialiasingHint (QCPPainter *painter) const
            void applyErrorBarsAntialiasingHint (QCPPainter *painter) const
            double distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const
            virtual void parentPlotInitialized (QCustomPlot *parentPlot)
            void initializeParentPlot (QCustomPlot *parentPlot)
            void setParentLayerable (QCPLayerable *parentLayerable)
            bool moveToLayer (QCPLayer *layer, bool prepend)
            void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
            - Protected Functions inherited from QCPAbstractPlottable
            virtual QRect clipRect () const
            virtual QCP::Interaction selectionCategory () const
            void applyDefaultAntialiasingHint (QCPPainter *painter) const
            virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
            virtual void deselectEvent (bool *selectionStateChanged)
            void coordsToPixels (double key, double value, double &x, double &y) const
            const QPointF coordsToPixels (double key, double value) const
            void pixelsToCoords (double x, double y, double &key, double &value) const
            void pixelsToCoords (const QPointF &pixelPos, double &key, double &value) const
            QPen mainPen () const
            QBrush mainBrush () const
            void applyFillAntialiasingHint (QCPPainter *painter) const
            void applyScattersAntialiasingHint (QCPPainter *painter) const
            void applyErrorBarsAntialiasingHint (QCPPainter *painter) const
            double distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const
            - Protected Functions inherited from QCPLayerable
            virtual void parentPlotInitialized (QCustomPlot *parentPlot)
            void initializeParentPlot (QCustomPlot *parentPlot)
            void setParentLayerable (QCPLayerable *parentLayerable)
            bool moveToLayer (QCPLayer *layer, bool prepend)
            void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
            +

            Protected Static Functions

            static void connectBars (QCPBars *lower, QCPBars *upper)
            + + + + + +

            +Additional Inherited Members

            - Signals inherited from QCPAbstractPlottable
            void selectionChanged (bool selected)
            void selectableChanged (bool selectable)
            - Protected Types inherited from QCPAbstractPlottable
            enum  SignDomain

            Detailed Description

            A plottable representing a bar chart in a plot.

            @@ -177,42 +181,7 @@

            and then modify the properties of the newly created plottable, e.g.:

            newBars->setName("Country population");
            newBars->setData(xData, yData);
            -

            Member Enumeration Documentation

            - -
            -
            - - - - - -
            - - - - -
            enum QCPAbstractPlottable::SignDomain
            -
            -protectedinherited
            -
            -

            Represents negative and positive sign domain for passing to getKeyRange and getValueRange.

            -
            Enumerator:
            - - - -
            sdNegative  -

            The negative sign domain, i.e. numbers smaller than zero.

            -
            sdBoth  -

            Both sign domains, including zero, i.e. all (rational) numbers.

            -
            sdPositive  -

            The positive sign domain, i.e. numbers greater than zero.

            -
            -
            -
            - -
            -
            -

            Constructor & Destructor Documentation

            +

            Constructor & Destructor Documentation

            @@ -733,7 +702,7 @@
            - +
            @@ -744,7 +713,7 @@ - + @@ -764,14 +733,15 @@
            QCPRange QCPBars::getKeyRange ( bool & validRange, foundRange,
            -

            called by rescaleAxes functions to get the full data key bounds. For logarithmic plots, one can set inSignDomain to either sdNegative or sdPositive in order to restrict the returned range to that sign domain. E.g. when only negative range is wanted, set inSignDomain to sdNegative and all positive points will be ignored for range calculation. For no restriction, just set inSignDomain to sdBoth (default). validRange is an output parameter that indicates whether a proper range could be found or not. If this is false, you shouldn't use the returned range (e.g. no points in data).

            -
            See Also
            rescaleAxes, getValueRange
            +

            called by rescaleAxes functions to get the full data key bounds. For logarithmic plots, one can set inSignDomain to either sdNegative or sdPositive in order to restrict the returned range to that sign domain. E.g. when only negative range is wanted, set inSignDomain to sdNegative and all positive points will be ignored for range calculation. For no restriction, just set inSignDomain to sdBoth (default). foundRange is an output parameter that indicates whether a range could be found or not. If this is false, you shouldn't use the returned range (e.g. no points in data).

            +

            Note that foundRange is not the same as QCPRange::validRange, since the range returned by this function may have size zero, which wouldn't count as a valid range.

            +
            See Also
            rescaleAxes, getValueRange
            -

            Implements QCPAbstractPlottable.

            +

            Implements QCPAbstractPlottable.

            - +
            @@ -782,7 +752,7 @@ - + @@ -802,10 +772,11 @@
            QCPRange QCPBars::getValueRange ( bool & validRange, foundRange,
            -

            called by rescaleAxes functions to get the full data value bounds. For logarithmic plots, one can set inSignDomain to either sdNegative or sdPositive in order to restrict the returned range to that sign domain. E.g. when only negative range is wanted, set inSignDomain to sdNegative and all positive points will be ignored for range calculation. For no restriction, just set inSignDomain to sdBoth (default). validRange is an output parameter that indicates whether a proper range could be found or not. If this is false, you shouldn't use the returned range (e.g. no points in data).

            -
            See Also
            rescaleAxes, getKeyRange
            +

            called by rescaleAxes functions to get the full data value bounds. For logarithmic plots, one can set inSignDomain to either sdNegative or sdPositive in order to restrict the returned range to that sign domain. E.g. when only negative range is wanted, set inSignDomain to sdNegative and all positive points will be ignored for range calculation. For no restriction, just set inSignDomain to sdBoth (default). foundRange is an output parameter that indicates whether a range could be found or not. If this is false, you shouldn't use the returned range (e.g. no points in data).

            +

            Note that foundRange is not the same as QCPRange::validRange, since the range returned by this function may have size zero, which wouldn't count as a valid range.

            +
            See Also
            rescaleAxes, getKeyRange
            -

            Implements QCPAbstractPlottable.

            +

            Implements QCPAbstractPlottable.

            @@ -916,1316 +887,6 @@ - -
            -
            - - - - - -
            - - - - - - - - -
            void QCPAbstractPlottable::setName (const QString & name)
            -
            -inherited
            -
            -

            The name is the textual representation of this plottable as it is displayed in the legend (QCPLegend). It may contain any UTF-8 characters, including newlines.

            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - -
            void QCPAbstractPlottable::setAntialiasedFill (bool enabled)
            -
            -inherited
            -
            -

            Sets whether fills of this plottable is drawn antialiased or not.

            -

            Note that this setting may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - -
            void QCPAbstractPlottable::setAntialiasedScatters (bool enabled)
            -
            -inherited
            -
            -

            Sets whether the scatter symbols of this plottable are drawn antialiased or not.

            -

            Note that this setting may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - -
            void QCPAbstractPlottable::setAntialiasedErrorBars (bool enabled)
            -
            -inherited
            -
            -

            Sets whether the error bars of this plottable are drawn antialiased or not.

            -

            Note that this setting may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - -
            void QCPAbstractPlottable::setPen (const QPen & pen)
            -
            -inherited
            -
            -

            The pen is used to draw basic lines that make up the plottable representation in the plot.

            -

            For example, the QCPGraph subclass draws its graph lines and scatter points with this pen.

            -
            See Also
            setBrush
            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - -
            void QCPAbstractPlottable::setSelectedPen (const QPen & pen)
            -
            -inherited
            -
            -

            When the plottable is selected, this pen is used to draw basic lines instead of the normal pen set via setPen.

            -
            See Also
            setSelected, setSelectable, setSelectedBrush, selectTest
            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - -
            void QCPAbstractPlottable::setBrush (const QBrush & brush)
            -
            -inherited
            -
            -

            The brush is used to draw basic fills of the plottable representation in the plot. The Fill can be a color, gradient or texture, see the usage of QBrush.

            -

            For example, the QCPGraph subclass draws the fill under the graph with this brush, when it's not set to Qt::NoBrush.

            -
            See Also
            setPen
            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - -
            void QCPAbstractPlottable::setSelectedBrush (const QBrush & brush)
            -
            -inherited
            -
            -

            When the plottable is selected, this brush is used to draw fills instead of the normal brush set via setBrush.

            -
            See Also
            setSelected, setSelectable, setSelectedPen, selectTest
            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - -
            void QCPAbstractPlottable::setKeyAxis (QCPAxisaxis)
            -
            -inherited
            -
            -

            The key axis of a plottable can be set to any axis of a QCustomPlot, as long as it is orthogonal to the plottable's value axis. This function performs no checks to make sure this is the case. The typical mathematical choice is to use the x-axis (QCustomPlot::xAxis) as key axis and the y-axis (QCustomPlot::yAxis) as value axis.

            -

            Normally, the key and value axes are set in the constructor of the plottable (or QCustomPlot::addGraph when working with QCPGraphs through the dedicated graph interface).

            -
            See Also
            setValueAxis
            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - -
            void QCPAbstractPlottable::setValueAxis (QCPAxisaxis)
            -
            -inherited
            -
            -

            The value axis of a plottable can be set to any axis of a QCustomPlot, as long as it is orthogonal to the plottable's key axis. This function performs no checks to make sure this is the case. The typical mathematical choice is to use the x-axis (QCustomPlot::xAxis) as key axis and the y-axis (QCustomPlot::yAxis) as value axis.

            -

            Normally, the key and value axes are set in the constructor of the plottable (or QCustomPlot::addGraph when working with QCPGraphs through the dedicated graph interface).

            -
            See Also
            setKeyAxis
            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - -
            void QCPAbstractPlottable::setSelectable (bool selectable)
            -
            -inherited
            -
            -

            Sets whether the user can (de-)select this plottable by clicking on the QCustomPlot surface. (When QCustomPlot::setInteractions contains iSelectPlottables.)

            -

            However, even when selectable was set to false, it is possible to set the selection manually, by calling setSelected directly.

            -
            See Also
            setSelected
            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - -
            void QCPAbstractPlottable::setSelected (bool selected)
            -
            -inherited
            -
            -

            Sets whether this plottable is selected or not. When selected, it uses a different pen and brush to draw its lines and fills, see setSelectedPen and setSelectedBrush.

            -

            The entire selection mechanism for plottables is handled automatically when QCustomPlot::setInteractions contains iSelectPlottables. You only need to call this function when you wish to change the selection state manually.

            -

            This function can change the selection state even when setSelectable was set to false.

            -

            emits the selectionChanged signal when selected is different from the previous selection state.

            -
            See Also
            setSelectable, selectTest
            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - -
            bool QCPAbstractPlottable::addToLegend ()
            -
            -virtualinherited
            -
            -

            Adds this plottable to the legend of the parent QCustomPlot (QCustomPlot::legend).

            -

            Normally, a QCPPlottableLegendItem is created and inserted into the legend. If the plottable needs a more specialized representation in the legend, this function will take this into account and instead create the specialized subclass of QCPAbstractLegendItem.

            -

            Returns true on success, i.e. when the legend exists and a legend item associated with this plottable isn't already in the legend.

            -
            See Also
            removeFromLegend, QCPLegend::addItem
            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - -
            bool QCPAbstractPlottable::removeFromLegend () const
            -
            -virtualinherited
            -
            -

            Removes the plottable from the legend of the parent QCustomPlot. This means the QCPAbstractLegendItem (usually a QCPPlottableLegendItem) that is associated with this plottable is removed.

            -

            Returns true on success, i.e. if the legend exists and a legend item associated with this plottable was found and removed.

            -
            See Also
            addToLegend, QCPLegend::removeItem
            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - -
            void QCPAbstractPlottable::rescaleAxes (bool onlyEnlarge = false) const
            -
            -inherited
            -
            -

            Rescales the key and value axes associated with this plottable to contain all displayed data, so the whole plottable is visible. If the scaling of an axis is logarithmic, rescaleAxes will make sure not to rescale to an illegal range i.e. a range containing different signs and/or zero. Instead it will stay in the current sign domain and ignore all parts of the plottable that lie outside of that domain.

            -

            onlyEnlarge makes sure the ranges are only expanded, never reduced. So it's possible to show multiple plottables in their entirety by multiple calls to rescaleAxes where the first call has onlyEnlarge set to false (the default), and all subsequent set to true.

            -
            See Also
            rescaleKeyAxis, rescaleValueAxis, QCustomPlot::rescaleAxes, QCPAxis::rescale
            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - -
            void QCPAbstractPlottable::rescaleKeyAxis (bool onlyEnlarge = false) const
            -
            -inherited
            -
            -

            Rescales the key axis of the plottable so the whole plottable is visible.

            -

            See rescaleAxes for detailed behaviour.

            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - -
            void QCPAbstractPlottable::rescaleValueAxis (bool onlyEnlarge = false) const
            -
            -inherited
            -
            -

            Rescales the value axis of the plottable so the whole plottable is visible.

            -

            Returns true if the axis was actually scaled. This might not be the case if this plottable has an invalid range, e.g. because it has no data points.

            -

            See rescaleAxes for detailed behaviour.

            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - -
            void QCPAbstractPlottable::selectionChanged (bool selected)
            -
            -signalinherited
            -
            -

            This signal is emitted when the selection state of this plottable has changed to selected, either by user interaction or by a direct call to setSelected.

            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - -
            QRect QCPAbstractPlottable::clipRect () const
            -
            -protectedvirtualinherited
            -
            -

            Returns the clipping rectangle of this layerable object. By default, this is the viewport of the parent QCustomPlot. Specific subclasses may reimplement this function to provide different clipping rects.

            -

            The returned clipping rect is set on the painter before the draw function of the respective object is called.

            - -

            Reimplemented from QCPLayerable.

            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - -
            QCP::Interaction QCPAbstractPlottable::selectionCategory () const
            -
            -protectedvirtualinherited
            -
            -

            Returns the selection category this layerable shall belong to. The selection category is used in conjunction with QCustomPlot::setInteractions to control which objects are selectable and which aren't.

            -

            Subclasses that don't fit any of the normal QCP::Interaction values can use QCP::iSelectOther. This is what the default implementation returns.

            -
            See Also
            QCustomPlot::setInteractions
            - -

            Reimplemented from QCPLayerable.

            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - -
            void QCPAbstractPlottable::applyDefaultAntialiasingHint (QCPPainterpainter) const
            -
            -protectedvirtualinherited
            -
            -

            A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing plottable lines.

            -

            This is the antialiasing state the painter passed to the draw method is in by default.

            -

            This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

            -
            See Also
            setAntialiased, applyFillAntialiasingHint, applyScattersAntialiasingHint, applyErrorBarsAntialiasingHint
            - -

            Implements QCPLayerable.

            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            void QCPAbstractPlottable::selectEvent (QMouseEvent * event,
            bool additive,
            const QVariant & details,
            bool * selectionStateChanged 
            )
            -
            -protectedvirtualinherited
            -
            -

            This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

            -

            event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

            -

            Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

            -

            selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

            -
            See Also
            selectTest, deselectEvent
            - -

            Reimplemented from QCPLayerable.

            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - -
            void QCPAbstractPlottable::deselectEvent (bool * selectionStateChanged)
            -
            -protectedvirtualinherited
            -
            -

            This event is called when the layerable shall be deselected, either as consequence of a user interaction or a call to QCustomPlot::deselectAll. Subclasses should react to it by unsetting their selection appropriately.

            -

            just as in selectEvent, the output parameter selectionStateChanged (if non-null), must return true or false when the selection state of this layerable has changed or not changed, respectively.

            -
            See Also
            selectTest, selectEvent
            - -

            Reimplemented from QCPLayerable.

            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            void QCPAbstractPlottable::coordsToPixels (double key,
            double value,
            double & x,
            double & y 
            ) const
            -
            -protectedinherited
            -
            -

            Convenience function for transforming a key/value pair to pixels on the QCustomPlot surface, taking the orientations of the axes associated with this plottable into account (e.g. whether key represents x or y).

            -

            key and value are transformed to the coodinates in pixels and are written to x and y.

            -
            See Also
            pixelsToCoords, QCPAxis::coordToPixel
            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - - - - - - - - - - - -
            const QPointF QCPAbstractPlottable::coordsToPixels (double key,
            double value 
            ) const
            -
            -protectedinherited
            -
            -

            This is an overloaded function.

            -

            Returns the input as pixel coordinates in a QPointF.

            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            void QCPAbstractPlottable::pixelsToCoords (double x,
            double y,
            double & key,
            double & value 
            ) const
            -
            -protectedinherited
            -
            -

            Convenience function for transforming a x/y pixel pair on the QCustomPlot surface to plot coordinates, taking the orientations of the axes associated with this plottable into account (e.g. whether key represents x or y).

            -

            x and y are transformed to the plot coodinates and are written to key and value.

            -
            See Also
            coordsToPixels, QCPAxis::coordToPixel
            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - - - - - - - - - - - - - - - - - -
            void QCPAbstractPlottable::pixelsToCoords (const QPointF & pixelPos,
            double & key,
            double & value 
            ) const
            -
            -protectedinherited
            -
            -

            This is an overloaded function.

            -

            Returns the pixel input pixelPos as plot coordinates key and value.

            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - -
            QPen QCPAbstractPlottable::mainPen () const
            -
            -protectedinherited
            -
            -

            Returns the pen that should be used for drawing lines of the plottable. Returns mPen when the graph is not selected and mSelectedPen when it is.

            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - -
            QBrush QCPAbstractPlottable::mainBrush () const
            -
            -protectedinherited
            -
            -

            Returns the brush that should be used for drawing fills of the plottable. Returns mBrush when the graph is not selected and mSelectedBrush when it is.

            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - -
            void QCPAbstractPlottable::applyFillAntialiasingHint (QCPPainterpainter) const
            -
            -protectedinherited
            -
            -

            A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing plottable fills.

            -

            This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

            -
            See Also
            setAntialiased, applyDefaultAntialiasingHint, applyScattersAntialiasingHint, applyErrorBarsAntialiasingHint
            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - -
            void QCPAbstractPlottable::applyScattersAntialiasingHint (QCPPainterpainter) const
            -
            -protectedinherited
            -
            -

            A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing plottable scatter points.

            -

            This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

            -
            See Also
            setAntialiased, applyFillAntialiasingHint, applyDefaultAntialiasingHint, applyErrorBarsAntialiasingHint
            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - -
            void QCPAbstractPlottable::applyErrorBarsAntialiasingHint (QCPPainterpainter) const
            -
            -protectedinherited
            -
            -

            A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing plottable error bars.

            -

            This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

            -
            See Also
            setAntialiased, applyFillAntialiasingHint, applyScattersAntialiasingHint, applyDefaultAntialiasingHint
            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - - - - - - - - - - - - - - - - - -
            double QCPAbstractPlottable::distSqrToLine (const QPointF & start,
            const QPointF & end,
            const QPointF & point 
            ) const
            -
            -protectedinherited
            -
            -

            Finds the shortest squared distance of point to the line segment defined by start and end.

            -

            This function may be used to help with the implementation of the selectTest function for specific plottables.

            -
            Note
            This function is identical to QCPAbstractItem::distSqrToLine
            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - -
            QCPLayerable * QCPLayerable::parentLayerable () const
            -
            -inlineinherited
            -
            -

            Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.

            -

            Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.

            -

            A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.

            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - -
            void QCPLayerable::setVisible (bool on)
            -
            -inherited
            -
            -

            Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.

            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - -
            bool QCPLayerable::setLayer (QCPLayerlayer)
            -
            -inherited
            -
            -

            Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.

            -

            Returns true on success, i.e. if layer is a valid layer.

            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - -
            bool QCPLayerable::setLayer (const QString & layerName)
            -
            -inherited
            -
            -

            This is an overloaded function.

            -

            Sets the layer of this layerable object by name

            -

            Returns true on success, i.e. if layerName is a valid layer name.

            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - -
            void QCPLayerable::setAntialiased (bool enabled)
            -
            -inherited
            -
            -

            Sets whether this object will be drawn antialiased or not.

            -

            Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - -
            bool QCPLayerable::realVisibility () const
            -
            -inherited
            -
            -

            Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.

            -

            If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.

            -

            If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.

            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - -
            void QCPLayerable::parentPlotInitialized (QCustomPlotparentPlot)
            -
            -protectedvirtualinherited
            -
            -

            This function is called by initializeParentPlot, to allow subclasses to react on the setting of a parent plot. This is the case when 0 was passed as parent plot in the constructor, and the parent plot is set at a later time.

            -

            For example, QCPLayoutElement/QCPLayout hierarchies may be created independently of any QCustomPlot at first. When they are then added to a layout inside the QCustomPlot, the top level element of the hierarchy gets its parent plot initialized with initializeParentPlot. To propagate the parent plot to all the children of the hierarchy, the top level element then uses this function to pass the parent plot on to its child elements.

            -

            The default implementation does nothing.

            -
            See Also
            initializeParentPlot
            - -

            Reimplemented in QCPLegend, and QCPLayoutElement.

            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - -
            void QCPLayerable::initializeParentPlot (QCustomPlotparentPlot)
            -
            -protectedinherited
            -
            -

            Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.

            -

            Note that, unlike when passing a non-null parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.

            -

            Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.

            -

            The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).

            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - -
            void QCPLayerable::setParentLayerable (QCPLayerableparentLayerable)
            -
            -protectedinherited
            -
            -

            Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.

            -

            The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.

            -
            See Also
            realVisibility
            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - - - - - - - - - - - -
            bool QCPLayerable::moveToLayer (QCPLayerlayer,
            bool prepend 
            )
            -
            -protectedinherited
            -
            -

            Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.

            -

            Returns true on success, i.e. if layer is a valid layer.

            - -
            -
            - -
            -
            - - - - - -
            - - - - - - - - - - - - - - - - - - - - - - - - -
            void QCPLayerable::applyAntialiasingHint (QCPPainterpainter,
            bool localAntialiased,
            QCP::AntialiasedElement overrideElement 
            ) const
            -
            -protectedinherited
            -
            -

            Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.

            - -
            -

            The documentation for this class was generated from the following files:
            • src/plottables/plottable-bars.h
            • src/plottables/plottable-bars.cpp
            • diff -Nru qcustomplot-1.1.0/documentation/html/classQCPColorGradient.html qcustomplot-1.2.0/documentation/html/classQCPColorGradient.html --- qcustomplot-1.1.0/documentation/html/classQCPColorGradient.html 1970-01-01 00:00:00.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPColorGradient.html 2014-03-14 21:11:26.000000000 +0000 @@ -0,0 +1,452 @@ + + + + +QCPColorGradient Class Reference + + + + + + +
              + +
              +
              QCPColorGradient Class Reference
              +
              +
              + +

              Defines a color gradient for use with e.g. QCPColorMap. + More...

              + + + + +

              +Public Types

              enum  ColorInterpolation
              enum  GradientPreset
              + + + + + + + + + + + + + + + + + + +

              +Public Functions

               QCPColorGradient (GradientPreset preset=gpCold)
              +bool operator== (const QCPColorGradient &other) const
              +bool operator!= (const QCPColorGradient &other) const
              +int levelCount () const
              +QMap< double, QColor > colorStops () const
              +ColorInterpolation colorInterpolation () const
              +bool periodic () const
              void setLevelCount (int n)
              void setColorStops (const QMap< double, QColor > &colorStops)
              void setColorStopAt (double position, const QColor &color)
              void setColorInterpolation (ColorInterpolation interpolation)
              void setPeriodic (bool enabled)
              void colorize (const double *data, const QCPRange &range, QRgb *scanLine, int n, int dataIndexFactor=1, bool logarithmic=false)
              QRgb color (double position, const QCPRange &range, bool logarithmic=false)
              void loadPreset (GradientPreset preset)
              void clearColorStops ()
              QCPColorGradient inverted () const
              + + +

              +Protected Functions

              void updateColorBuffer ()
              +

              Detailed Description

              +

              Defines a color gradient for use with e.g. QCPColorMap.

              +

              This class describes a color gradient which can be used to encode data with color. For example, QCPColorMap and QCPColorScale have a setGradient method which takes an instance of this class. Colors are set with setColorStopAt(double position, const QColor &color) with a position from 0 to 1. In between these defined color positions, the color will be interpolated linearly either in RGB or HSV space, see setColorInterpolation.

              +

              Alternatively, load one of the preset color gradients shown in the image below, with loadPreset, or by directly specifying the preset in the constructor.

              +
              +QCPColorGradient.png +
              +

              The fact that the QCPColorGradient(GradientPreset preset) constructor allows directly converting a GradientPreset to a QCPColorGradient, you can also directly pass GradientPreset to all the setGradient methods, e.g.:

              +
              colorMap->setGradient(QCPColorGradient::gpHot);
              +

              The total number of levels used in the gradient can be set with setLevelCount. Whether the color gradient shall be applied periodically (wrapping around) to data values that lie outside the data range specified on the plottable instance can be controlled with setPeriodic.

              +

              Member Enumeration Documentation

              + +
              +
              +

              Defines the color spaces in which color interpolation between gradient stops can be performed.

              +
              See Also
              setColorInterpolation
              +
              Enumerator:
              + + +
              ciRGB  +

              Color channels red, green and blue are linearly interpolated.

              +
              ciHSV  +

              Color channels hue, saturation and value are linearly interpolated (The hue is interpolated over the shortest angle distance)

              +
              +
              +
              + +
              +
              + +
              +
              +

              Defines the available presets that can be loaded with loadPreset. See the documentation there for an image of the presets.

              +
              Enumerator:
              + + + + + + + + + + + + +
              gpGrayscale  +

              Continuous lightness from black to white (suited for non-biased data representation)

              +
              gpHot  +

              Continuous lightness from black over firey colors to white (suited for non-biased data representation)

              +
              gpCold  +

              Continuous lightness from black over icey colors to white (suited for non-biased data representation)

              +
              gpNight  +

              Continuous lightness from black over weak blueish colors to white (suited for non-biased data representation)

              +
              gpCandy  +

              Blue over pink to white.

              +
              gpGeography  +

              Colors suitable to represent different elevations on geographical maps.

              +
              gpIon  +

              Half hue spectrum from black over purple to blue and finally green (creates banding illusion but allows more precise magnitude estimates)

              +
              gpThermal  +

              Colors suitable for thermal imaging, ranging from dark blue over purple to orange, yellow and white.

              +
              gpPolar  +

              Colors suitable to emphasize polarity around the center, with blue for negative, black in the middle and red for positive values.

              +
              gpSpectrum  +

              An approximation of the visible light spectrum (creates banding illusion but allows more precise magnitude estimates)

              +
              gpJet  +

              Hue variation similar to a spectrum, often used in numerical visualization (creates banding illusion but allows more precise magnitude estimates)

              +
              gpHues  +

              Full hue cycle, with highest and lowest color red (suitable for periodic data, such as angles and phases, see setPeriodic)

              +
              +
              +
              + +
              +
              +

              Constructor & Destructor Documentation

              + +
              +
              + + + + + + + + +
              QCPColorGradient::QCPColorGradient (GradientPreset preset = gpCold)
              +
              +

              Constructs a new QCPColorGradient initialized with the colors and color interpolation according to preset.

              +

              The color level count is initialized to 350.

              + +
              +
              +

              Member Function Documentation

              + +
              +
              + + + + + + + + +
              void QCPColorGradient::setLevelCount (int n)
              +
              +

              Sets the number of discretization levels of the color gradient to n. The default is 350 which is typically enough to create a smooth appearance.

              +
              +QCPColorGradient-levelcount.png +
              + +
              +
              + +
              +
              + + + + + + + + +
              void QCPColorGradient::setColorStops (const QMap< double, QColor > & colorStops)
              +
              +

              Sets at which positions from 0 to 1 which color shall occur. The positions are the keys, the colors are the values of the passed QMap colorStops. In between these color stops, the color is interpolated according to setColorInterpolation.

              +

              A more convenient way to create a custom gradient may be to clear all color stops with clearColorStops and then adding them one by one with setColorStopAt.

              +
              See Also
              clearColorStops
              + +
              +
              + +
              +
              + + + + + + + + + + + + + + + + + + +
              void QCPColorGradient::setColorStopAt (double position,
              const QColor & color 
              )
              +
              +

              Sets the color the gradient will have at the specified position (from 0 to 1). In between these color stops, the color is interpolated according to setColorInterpolation.

              +
              See Also
              setColorStops, clearColorStops
              + +
              +
              + +
              +
              + + + + + + + + +
              void QCPColorGradient::setColorInterpolation (QCPColorGradient::ColorInterpolation interpolation)
              +
              +

              Sets whether the colors in between the configured color stops (see setColorStopAt) shall be interpolated linearly in RGB or in HSV color space.

              +

              For example, a sweep in RGB space from red to green will have a muddy brown intermediate color, whereas in HSV space the intermediate color is yellow.

              + +
              +
              + +
              +
              + + + + + + + + +
              void QCPColorGradient::setPeriodic (bool enabled)
              +
              +

              Sets whether data points that are outside the configured data range (e.g. QCPColorMap::setDataRange) are colored by periodically repeating the color gradient or whether they all have the same color, corresponding to the respective gradient boundary color.

              +
              +QCPColorGradient-periodic.png +
              +

              As shown in the image above, gradients that have the same start and end color are especially suitable for a periodic gradient mapping, since they produce smooth color transitions throughout the color map. A preset that has this property is gpHues.

              +

              In practice, using periodic color gradients makes sense when the data corresponds to a periodic dimension, such as an angle or a phase. If this is not the case, the color encoding might become ambiguous, because multiple different data values are shown as the same color.

              + +
              +
              + +
              +
              + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
              void QCPColorGradient::colorize (const double * data,
              const QCPRangerange,
              QRgb * scanLine,
              int n,
              int dataIndexFactor = 1,
              bool logarithmic = false 
              )
              +
              +

              This method is used to quickly convert a data array to colors. The colors will be output in the array scanLine. Both data and scanLine must have the length n when passed to this function. The data range that shall be used for mapping the data value to the gradient is passed in range. logarithmic indicates whether the data values shall be mapped to colors logarithmically.

              +

              if data actually contains 2D-data linearized via [row*columnCount + column], you can set dataIndexFactor to columnCount to convert a column instead of a row of the data array, in scanLine. scanLine will remain a regular (1D) array. This works because data is addressed data[i*dataIndexFactor].

              + +
              +
              + +
              +
              + + + + + + + + + + + + + + + + + + + + + + + + +
              QRgb QCPColorGradient::color (double position,
              const QCPRangerange,
              bool logarithmic = false 
              )
              +
              +

              This method is used to colorize a single data value given in position, to colors. The data range that shall be used for mapping the data value to the gradient is passed in range. logarithmic indicates whether the data value shall be mapped to a color logarithmically.

              +

              If an entire array of data values shall be converted, rather use colorize, for better performance.

              + +
              +
              + +
              +
              + + + + + + + + +
              void QCPColorGradient::loadPreset (GradientPreset preset)
              +
              +

              Clears the current color stops and loads the specified preset. A preset consists of predefined color stops and the corresponding color interpolation method.

              +

              The available presets are:

              +
              +QCPColorGradient.png +
              + +
              +
              + +
              +
              + + + + + + + +
              void QCPColorGradient::clearColorStops ()
              +
              +

              Clears all color stops.

              +
              See Also
              setColorStops, setColorStopAt
              + +
              +
              + +
              +
              + + + + + + + +
              QCPColorGradient QCPColorGradient::inverted () const
              +
              +

              Returns an inverted gradient. The inverted gradient has all properties as this QCPColorGradient, but the order of the color stops is inverted.

              +
              See Also
              setColorStops, setColorStopAt
              + +
              +
              + +
              +
              + + + + + +
              + + + + + + + +
              void QCPColorGradient::updateColorBuffer ()
              +
              +protected
              +
              +

              Updates the internal color buffer which will be used by colorize and color, to quickly convert positions to colors. This is where the interpolation between color stops is calculated.

              + +
              +
              +
              The documentation for this class was generated from the following files: +
              + + + diff -Nru qcustomplot-1.1.0/documentation/html/classQCPColorMapData.html qcustomplot-1.2.0/documentation/html/classQCPColorMapData.html --- qcustomplot-1.1.0/documentation/html/classQCPColorMapData.html 1970-01-01 00:00:00.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPColorMapData.html 2014-03-14 21:11:26.000000000 +0000 @@ -0,0 +1,516 @@ + + + + +QCPColorMapData Class Reference + + + + + + +
              + +
              +
              QCPColorMapData Class Reference
              +
              +
              + +

              Holds the two-dimensional data of a QCPColorMap plottable. + More...

              + + + + + + + + + + + + + + + + + + + + + + + + + + +

              +Public Functions

               QCPColorMapData (int keySize, int valueSize, const QCPRange &keyRange, const QCPRange &valueRange)
               QCPColorMapData (const QCPColorMapData &other)
              QCPColorMapDataoperator= (const QCPColorMapData &other)
              +int keySize () const
              +int valueSize () const
              +QCPRange keyRange () const
              +QCPRange valueRange () const
              +QCPRange dataBounds () const
              +double data (double key, double value)
              +double cell (int keyIndex, int valueIndex)
              void setSize (int keySize, int valueSize)
              void setKeySize (int keySize)
              void setValueSize (int valueSize)
              void setRange (const QCPRange &keyRange, const QCPRange &valueRange)
              void setKeyRange (const QCPRange &keyRange)
              void setValueRange (const QCPRange &valueRange)
              void setData (double key, double value, double z)
              void setCell (int keyIndex, int valueIndex, double z)
              void recalculateDataBounds ()
              void clear ()
              void fill (double z)
              bool isEmpty () const
              void coordToCell (double key, double value, int *keyIndex, int *valueIndex) const
              void cellToCoord (int keyIndex, int valueIndex, double *key, double *value) const
              +

              Detailed Description

              +

              Holds the two-dimensional data of a QCPColorMap plottable.

              +

              This class is a data storage for QCPColorMap. It holds a two-dimensional array, which QCPColorMap then displays as a 2D image in the plot, where the array values are represented by a color, depending on the value.

              +

              The size of the array can be controlled via setSize (or setKeySize, setValueSize). Which plot coordinates these cells correspond to can be configured with setRange (or setKeyRange, setValueRange).

              +

              The data cells can be accessed in two ways: They can be directly addressed by an integer index with setCell. This is the fastest method. Alternatively, they can be addressed by their plot coordinate with setData. plot coordinate to cell index transformations and vice versa are provided by the functions coordToCell and cellToCoord.

              +

              This class also buffers the minimum and maximum values that are in the data set, to provide QCPColorMap::rescaleDataRange with the necessary information quickly. Setting a cell to a value that is greater than the current maximum increases this maximum to the new value. However, setting the cell that currently holds the maximum value to a smaller value doesn't decrease the maximum again, because finding the true new maximum would require going through the entire data array, which might be time consuming. The same holds for the data minimum. This functionality is given by recalculateDataBounds, such that you can decide when it is sensible to find the true current minimum and maximum. The method QCPColorMap::rescaleDataRange offers a convenience parameter recalculateDataBounds which may be set to true to automatically call recalculateDataBounds internally.

              +

              Constructor & Destructor Documentation

              + +
              +
              + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
              QCPColorMapData::QCPColorMapData (int keySize,
              int valueSize,
              const QCPRangekeyRange,
              const QCPRangevalueRange 
              )
              +
              +

              Constructs a new QCPColorMapData instance. The instance has keySize cells in the key direction and valueSize cells in the value direction. These cells will be displayed by the QCPColorMap at the coordinates keyRange and valueRange.

              +
              See Also
              setSize, setKeySize, setValueSize, setRange, setKeyRange, setValueRange
              + +
              +
              + +
              +
              + + + + + + + + +
              QCPColorMapData::QCPColorMapData (const QCPColorMapDataother)
              +
              +

              Constructs a new QCPColorMapData instance copying the data and range of other.

              + +
              +
              +

              Member Function Documentation

              + +
              +
              + + + + + + + + +
              QCPColorMapData & QCPColorMapData::operator= (const QCPColorMapDataother)
              +
              +

              Overwrites this color map data instance with the data stored in other.

              + +
              +
              + +
              +
              + + + + + + + + + + + + + + + + + + +
              void QCPColorMapData::setSize (int keySize,
              int valueSize 
              )
              +
              +

              Resizes the data array to have keySize cells in the key dimension and valueSize cells in the value dimension.

              +

              The current data is discarded and the map cells are set to 0, unless the map had already the requested size.

              +

              Setting at least one of keySize or valueSize to zero frees the internal data array and isEmpty returns true.

              +
              See Also
              setRange, setKeySize, setValueSize
              + +
              +
              + +
              +
              + + + + + + + + +
              void QCPColorMapData::setKeySize (int keySize)
              +
              +

              Resizes the data array to have keySize cells in the key dimension.

              +

              The current data is discarded and the map cells are set to 0, unless the map had already the requested size.

              +

              Setting keySize to zero frees the internal data array and isEmpty returns true.

              +
              See Also
              setKeyRange, setSize, setValueSize
              + +
              +
              + +
              +
              + + + + + + + + +
              void QCPColorMapData::setValueSize (int valueSize)
              +
              +

              Resizes the data array to have valueSize cells in the value dimension.

              +

              The current data is discarded and the map cells are set to 0, unless the map had already the requested size.

              +

              Setting valueSize to zero frees the internal data array and isEmpty returns true.

              +
              See Also
              setValueRange, setSize, setKeySize
              + +
              +
              + +
              +
              + + + + + + + + + + + + + + + + + + +
              void QCPColorMapData::setRange (const QCPRangekeyRange,
              const QCPRangevalueRange 
              )
              +
              +

              Sets the coordinate ranges the data shall be distributed over. This defines the rectangular area covered by the color map in plot coordinates.

              +

              The outer cells will be centered on the range boundaries given to this function. For example, if the key size (setKeySize) is 3 and keyRange is set to QCPRange(2, 3) there will be cells centered on the key coordinates 2, 2.5 and 3.

              +
              See Also
              setSize
              + +
              +
              + +
              +
              + + + + + + + + +
              void QCPColorMapData::setKeyRange (const QCPRangekeyRange)
              +
              +

              Sets the coordinate range the data shall be distributed over in the key dimension. Together with the value range, This defines the rectangular area covered by the color map in plot coordinates.

              +

              The outer cells will be centered on the range boundaries given to this function. For example, if the key size (setKeySize) is 3 and keyRange is set to QCPRange(2, 3) there will be cells centered on the key coordinates 2, 2.5 and 3.

              +
              See Also
              setRange, setValueRange, setSize
              + +
              +
              + +
              +
              + + + + + + + + +
              void QCPColorMapData::setValueRange (const QCPRangevalueRange)
              +
              +

              Sets the coordinate range the data shall be distributed over in the value dimension. Together with the key range, This defines the rectangular area covered by the color map in plot coordinates.

              +

              The outer cells will be centered on the range boundaries given to this function. For example, if the value size (setValueSize) is 3 and valueRange is set to QCPRange(2, 3) there will be cells centered on the value coordinates 2, 2.5 and 3.

              +
              See Also
              setRange, setKeyRange, setSize
              + +
              +
              + +
              +
              + + + + + + + + + + + + + + + + + + + + + + + + +
              void QCPColorMapData::setData (double key,
              double value,
              double z 
              )
              +
              +

              Sets the data of the cell, which lies at the plot coordinates given by key and value, to z.

              +
              See Also
              setCell, setRange
              + +
              +
              + +
              +
              + + + + + + + + + + + + + + + + + + + + + + + + +
              void QCPColorMapData::setCell (int keyIndex,
              int valueIndex,
              double z 
              )
              +
              +

              Sets the data of the cell with indices keyIndex and valueIndex to z. The indices enumerate the cells starting from zero, up to the map's size-1 in the respective dimension (see setSize).

              +

              In the standard plot configuration (horizontal key axis and vertical value axis, both not range-reversed), the cell with indices (0, 0) is in the bottom left corner and the cell with indices (keySize-1, valueSize-1) is in the top right corner of the color map.

              +
              See Also
              setData, setSize
              + +
              +
              + +
              +
              + + + + + + + +
              void QCPColorMapData::recalculateDataBounds ()
              +
              +

              Goes through the data and updates the buffered minimum and maximum data values.

              +

              Calling this method is only advised if you are about to call QCPColorMap::rescaleDataRange and can not guarantee that the cells holding the maximum or minimum data haven't been overwritten with a smaller or larger value respectively, since the buffered maximum/minimum values have been updated the last time. Why this is the case is explained in the class description (QCPColorMapData).

              +

              Note that the method QCPColorMap::rescaleDataRange provides a parameter recalculateDataBounds for convenience. Setting this to true will call this method for you, before doing the rescale.

              + +
              +
              + +
              +
              + + + + + + + +
              void QCPColorMapData::clear ()
              +
              +

              Frees the internal data memory.

              +

              This is equivalent to calling setSize(0, 0).

              + +
              +
              + +
              +
              + + + + + + + + +
              void QCPColorMapData::fill (double z)
              +
              +

              Sets all cells to the value z.

              + +
              +
              + +
              +
              + + + + + +
              + + + + + + + +
              bool QCPColorMapData::isEmpty () const
              +
              +inline
              +
              +

              Returns whether this instance carries no data. This is equivalent to having a size where at least one of the dimensions is 0 (see setSize).

              + +
              +
              + +
              +
              + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
              void QCPColorMapData::coordToCell (double key,
              double value,
              int * keyIndex,
              int * valueIndex 
              ) const
              +
              +

              Transforms plot coordinates given by key and value to cell indices of this QCPColorMapData instance. The resulting cell indices are returned via the output parameters keyIndex and valueIndex.

              +

              The retrieved key/value cell indices can then be used for example with setCell.

              +

              If you are only interested in a key or value index, you may pass 0 as valueIndex or keyIndex.

              +
              See Also
              cellToCoord, QCPAxis::coordToPixel
              + +
              +
              + +
              +
              + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
              void QCPColorMapData::cellToCoord (int keyIndex,
              int valueIndex,
              double * key,
              double * value 
              ) const
              +
              +

              Transforms cell indices given by keyIndex and valueIndex to cell indices of this QCPColorMapData instance. The resulting coordinates are returned via the output parameters key and value.

              +

              If you are only interested in a key or value coordinate, you may pass 0 as key or value.

              +
              See Also
              coordToCell, QCPAxis::pixelToCoord
              + +
              +
              +
              The documentation for this class was generated from the following files: +
              + + + diff -Nru qcustomplot-1.1.0/documentation/html/classQCPColorMap.html qcustomplot-1.2.0/documentation/html/classQCPColorMap.html --- qcustomplot-1.1.0/documentation/html/classQCPColorMap.html 1970-01-01 00:00:00.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPColorMap.html 2014-03-14 21:11:27.000000000 +0000 @@ -0,0 +1,790 @@ + + + + +QCPColorMap Class Reference + + + + + + +
              + +
              +
              QCPColorMap Class Reference
              +
              +
              + +

              A plottable representing a two-dimensional color map in a plot. + More...

              +
              +Inheritance diagram for QCPColorMap:
              +
              +
              Inheritance graph
              + + +
              + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

              +Public Functions

               QCPColorMap (QCPAxis *keyAxis, QCPAxis *valueAxis)
              QCPColorMapDatadata () const
              +QCPRange dataRange () const
              +QCPAxis::ScaleType dataScaleType () const
              +bool interpolate () const
              +bool tightBoundary () const
              +QCPColorGradient gradient () const
              +QCPColorScalecolorScale () const
              void setData (QCPColorMapData *data, bool copy=false)
              Q_SLOT void setDataRange (const QCPRange &dataRange)
              Q_SLOT void setDataScaleType (QCPAxis::ScaleType scaleType)
              Q_SLOT void setGradient (const QCPColorGradient &gradient)
              void setInterpolate (bool enabled)
              void setTightBoundary (bool enabled)
              void setColorScale (QCPColorScale *colorScale)
              void rescaleDataRange (bool recalculateDataBounds=false)
              Q_SLOT void updateLegendIcon (Qt::TransformationMode transformMode=Qt::SmoothTransformation, const QSize &thumbSize=QSize(32, 18))
              virtual void clearData ()
              virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const
              - Public Functions inherited from QCPAbstractPlottable
               QCPAbstractPlottable (QCPAxis *keyAxis, QCPAxis *valueAxis)
              +QString name () const
              +bool antialiasedFill () const
              +bool antialiasedScatters () const
              +bool antialiasedErrorBars () const
              +QPen pen () const
              +QPen selectedPen () const
              +QBrush brush () const
              +QBrush selectedBrush () const
              +QCPAxiskeyAxis () const
              +QCPAxisvalueAxis () const
              +bool selectable () const
              +bool selected () const
              void setName (const QString &name)
              void setAntialiasedFill (bool enabled)
              void setAntialiasedScatters (bool enabled)
              void setAntialiasedErrorBars (bool enabled)
              void setPen (const QPen &pen)
              void setSelectedPen (const QPen &pen)
              void setBrush (const QBrush &brush)
              void setSelectedBrush (const QBrush &brush)
              void setKeyAxis (QCPAxis *axis)
              void setValueAxis (QCPAxis *axis)
              Q_SLOT void setSelectable (bool selectable)
              Q_SLOT void setSelected (bool selected)
              virtual bool addToLegend ()
              virtual bool removeFromLegend () const
              void rescaleAxes (bool onlyEnlarge=false) const
              void rescaleKeyAxis (bool onlyEnlarge=false) const
              void rescaleValueAxis (bool onlyEnlarge=false) const
              - Public Functions inherited from QCPLayerable
               QCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0)
              +bool visible () const
              +QCustomPlotparentPlot () const
              QCPLayerableparentLayerable () const
              +QCPLayerlayer () const
              +bool antialiased () const
              void setVisible (bool on)
              Q_SLOT bool setLayer (QCPLayer *layer)
              bool setLayer (const QString &layerName)
              void setAntialiased (bool enabled)
              bool realVisibility () const
              + + + + + + + + + +

              +Signals

              void dataRangeChanged (QCPRange newRange)
              void dataScaleTypeChanged (QCPAxis::ScaleType scaleType)
              void gradientChanged (QCPColorGradient newGradient)
              - Signals inherited from QCPAbstractPlottable
              void selectionChanged (bool selected)
              void selectableChanged (bool selectable)
              - Signals inherited from QCPLayerable
              void layerChanged (QCPLayer *newLayer)
              + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

              +Protected Functions

              virtual void updateMapImage ()
              virtual void draw (QCPPainter *painter)
              virtual void drawLegendIcon (QCPPainter *painter, const QRectF &rect) const
              virtual QCPRange getKeyRange (bool &foundRange, SignDomain inSignDomain=sdBoth) const
              virtual QCPRange getValueRange (bool &foundRange, SignDomain inSignDomain=sdBoth) const
              - Protected Functions inherited from QCPAbstractPlottable
              virtual QRect clipRect () const
              virtual QCP::Interaction selectionCategory () const
              void applyDefaultAntialiasingHint (QCPPainter *painter) const
              virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
              virtual void deselectEvent (bool *selectionStateChanged)
              void coordsToPixels (double key, double value, double &x, double &y) const
              const QPointF coordsToPixels (double key, double value) const
              void pixelsToCoords (double x, double y, double &key, double &value) const
              void pixelsToCoords (const QPointF &pixelPos, double &key, double &value) const
              QPen mainPen () const
              QBrush mainBrush () const
              void applyFillAntialiasingHint (QCPPainter *painter) const
              void applyScattersAntialiasingHint (QCPPainter *painter) const
              void applyErrorBarsAntialiasingHint (QCPPainter *painter) const
              double distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const
              - Protected Functions inherited from QCPLayerable
              virtual void parentPlotInitialized (QCustomPlot *parentPlot)
              void initializeParentPlot (QCustomPlot *parentPlot)
              void setParentLayerable (QCPLayerable *parentLayerable)
              bool moveToLayer (QCPLayer *layer, bool prepend)
              void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
              + + + +

              +Additional Inherited Members

              - Protected Types inherited from QCPAbstractPlottable
              enum  SignDomain
              +

              Detailed Description

              +

              A plottable representing a two-dimensional color map in a plot.

              +
              +QCPColorMap.png +
              +

              The data is stored in the class QCPColorMapData, which can be accessed via the data() method.

              +

              A color map has three dimensions to represent a data point: The key dimension, the value dimension and the data dimension. As with other plottables such as graphs, key and value correspond to two orthogonal axes on the QCustomPlot surface that you specify in the QColorMap constructor. The data dimension however is encoded as the color of the point at (key, value).

              +

              Set the number of points (or cells) in the key/value dimension via QCPColorMapData::setSize. The plot coordinate range over which these points will be displayed is specified via QCPColorMapData::setRange. The first cell will be centered on the lower range boundary and the last cell will be centered on the upper range boundary. The data can be set by either accessing the cells directly with QCPColorMapData::setCell or by addressing the cells via their plot coordinates with QCPColorMapData::setData. If possible, you should prefer setCell, since it doesn't need to do any coordinate transformation and thus performs a bit better.

              +

              The cell with index (0, 0) is at the bottom left, if the color map uses normal (i.e. not reversed) key and value axes.

              +

              To show the user which colors correspond to which data values, a QCPColorScale is typically placed to the right of the axis rect. See the documentation there for details on how to add and use a color scale.

              +

              +Changing the appearance

              +

              The central part of the appearance is the color gradient, which can be specified via setGradient. See the documentation of QCPColorGradient for details on configuring a color gradient.

              +

              The data range that is mapped to the colors of the gradient can be specified with setDataRange. To make the data range encompass the whole data set minimum to maximum, call rescaleDataRange.

              +

              +Usage

              +

              Like all data representing objects in QCustomPlot, the QCPColorMap is a plottable (QCPAbstractPlottable). So the plottable-interface of QCustomPlot applies (QCustomPlot::plottable, QCustomPlot::addPlottable, QCustomPlot::removePlottable, etc.)

              +

              Usually, you first create an instance:

              +
              QCPColorMap *colorMap = new QCPColorMap(customPlot->xAxis, customPlot->yAxis);
              +

              add it to the customPlot with QCustomPlot::addPlottable:

              +
              customPlot->addPlottable(colorMap);
              +

              and then modify the properties of the newly created color map, e.g.:

              +
              colorMap->data()->setSize(50, 50);
              +
              colorMap->data()->setRange(QCPRange(0, 2), QCPRange(0, 2));
              +
              for (int x=0; x<50; ++x)
              +
              for (int y=0; y<50; ++y)
              +
              colorMap->data()->setCell(x, y, qCos(x/10.0)+qSin(y/10.0));
              + +
              colorMap->rescaleDataRange(true);
              +
              customPlot->rescaleAxes();
              +
              customPlot->replot();
              +
              Note
              The QCPColorMap always displays the data at equal key/value intervals, even if the key or value axis is set to a logarithmic scaling. If you want to use QCPColorMap with logarithmic axes, you shouldn't use the QCPColorMapData::setData method as it uses a linear transformation to determine the cell index. Rather directly access the cell index with QCPColorMapData::setCell.
              +

              Constructor & Destructor Documentation

              + +
              +
              + + + + + +
              + + + + + + + + + + + + + + + + + + +
              QCPColorMap::QCPColorMap (QCPAxiskeyAxis,
              QCPAxisvalueAxis 
              )
              +
              +explicit
              +
              +

              Constructs a color map with the specified keyAxis and valueAxis.

              +

              The constructed QCPColorMap can be added to the plot with QCustomPlot::addPlottable, QCustomPlot then takes ownership of the color map.

              + +
              +
              +

              Member Function Documentation

              + +
              +
              + + + + + +
              + + + + + + + +
              QCPColorMapData * QCPColorMap::data () const
              +
              +inline
              +
              +

              Returns a pointer to the internal data storage of type QCPColorMapData. Access this to modify data points (cells) and the color map key/value range.

              +
              See Also
              setData
              + +
              +
              + +
              +
              + + + + + + + + + + + + + + + + + + +
              void QCPColorMap::setData (QCPColorMapDatadata,
              bool copy = false 
              )
              +
              +

              Replaces the current data with the provided data.

              +

              If copy is set to true, the data object will only be copied. if false, the color map takes ownership of the passed data and replaces the internal data pointer with it. This is significantly faster than copying for large datasets.

              + +
              +
              + +
              +
              + + + + + + + + +
              void QCPColorMap::setDataRange (const QCPRangedataRange)
              +
              +

              Sets the data range of this color map to dataRange. The data range defines which data values are mapped to the color gradient.

              +

              To make the data range span the full range of the data set, use rescaleDataRange.

              +
              See Also
              QCPColorScale::setDataRange
              + +
              +
              + +
              +
              + + + + + + + + +
              void QCPColorMap::setDataScaleType (QCPAxis::ScaleType scaleType)
              +
              +

              Sets whether the data is correlated with the color gradient linearly or logarithmically.

              +
              See Also
              QCPColorScale::setDataScaleType
              + +
              +
              + +
              +
              + + + + + + + + +
              void QCPColorMap::setGradient (const QCPColorGradientgradient)
              +
              +

              Sets the color gradient that is used to represent the data. For more details on how to create an own gradient or use one of the preset gradients, see QCPColorGradient.

              +

              The colors defined by the gradient will be used to represent data values in the currently set data range, see setDataRange. Data points that are outside this data range will either be colored uniformly with the respective gradient boundary color, or the gradient will repeat, depending on QCPColorGradient::setPeriodic.

              +
              See Also
              QCPColorScale::setGradient
              + +
              +
              + +
              +
              + + + + + + + + +
              void QCPColorMap::setInterpolate (bool enabled)
              +
              +

              Sets whether the color map image shall use bicubic interpolation when displaying the color map shrinked or expanded, and not at a 1:1 pixel-to-data scale.

              +
              +QCPColorMap-interpolate.png +
              +A 10*10 color map, with interpolation and without interpolation enabled
              + +
              +
              + +
              +
              + + + + + + + + +
              void QCPColorMap::setTightBoundary (bool enabled)
              +
              +

              Sets whether the outer most data rows and columns are clipped to the specified key and value range (see QCPColorMapData::setKeyRange, QCPColorMapData::setValueRange).

              +

              if enabled is set to false, the data points at the border of the color map are drawn with the same width and height as all other data points. Since the data points are represented by rectangles of one color centered on the data coordinate, this means that the shown color map extends by half a data point over the specified key/value range in each direction.

              +
              +QCPColorMap-tightboundary.png +
              +A color map, with tight boundary enabled and disabled
              + +
              +
              + +
              +
              + + + + + + + + +
              void QCPColorMap::setColorScale (QCPColorScalecolorScale)
              +
              +

              Associates the color scale colorScale with this color map.

              +

              This means that both the color scale and the color map synchronize their gradient, data range and data scale type (setGradient, setDataRange, setDataScaleType). Multiple color maps can be associated with one single color scale. This causes the color maps to also synchronize those properties, via the mutual color scale.

              +

              This function causes the color map to adopt the current color gradient, data range and data scale type of colorScale. After this call, you may change these properties at either the color map or the color scale, and the setting will be applied to both.

              +

              Pass 0 as colorScale to disconnect the color scale from this color map again.

              + +
              +
              + +
              +
              + + + + + + + + +
              void QCPColorMap::rescaleDataRange (bool recalculateDataBounds = false)
              +
              +

              Sets the data range (setDataRange) to span the minimum and maximum values that occur in the current data set. This corresponds to the rescaleKeyAxis or rescaleValueAxis methods, only for the third data dimension of the color map.

              +

              The minimum and maximum values of the data set are buffered in the internal QCPColorMapData instance (data). As data is updated via its QCPColorMapData::setCell or QCPColorMapData::setData, the buffered minimum and maximum values are updated, too. For performance reasons, however, they are only updated in an expanding fashion. So the buffered maximum can only increase and the buffered minimum can only decrease. In consequence, changes to the data that actually lower the maximum of the data set (by overwriting the cell holding the current maximum with a smaller value), aren't recognized and the buffered maximum overestimates the true maximum of the data set. The same happens for the buffered minimum. To recalculate the true minimum and maximum by explicitly looking at each cell, the method QCPColorMapData::recalculateDataBounds can be used. For convenience, setting the parameter recalculateDataBounds calls this method before setting the data range to the buffered minimum and maximum.

              +
              See Also
              setDataRange
              + +
              +
              + +
              +
              + + + + + + + + + + + + + + + + + + +
              void QCPColorMap::updateLegendIcon (Qt::TransformationMode transformMode = Qt::SmoothTransformation,
              const QSize & thumbSize = QSize(32, 18) 
              )
              +
              +

              Takes the current appearance of the color map and updates the legend icon, which is used to represent this color map in the legend (see QCPLegend).

              +

              The transformMode specifies whether the rescaling is done by a faster, low quality image scaling algorithm (Qt::FastTransformation) or by a slower, higher quality algorithm (Qt::SmoothTransformation).

              +

              The current color map appearance is scaled down to thumbSize. Ideally, this should be equal to the size of the legend icon (see QCPLegend::setIconSize). If it isn't exactly the configured legend icon size, the thumb will be rescaled during drawing of the legend item.

              +
              See Also
              setDataRange
              + +
              +
              + +
              +
              + + + + + +
              + + + + + + + +
              void QCPColorMap::clearData ()
              +
              +virtual
              +
              +

              Clears the colormap data by calling QCPColorMapData::clear() on the internal data. This also resizes the map to 0x0 cells.

              + +

              Implements QCPAbstractPlottable.

              + +
              +
              + +
              +
              + + + + + +
              + + + + + + + + + + + + + + + + + + + + + + + + +
              double QCPColorMap::selectTest (const QPointF & pos,
              bool onlySelectable,
              QVariant * details = 0 
              ) const
              +
              +virtual
              +
              +

              This function is used to decide whether a click hits a layerable object or not.

              +

              pos is a point in pixel coordinates on the QCustomPlot surface. This function returns the shortest pixel distance of this point to the object. If the object is either invisible or the distance couldn't be determined, -1.0 is returned. Further, if onlySelectable is true and the object is not selectable, -1.0 is returned, too.

              +

              If the item is represented not by single lines but by an area like QCPItemRect or QCPItemText, a click inside the area returns a constant value greater zero (typically the selectionTolerance of the parent QCustomPlot multiplied by 0.99). If the click lies outside the area, this function returns -1.0.

              +

              Providing a constant value for area objects allows selecting line objects even when they are obscured by such area objects, by clicking close to the lines (i.e. closer than 0.99*selectionTolerance).

              +

              The actual setting of the selection state is not done by this function. This is handled by the parent QCustomPlot when the mouseReleaseEvent occurs, and the finally selected object is notified via the selectEvent/deselectEvent methods.

              +

              details is an optional output parameter. Every layerable subclass may place any information in details. This information will be passed to selectEvent when the parent QCustomPlot decides on the basis of this selectTest call, that the object was successfully selected. The subsequent call to selectEvent will carry the details. This is useful for multi-part objects (like QCPAxis). This way, a possibly complex calculation to decide which part was clicked is only done once in selectTest. The result (i.e. the actually clicked part) can then be placed in details. So in the subsequent selectEvent, the decision which part was selected doesn't have to be done a second time for a single selection operation.

              +

              You may pass 0 as details to indicate that you are not interested in those selection details.

              +
              See Also
              selectEvent, deselectEvent, QCustomPlot::setInteractions
              + +

              Implements QCPAbstractPlottable.

              + +
              +
              + +
              +
              + + + + + +
              + + + + + + + + +
              void QCPColorMap::dataRangeChanged (QCPRange newRange)
              +
              +signal
              +
              +

              This signal is emitted when the data range changes.

              +
              See Also
              setDataRange
              + +
              +
              + +
              +
              + + + + + +
              + + + + + + + + +
              void QCPColorMap::dataScaleTypeChanged (QCPAxis::ScaleType scaleType)
              +
              +signal
              +
              +

              This signal is emitted when the data scale type changes.

              +
              See Also
              setDataScaleType
              + +
              +
              + +
              +
              + + + + + +
              + + + + + + + + +
              void QCPColorMap::gradientChanged (QCPColorGradient newGradient)
              +
              +signal
              +
              +

              This signal is emitted when the gradient changes.

              +
              See Also
              setGradient
              + +
              +
              + +
              +
              + + + + + +
              + + + + + + + +
              void QCPColorMap::updateMapImage ()
              +
              +protectedvirtual
              +
              +

              Updates the internal map image buffer by going through the internal QCPColorMapData and turning the data values into color pixels with QCPColorGradient::colorize.

              +

              This method is called by QCPColorMap::draw if either the data has been modified or the map image has been invalidated for a different reason (e.g. a change of the data range with setDataRange).

              + +
              +
              + +
              +
              + + + + + +
              + + + + + + + + +
              void QCPColorMap::draw (QCPPainterpainter)
              +
              +protectedvirtual
              +
              +

              This function draws the layerable with the specified painter. It is only called by QCustomPlot, if the layerable is visible (setVisible).

              +

              Before this function is called, the painter's antialiasing state is set via applyDefaultAntialiasingHint, see the documentation there. Further, the clipping rectangle was set to clipRect.

              + +

              Implements QCPAbstractPlottable.

              + +
              +
              + +
              +
              + + + + + +
              + + + + + + + + + + + + + + + + + + +
              void QCPColorMap::drawLegendIcon (QCPPainterpainter,
              const QRectF & rect 
              ) const
              +
              +protectedvirtual
              +
              +

              called by QCPLegend::draw (via QCPPlottableLegendItem::draw) to create a graphical representation of this plottable inside rect, next to the plottable name.

              + +

              Implements QCPAbstractPlottable.

              + +
              +
              + +
              +
              + + + + + +
              + + + + + + + + + + + + + + + + + + +
              QCPRange QCPColorMap::getKeyRange (bool & foundRange,
              SignDomain inSignDomain = sdBoth 
              ) const
              +
              +protectedvirtual
              +
              +

              called by rescaleAxes functions to get the full data key bounds. For logarithmic plots, one can set inSignDomain to either sdNegative or sdPositive in order to restrict the returned range to that sign domain. E.g. when only negative range is wanted, set inSignDomain to sdNegative and all positive points will be ignored for range calculation. For no restriction, just set inSignDomain to sdBoth (default). foundRange is an output parameter that indicates whether a range could be found or not. If this is false, you shouldn't use the returned range (e.g. no points in data).

              +

              Note that foundRange is not the same as QCPRange::validRange, since the range returned by this function may have size zero, which wouldn't count as a valid range.

              +
              See Also
              rescaleAxes, getValueRange
              + +

              Implements QCPAbstractPlottable.

              + +
              +
              + +
              +
              + + + + + +
              + + + + + + + + + + + + + + + + + + +
              QCPRange QCPColorMap::getValueRange (bool & foundRange,
              SignDomain inSignDomain = sdBoth 
              ) const
              +
              +protectedvirtual
              +
              +

              called by rescaleAxes functions to get the full data value bounds. For logarithmic plots, one can set inSignDomain to either sdNegative or sdPositive in order to restrict the returned range to that sign domain. E.g. when only negative range is wanted, set inSignDomain to sdNegative and all positive points will be ignored for range calculation. For no restriction, just set inSignDomain to sdBoth (default). foundRange is an output parameter that indicates whether a range could be found or not. If this is false, you shouldn't use the returned range (e.g. no points in data).

              +

              Note that foundRange is not the same as QCPRange::validRange, since the range returned by this function may have size zero, which wouldn't count as a valid range.

              +
              See Also
              rescaleAxes, getKeyRange
              + +

              Implements QCPAbstractPlottable.

              + +
              +
              +
              The documentation for this class was generated from the following files: +
              + + + Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/classQCPColorMap__inherit__graph.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/classQCPColorMap__inherit__graph.png differ diff -Nru qcustomplot-1.1.0/documentation/html/classQCPColorScale.html qcustomplot-1.2.0/documentation/html/classQCPColorScale.html --- qcustomplot-1.1.0/documentation/html/classQCPColorScale.html 1970-01-01 00:00:00.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPColorScale.html 2014-03-14 21:11:27.000000000 +0000 @@ -0,0 +1,654 @@ + + + + +QCPColorScale Class Reference + + + + + + +
              + +
              +
              QCPColorScale Class Reference
              +
              +
              + +

              A color scale for use with color coding data such as QCPColorMap. + More...

              +
              +Inheritance diagram for QCPColorScale:
              +
              +
              Inheritance graph
              + + +
              + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

              +Public Functions

               QCPColorScale (QCustomPlot *parentPlot)
              QCPAxisaxis () const
              +QCPAxis::AxisType type () const
              +QCPRange dataRange () const
              +QCPAxis::ScaleType dataScaleType () const
              +QCPColorGradient gradient () const
              +QString label () const
              +int barWidth () const
              +bool rangeDrag () const
              +bool rangeZoom () const
              void setType (QCPAxis::AxisType type)
              Q_SLOT void setDataRange (const QCPRange &dataRange)
              Q_SLOT void setDataScaleType (QCPAxis::ScaleType scaleType)
              Q_SLOT void setGradient (const QCPColorGradient &gradient)
              void setLabel (const QString &str)
              void setBarWidth (int width)
              void setRangeDrag (bool enabled)
              void setRangeZoom (bool enabled)
              QList< QCPColorMap * > colorMaps () const
              void rescaleDataRange (bool onlyVisibleMaps)
              virtual void update (UpdatePhase phase)
              - Public Functions inherited from QCPLayoutElement
               QCPLayoutElement (QCustomPlot *parentPlot=0)
              QCPLayoutlayout () const
              QRect rect () const
              +QRect outerRect () const
              +QMargins margins () const
              +QMargins minimumMargins () const
              +QCP::MarginSides autoMargins () const
              +QSize minimumSize () const
              +QSize maximumSize () const
              +QCPMarginGroupmarginGroup (QCP::MarginSide side) const
              +QHash< QCP::MarginSide,
              +QCPMarginGroup * > 
              marginGroups () const
              void setOuterRect (const QRect &rect)
              void setMargins (const QMargins &margins)
              void setMinimumMargins (const QMargins &margins)
              void setAutoMargins (QCP::MarginSides sides)
              void setMinimumSize (const QSize &size)
              void setMinimumSize (int width, int height)
              void setMaximumSize (const QSize &size)
              void setMaximumSize (int width, int height)
              void setMarginGroup (QCP::MarginSides sides, QCPMarginGroup *group)
              virtual QSize minimumSizeHint () const
              virtual QSize maximumSizeHint () const
              virtual QList< QCPLayoutElement * > elements (bool recursive) const
              virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const
              - Public Functions inherited from QCPLayerable
               QCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0)
              +bool visible () const
              +QCustomPlotparentPlot () const
              QCPLayerableparentLayerable () const
              +QCPLayerlayer () const
              +bool antialiased () const
              void setVisible (bool on)
              Q_SLOT bool setLayer (QCPLayer *layer)
              bool setLayer (const QString &layerName)
              void setAntialiased (bool enabled)
              bool realVisibility () const
              + + + + +

              +Signals

              void dataRangeChanged (QCPRange newRange)
              void dataScaleTypeChanged (QCPAxis::ScaleType scaleType)
              void gradientChanged (QCPColorGradient newGradient)
              + + + + + + + + + + + + + + + + + + + + +

              +Protected Functions

              virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
              virtual void mousePressEvent (QMouseEvent *event)
              virtual void mouseMoveEvent (QMouseEvent *event)
              virtual void mouseReleaseEvent (QMouseEvent *event)
              virtual void wheelEvent (QWheelEvent *event)
              - Protected Functions inherited from QCPLayoutElement
              virtual int calculateAutoMargin (QCP::MarginSide side)
              virtual void mouseDoubleClickEvent (QMouseEvent *event)
              virtual void draw (QCPPainter *painter)
              virtual void parentPlotInitialized (QCustomPlot *parentPlot)
              - Protected Functions inherited from QCPLayerable
              virtual QCP::Interaction selectionCategory () const
              virtual QRect clipRect () const
              virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
              virtual void deselectEvent (bool *selectionStateChanged)
              void initializeParentPlot (QCustomPlot *parentPlot)
              void setParentLayerable (QCPLayerable *parentLayerable)
              bool moveToLayer (QCPLayer *layer, bool prepend)
              void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
              + + + +

              +Additional Inherited Members

              - Public Types inherited from QCPLayoutElement
              enum  UpdatePhase
              +

              Detailed Description

              +

              A color scale for use with color coding data such as QCPColorMap.

              +

              This layout element can be placed on the plot to correlate a color gradient with data values. It is usually used in combination with one or multiple QCPColorMaps.

              +
              +QCPColorScale.png +
              +

              The color scale can be either horizontal or vertical, as shown in the image above. The orientation and the side where the numbers appear is controlled with setType.

              +

              Use QCPColorMap::setColorScale to connect a color map with a color scale. Once they are connected, they share their gradient, data range and data scale type (setGradient, setDataRange, setDataScaleType). Multiple color maps may be associated with a single color scale, to make them all synchronize these properties.

              +

              To have finer control over the number display and axis behaviour, you can directly access the axis. See the documentation of QCPAxis for details about configuring axes. For example, if you want to change the number of automatically generated ticks, call

              +
              colorScale->axis()->setAutoTickCount(3);
              +

              Placing a color scale next to the main axis rect works like with any other layout element:

              +
              QCPColorScale *colorScale = new QCPColorScale(customPlot);
              +
              customPlot->plotLayout()->addElement(0, 1, colorScale);
              +
              colorScale->setLabel("Some Label Text");
              +

              In this case we have placed it to the right of the default axis rect, so it wasn't necessary to call setType, since QCPAxis::atRight is already the default. The text next to the color scale can be set with setLabel.

              +

              For optimum appearance (like in the image above), it may be desirable to line up the axis rect and the borders of the color scale. Use a QCPMarginGroup to achieve this:

              +
              QCPMarginGroup *group = new QCPMarginGroup(customPlot);
              + +
              customPlot->axisRect()->setMarginGroup(QCP::msTop|QCP::msBottom, group);
              +

              Color scales are initialized with a non-zero minimum top and bottom margin (setMinimumMargins), because vertical color scales are most common and the minimum top/bottom margin makes sure it keeps some distance to the top/bottom widget border. So if you change to a horizontal color scale by setting setType to QCPAxis::atBottom or QCPAxis::atTop, you might want to also change the minimum margins accordingly, e.g. setMinimumMargins(QMargins(6, 0, 6, 0)).

              +

              Constructor & Destructor Documentation

              + +
              +
              + + + + + +
              + + + + + + + + +
              QCPColorScale::QCPColorScale (QCustomPlotparentPlot)
              +
              +explicit
              +
              +

              Constructs a new QCPColorScale.

              + +
              +
              +

              Member Function Documentation

              + +
              +
              + + + + + +
              + + + + + + + +
              QCPAxis * QCPColorScale::axis () const
              +
              +inline
              +
              +

              Returns the internal QCPAxis instance of this color scale. You can access it to alter the appearance and behaviour of the axis. QCPColorScale duplicates some properties in its interface for convenience. Those are setDataRange (QCPAxis::setRange), setDataScaleType (QCPAxis::setScaleType), and the method setLabel (QCPAxis::setLabel). As they each are connected, it does not matter whether you use the method on the QCPColorScale or on its QCPAxis.

              +

              If the type of the color scale is changed with setType, the axis returned by this method will change, too, to either the left, right, bottom or top axis, depending on which type was set.

              + +
              +
              + +
              +
              + + + + + + + + +
              void QCPColorScale::setType (QCPAxis::AxisType type)
              +
              +

              Sets at which side of the color scale the axis is placed, and thus also its orientation.

              +

              Note that after setting type to a different value, the axis returned by axis() will be a different one. The new axis will adopt the following properties from the previous axis: The range, scale type, log base and label.

              + +
              +
              + +
              +
              + + + + + + + + +
              void QCPColorScale::setDataRange (const QCPRangedataRange)
              +
              +

              Sets the range spanned by the color gradient and that is shown by the axis in the color scale.

              +

              It is equivalent to calling QCPColorMap::setDataRange on any of the connected color maps. It is also equivalent to directly accessing the axis and setting its range with QCPAxis::setRange.

              +
              See Also
              setDataScaleType, setGradient, rescaleDataRange
              + +
              +
              + +
              +
              + + + + + + + + +
              void QCPColorScale::setDataScaleType (QCPAxis::ScaleType scaleType)
              +
              +

              Sets the scale type of the color scale, i.e. whether values are linearly associated with colors or logarithmically.

              +

              It is equivalent to calling QCPColorMap::setDataScaleType on any of the connected color maps. It is also equivalent to directly accessing the axis and setting its scale type with QCPAxis::setScaleType.

              +
              See Also
              setDataRange, setGradient
              + +
              +
              + +
              +
              + + + + + + + + +
              void QCPColorScale::setGradient (const QCPColorGradientgradient)
              +
              +

              Sets the color gradient that will be used to represent data values.

              +

              It is equivalent to calling QCPColorMap::setGradient on any of the connected color maps.

              +
              See Also
              setDataRange, setDataScaleType
              + +
              +
              + +
              +
              + + + + + + + + +
              void QCPColorScale::setLabel (const QString & str)
              +
              +

              Sets the axis label of the color scale. This is equivalent to calling QCPAxis::setLabel on the internal axis.

              + +
              +
              + +
              +
              + + + + + + + + +
              void QCPColorScale::setBarWidth (int width)
              +
              +

              Sets the width (or height, for horizontal color scales) the bar where the gradient is displayed will have.

              + +
              +
              + +
              +
              + + + + + + + + +
              void QCPColorScale::setRangeDrag (bool enabled)
              +
              +

              Sets whether the user can drag the data range (setDataRange).

              +

              Note that QCP::iRangeDrag must be in the QCustomPlot's interactions (QCustomPlot::setInteractions) to allow range dragging.

              + +
              +
              + +
              +
              + + + + + + + + +
              void QCPColorScale::setRangeZoom (bool enabled)
              +
              +

              Sets whether the user can zoom the data range (setDataRange) by scrolling the mouse wheel.

              +

              Note that QCP::iRangeZoom must be in the QCustomPlot's interactions (QCustomPlot::setInteractions) to allow range dragging.

              + +
              +
              + +
              +
              + + + + + + + +
              QList< QCPColorMap * > QCPColorScale::colorMaps () const
              +
              +

              Returns a list of all the color maps associated with this color scale.

              + +
              +
              + +
              +
              + + + + + + + + +
              void QCPColorScale::rescaleDataRange (bool onlyVisibleMaps)
              +
              +

              Changes the data range such that all color maps associated with this color scale are fully mapped to the gradient in the data dimension.

              +
              See Also
              setDataRange
              + +
              +
              + +
              +
              + + + + + +
              + + + + + + + + +
              void QCPColorScale::update (UpdatePhase phase)
              +
              +virtual
              +
              +

              Updates the layout element and sub-elements. This function is automatically called before every replot by the parent layout element. It is called multiple times, once for every UpdatePhase. The phases are run through in the order of the enum values. For details about what happens at the different phases, see the documentation of UpdatePhase.

              +

              Layout elements that have child elements should call the update method of their child elements, and pass the current phase unchanged.

              +

              The default implementation executes the automatic margin mechanism in the upMargins phase. Subclasses should make sure to call the base class implementation.

              + +

              Reimplemented from QCPLayoutElement.

              + +
              +
              + +
              +
              + + + + + +
              + + + + + + + + +
              void QCPColorScale::dataRangeChanged (QCPRange newRange)
              +
              +signal
              +
              +

              This signal is emitted when the data range changes.

              +
              See Also
              setDataRange
              + +
              +
              + +
              +
              + + + + + +
              + + + + + + + + +
              void QCPColorScale::dataScaleTypeChanged (QCPAxis::ScaleType scaleType)
              +
              +signal
              +
              +

              This signal is emitted when the data scale type changes.

              +
              See Also
              setDataScaleType
              + +
              +
              + +
              +
              + + + + + +
              + + + + + + + + +
              void QCPColorScale::gradientChanged (QCPColorGradient newGradient)
              +
              +signal
              +
              +

              This signal is emitted when the gradient changes.

              +
              See Also
              setGradient
              + +
              +
              + +
              +
              + + + + + +
              + + + + + + + + +
              void QCPColorScale::applyDefaultAntialiasingHint (QCPPainterpainter) const
              +
              +protectedvirtual
              +
              +

              This function applies the default antialiasing setting to the specified painter, using the function applyAntialiasingHint. It is the antialiasing state the painter is put in, when draw is called on the layerable. If the layerable has multiple entities whose antialiasing setting may be specified individually, this function should set the antialiasing state of the most prominent entity. In this case however, the draw function usually calls the specialized versions of this function before drawing each entity, effectively overriding the setting of the default antialiasing hint.

              +

              First example: QCPGraph has multiple entities that have an antialiasing setting: The graph line, fills, scatters and error bars. Those can be configured via QCPGraph::setAntialiased, QCPGraph::setAntialiasedFill, QCPGraph::setAntialiasedScatters etc. Consequently, there isn't only the QCPGraph::applyDefaultAntialiasingHint function (which corresponds to the graph line's antialiasing), but specialized ones like QCPGraph::applyFillAntialiasingHint and QCPGraph::applyScattersAntialiasingHint. So before drawing one of those entities, QCPGraph::draw calls the respective specialized applyAntialiasingHint function.

              +

              Second example: QCPItemLine consists only of a line so there is only one antialiasing setting which can be controlled with QCPItemLine::setAntialiased. (This function is inherited by all layerables. The specialized functions, as seen on QCPGraph, must be added explicitly to the respective layerable subclass.) Consequently it only has the normal QCPItemLine::applyDefaultAntialiasingHint. The QCPItemLine::draw function doesn't need to care about setting any antialiasing states, because the default antialiasing hint is already set on the painter when the draw function is called, and that's the state it wants to draw the line with.

              + +

              Reimplemented from QCPLayoutElement.

              + +
              +
              + +
              +
              + + + + + +
              + + + + + + + + +
              void QCPColorScale::mousePressEvent (QMouseEvent * event)
              +
              +protectedvirtual
              +
              +

              This event is called, if the mouse was pressed while being inside the outer rect of this layout element.

              + +

              Reimplemented from QCPLayoutElement.

              + +
              +
              + +
              +
              + + + + + +
              + + + + + + + + +
              void QCPColorScale::mouseMoveEvent (QMouseEvent * event)
              +
              +protectedvirtual
              +
              +

              This event is called, if the mouse is moved inside the outer rect of this layout element.

              + +

              Reimplemented from QCPLayoutElement.

              + +
              +
              + +
              +
              + + + + + +
              + + + + + + + + +
              void QCPColorScale::mouseReleaseEvent (QMouseEvent * event)
              +
              +protectedvirtual
              +
              +

              This event is called, if the mouse was previously pressed inside the outer rect of this layout element and is now released.

              + +

              Reimplemented from QCPLayoutElement.

              + +
              +
              + +
              +
              + + + + + +
              + + + + + + + + +
              void QCPColorScale::wheelEvent (QWheelEvent * event)
              +
              +protectedvirtual
              +
              +

              This event is called, if the mouse wheel is scrolled while the cursor is inside the rect of this layout element.

              + +

              Reimplemented from QCPLayoutElement.

              + +
              +
              +
              The documentation for this class was generated from the following files: +
              + + + Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/classQCPColorScale__inherit__graph.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/classQCPColorScale__inherit__graph.png differ diff -Nru qcustomplot-1.1.0/documentation/html/classQCPCurve.html qcustomplot-1.2.0/documentation/html/classQCPCurve.html --- qcustomplot-1.1.0/documentation/html/classQCPCurve.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPCurve.html 2014-03-14 21:11:27.000000000 +0000 @@ -18,8 +18,6 @@
              QCPCurve Class Reference
              @@ -65,100 +63,106 @@ void removeData (double t) virtual void clearData () virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const - +- Public Functions inherited from QCPAbstractPlottableQCPAbstractPlottable (QCPAxis *keyAxis, QCPAxis *valueAxis) + QString name () const - + bool antialiasedFill () const - + bool antialiasedScatters () const - + bool antialiasedErrorBars () const - + QPen pen () const - + QPen selectedPen () const - + QBrush brush () const - + QBrush selectedBrush () const - + QCPAxiskeyAxis () const - + QCPAxisvalueAxis () const - + bool selectable () const - + bool selected () const -void setName (const QString &name) -void setAntialiasedFill (bool enabled) -void setAntialiasedScatters (bool enabled) -void setAntialiasedErrorBars (bool enabled) -void setPen (const QPen &pen) -void setSelectedPen (const QPen &pen) -void setBrush (const QBrush &brush) -void setSelectedBrush (const QBrush &brush) -void setKeyAxis (QCPAxis *axis) -void setValueAxis (QCPAxis *axis) -Q_SLOT void setSelectable (bool selectable) -Q_SLOT void setSelected (bool selected) -virtual bool addToLegend () -virtual bool removeFromLegend () const -void rescaleAxes (bool onlyEnlarge=false) const -void rescaleKeyAxis (bool onlyEnlarge=false) const -void rescaleValueAxis (bool onlyEnlarge=false) const - +void setName (const QString &name) +void setAntialiasedFill (bool enabled) +void setAntialiasedScatters (bool enabled) +void setAntialiasedErrorBars (bool enabled) +void setPen (const QPen &pen) +void setSelectedPen (const QPen &pen) +void setBrush (const QBrush &brush) +void setSelectedBrush (const QBrush &brush) +void setKeyAxis (QCPAxis *axis) +void setValueAxis (QCPAxis *axis) +Q_SLOT void setSelectable (bool selectable) +Q_SLOT void setSelected (bool selected) +virtual bool addToLegend () +virtual bool removeFromLegend () const +void rescaleAxes (bool onlyEnlarge=false) const +void rescaleKeyAxis (bool onlyEnlarge=false) const +void rescaleValueAxis (bool onlyEnlarge=false) const +- Public Functions inherited from QCPLayerableQCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0) + bool visible () const - + QCustomPlotparentPlot () const -QCPLayerableparentLayerable () const - +QCPLayerableparentLayerable () const + QCPLayerlayer () const - + bool antialiased () const -void setVisible (bool on) -bool setLayer (QCPLayer *layer) -bool setLayer (const QString &layerName) -void setAntialiased (bool enabled) -bool realVisibility () const - - - -

              -Signals

              void selectionChanged (bool selected)
              - - + + + + +

              -Protected Types

              enum  SignDomain
              void setVisible (bool on)
              Q_SLOT bool setLayer (QCPLayer *layer)
              bool setLayer (const QString &layerName)
              void setAntialiased (bool enabled)
              bool realVisibility () const
              - - + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + +

              Protected Functions

              virtual void draw (QCPPainter *painter)
              virtual void drawLegendIcon (QCPPainter *painter, const QRectF &rect) const
              virtual QCPRange getKeyRange (bool &validRange, SignDomain inSignDomain=sdBoth) const
              virtual QCPRange getValueRange (bool &validRange, SignDomain inSignDomain=sdBoth) const
              virtual QCPRange getKeyRange (bool &foundRange, SignDomain inSignDomain=sdBoth) const
              virtual QCPRange getValueRange (bool &foundRange, SignDomain inSignDomain=sdBoth) const
              virtual void drawScatterPlot (QCPPainter *painter, const QVector< QPointF > *pointData) const
              void getCurveData (QVector< QPointF > *lineData) const
              double pointDistance (const QPointF &pixelPoint) const
              QPointF outsideCoordsToPixels (double key, double value, int region, QRect axisRect) const
              virtual QRect clipRect () const
              virtual QCP::Interaction selectionCategory () const
              void applyDefaultAntialiasingHint (QCPPainter *painter) const
              virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
              virtual void deselectEvent (bool *selectionStateChanged)
              void coordsToPixels (double key, double value, double &x, double &y) const
              const QPointF coordsToPixels (double key, double value) const
              void pixelsToCoords (double x, double y, double &key, double &value) const
              void pixelsToCoords (const QPointF &pixelPos, double &key, double &value) const
              QPen mainPen () const
              QBrush mainBrush () const
              void applyFillAntialiasingHint (QCPPainter *painter) const
              void applyScattersAntialiasingHint (QCPPainter *painter) const
              void applyErrorBarsAntialiasingHint (QCPPainter *painter) const
              double distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const
              virtual void parentPlotInitialized (QCustomPlot *parentPlot)
              void initializeParentPlot (QCustomPlot *parentPlot)
              void setParentLayerable (QCPLayerable *parentLayerable)
              bool moveToLayer (QCPLayer *layer, bool prepend)
              void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
              - Protected Functions inherited from QCPAbstractPlottable
              virtual QRect clipRect () const
              virtual QCP::Interaction selectionCategory () const
              void applyDefaultAntialiasingHint (QCPPainter *painter) const
              virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
              virtual void deselectEvent (bool *selectionStateChanged)
              void coordsToPixels (double key, double value, double &x, double &y) const
              const QPointF coordsToPixels (double key, double value) const
              void pixelsToCoords (double x, double y, double &key, double &value) const
              void pixelsToCoords (const QPointF &pixelPos, double &key, double &value) const
              QPen mainPen () const
              QBrush mainBrush () const
              void applyFillAntialiasingHint (QCPPainter *painter) const
              void applyScattersAntialiasingHint (QCPPainter *painter) const
              void applyErrorBarsAntialiasingHint (QCPPainter *painter) const
              double distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const
              - Protected Functions inherited from QCPLayerable
              virtual void parentPlotInitialized (QCustomPlot *parentPlot)
              void initializeParentPlot (QCustomPlot *parentPlot)
              void setParentLayerable (QCPLayerable *parentLayerable)
              bool moveToLayer (QCPLayer *layer, bool prepend)
              void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
              + + + + + +

              +Additional Inherited Members

              - Signals inherited from QCPAbstractPlottable
              void selectionChanged (bool selected)
              void selectableChanged (bool selectable)
              - Protected Types inherited from QCPAbstractPlottable
              enum  SignDomain

              Detailed Description

              A plottable representing a parametric curve in a plot.

              @@ -205,40 +209,6 @@
              - -
              -
              - - - - - -
              - - - - -
              enum QCPAbstractPlottable::SignDomain
              -
              -protectedinherited
              -
              -

              Represents negative and positive sign domain for passing to getKeyRange and getValueRange.

              -
              Enumerator:
              - - - -
              sdNegative  -

              The negative sign domain, i.e. numbers smaller than zero.

              -
              sdBoth  -

              Both sign domains, including zero, i.e. all (rational) numbers.

              -
              sdPositive  -

              The positive sign domain, i.e. numbers greater than zero.

              -
              -
              -
              - -
              -

              Constructor & Destructor Documentation

              @@ -764,7 +734,7 @@
              - +
              @@ -775,7 +745,7 @@ - + @@ -795,14 +765,15 @@
              QCPRange QCPCurve::getKeyRange ( bool & validRange, foundRange,
              -

              called by rescaleAxes functions to get the full data key bounds. For logarithmic plots, one can set inSignDomain to either sdNegative or sdPositive in order to restrict the returned range to that sign domain. E.g. when only negative range is wanted, set inSignDomain to sdNegative and all positive points will be ignored for range calculation. For no restriction, just set inSignDomain to sdBoth (default). validRange is an output parameter that indicates whether a proper range could be found or not. If this is false, you shouldn't use the returned range (e.g. no points in data).

              -
              See Also
              rescaleAxes, getValueRange
              +

              called by rescaleAxes functions to get the full data key bounds. For logarithmic plots, one can set inSignDomain to either sdNegative or sdPositive in order to restrict the returned range to that sign domain. E.g. when only negative range is wanted, set inSignDomain to sdNegative and all positive points will be ignored for range calculation. For no restriction, just set inSignDomain to sdBoth (default). foundRange is an output parameter that indicates whether a range could be found or not. If this is false, you shouldn't use the returned range (e.g. no points in data).

              +

              Note that foundRange is not the same as QCPRange::validRange, since the range returned by this function may have size zero, which wouldn't count as a valid range.

              +
              See Also
              rescaleAxes, getValueRange
              -

              Implements QCPAbstractPlottable.

              +

              Implements QCPAbstractPlottable.

              - +
              @@ -813,7 +784,7 @@ - + @@ -833,10 +804,11 @@
              QCPRange QCPCurve::getValueRange ( bool & validRange, foundRange,
              -

              called by rescaleAxes functions to get the full data value bounds. For logarithmic plots, one can set inSignDomain to either sdNegative or sdPositive in order to restrict the returned range to that sign domain. E.g. when only negative range is wanted, set inSignDomain to sdNegative and all positive points will be ignored for range calculation. For no restriction, just set inSignDomain to sdBoth (default). validRange is an output parameter that indicates whether a proper range could be found or not. If this is false, you shouldn't use the returned range (e.g. no points in data).

              -
              See Also
              rescaleAxes, getKeyRange
              +

              called by rescaleAxes functions to get the full data value bounds. For logarithmic plots, one can set inSignDomain to either sdNegative or sdPositive in order to restrict the returned range to that sign domain. E.g. when only negative range is wanted, set inSignDomain to sdNegative and all positive points will be ignored for range calculation. For no restriction, just set inSignDomain to sdBoth (default). foundRange is an output parameter that indicates whether a range could be found or not. If this is false, you shouldn't use the returned range (e.g. no points in data).

              +

              Note that foundRange is not the same as QCPRange::validRange, since the range returned by this function may have size zero, which wouldn't count as a valid range.

              +
              See Also
              rescaleAxes, getKeyRange
              -

              Implements QCPAbstractPlottable.

              +

              Implements QCPAbstractPlottable.

              @@ -972,1316 +944,6 @@ - -
              -
              - - - - - -
              - - - - - - - - -
              void QCPAbstractPlottable::setName (const QString & name)
              -
              -inherited
              -
              -

              The name is the textual representation of this plottable as it is displayed in the legend (QCPLegend). It may contain any UTF-8 characters, including newlines.

              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - -
              void QCPAbstractPlottable::setAntialiasedFill (bool enabled)
              -
              -inherited
              -
              -

              Sets whether fills of this plottable is drawn antialiased or not.

              -

              Note that this setting may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - -
              void QCPAbstractPlottable::setAntialiasedScatters (bool enabled)
              -
              -inherited
              -
              -

              Sets whether the scatter symbols of this plottable are drawn antialiased or not.

              -

              Note that this setting may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - -
              void QCPAbstractPlottable::setAntialiasedErrorBars (bool enabled)
              -
              -inherited
              -
              -

              Sets whether the error bars of this plottable are drawn antialiased or not.

              -

              Note that this setting may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - -
              void QCPAbstractPlottable::setPen (const QPen & pen)
              -
              -inherited
              -
              -

              The pen is used to draw basic lines that make up the plottable representation in the plot.

              -

              For example, the QCPGraph subclass draws its graph lines and scatter points with this pen.

              -
              See Also
              setBrush
              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - -
              void QCPAbstractPlottable::setSelectedPen (const QPen & pen)
              -
              -inherited
              -
              -

              When the plottable is selected, this pen is used to draw basic lines instead of the normal pen set via setPen.

              -
              See Also
              setSelected, setSelectable, setSelectedBrush, selectTest
              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - -
              void QCPAbstractPlottable::setBrush (const QBrush & brush)
              -
              -inherited
              -
              -

              The brush is used to draw basic fills of the plottable representation in the plot. The Fill can be a color, gradient or texture, see the usage of QBrush.

              -

              For example, the QCPGraph subclass draws the fill under the graph with this brush, when it's not set to Qt::NoBrush.

              -
              See Also
              setPen
              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - -
              void QCPAbstractPlottable::setSelectedBrush (const QBrush & brush)
              -
              -inherited
              -
              -

              When the plottable is selected, this brush is used to draw fills instead of the normal brush set via setBrush.

              -
              See Also
              setSelected, setSelectable, setSelectedPen, selectTest
              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - -
              void QCPAbstractPlottable::setKeyAxis (QCPAxisaxis)
              -
              -inherited
              -
              -

              The key axis of a plottable can be set to any axis of a QCustomPlot, as long as it is orthogonal to the plottable's value axis. This function performs no checks to make sure this is the case. The typical mathematical choice is to use the x-axis (QCustomPlot::xAxis) as key axis and the y-axis (QCustomPlot::yAxis) as value axis.

              -

              Normally, the key and value axes are set in the constructor of the plottable (or QCustomPlot::addGraph when working with QCPGraphs through the dedicated graph interface).

              -
              See Also
              setValueAxis
              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - -
              void QCPAbstractPlottable::setValueAxis (QCPAxisaxis)
              -
              -inherited
              -
              -

              The value axis of a plottable can be set to any axis of a QCustomPlot, as long as it is orthogonal to the plottable's key axis. This function performs no checks to make sure this is the case. The typical mathematical choice is to use the x-axis (QCustomPlot::xAxis) as key axis and the y-axis (QCustomPlot::yAxis) as value axis.

              -

              Normally, the key and value axes are set in the constructor of the plottable (or QCustomPlot::addGraph when working with QCPGraphs through the dedicated graph interface).

              -
              See Also
              setKeyAxis
              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - -
              void QCPAbstractPlottable::setSelectable (bool selectable)
              -
              -inherited
              -
              -

              Sets whether the user can (de-)select this plottable by clicking on the QCustomPlot surface. (When QCustomPlot::setInteractions contains iSelectPlottables.)

              -

              However, even when selectable was set to false, it is possible to set the selection manually, by calling setSelected directly.

              -
              See Also
              setSelected
              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - -
              void QCPAbstractPlottable::setSelected (bool selected)
              -
              -inherited
              -
              -

              Sets whether this plottable is selected or not. When selected, it uses a different pen and brush to draw its lines and fills, see setSelectedPen and setSelectedBrush.

              -

              The entire selection mechanism for plottables is handled automatically when QCustomPlot::setInteractions contains iSelectPlottables. You only need to call this function when you wish to change the selection state manually.

              -

              This function can change the selection state even when setSelectable was set to false.

              -

              emits the selectionChanged signal when selected is different from the previous selection state.

              -
              See Also
              setSelectable, selectTest
              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - -
              bool QCPAbstractPlottable::addToLegend ()
              -
              -virtualinherited
              -
              -

              Adds this plottable to the legend of the parent QCustomPlot (QCustomPlot::legend).

              -

              Normally, a QCPPlottableLegendItem is created and inserted into the legend. If the plottable needs a more specialized representation in the legend, this function will take this into account and instead create the specialized subclass of QCPAbstractLegendItem.

              -

              Returns true on success, i.e. when the legend exists and a legend item associated with this plottable isn't already in the legend.

              -
              See Also
              removeFromLegend, QCPLegend::addItem
              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - -
              bool QCPAbstractPlottable::removeFromLegend () const
              -
              -virtualinherited
              -
              -

              Removes the plottable from the legend of the parent QCustomPlot. This means the QCPAbstractLegendItem (usually a QCPPlottableLegendItem) that is associated with this plottable is removed.

              -

              Returns true on success, i.e. if the legend exists and a legend item associated with this plottable was found and removed.

              -
              See Also
              addToLegend, QCPLegend::removeItem
              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - -
              void QCPAbstractPlottable::rescaleAxes (bool onlyEnlarge = false) const
              -
              -inherited
              -
              -

              Rescales the key and value axes associated with this plottable to contain all displayed data, so the whole plottable is visible. If the scaling of an axis is logarithmic, rescaleAxes will make sure not to rescale to an illegal range i.e. a range containing different signs and/or zero. Instead it will stay in the current sign domain and ignore all parts of the plottable that lie outside of that domain.

              -

              onlyEnlarge makes sure the ranges are only expanded, never reduced. So it's possible to show multiple plottables in their entirety by multiple calls to rescaleAxes where the first call has onlyEnlarge set to false (the default), and all subsequent set to true.

              -
              See Also
              rescaleKeyAxis, rescaleValueAxis, QCustomPlot::rescaleAxes, QCPAxis::rescale
              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - -
              void QCPAbstractPlottable::rescaleKeyAxis (bool onlyEnlarge = false) const
              -
              -inherited
              -
              -

              Rescales the key axis of the plottable so the whole plottable is visible.

              -

              See rescaleAxes for detailed behaviour.

              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - -
              void QCPAbstractPlottable::rescaleValueAxis (bool onlyEnlarge = false) const
              -
              -inherited
              -
              -

              Rescales the value axis of the plottable so the whole plottable is visible.

              -

              Returns true if the axis was actually scaled. This might not be the case if this plottable has an invalid range, e.g. because it has no data points.

              -

              See rescaleAxes for detailed behaviour.

              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - -
              void QCPAbstractPlottable::selectionChanged (bool selected)
              -
              -signalinherited
              -
              -

              This signal is emitted when the selection state of this plottable has changed to selected, either by user interaction or by a direct call to setSelected.

              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - -
              QRect QCPAbstractPlottable::clipRect () const
              -
              -protectedvirtualinherited
              -
              -

              Returns the clipping rectangle of this layerable object. By default, this is the viewport of the parent QCustomPlot. Specific subclasses may reimplement this function to provide different clipping rects.

              -

              The returned clipping rect is set on the painter before the draw function of the respective object is called.

              - -

              Reimplemented from QCPLayerable.

              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - -
              QCP::Interaction QCPAbstractPlottable::selectionCategory () const
              -
              -protectedvirtualinherited
              -
              -

              Returns the selection category this layerable shall belong to. The selection category is used in conjunction with QCustomPlot::setInteractions to control which objects are selectable and which aren't.

              -

              Subclasses that don't fit any of the normal QCP::Interaction values can use QCP::iSelectOther. This is what the default implementation returns.

              -
              See Also
              QCustomPlot::setInteractions
              - -

              Reimplemented from QCPLayerable.

              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - -
              void QCPAbstractPlottable::applyDefaultAntialiasingHint (QCPPainterpainter) const
              -
              -protectedvirtualinherited
              -
              -

              A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing plottable lines.

              -

              This is the antialiasing state the painter passed to the draw method is in by default.

              -

              This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

              -
              See Also
              setAntialiased, applyFillAntialiasingHint, applyScattersAntialiasingHint, applyErrorBarsAntialiasingHint
              - -

              Implements QCPLayerable.

              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
              void QCPAbstractPlottable::selectEvent (QMouseEvent * event,
              bool additive,
              const QVariant & details,
              bool * selectionStateChanged 
              )
              -
              -protectedvirtualinherited
              -
              -

              This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

              -

              event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

              -

              Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

              -

              selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

              -
              See Also
              selectTest, deselectEvent
              - -

              Reimplemented from QCPLayerable.

              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - -
              void QCPAbstractPlottable::deselectEvent (bool * selectionStateChanged)
              -
              -protectedvirtualinherited
              -
              -

              This event is called when the layerable shall be deselected, either as consequence of a user interaction or a call to QCustomPlot::deselectAll. Subclasses should react to it by unsetting their selection appropriately.

              -

              just as in selectEvent, the output parameter selectionStateChanged (if non-null), must return true or false when the selection state of this layerable has changed or not changed, respectively.

              -
              See Also
              selectTest, selectEvent
              - -

              Reimplemented from QCPLayerable.

              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
              void QCPAbstractPlottable::coordsToPixels (double key,
              double value,
              double & x,
              double & y 
              ) const
              -
              -protectedinherited
              -
              -

              Convenience function for transforming a key/value pair to pixels on the QCustomPlot surface, taking the orientations of the axes associated with this plottable into account (e.g. whether key represents x or y).

              -

              key and value are transformed to the coodinates in pixels and are written to x and y.

              -
              See Also
              pixelsToCoords, QCPAxis::coordToPixel
              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - - - - - - - - - - - -
              const QPointF QCPAbstractPlottable::coordsToPixels (double key,
              double value 
              ) const
              -
              -protectedinherited
              -
              -

              This is an overloaded function.

              -

              Returns the input as pixel coordinates in a QPointF.

              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
              void QCPAbstractPlottable::pixelsToCoords (double x,
              double y,
              double & key,
              double & value 
              ) const
              -
              -protectedinherited
              -
              -

              Convenience function for transforming a x/y pixel pair on the QCustomPlot surface to plot coordinates, taking the orientations of the axes associated with this plottable into account (e.g. whether key represents x or y).

              -

              x and y are transformed to the plot coodinates and are written to key and value.

              -
              See Also
              coordsToPixels, QCPAxis::coordToPixel
              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - - - - - - - - - - - - - - - - - -
              void QCPAbstractPlottable::pixelsToCoords (const QPointF & pixelPos,
              double & key,
              double & value 
              ) const
              -
              -protectedinherited
              -
              -

              This is an overloaded function.

              -

              Returns the pixel input pixelPos as plot coordinates key and value.

              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - -
              QPen QCPAbstractPlottable::mainPen () const
              -
              -protectedinherited
              -
              -

              Returns the pen that should be used for drawing lines of the plottable. Returns mPen when the graph is not selected and mSelectedPen when it is.

              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - -
              QBrush QCPAbstractPlottable::mainBrush () const
              -
              -protectedinherited
              -
              -

              Returns the brush that should be used for drawing fills of the plottable. Returns mBrush when the graph is not selected and mSelectedBrush when it is.

              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - -
              void QCPAbstractPlottable::applyFillAntialiasingHint (QCPPainterpainter) const
              -
              -protectedinherited
              -
              -

              A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing plottable fills.

              -

              This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

              -
              See Also
              setAntialiased, applyDefaultAntialiasingHint, applyScattersAntialiasingHint, applyErrorBarsAntialiasingHint
              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - -
              void QCPAbstractPlottable::applyScattersAntialiasingHint (QCPPainterpainter) const
              -
              -protectedinherited
              -
              -

              A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing plottable scatter points.

              -

              This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

              -
              See Also
              setAntialiased, applyFillAntialiasingHint, applyDefaultAntialiasingHint, applyErrorBarsAntialiasingHint
              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - -
              void QCPAbstractPlottable::applyErrorBarsAntialiasingHint (QCPPainterpainter) const
              -
              -protectedinherited
              -
              -

              A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing plottable error bars.

              -

              This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

              -
              See Also
              setAntialiased, applyFillAntialiasingHint, applyScattersAntialiasingHint, applyDefaultAntialiasingHint
              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - - - - - - - - - - - - - - - - - -
              double QCPAbstractPlottable::distSqrToLine (const QPointF & start,
              const QPointF & end,
              const QPointF & point 
              ) const
              -
              -protectedinherited
              -
              -

              Finds the shortest squared distance of point to the line segment defined by start and end.

              -

              This function may be used to help with the implementation of the selectTest function for specific plottables.

              -
              Note
              This function is identical to QCPAbstractItem::distSqrToLine
              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - -
              QCPLayerable * QCPLayerable::parentLayerable () const
              -
              -inlineinherited
              -
              -

              Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.

              -

              Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.

              -

              A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.

              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - -
              void QCPLayerable::setVisible (bool on)
              -
              -inherited
              -
              -

              Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.

              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - -
              bool QCPLayerable::setLayer (QCPLayerlayer)
              -
              -inherited
              -
              -

              Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.

              -

              Returns true on success, i.e. if layer is a valid layer.

              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - -
              bool QCPLayerable::setLayer (const QString & layerName)
              -
              -inherited
              -
              -

              This is an overloaded function.

              -

              Sets the layer of this layerable object by name

              -

              Returns true on success, i.e. if layerName is a valid layer name.

              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - -
              void QCPLayerable::setAntialiased (bool enabled)
              -
              -inherited
              -
              -

              Sets whether this object will be drawn antialiased or not.

              -

              Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - -
              bool QCPLayerable::realVisibility () const
              -
              -inherited
              -
              -

              Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.

              -

              If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.

              -

              If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.

              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - -
              void QCPLayerable::parentPlotInitialized (QCustomPlotparentPlot)
              -
              -protectedvirtualinherited
              -
              -

              This function is called by initializeParentPlot, to allow subclasses to react on the setting of a parent plot. This is the case when 0 was passed as parent plot in the constructor, and the parent plot is set at a later time.

              -

              For example, QCPLayoutElement/QCPLayout hierarchies may be created independently of any QCustomPlot at first. When they are then added to a layout inside the QCustomPlot, the top level element of the hierarchy gets its parent plot initialized with initializeParentPlot. To propagate the parent plot to all the children of the hierarchy, the top level element then uses this function to pass the parent plot on to its child elements.

              -

              The default implementation does nothing.

              -
              See Also
              initializeParentPlot
              - -

              Reimplemented in QCPLegend, and QCPLayoutElement.

              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - -
              void QCPLayerable::initializeParentPlot (QCustomPlotparentPlot)
              -
              -protectedinherited
              -
              -

              Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.

              -

              Note that, unlike when passing a non-null parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.

              -

              Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.

              -

              The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).

              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - -
              void QCPLayerable::setParentLayerable (QCPLayerableparentLayerable)
              -
              -protectedinherited
              -
              -

              Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.

              -

              The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.

              -
              See Also
              realVisibility
              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - - - - - - - - - - - -
              bool QCPLayerable::moveToLayer (QCPLayerlayer,
              bool prepend 
              )
              -
              -protectedinherited
              -
              -

              Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.

              -

              Returns true on success, i.e. if layer is a valid layer.

              - -
              -
              - -
              -
              - - - - - -
              - - - - - - - - - - - - - - - - - - - - - - - - -
              void QCPLayerable::applyAntialiasingHint (QCPPainterpainter,
              bool localAntialiased,
              QCP::AntialiasedElement overrideElement 
              ) const
              -
              -protectedinherited
              -
              -

              Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.

              - -
              -

              The documentation for this class was generated from the following files:
              • src/plottables/plottable-curve.h
              • src/plottables/plottable-curve.cpp
              • diff -Nru qcustomplot-1.1.0/documentation/html/classQCPGraph.html qcustomplot-1.2.0/documentation/html/classQCPGraph.html --- qcustomplot-1.1.0/documentation/html/classQCPGraph.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPGraph.html 2014-03-14 21:11:27.000000000 +0000 @@ -18,8 +18,6 @@
                QCPGraph Class Reference
                @@ -44,8 +42,7 @@

                Public Functions

                 QCPGraph (QCPAxis *keyAxis, QCPAxis *valueAxis) - -const QCPDataMapdata () const +QCPDataMapdata () const LineStyle lineStyle () const @@ -60,7 +57,9 @@ bool errorBarSkipSymbol () const QCPGraphchannelFillGraph () const -void setData (QCPDataMap *data, bool copy=false) + +bool adaptiveSampling () const +void setData (QCPDataMap *data, bool copy=false) void setData (const QVector< double > &key, const QVector< double > &value) void setDataKeyError (const QVector< double > &key, const QVector< double > &value, const QVector< double > &keyError) void setDataKeyError (const QVector< double > &key, const QVector< double > &value, const QVector< double > &keyErrorMinus, const QVector< double > &keyErrorPlus) @@ -75,8 +74,9 @@ void setErrorBarSize (double size) void setErrorBarSkipSymbol (bool enabled) void setChannelFillGraph (QCPGraph *targetGraph) +void setAdaptiveSampling (bool enabled) void addData (const QCPDataMap &dataMap) -void addData (const QCPData &data) +void addData (const QCPData &data) void addData (double key, double value) void addData (const QVector< double > &keys, const QVector< double > &values) void removeDataBefore (double key) @@ -88,121 +88,129 @@ void rescaleAxes (bool onlyEnlarge, bool includeErrorBars) const void rescaleKeyAxis (bool onlyEnlarge, bool includeErrorBars) const void rescaleValueAxis (bool onlyEnlarge, bool includeErrorBars) const - +- Public Functions inherited from QCPAbstractPlottableQCPAbstractPlottable (QCPAxis *keyAxis, QCPAxis *valueAxis) + QString name () const - + bool antialiasedFill () const - + bool antialiasedScatters () const - + bool antialiasedErrorBars () const - + QPen pen () const - + QPen selectedPen () const - + QBrush brush () const - + QBrush selectedBrush () const - + QCPAxiskeyAxis () const - + QCPAxisvalueAxis () const - + bool selectable () const - + bool selected () const -void setName (const QString &name) -void setAntialiasedFill (bool enabled) -void setAntialiasedScatters (bool enabled) -void setAntialiasedErrorBars (bool enabled) -void setPen (const QPen &pen) -void setSelectedPen (const QPen &pen) -void setBrush (const QBrush &brush) -void setSelectedBrush (const QBrush &brush) -void setKeyAxis (QCPAxis *axis) -void setValueAxis (QCPAxis *axis) -Q_SLOT void setSelectable (bool selectable) -Q_SLOT void setSelected (bool selected) -virtual bool addToLegend () -virtual bool removeFromLegend () const -void rescaleAxes (bool onlyEnlarge=false) const -void rescaleKeyAxis (bool onlyEnlarge=false) const -void rescaleValueAxis (bool onlyEnlarge=false) const - +void setName (const QString &name) +void setAntialiasedFill (bool enabled) +void setAntialiasedScatters (bool enabled) +void setAntialiasedErrorBars (bool enabled) +void setPen (const QPen &pen) +void setSelectedPen (const QPen &pen) +void setBrush (const QBrush &brush) +void setSelectedBrush (const QBrush &brush) +void setKeyAxis (QCPAxis *axis) +void setValueAxis (QCPAxis *axis) +Q_SLOT void setSelectable (bool selectable) +Q_SLOT void setSelected (bool selected) +virtual bool addToLegend () +virtual bool removeFromLegend () const +void rescaleAxes (bool onlyEnlarge=false) const +void rescaleKeyAxis (bool onlyEnlarge=false) const +void rescaleValueAxis (bool onlyEnlarge=false) const +- Public Functions inherited from QCPLayerableQCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0) + bool visible () const - + QCustomPlotparentPlot () const -QCPLayerableparentLayerable () const - +QCPLayerableparentLayerable () const + QCPLayerlayer () const - + bool antialiased () const -void setVisible (bool on) -bool setLayer (QCPLayer *layer) -bool setLayer (const QString &layerName) -void setAntialiased (bool enabled) -bool realVisibility () const - - - -

                -Signals

                void selectionChanged (bool selected)
                - - + + + + +

                -Protected Types

                enum  SignDomain
                void setVisible (bool on)
                Q_SLOT bool setLayer (QCPLayer *layer)
                bool setLayer (const QString &layerName)
                void setAntialiased (bool enabled)
                bool realVisibility () const
                - - - - + + + + - + - - - - - - - - - + + + + + + + + + + + - - - - + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + +

                Protected Functions

                virtual void draw (QCPPainter *painter)
                virtual void drawLegendIcon (QCPPainter *painter, const QRectF &rect) const
                virtual QCPRange getKeyRange (bool &validRange, SignDomain inSignDomain=sdBoth) const
                virtual QCPRange getValueRange (bool &validRange, SignDomain inSignDomain=sdBoth) const
                virtual QCPRange getKeyRange (bool &validRange, SignDomain inSignDomain, bool includeErrors) const
                virtual QCPRange getValueRange (bool &validRange, SignDomain inSignDomain, bool includeErrors) const
                virtual QCPRange getKeyRange (bool &foundRange, SignDomain inSignDomain=sdBoth) const
                virtual QCPRange getValueRange (bool &foundRange, SignDomain inSignDomain=sdBoth) const
                virtual QCPRange getKeyRange (bool &foundRange, SignDomain inSignDomain, bool includeErrors) const
                virtual QCPRange getValueRange (bool &foundRange, SignDomain inSignDomain, bool includeErrors) const
                virtual void drawFill (QCPPainter *painter, QVector< QPointF > *lineData) const
                virtual void drawScatterPlot (QCPPainter *painter, QVector< QCPData > *pointData) const
                virtual void drawScatterPlot (QCPPainter *painter, QVector< QCPData > *scatterData) const
                virtual void drawLinePlot (QCPPainter *painter, QVector< QPointF > *lineData) const
                virtual void drawImpulsePlot (QCPPainter *painter, QVector< QPointF > *lineData) const
                void getPlotData (QVector< QPointF > *lineData, QVector< QCPData > *pointData) const
                void getScatterPlotData (QVector< QCPData > *pointData) const
                void getLinePlotData (QVector< QPointF > *lineData, QVector< QCPData > *pointData) const
                void getStepLeftPlotData (QVector< QPointF > *lineData, QVector< QCPData > *pointData) const
                void getStepRightPlotData (QVector< QPointF > *lineData, QVector< QCPData > *pointData) const
                void getStepCenterPlotData (QVector< QPointF > *lineData, QVector< QCPData > *pointData) const
                void getImpulsePlotData (QVector< QPointF > *lineData, QVector< QCPData > *pointData) const
                void drawError (QCPPainter *painter, double x, double y, const QCPData &data) const
                void getVisibleDataBounds (QCPDataMap::const_iterator &lower, QCPDataMap::const_iterator &upper, int &count) const
                void getPreparedData (QVector< QCPData > *lineData, QVector< QCPData > *scatterData) const
                void getPlotData (QVector< QPointF > *lineData, QVector< QCPData > *scatterData) const
                void getScatterPlotData (QVector< QCPData > *scatterData) const
                void getLinePlotData (QVector< QPointF > *linePixelData, QVector< QCPData > *scatterData) const
                void getStepLeftPlotData (QVector< QPointF > *linePixelData, QVector< QCPData > *scatterData) const
                void getStepRightPlotData (QVector< QPointF > *linePixelData, QVector< QCPData > *scatterData) const
                void getStepCenterPlotData (QVector< QPointF > *linePixelData, QVector< QCPData > *scatterData) const
                void getImpulsePlotData (QVector< QPointF > *linePixelData, QVector< QCPData > *scatterData) const
                void drawError (QCPPainter *painter, double x, double y, const QCPData &data) const
                void getVisibleDataBounds (QCPDataMap::const_iterator &lower, QCPDataMap::const_iterator &upper) const
                int countDataInBounds (const QCPDataMap::const_iterator &lower, const QCPDataMap::const_iterator &upper, int maxCount) const
                void addFillBasePoints (QVector< QPointF > *lineData) const
                void removeFillBasePoints (QVector< QPointF > *lineData) const
                QPointF lowerFillBasePoint (double lowerKey) const
                QPointF upperFillBasePoint (double upperKey) const
                const QPolygonF getChannelFillPolygon (const QVector< QPointF > *lineData) const
                int findIndexBelowX (const QVector< QPointF > *data, double x) const
                int findIndexAboveX (const QVector< QPointF > *data, double x) const
                int findIndexBelowY (const QVector< QPointF > *data, double y) const
                int findIndexAboveY (const QVector< QPointF > *data, double y) const
                int findIndexBelowX (const QVector< QPointF > *data, double x) const
                int findIndexAboveX (const QVector< QPointF > *data, double x) const
                int findIndexBelowY (const QVector< QPointF > *data, double y) const
                int findIndexAboveY (const QVector< QPointF > *data, double y) const
                double pointDistance (const QPointF &pixelPoint) const
                virtual QRect clipRect () const
                virtual QCP::Interaction selectionCategory () const
                void applyDefaultAntialiasingHint (QCPPainter *painter) const
                virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                virtual void deselectEvent (bool *selectionStateChanged)
                void coordsToPixels (double key, double value, double &x, double &y) const
                const QPointF coordsToPixels (double key, double value) const
                void pixelsToCoords (double x, double y, double &key, double &value) const
                void pixelsToCoords (const QPointF &pixelPos, double &key, double &value) const
                QPen mainPen () const
                QBrush mainBrush () const
                void applyFillAntialiasingHint (QCPPainter *painter) const
                void applyScattersAntialiasingHint (QCPPainter *painter) const
                void applyErrorBarsAntialiasingHint (QCPPainter *painter) const
                double distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const
                virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                void initializeParentPlot (QCustomPlot *parentPlot)
                void setParentLayerable (QCPLayerable *parentLayerable)
                bool moveToLayer (QCPLayer *layer, bool prepend)
                void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                - Protected Functions inherited from QCPAbstractPlottable
                virtual QRect clipRect () const
                virtual QCP::Interaction selectionCategory () const
                void applyDefaultAntialiasingHint (QCPPainter *painter) const
                virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                virtual void deselectEvent (bool *selectionStateChanged)
                void coordsToPixels (double key, double value, double &x, double &y) const
                const QPointF coordsToPixels (double key, double value) const
                void pixelsToCoords (double x, double y, double &key, double &value) const
                void pixelsToCoords (const QPointF &pixelPos, double &key, double &value) const
                QPen mainPen () const
                QBrush mainBrush () const
                void applyFillAntialiasingHint (QCPPainter *painter) const
                void applyScattersAntialiasingHint (QCPPainter *painter) const
                void applyErrorBarsAntialiasingHint (QCPPainter *painter) const
                double distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const
                - Protected Functions inherited from QCPLayerable
                virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                void initializeParentPlot (QCustomPlot *parentPlot)
                void setParentLayerable (QCPLayerable *parentLayerable)
                bool moveToLayer (QCPLayer *layer, bool prepend)
                void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                + + + + + +

                +Additional Inherited Members

                - Signals inherited from QCPAbstractPlottable
                void selectionChanged (bool selected)
                void selectableChanged (bool selectable)
                - Protected Types inherited from QCPAbstractPlottable
                enum  SignDomain

                Detailed Description

                A plottable representing a graph in a plot.

                @@ -210,7 +218,7 @@ QCPGraph.png

                Usually QCustomPlot creates graphs internally via QCustomPlot::addGraph and the resulting instance is accessed via QCustomPlot::graph.

                -

                To plot data, assign it with the setData or addData functions.

                +

                To plot data, assign it with the setData or addData functions. Alternatively, you can also access and modify the graph's data via the data method, which returns a pointer to the internal QCPDataMap.

                Graphs are used to display single-valued data. Single-valued means that there should only be one data point per unique key coordinate. In other words, the graph can't have loops. If you do want to plot non-single-valued curves, rather use the QCPCurve plottable.

                Changing the appearance

                @@ -286,40 +294,6 @@ - -
                -
                - - - - - -
                - - - - -
                enum QCPAbstractPlottable::SignDomain
                -
                -protectedinherited
                -
                -

                Represents negative and positive sign domain for passing to getKeyRange and getValueRange.

                -
                Enumerator:
                - - - -
                sdNegative  -

                The negative sign domain, i.e. numbers smaller than zero.

                -
                sdBoth  -

                Both sign domains, including zero, i.e. all (rational) numbers.

                -
                sdPositive  -

                The positive sign domain, i.e. numbers greater than zero.

                -
                -
                -
                - -
                -

                Constructor & Destructor Documentation

                @@ -359,6 +333,30 @@

                Member Function Documentation

                + +
                +
                + + + + + +
                + + + + + + + +
                QCPDataMap * QCPGraph::data () const
                +
                +inline
                +
                +

                Returns a pointer to the internal data storage of type QCPDataMap. You may use it to directly manipulate the data, which may be more convenient and faster than using the regular setData or addData methods, in certain situations.

                + +
                +
                @@ -383,7 +381,8 @@

                Replaces the current data with the provided data.

                -

                If copy is set to true, data points in data will only be copied. if false, the graph takes ownership of the passed data and replaces the internal data pointer with it. This is significantly faster than copying for large datasets.

                +

                If copy is set to true, data points in data will only be copied. if false, the graph takes ownership of the passed data and replaces the internal data pointer with it. This is significantly faster than copying for large datasets.

                +

                Alternatively, you can also access and modify the graph's data via the data method, which returns a pointer to the internal QCPDataMap.

                @@ -782,6 +781,35 @@ + +
                +
                + + + + + + + + +
                void QCPGraph::setAdaptiveSampling (bool enabled)
                +
                +

                Sets whether adaptive sampling shall be used when plotting this graph. QCustomPlot's adaptive sampling technique can drastically improve the replot performance for graphs with a larger number of points (e.g. above 10,000), without notably changing the appearance of the graph.

                +

                By default, adaptive sampling is enabled. Even if enabled, QCustomPlot decides whether adaptive sampling shall actually be used on a per-graph basis. So leaving adaptive sampling enabled has no disadvantage in almost all cases.

                +
                +adaptive-sampling-line.png +
                +A line plot of 500,000 points without and with adaptive sampling
                +

                As can be seen, line plots experience no visual degradation from adaptive sampling. Outliers are reproduced reliably, as well as the overall shape of the data set. The replot time reduces dramatically though. This allows QCustomPlot to display large amounts of data in realtime.

                +
                +adaptive-sampling-scatter.png +
                +A scatter plot of 100,000 points without and with adaptive sampling
                +

                Care must be taken when using high-density scatter plots in combination with adaptive sampling. The adaptive sampling algorithm treats scatter plots more carefully than line plots which still gives a significant reduction of replot times, but not quite as much as for line plots. This is because scatter plots inherently need more data points to be preserved in order to still resemble the original, non-adaptive-sampling plot. As shown above, the results still aren't quite identical, as banding occurs for the outer data points. This is in fact intentional, such that the boundaries of the data cloud stay visible to the viewer. How strong the banding appears, depends on the point density, i.e. the number of points in the plot.

                +

                For some situations with scatter plots it might thus be desirable to manually turn adaptive sampling off. For example, when saving the plot to disk. This can be achieved by setting enabled to false before issuing a command like QCustomPlot::savePng, and setting enabled back to true afterwards.

                + +
                +
                @@ -795,7 +823,8 @@
                -

                Adds the provided data points in dataMap to the current data.

                +

                Adds the provided data points in dataMap to the current data.

                +

                Alternatively, you can also access and modify the graph's data via the data method, which returns a pointer to the internal QCPDataMap.

                See Also
                removeData
                @@ -814,7 +843,8 @@

                This is an overloaded function.

                -

                Adds the provided single data point in data to the current data.

                +

                Adds the provided single data point in data to the current data.

                +

                Alternatively, you can also access and modify the graph's data via the data method, which returns a pointer to the internal QCPDataMap.

                See Also
                removeData
                @@ -843,7 +873,8 @@

                This is an overloaded function.

                -

                Adds the provided single data point as key and value pair to the current data.

                +

                Adds the provided single data point as key and value pair to the current data.

                +

                Alternatively, you can also access and modify the graph's data via the data method, which returns a pointer to the internal QCPDataMap.

                See Also
                removeData
                @@ -872,7 +903,8 @@

                This is an overloaded function.

                -

                Adds the provided data points as key and value pairs to the current data.

                +

                Adds the provided data points as key and value pairs to the current data.

                +

                Alternatively, you can also access and modify the graph's data via the data method, which returns a pointer to the internal QCPDataMap.

                See Also
                removeData
                @@ -1189,7 +1221,7 @@ - +
                @@ -1200,7 +1232,7 @@ - + @@ -1220,14 +1252,15 @@
                QCPRange QCPGraph::getKeyRange ( bool & validRange, foundRange,
                -

                called by rescaleAxes functions to get the full data key bounds. For logarithmic plots, one can set inSignDomain to either sdNegative or sdPositive in order to restrict the returned range to that sign domain. E.g. when only negative range is wanted, set inSignDomain to sdNegative and all positive points will be ignored for range calculation. For no restriction, just set inSignDomain to sdBoth (default). validRange is an output parameter that indicates whether a proper range could be found or not. If this is false, you shouldn't use the returned range (e.g. no points in data).

                -
                See Also
                rescaleAxes, getValueRange
                +

                called by rescaleAxes functions to get the full data key bounds. For logarithmic plots, one can set inSignDomain to either sdNegative or sdPositive in order to restrict the returned range to that sign domain. E.g. when only negative range is wanted, set inSignDomain to sdNegative and all positive points will be ignored for range calculation. For no restriction, just set inSignDomain to sdBoth (default). foundRange is an output parameter that indicates whether a range could be found or not. If this is false, you shouldn't use the returned range (e.g. no points in data).

                +

                Note that foundRange is not the same as QCPRange::validRange, since the range returned by this function may have size zero, which wouldn't count as a valid range.

                +
                See Also
                rescaleAxes, getValueRange
                -

                Implements QCPAbstractPlottable.

                +

                Implements QCPAbstractPlottable.

                - +
                @@ -1238,7 +1271,7 @@ - + @@ -1258,14 +1291,15 @@
                QCPRange QCPGraph::getValueRange ( bool & validRange, foundRange,
                -

                called by rescaleAxes functions to get the full data value bounds. For logarithmic plots, one can set inSignDomain to either sdNegative or sdPositive in order to restrict the returned range to that sign domain. E.g. when only negative range is wanted, set inSignDomain to sdNegative and all positive points will be ignored for range calculation. For no restriction, just set inSignDomain to sdBoth (default). validRange is an output parameter that indicates whether a proper range could be found or not. If this is false, you shouldn't use the returned range (e.g. no points in data).

                -
                See Also
                rescaleAxes, getKeyRange
                +

                called by rescaleAxes functions to get the full data value bounds. For logarithmic plots, one can set inSignDomain to either sdNegative or sdPositive in order to restrict the returned range to that sign domain. E.g. when only negative range is wanted, set inSignDomain to sdNegative and all positive points will be ignored for range calculation. For no restriction, just set inSignDomain to sdBoth (default). foundRange is an output parameter that indicates whether a range could be found or not. If this is false, you shouldn't use the returned range (e.g. no points in data).

                +

                Note that foundRange is not the same as QCPRange::validRange, since the range returned by this function may have size zero, which wouldn't count as a valid range.

                +
                See Also
                rescaleAxes, getKeyRange
                -

                Implements QCPAbstractPlottable.

                +

                Implements QCPAbstractPlottable.

                - +
                @@ -1276,7 +1310,7 @@ - + @@ -1304,11 +1338,11 @@

                This is an overloaded function.

                Allows to specify whether the error bars should be included in the range calculation.

                -
                See Also
                getKeyRange(bool &validRange, SignDomain inSignDomain)
                +
                See Also
                getKeyRange(bool &foundRange, SignDomain inSignDomain)
                - +
                QCPRange QCPGraph::getKeyRange ( bool & validRange, foundRange,
                @@ -1319,7 +1353,7 @@ - + @@ -1347,7 +1381,7 @@

                This is an overloaded function.

                Allows to specify whether the error bars should be included in the range calculation.

                -
                See Also
                getValueRange(bool &validRange, SignDomain inSignDomain)
                +
                See Also
                getValueRange(bool &foundRange, SignDomain inSignDomain)
                @@ -1389,7 +1423,7 @@ - +
                QCPRange QCPGraph::getValueRange ( bool & validRange, foundRange,
                @@ -1406,7 +1440,7 @@ - + @@ -1420,7 +1454,7 @@
                QVector< QCPData > * pointData scatterData 
                -

                Draws scatter symbols at every data point passed in pointData. scatter symbols are independent of the line style and are always drawn if the scatter style's shape is not QCPScatterStyle::ssNone. Hence, the pointData vector is outputted by all "get(...)PlotData" functions, together with the (line style dependent) line data.

                +

                Draws scatter symbols at every data point passed in scatterData. scatter symbols are independent of the line style and are always drawn if the scatter style's shape is not QCPScatterStyle::ssNone. Hence, the scatterData vector is outputted by all "get(...)PlotData" functions, together with the (line style dependent) line data.

                See Also
                drawLinePlot, drawImpulsePlot
                @@ -1456,8 +1490,8 @@
                -

                Draws line graphs from the provided data. It connects all points in lineData, which was created by one of the "get(...)PlotData" functions for line styles that require simple line connections between the point vector they create. These are for example getLinePlotData, getStepLeftPlotData, getStepRightPlotData and getStepCenterPlotData.

                -
                See Also
                drawScatterPlot, drawImpulsePlot
                +

                Draws line graphs from the provided data. It connects all points in lineData, which was created by one of the "get(...)PlotData" functions for line styles that require simple line connections between the point vector they create. These are for example getLinePlotData, getStepLeftPlotData, getStepRightPlotData and getStepCenterPlotData.

                +
                See Also
                drawScatterPlot, drawImpulsePlot
                @@ -1492,12 +1526,49 @@
                -

                Draws impulses from the provided data, i.e. it connects all line pairs in lineData, which was created by getImpulsePlotData.

                -
                See Also
                drawScatterPlot, drawLinePlot
                +

                Draws impulses from the provided data, i.e. it connects all line pairs in lineData, which was created by getImpulsePlotData.

                +
                See Also
                drawScatterPlot, drawLinePlot
                + +
                + + +
                +
                + + + + + +
                + + + + + + + + + + + + + + + + + + +
                void QCPGraph::getPreparedData (QVector< QCPData > * lineData,
                QVector< QCPData > * scatterData 
                ) const
                +
                +protected
                +
                +

                Returns the lineData and scatterData that need to be plotted for this graph taking into consideration the current axis ranges and, if setAdaptiveSampling is enabled, local point densities.

                +

                0 may be passed as lineData or scatterData to indicate that the respective dataset isn't needed. For example, if the scatter style (setScatterStyle) is QCPScatterStyle::ssNone, scatterData should be 0 to prevent unnecessary calculations.

                +

                This method is used by the various "get(...)PlotData" methods to get the basic working set of data.

                - +
                @@ -1514,7 +1585,7 @@ - + @@ -1530,12 +1601,12 @@

                This function branches out to the line style specific "get(...)PlotData" functions, according to the line style of the graph.

                lineData will be filled with raw points that will be drawn with the according draw functions, e.g. drawLinePlot and drawImpulsePlot. These aren't necessarily the original data points, since for step plots for example, additional points are needed for drawing lines that make up steps. If the line style of the graph is lsNone, the lineData vector will be left untouched.

                -

                pointData will be filled with the original data points so drawScatterPlot can draw the scatter symbols accordingly. If no scatters need to be drawn, i.e. the scatter style's shape is QCPScatterStyle::ssNone, pass 0 as pointData, and this step will be skipped.

                -
                See Also
                getScatterPlotData, getLinePlotData, getStepLeftPlotData, getStepRightPlotData, getStepCenterPlotData, getImpulsePlotData
                +

                scatterData will be filled with the original data points so drawScatterPlot can draw the scatter symbols accordingly. If no scatters need to be drawn, i.e. the scatter style's shape is QCPScatterStyle::ssNone, pass 0 as scatterData, and this step will be skipped.

                +
                See Also
                getScatterPlotData, getLinePlotData, getStepLeftPlotData, getStepRightPlotData, getStepCenterPlotData, getImpulsePlotData
                - +
                QVector< QCPData > * pointData scatterData 
                @@ -1546,7 +1617,7 @@ - +
                void QCPGraph::getScatterPlotData ( QVector< QCPData > * pointData)scatterData) const
                @@ -1556,13 +1627,13 @@
                -

                If line style is lsNone and the scatter style's shape is not QCPScatterStyle::ssNone, this function serves at providing the visible data points in pointData, so the drawScatterPlot function can draw the scatter points accordingly.

                +

                If line style is lsNone and the scatter style's shape is not QCPScatterStyle::ssNone, this function serves at providing the visible data points in scatterData, so the drawScatterPlot function can draw the scatter points accordingly.

                If line style is not lsNone, this function is not called and the data for the scatter points are (if needed) calculated inside the corresponding other "get(...)PlotData" functions.

                -
                See Also
                drawScatterPlot
                +
                See Also
                drawScatterPlot
                - +
                @@ -1573,13 +1644,13 @@ - + - + @@ -1593,13 +1664,13 @@
                void QCPGraph::getLinePlotData ( QVector< QPointF > * lineData, linePixelData,
                QVector< QCPData > * pointData scatterData 
                -

                Places the raw data points needed for a normal linearly connected graph in lineData.

                -

                As for all plot data retrieval functions, pointData just contains all unaltered data (scatter) points that are visible for drawing scatter points, if necessary. If drawing scatter points is disabled (i.e. the scatter style's shape is QCPScatterStyle::ssNone), pass 0 as pointData, and the function will skip filling the vector.

                +

                Places the raw data points needed for a normal linearly connected graph in linePixelData.

                +

                As for all plot data retrieval functions, scatterData just contains all unaltered data (scatter) points that are visible for drawing scatter points, if necessary. If drawing scatter points is disabled (i.e. the scatter style's shape is QCPScatterStyle::ssNone), pass 0 as scatterData, and the function will skip filling the vector.

                See Also
                drawLinePlot
                - +
                @@ -1610,13 +1681,13 @@ - + - + @@ -1631,12 +1702,12 @@
                void QCPGraph::getStepLeftPlotData ( QVector< QPointF > * lineData, linePixelData,
                QVector< QCPData > * pointData scatterData 

                Places the raw data points needed for a step plot with left oriented steps in lineData.

                -

                As for all plot data retrieval functions, pointData just contains all unaltered data (scatter) points that are visible for drawing scatter points, if necessary. If drawing scatter points is disabled (i.e. the scatter style's shape is QCPScatterStyle::ssNone), pass 0 as pointData, and the function will skip filling the vector.

                +

                As for all plot data retrieval functions, scatterData just contains all unaltered data (scatter) points that are visible for drawing scatter points, if necessary. If drawing scatter points is disabled (i.e. the scatter style's shape is QCPScatterStyle::ssNone), pass 0 as scatterData, and the function will skip filling the vector.

                See Also
                drawLinePlot
                - +
                @@ -1647,13 +1718,13 @@ - + - + @@ -1668,12 +1739,12 @@
                void QCPGraph::getStepRightPlotData ( QVector< QPointF > * lineData, linePixelData,
                QVector< QCPData > * pointData scatterData 

                Places the raw data points needed for a step plot with right oriented steps in lineData.

                -

                As for all plot data retrieval functions, pointData just contains all unaltered data (scatter) points that are visible for drawing scatter points, if necessary. If drawing scatter points is disabled (i.e. the scatter style's shape is QCPScatterStyle::ssNone), pass 0 as pointData, and the function will skip filling the vector.

                +

                As for all plot data retrieval functions, scatterData just contains all unaltered data (scatter) points that are visible for drawing scatter points, if necessary. If drawing scatter points is disabled (i.e. the scatter style's shape is QCPScatterStyle::ssNone), pass 0 as scatterData, and the function will skip filling the vector.

                See Also
                drawLinePlot
                - +
                @@ -1684,13 +1755,13 @@ - + - + @@ -1705,12 +1776,12 @@
                void QCPGraph::getStepCenterPlotData ( QVector< QPointF > * lineData, linePixelData,
                QVector< QCPData > * pointData scatterData 

                Places the raw data points needed for a step plot with centered steps in lineData.

                -

                As for all plot data retrieval functions, pointData just contains all unaltered data (scatter) points that are visible for drawing scatter points, if necessary. If drawing scatter points is disabled (i.e. the scatter style's shape is QCPScatterStyle::ssNone), pass 0 as pointData, and the function will skip filling the vector.

                +

                As for all plot data retrieval functions, scatterData just contains all unaltered data (scatter) points that are visible for drawing scatter points, if necessary. If drawing scatter points is disabled (i.e. the scatter style's shape is QCPScatterStyle::ssNone), pass 0 as scatterData, and the function will skip filling the vector.

                See Also
                drawLinePlot
                - +
                @@ -1721,13 +1792,13 @@ - + - + @@ -1742,7 +1813,7 @@
                void QCPGraph::getImpulsePlotData ( QVector< QPointF > * lineData, linePixelData,
                QVector< QCPData > * pointData scatterData 

                Places the raw data points needed for an impulse plot in lineData.

                -

                As for all plot data retrieval functions, pointData just contains all unaltered data (scatter) points that are visible for drawing scatter points, if necessary. If drawing scatter points is disabled (i.e. the scatter style's shape is QCPScatterStyle::ssNone), pass 0 as pointData, and the function will skip filling the vector.

                +

                As for all plot data retrieval functions, scatterData just contains all unaltered data (scatter) points that are visible for drawing scatter points, if necessary. If drawing scatter points is disabled (i.e. the scatter style's shape is QCPScatterStyle::ssNone), pass 0 as scatterData, and the function will skip filling the vector.

                See Also
                drawImpulsePlot
                @@ -1790,11 +1861,11 @@
                -

                called by the scatter drawing function (drawScatterPlot) to draw the error bars on one data point. x and y pixel positions of the data point are passed since they are already known in pixel coordinates in the drawing function, so we save some extra coordToPixel transforms here. data is therefore only used for the errors, not key and value.

                +

                called by the scatter drawing function (drawScatterPlot) to draw the error bars on one data point. x and y pixel positions of the data point are passed since they are already known in pixel coordinates in the drawing function, so we save some extra coordToPixel transforms here. data is therefore only used for the errors, not key and value.

                - +
                @@ -1811,13 +1882,51 @@ + + + + + + + +
                QCPDataMap::const_iterator & upper 
                ) const
                + + +protected + + +
                +

                called by getPreparedData to determine which data (key) range is visible at the current key axis range setting, so only that needs to be processed.

                +

                lower returns an iterator to the lowest data point that needs to be taken into account when plotting. Note that in order to get a clean plot all the way to the edge of the axis rect, lower may still be just outside the visible range.

                +

                upper returns an iterator to the highest data point. Same as before, upper may also lie just outside of the visible range.

                +

                if the graph contains no data, both lower and upper point to constEnd.

                + +
                +
                + +
                +
                + + +
                + + + + + + + + + + + - - + + @@ -1831,11 +1940,8 @@
                int QCPGraph::countDataInBounds (const QCPDataMap::const_iterator & lower,
                const QCPDataMap::const_iterator &  upper,
                int & count int maxCount 
                -

                called by the specific plot data generating functions "get(...)PlotData" to determine which data range is visible, so only that needs to be processed.

                -

                lower returns an iterator to the lowest data point that needs to be taken into account when plotting. Note that in order to get a clean plot all the way to the edge of the axes, lower may still be outside the visible range.

                -

                upper returns an iterator to the highest data point. Same as before, upper may also lie outside of the visible range.

                -

                count number of data points that need plotting, i.e. points between lower and upper, including them. This is useful for allocating the array of QPointFs in the specific drawing functions.

                -

                if the graph contains no data, count is zero and both lower and upper point to constEnd.

                +

                Counts the number of data points between lower and upper (including them), up to a maximum of maxCount.

                +

                This function is used by getPreparedData to determine whether adaptive sampling shall be used (if enabled via setAdaptiveSampling) or not. This is also why counting of data points only needs to be done until maxCount is reached, which should be set to the number of data points at which adaptive sampling sets in.

                @@ -1967,7 +2073,7 @@
                -

                Generates the polygon needed for drawing channel fills between this graph (data passed via lineData) and the graph specified by mChannelFillGraph (data generated by calling its getPlotData function). May return an empty polygon if the key ranges have no overlap or fill target graph and this graph don't have same orientation (i.e. both key axes horizontal or both key axes vertical). For increased performance (due to implicit sharing), keep the returned QPolygonF const.

                +

                Generates the polygon needed for drawing channel fills between this graph (data passed via lineData) and the graph specified by mChannelFillGraph (data generated by calling its getPlotData function). May return an empty polygon if the key ranges have no overlap or fill target graph and this graph don't have same orientation (i.e. both key axes horizontal or both key axes vertical). For increased performance (due to implicit sharing), keep the returned QPolygonF const.

                @@ -2141,1316 +2247,6 @@ - -
                -
                - - - - - -
                - - - - - - - - -
                void QCPAbstractPlottable::setName (const QString & name)
                -
                -inherited
                -
                -

                The name is the textual representation of this plottable as it is displayed in the legend (QCPLegend). It may contain any UTF-8 characters, including newlines.

                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - -
                void QCPAbstractPlottable::setAntialiasedFill (bool enabled)
                -
                -inherited
                -
                -

                Sets whether fills of this plottable is drawn antialiased or not.

                -

                Note that this setting may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - -
                void QCPAbstractPlottable::setAntialiasedScatters (bool enabled)
                -
                -inherited
                -
                -

                Sets whether the scatter symbols of this plottable are drawn antialiased or not.

                -

                Note that this setting may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - -
                void QCPAbstractPlottable::setAntialiasedErrorBars (bool enabled)
                -
                -inherited
                -
                -

                Sets whether the error bars of this plottable are drawn antialiased or not.

                -

                Note that this setting may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - -
                void QCPAbstractPlottable::setPen (const QPen & pen)
                -
                -inherited
                -
                -

                The pen is used to draw basic lines that make up the plottable representation in the plot.

                -

                For example, the QCPGraph subclass draws its graph lines and scatter points with this pen.

                -
                See Also
                setBrush
                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - -
                void QCPAbstractPlottable::setSelectedPen (const QPen & pen)
                -
                -inherited
                -
                -

                When the plottable is selected, this pen is used to draw basic lines instead of the normal pen set via setPen.

                -
                See Also
                setSelected, setSelectable, setSelectedBrush, selectTest
                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - -
                void QCPAbstractPlottable::setBrush (const QBrush & brush)
                -
                -inherited
                -
                -

                The brush is used to draw basic fills of the plottable representation in the plot. The Fill can be a color, gradient or texture, see the usage of QBrush.

                -

                For example, the QCPGraph subclass draws the fill under the graph with this brush, when it's not set to Qt::NoBrush.

                -
                See Also
                setPen
                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - -
                void QCPAbstractPlottable::setSelectedBrush (const QBrush & brush)
                -
                -inherited
                -
                -

                When the plottable is selected, this brush is used to draw fills instead of the normal brush set via setBrush.

                -
                See Also
                setSelected, setSelectable, setSelectedPen, selectTest
                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - -
                void QCPAbstractPlottable::setKeyAxis (QCPAxisaxis)
                -
                -inherited
                -
                -

                The key axis of a plottable can be set to any axis of a QCustomPlot, as long as it is orthogonal to the plottable's value axis. This function performs no checks to make sure this is the case. The typical mathematical choice is to use the x-axis (QCustomPlot::xAxis) as key axis and the y-axis (QCustomPlot::yAxis) as value axis.

                -

                Normally, the key and value axes are set in the constructor of the plottable (or QCustomPlot::addGraph when working with QCPGraphs through the dedicated graph interface).

                -
                See Also
                setValueAxis
                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - -
                void QCPAbstractPlottable::setValueAxis (QCPAxisaxis)
                -
                -inherited
                -
                -

                The value axis of a plottable can be set to any axis of a QCustomPlot, as long as it is orthogonal to the plottable's key axis. This function performs no checks to make sure this is the case. The typical mathematical choice is to use the x-axis (QCustomPlot::xAxis) as key axis and the y-axis (QCustomPlot::yAxis) as value axis.

                -

                Normally, the key and value axes are set in the constructor of the plottable (or QCustomPlot::addGraph when working with QCPGraphs through the dedicated graph interface).

                -
                See Also
                setKeyAxis
                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - -
                void QCPAbstractPlottable::setSelectable (bool selectable)
                -
                -inherited
                -
                -

                Sets whether the user can (de-)select this plottable by clicking on the QCustomPlot surface. (When QCustomPlot::setInteractions contains iSelectPlottables.)

                -

                However, even when selectable was set to false, it is possible to set the selection manually, by calling setSelected directly.

                -
                See Also
                setSelected
                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - -
                void QCPAbstractPlottable::setSelected (bool selected)
                -
                -inherited
                -
                -

                Sets whether this plottable is selected or not. When selected, it uses a different pen and brush to draw its lines and fills, see setSelectedPen and setSelectedBrush.

                -

                The entire selection mechanism for plottables is handled automatically when QCustomPlot::setInteractions contains iSelectPlottables. You only need to call this function when you wish to change the selection state manually.

                -

                This function can change the selection state even when setSelectable was set to false.

                -

                emits the selectionChanged signal when selected is different from the previous selection state.

                -
                See Also
                setSelectable, selectTest
                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - -
                bool QCPAbstractPlottable::addToLegend ()
                -
                -virtualinherited
                -
                -

                Adds this plottable to the legend of the parent QCustomPlot (QCustomPlot::legend).

                -

                Normally, a QCPPlottableLegendItem is created and inserted into the legend. If the plottable needs a more specialized representation in the legend, this function will take this into account and instead create the specialized subclass of QCPAbstractLegendItem.

                -

                Returns true on success, i.e. when the legend exists and a legend item associated with this plottable isn't already in the legend.

                -
                See Also
                removeFromLegend, QCPLegend::addItem
                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - -
                bool QCPAbstractPlottable::removeFromLegend () const
                -
                -virtualinherited
                -
                -

                Removes the plottable from the legend of the parent QCustomPlot. This means the QCPAbstractLegendItem (usually a QCPPlottableLegendItem) that is associated with this plottable is removed.

                -

                Returns true on success, i.e. if the legend exists and a legend item associated with this plottable was found and removed.

                -
                See Also
                addToLegend, QCPLegend::removeItem
                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - -
                void QCPAbstractPlottable::rescaleAxes (bool onlyEnlarge = false) const
                -
                -inherited
                -
                -

                Rescales the key and value axes associated with this plottable to contain all displayed data, so the whole plottable is visible. If the scaling of an axis is logarithmic, rescaleAxes will make sure not to rescale to an illegal range i.e. a range containing different signs and/or zero. Instead it will stay in the current sign domain and ignore all parts of the plottable that lie outside of that domain.

                -

                onlyEnlarge makes sure the ranges are only expanded, never reduced. So it's possible to show multiple plottables in their entirety by multiple calls to rescaleAxes where the first call has onlyEnlarge set to false (the default), and all subsequent set to true.

                -
                See Also
                rescaleKeyAxis, rescaleValueAxis, QCustomPlot::rescaleAxes, QCPAxis::rescale
                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - -
                void QCPAbstractPlottable::rescaleKeyAxis (bool onlyEnlarge = false) const
                -
                -inherited
                -
                -

                Rescales the key axis of the plottable so the whole plottable is visible.

                -

                See rescaleAxes for detailed behaviour.

                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - -
                void QCPAbstractPlottable::rescaleValueAxis (bool onlyEnlarge = false) const
                -
                -inherited
                -
                -

                Rescales the value axis of the plottable so the whole plottable is visible.

                -

                Returns true if the axis was actually scaled. This might not be the case if this plottable has an invalid range, e.g. because it has no data points.

                -

                See rescaleAxes for detailed behaviour.

                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - -
                void QCPAbstractPlottable::selectionChanged (bool selected)
                -
                -signalinherited
                -
                -

                This signal is emitted when the selection state of this plottable has changed to selected, either by user interaction or by a direct call to setSelected.

                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - -
                QRect QCPAbstractPlottable::clipRect () const
                -
                -protectedvirtualinherited
                -
                -

                Returns the clipping rectangle of this layerable object. By default, this is the viewport of the parent QCustomPlot. Specific subclasses may reimplement this function to provide different clipping rects.

                -

                The returned clipping rect is set on the painter before the draw function of the respective object is called.

                - -

                Reimplemented from QCPLayerable.

                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - -
                QCP::Interaction QCPAbstractPlottable::selectionCategory () const
                -
                -protectedvirtualinherited
                -
                -

                Returns the selection category this layerable shall belong to. The selection category is used in conjunction with QCustomPlot::setInteractions to control which objects are selectable and which aren't.

                -

                Subclasses that don't fit any of the normal QCP::Interaction values can use QCP::iSelectOther. This is what the default implementation returns.

                -
                See Also
                QCustomPlot::setInteractions
                - -

                Reimplemented from QCPLayerable.

                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - -
                void QCPAbstractPlottable::applyDefaultAntialiasingHint (QCPPainterpainter) const
                -
                -protectedvirtualinherited
                -
                -

                A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing plottable lines.

                -

                This is the antialiasing state the painter passed to the draw method is in by default.

                -

                This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                -
                See Also
                setAntialiased, applyFillAntialiasingHint, applyScattersAntialiasingHint, applyErrorBarsAntialiasingHint
                - -

                Implements QCPLayerable.

                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                void QCPAbstractPlottable::selectEvent (QMouseEvent * event,
                bool additive,
                const QVariant & details,
                bool * selectionStateChanged 
                )
                -
                -protectedvirtualinherited
                -
                -

                This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

                -

                event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

                -

                Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

                -

                selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

                -
                See Also
                selectTest, deselectEvent
                - -

                Reimplemented from QCPLayerable.

                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - -
                void QCPAbstractPlottable::deselectEvent (bool * selectionStateChanged)
                -
                -protectedvirtualinherited
                -
                -

                This event is called when the layerable shall be deselected, either as consequence of a user interaction or a call to QCustomPlot::deselectAll. Subclasses should react to it by unsetting their selection appropriately.

                -

                just as in selectEvent, the output parameter selectionStateChanged (if non-null), must return true or false when the selection state of this layerable has changed or not changed, respectively.

                -
                See Also
                selectTest, selectEvent
                - -

                Reimplemented from QCPLayerable.

                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                void QCPAbstractPlottable::coordsToPixels (double key,
                double value,
                double & x,
                double & y 
                ) const
                -
                -protectedinherited
                -
                -

                Convenience function for transforming a key/value pair to pixels on the QCustomPlot surface, taking the orientations of the axes associated with this plottable into account (e.g. whether key represents x or y).

                -

                key and value are transformed to the coodinates in pixels and are written to x and y.

                -
                See Also
                pixelsToCoords, QCPAxis::coordToPixel
                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - - - - - - - - - - - -
                const QPointF QCPAbstractPlottable::coordsToPixels (double key,
                double value 
                ) const
                -
                -protectedinherited
                -
                -

                This is an overloaded function.

                -

                Returns the input as pixel coordinates in a QPointF.

                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                void QCPAbstractPlottable::pixelsToCoords (double x,
                double y,
                double & key,
                double & value 
                ) const
                -
                -protectedinherited
                -
                -

                Convenience function for transforming a x/y pixel pair on the QCustomPlot surface to plot coordinates, taking the orientations of the axes associated with this plottable into account (e.g. whether key represents x or y).

                -

                x and y are transformed to the plot coodinates and are written to key and value.

                -
                See Also
                coordsToPixels, QCPAxis::coordToPixel
                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - - - - - - - - - - - - - - - - - -
                void QCPAbstractPlottable::pixelsToCoords (const QPointF & pixelPos,
                double & key,
                double & value 
                ) const
                -
                -protectedinherited
                -
                -

                This is an overloaded function.

                -

                Returns the pixel input pixelPos as plot coordinates key and value.

                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - -
                QPen QCPAbstractPlottable::mainPen () const
                -
                -protectedinherited
                -
                -

                Returns the pen that should be used for drawing lines of the plottable. Returns mPen when the graph is not selected and mSelectedPen when it is.

                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - -
                QBrush QCPAbstractPlottable::mainBrush () const
                -
                -protectedinherited
                -
                -

                Returns the brush that should be used for drawing fills of the plottable. Returns mBrush when the graph is not selected and mSelectedBrush when it is.

                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - -
                void QCPAbstractPlottable::applyFillAntialiasingHint (QCPPainterpainter) const
                -
                -protectedinherited
                -
                -

                A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing plottable fills.

                -

                This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                -
                See Also
                setAntialiased, applyDefaultAntialiasingHint, applyScattersAntialiasingHint, applyErrorBarsAntialiasingHint
                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - -
                void QCPAbstractPlottable::applyScattersAntialiasingHint (QCPPainterpainter) const
                -
                -protectedinherited
                -
                -

                A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing plottable scatter points.

                -

                This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                -
                See Also
                setAntialiased, applyFillAntialiasingHint, applyDefaultAntialiasingHint, applyErrorBarsAntialiasingHint
                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - -
                void QCPAbstractPlottable::applyErrorBarsAntialiasingHint (QCPPainterpainter) const
                -
                -protectedinherited
                -
                -

                A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing plottable error bars.

                -

                This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                -
                See Also
                setAntialiased, applyFillAntialiasingHint, applyScattersAntialiasingHint, applyDefaultAntialiasingHint
                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - - - - - - - - - - - - - - - - - -
                double QCPAbstractPlottable::distSqrToLine (const QPointF & start,
                const QPointF & end,
                const QPointF & point 
                ) const
                -
                -protectedinherited
                -
                -

                Finds the shortest squared distance of point to the line segment defined by start and end.

                -

                This function may be used to help with the implementation of the selectTest function for specific plottables.

                -
                Note
                This function is identical to QCPAbstractItem::distSqrToLine
                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - -
                QCPLayerable * QCPLayerable::parentLayerable () const
                -
                -inlineinherited
                -
                -

                Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.

                -

                Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.

                -

                A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.

                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - -
                void QCPLayerable::setVisible (bool on)
                -
                -inherited
                -
                -

                Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.

                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - -
                bool QCPLayerable::setLayer (QCPLayerlayer)
                -
                -inherited
                -
                -

                Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.

                -

                Returns true on success, i.e. if layer is a valid layer.

                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - -
                bool QCPLayerable::setLayer (const QString & layerName)
                -
                -inherited
                -
                -

                This is an overloaded function.

                -

                Sets the layer of this layerable object by name

                -

                Returns true on success, i.e. if layerName is a valid layer name.

                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - -
                void QCPLayerable::setAntialiased (bool enabled)
                -
                -inherited
                -
                -

                Sets whether this object will be drawn antialiased or not.

                -

                Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - -
                bool QCPLayerable::realVisibility () const
                -
                -inherited
                -
                -

                Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.

                -

                If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.

                -

                If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.

                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - -
                void QCPLayerable::parentPlotInitialized (QCustomPlotparentPlot)
                -
                -protectedvirtualinherited
                -
                -

                This function is called by initializeParentPlot, to allow subclasses to react on the setting of a parent plot. This is the case when 0 was passed as parent plot in the constructor, and the parent plot is set at a later time.

                -

                For example, QCPLayoutElement/QCPLayout hierarchies may be created independently of any QCustomPlot at first. When they are then added to a layout inside the QCustomPlot, the top level element of the hierarchy gets its parent plot initialized with initializeParentPlot. To propagate the parent plot to all the children of the hierarchy, the top level element then uses this function to pass the parent plot on to its child elements.

                -

                The default implementation does nothing.

                -
                See Also
                initializeParentPlot
                - -

                Reimplemented in QCPLegend, and QCPLayoutElement.

                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - -
                void QCPLayerable::initializeParentPlot (QCustomPlotparentPlot)
                -
                -protectedinherited
                -
                -

                Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.

                -

                Note that, unlike when passing a non-null parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.

                -

                Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.

                -

                The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).

                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - -
                void QCPLayerable::setParentLayerable (QCPLayerableparentLayerable)
                -
                -protectedinherited
                -
                -

                Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.

                -

                The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.

                -
                See Also
                realVisibility
                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - - - - - - - - - - - -
                bool QCPLayerable::moveToLayer (QCPLayerlayer,
                bool prepend 
                )
                -
                -protectedinherited
                -
                -

                Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.

                -

                Returns true on success, i.e. if layer is a valid layer.

                - -
                -
                - -
                -
                - - - - - -
                - - - - - - - - - - - - - - - - - - - - - - - - -
                void QCPLayerable::applyAntialiasingHint (QCPPainterpainter,
                bool localAntialiased,
                QCP::AntialiasedElement overrideElement 
                ) const
                -
                -protectedinherited
                -
                -

                Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.

                - -
                -

                The documentation for this class was generated from the following files:
                • src/plottables/plottable-graph.h
                • src/plottables/plottable-graph.cpp
                • diff -Nru qcustomplot-1.1.0/documentation/html/classQCPGrid.html qcustomplot-1.2.0/documentation/html/classQCPGrid.html --- qcustomplot-1.1.0/documentation/html/classQCPGrid.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPGrid.html 2014-03-14 21:11:27.000000000 +0000 @@ -54,21 +54,23 @@ void setPen (const QPen &pen) void setSubGridPen (const QPen &pen) void setZeroLinePen (const QPen &pen) - +- Public Functions inherited from QCPLayerableQCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0) + bool visible () const - + QCustomPlotparentPlot () const -QCPLayerableparentLayerable () const - +QCPLayerableparentLayerable () const + QCPLayerlayer () const - + bool antialiased () const -void setVisible (bool on) -bool setLayer (QCPLayer *layer) -bool setLayer (const QString &layerName) -void setAntialiased (bool enabled) -virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const -bool realVisibility () const +void setVisible (bool on) +Q_SLOT bool setLayer (QCPLayer *layer) +bool setLayer (const QString &layerName) +void setAntialiased (bool enabled) +virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const +bool realVisibility () const @@ -76,15 +78,21 @@ - - - - - - - - - + + + + + + + + + + +

                  Protected Functions

                  virtual void draw (QCPPainter *painter)
                  void drawGridLines (QCPPainter *painter) const
                  void drawSubGridLines (QCPPainter *painter) const
                  virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                  virtual QCP::Interaction selectionCategory () const
                  virtual QRect clipRect () const
                  virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                  virtual void deselectEvent (bool *selectionStateChanged)
                  void initializeParentPlot (QCustomPlot *parentPlot)
                  void setParentLayerable (QCPLayerable *parentLayerable)
                  bool moveToLayer (QCPLayer *layer, bool prepend)
                  void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                  - Protected Functions inherited from QCPLayerable
                  virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                  virtual QCP::Interaction selectionCategory () const
                  virtual QRect clipRect () const
                  virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                  virtual void deselectEvent (bool *selectionStateChanged)
                  void initializeParentPlot (QCustomPlot *parentPlot)
                  void setParentLayerable (QCPLayerable *parentLayerable)
                  bool moveToLayer (QCPLayer *layer, bool prepend)
                  void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                  + + +

                  +Additional Inherited Members

                  - Signals inherited from QCPLayerable
                  void layerChanged (QCPLayer *newLayer)

                  Detailed Description

                  Responsible for drawing the grid of a QCPAxis.

                  @@ -323,511 +331,6 @@
                  - -
                  -
                  - - - - - -
                  - - - - - - - -
                  QCPLayerable * QCPLayerable::parentLayerable () const
                  -
                  -inlineinherited
                  -
                  -

                  Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.

                  -

                  Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.

                  -

                  A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.

                  - -
                  -
                  - -
                  -
                  - - - - - -
                  - - - - - - - - -
                  void QCPLayerable::setVisible (bool on)
                  -
                  -inherited
                  -
                  -

                  Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.

                  - -
                  -
                  - -
                  -
                  - - - - - -
                  - - - - - - - - -
                  bool QCPLayerable::setLayer (QCPLayerlayer)
                  -
                  -inherited
                  -
                  -

                  Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.

                  -

                  Returns true on success, i.e. if layer is a valid layer.

                  - -
                  -
                  - -
                  -
                  - - - - - -
                  - - - - - - - - -
                  bool QCPLayerable::setLayer (const QString & layerName)
                  -
                  -inherited
                  -
                  -

                  This is an overloaded function.

                  -

                  Sets the layer of this layerable object by name

                  -

                  Returns true on success, i.e. if layerName is a valid layer name.

                  - -
                  -
                  - -
                  -
                  - - - - - -
                  - - - - - - - - -
                  void QCPLayerable::setAntialiased (bool enabled)
                  -
                  -inherited
                  -
                  -

                  Sets whether this object will be drawn antialiased or not.

                  -

                  Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                  - -
                  -
                  - -
                  -
                  - - - - - -
                  - - - - - - - - - - - - - - - - - - - - - - - - -
                  double QCPLayerable::selectTest (const QPointF & pos,
                  bool onlySelectable,
                  QVariant * details = 0 
                  ) const
                  -
                  -virtualinherited
                  -
                  -

                  This function is used to decide whether a click hits a layerable object or not.

                  -

                  pos is a point in pixel coordinates on the QCustomPlot surface. This function returns the shortest pixel distance of this point to the object. If the object is either invisible or the distance couldn't be determined, -1.0 is returned. Further, if onlySelectable is true and the object is not selectable, -1.0 is returned, too.

                  -

                  If the item is represented not by single lines but by an area like QCPItemRect or QCPItemText, a click inside the area returns a constant value greater zero (typically the selectionTolerance of the parent QCustomPlot multiplied by 0.99). If the click lies outside the area, this function returns -1.0.

                  -

                  Providing a constant value for area objects allows selecting line objects even when they are obscured by such area objects, by clicking close to the lines (i.e. closer than 0.99*selectionTolerance).

                  -

                  The actual setting of the selection state is not done by this function. This is handled by the parent QCustomPlot when the mouseReleaseEvent occurs, and the finally selected object is notified via the selectEvent/deselectEvent methods.

                  -

                  details is an optional output parameter. Every layerable subclass may place any information in details. This information will be passed to selectEvent when the parent QCustomPlot decides on the basis of this selectTest call, that the object was successfully selected. The subsequent call to selectEvent will carry the details. This is useful for multi-part objects (like QCPAxis). This way, a possibly complex calculation to decide which part was clicked is only done once in selectTest. The result (i.e. the actually clicked part) can then be placed in details. So in the subsequent selectEvent, the decision which part was selected doesn't have to be done a second time for a single selection operation.

                  -

                  You may pass 0 as details to indicate that you are not interested in those selection details.

                  -
                  See Also
                  selectEvent, deselectEvent, QCustomPlot::setInteractions
                  - -

                  Reimplemented in QCPAxis, QCPLayoutInset, QCPLegend, QCPAbstractItem, QCPGraph, QCPLayoutElement, QCPCurve, QCPBars, QCPStatisticalBox, QCPItemTracer, QCPItemText, QCPAbstractPlottable, QCPAbstractLegendItem, QCPPlotTitle, QCPItemBracket, QCPItemPixmap, QCPItemCurve, QCPItemLine, QCPItemEllipse, QCPItemRect, and QCPItemStraightLine.

                  - -
                  -
                  - -
                  -
                  - - - - - -
                  - - - - - - - -
                  bool QCPLayerable::realVisibility () const
                  -
                  -inherited
                  -
                  -

                  Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.

                  -

                  If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.

                  -

                  If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.

                  - -
                  -
                  - -
                  -
                  - - - - - -
                  - - - - - - - - -
                  void QCPLayerable::parentPlotInitialized (QCustomPlotparentPlot)
                  -
                  -protectedvirtualinherited
                  -
                  -

                  This function is called by initializeParentPlot, to allow subclasses to react on the setting of a parent plot. This is the case when 0 was passed as parent plot in the constructor, and the parent plot is set at a later time.

                  -

                  For example, QCPLayoutElement/QCPLayout hierarchies may be created independently of any QCustomPlot at first. When they are then added to a layout inside the QCustomPlot, the top level element of the hierarchy gets its parent plot initialized with initializeParentPlot. To propagate the parent plot to all the children of the hierarchy, the top level element then uses this function to pass the parent plot on to its child elements.

                  -

                  The default implementation does nothing.

                  -
                  See Also
                  initializeParentPlot
                  - -

                  Reimplemented in QCPLegend, and QCPLayoutElement.

                  - -
                  -
                  - -
                  -
                  - - - - - -
                  - - - - - - - -
                  QCP::Interaction QCPLayerable::selectionCategory () const
                  -
                  -protectedvirtualinherited
                  -
                  -

                  Returns the selection category this layerable shall belong to. The selection category is used in conjunction with QCustomPlot::setInteractions to control which objects are selectable and which aren't.

                  -

                  Subclasses that don't fit any of the normal QCP::Interaction values can use QCP::iSelectOther. This is what the default implementation returns.

                  -
                  See Also
                  QCustomPlot::setInteractions
                  - -

                  Reimplemented in QCPAxis, QCPLegend, QCPAbstractItem, QCPAbstractPlottable, and QCPAbstractLegendItem.

                  - -
                  -
                  - -
                  -
                  - - - - - -
                  - - - - - - - -
                  QRect QCPLayerable::clipRect () const
                  -
                  -protectedvirtualinherited
                  -
                  -

                  Returns the clipping rectangle of this layerable object. By default, this is the viewport of the parent QCustomPlot. Specific subclasses may reimplement this function to provide different clipping rects.

                  -

                  The returned clipping rect is set on the painter before the draw function of the respective object is called.

                  - -

                  Reimplemented in QCPAbstractItem, QCPAbstractPlottable, and QCPAbstractLegendItem.

                  - -
                  -
                  - -
                  -
                  - - - - - -
                  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                  void QCPLayerable::selectEvent (QMouseEvent * event,
                  bool additive,
                  const QVariant & details,
                  bool * selectionStateChanged 
                  )
                  -
                  -protectedvirtualinherited
                  -
                  -

                  This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

                  -

                  event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

                  -

                  Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

                  -

                  selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

                  -
                  See Also
                  selectTest, deselectEvent
                  - -

                  Reimplemented in QCPAxis, QCPLegend, QCPAbstractItem, QCPAbstractPlottable, QCPPlotTitle, and QCPAbstractLegendItem.

                  - -
                  -
                  - -
                  -
                  - - - - - -
                  - - - - - - - - -
                  void QCPLayerable::deselectEvent (bool * selectionStateChanged)
                  -
                  -protectedvirtualinherited
                  -
                  -

                  This event is called when the layerable shall be deselected, either as consequence of a user interaction or a call to QCustomPlot::deselectAll. Subclasses should react to it by unsetting their selection appropriately.

                  -

                  just as in selectEvent, the output parameter selectionStateChanged (if non-null), must return true or false when the selection state of this layerable has changed or not changed, respectively.

                  -
                  See Also
                  selectTest, selectEvent
                  - -

                  Reimplemented in QCPAxis, QCPLegend, QCPAbstractItem, QCPAbstractPlottable, QCPPlotTitle, and QCPAbstractLegendItem.

                  - -
                  -
                  - -
                  -
                  - - - - - -
                  - - - - - - - - -
                  void QCPLayerable::initializeParentPlot (QCustomPlotparentPlot)
                  -
                  -protectedinherited
                  -
                  -

                  Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.

                  -

                  Note that, unlike when passing a non-null parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.

                  -

                  Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.

                  -

                  The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).

                  - -
                  -
                  - -
                  -
                  - - - - - -
                  - - - - - - - - -
                  void QCPLayerable::setParentLayerable (QCPLayerableparentLayerable)
                  -
                  -protectedinherited
                  -
                  -

                  Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.

                  -

                  The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.

                  -
                  See Also
                  realVisibility
                  - -
                  -
                  - -
                  -
                  - - - - - -
                  - - - - - - - - - - - - - - - - - - -
                  bool QCPLayerable::moveToLayer (QCPLayerlayer,
                  bool prepend 
                  )
                  -
                  -protectedinherited
                  -
                  -

                  Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.

                  -

                  Returns true on success, i.e. if layer is a valid layer.

                  - -
                  -
                  - -
                  -
                  - - - - - -
                  - - - - - - - - - - - - - - - - - - - - - - - - -
                  void QCPLayerable::applyAntialiasingHint (QCPPainterpainter,
                  bool localAntialiased,
                  QCP::AntialiasedElement overrideElement 
                  ) const
                  -
                  -protectedinherited
                  -
                  -

                  Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.

                  - -
                  -

                  The documentation for this class was generated from the following files:
                  • src/axis.h
                  • src/axis.cpp
                  • diff -Nru qcustomplot-1.1.0/documentation/html/classQCPItemBracket.html qcustomplot-1.2.0/documentation/html/classQCPItemBracket.html --- qcustomplot-1.1.0/documentation/html/classQCPItemBracket.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPItemBracket.html 2014-03-14 21:11:27.000000000 +0000 @@ -19,7 +19,6 @@ Public Types | Public Functions | Public Members | -Signals | Protected Types | Protected Functions
                    @@ -57,37 +56,41 @@ void setLength (double length) void setStyle (BracketStyle style) virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const - +- Public Functions inherited from QCPAbstractItemQCPAbstractItem (QCustomPlot *parentPlot) + bool clipToAxisRect () const - + QCPAxisRectclipAxisRect () const - + bool selectable () const - + bool selected () const -void setClipToAxisRect (bool clip) -void setClipAxisRect (QCPAxisRect *rect) -void setSelectable (bool selectable) -void setSelected (bool selected) -QList< QCPItemPosition * > positions () const -QList< QCPItemAnchor * > anchors () const -QCPItemPositionposition (const QString &name) const -QCPItemAnchoranchor (const QString &name) const -bool hasAnchor (const QString &name) const - +void setClipToAxisRect (bool clip) +void setClipAxisRect (QCPAxisRect *rect) +Q_SLOT void setSelectable (bool selectable) +Q_SLOT void setSelected (bool selected) +QList< QCPItemPosition * > positions () const +QList< QCPItemAnchor * > anchors () const +QCPItemPositionposition (const QString &name) const +QCPItemAnchoranchor (const QString &name) const +bool hasAnchor (const QString &name) const +- Public Functions inherited from QCPLayerableQCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0) + bool visible () const - + QCustomPlotparentPlot () const -QCPLayerableparentLayerable () const - +QCPLayerableparentLayerable () const + QCPLayerlayer () const - + bool antialiased () const -void setVisible (bool on) -bool setLayer (QCPLayer *layer) -bool setLayer (const QString &layerName) -void setAntialiased (bool enabled) -bool realVisibility () const +void setVisible (bool on) +Q_SLOT bool setLayer (QCPLayer *layer) +bool setLayer (const QString &layerName) +void setAntialiased (bool enabled) +bool realVisibility () const @@ -98,10 +101,6 @@

                    Public Members

                    QCPItemAnchor *const center
                    - - -

                    -Signals

                    void selectionChanged (bool selected)
                    @@ -111,20 +110,29 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + +

                    Protected Types

                    enum  AnchorIndex
                    virtual void draw (QCPPainter *painter)
                    virtual QPointF anchorPixelPoint (int anchorId) const
                    QPen mainPen () const
                    virtual QCP::Interaction selectionCategory () const
                    virtual QRect clipRect () const
                    virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
                    virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                    virtual void deselectEvent (bool *selectionStateChanged)
                    double distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const
                    double rectSelectTest (const QRectF &rect, const QPointF &pos, bool filledRect) const
                    QCPItemPositioncreatePosition (const QString &name)
                    QCPItemAnchorcreateAnchor (const QString &name, int anchorId)
                    virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                    void initializeParentPlot (QCustomPlot *parentPlot)
                    void setParentLayerable (QCPLayerable *parentLayerable)
                    bool moveToLayer (QCPLayer *layer, bool prepend)
                    void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                    - Protected Functions inherited from QCPAbstractItem
                    virtual QCP::Interaction selectionCategory () const
                    virtual QRect clipRect () const
                    virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
                    virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                    virtual void deselectEvent (bool *selectionStateChanged)
                    double distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const
                    double rectSelectTest (const QRectF &rect, const QPointF &pos, bool filledRect) const
                    QCPItemPositioncreatePosition (const QString &name)
                    QCPItemAnchorcreateAnchor (const QString &name, int anchorId)
                    - Protected Functions inherited from QCPLayerable
                    virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                    void initializeParentPlot (QCustomPlot *parentPlot)
                    void setParentLayerable (QCPLayerable *parentLayerable)
                    bool moveToLayer (QCPLayer *layer, bool prepend)
                    void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                    + + + +

                    +Additional Inherited Members

                    - Signals inherited from QCPAbstractItem
                    void selectionChanged (bool selected)
                    +void selectableChanged (bool selectable)

                    Detailed Description

                    A bracket for referencing/highlighting certain parts in the plot.

                    @@ -393,911 +401,6 @@
                    - -
                    -
                    - - - - - -
                    - - - - - - - - -
                    void QCPAbstractItem::setClipToAxisRect (bool clip)
                    -
                    -inherited
                    -
                    -

                    Sets whether the item shall be clipped to an axis rect or whether it shall be visible on the entire QCustomPlot. The axis rect can be set with setClipAxisRect.

                    -
                    See Also
                    setClipAxisRect
                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - - -
                    void QCPAbstractItem::setClipAxisRect (QCPAxisRectrect)
                    -
                    -inherited
                    -
                    -

                    Sets the clip axis rect. It defines the rect that will be used to clip the item when setClipToAxisRect is set to true.

                    -
                    See Also
                    setClipToAxisRect
                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - - -
                    void QCPAbstractItem::setSelectable (bool selectable)
                    -
                    -inherited
                    -
                    -

                    Sets whether the user can (de-)select this item by clicking on the QCustomPlot surface. (When QCustomPlot::setInteractions contains QCustomPlot::iSelectItems.)

                    -

                    However, even when selectable was set to false, it is possible to set the selection manually, by calling setSelected.

                    -
                    See Also
                    QCustomPlot::setInteractions, setSelected
                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - - -
                    void QCPAbstractItem::setSelected (bool selected)
                    -
                    -inherited
                    -
                    -

                    Sets whether this item is selected or not. When selected, it might use a different visual appearance (e.g. pen and brush), this depends on the specific item though.

                    -

                    The entire selection mechanism for items is handled automatically when QCustomPlot::setInteractions contains QCustomPlot::iSelectItems. You only need to call this function when you wish to change the selection state manually.

                    -

                    This function can change the selection state even when setSelectable was set to false.

                    -

                    emits the selectionChanged signal when selected is different from the previous selection state.

                    -
                    See Also
                    setSelectable, selectTest
                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - -
                    QList< QCPItemPosition * > QCPAbstractItem::positions () const
                    -
                    -inlineinherited
                    -
                    -

                    Returns all positions of the item in a list.

                    -
                    See Also
                    anchors, position
                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - -
                    QList< QCPItemAnchor * > QCPAbstractItem::anchors () const
                    -
                    -inlineinherited
                    -
                    -

                    Returns all anchors of the item in a list. Note that since a position (QCPItemPosition) is always also an anchor, the list will also contain the positions of this item.

                    -
                    See Also
                    positions, anchor
                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - - -
                    QCPItemPosition * QCPAbstractItem::position (const QString & name) const
                    -
                    -inherited
                    -
                    -

                    Returns the QCPItemPosition with the specified name. If this item doesn't have a position by that name, returns 0.

                    -

                    This function provides an alternative way to access item positions. Normally, you access positions direcly by their member pointers (which typically have the same variable name as name).

                    -
                    See Also
                    positions, anchor
                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - - -
                    QCPItemAnchor * QCPAbstractItem::anchor (const QString & name) const
                    -
                    -inherited
                    -
                    -

                    Returns the QCPItemAnchor with the specified name. If this item doesn't have an anchor by that name, returns 0.

                    -

                    This function provides an alternative way to access item anchors. Normally, you access anchors direcly by their member pointers (which typically have the same variable name as name).

                    -
                    See Also
                    anchors, position
                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - - -
                    bool QCPAbstractItem::hasAnchor (const QString & name) const
                    -
                    -inherited
                    -
                    -

                    Returns whether this item has an anchor with the specified name.

                    -

                    Note that you can check for positions with this function, too. This is because every position is also an anchor (QCPItemPosition inherits from QCPItemAnchor).

                    -
                    See Also
                    anchor, position
                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - - -
                    void QCPAbstractItem::selectionChanged (bool selected)
                    -
                    -signalinherited
                    -
                    -

                    This signal is emitted when the selection state of this item has changed, either by user interaction or by a direct call to setSelected.

                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - -
                    QCP::Interaction QCPAbstractItem::selectionCategory () const
                    -
                    -protectedvirtualinherited
                    -
                    -

                    Returns the selection category this layerable shall belong to. The selection category is used in conjunction with QCustomPlot::setInteractions to control which objects are selectable and which aren't.

                    -

                    Subclasses that don't fit any of the normal QCP::Interaction values can use QCP::iSelectOther. This is what the default implementation returns.

                    -
                    See Also
                    QCustomPlot::setInteractions
                    - -

                    Reimplemented from QCPLayerable.

                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - -
                    QRect QCPAbstractItem::clipRect () const
                    -
                    -protectedvirtualinherited
                    -
                    -

                    Returns the rect the visual representation of this item is clipped to. This depends on the current setting of setClipToAxisRect as well as the axis rect set with setClipAxisRect.

                    -

                    If the item is not clipped to an axis rect, the QCustomPlot::viewport rect is returned.

                    -
                    See Also
                    draw
                    - -

                    Reimplemented from QCPLayerable.

                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - - -
                    void QCPAbstractItem::applyDefaultAntialiasingHint (QCPPainterpainter) const
                    -
                    -protectedvirtualinherited
                    -
                    -

                    A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing item lines.

                    -

                    This is the antialiasing state the painter passed to the draw method is in by default.

                    -

                    This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                    -
                    See Also
                    setAntialiased
                    - -

                    Implements QCPLayerable.

                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                    void QCPAbstractItem::selectEvent (QMouseEvent * event,
                    bool additive,
                    const QVariant & details,
                    bool * selectionStateChanged 
                    )
                    -
                    -protectedvirtualinherited
                    -
                    -

                    This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

                    -

                    event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

                    -

                    Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

                    -

                    selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

                    -
                    See Also
                    selectTest, deselectEvent
                    - -

                    Reimplemented from QCPLayerable.

                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - - -
                    void QCPAbstractItem::deselectEvent (bool * selectionStateChanged)
                    -
                    -protectedvirtualinherited
                    -
                    -

                    This event is called when the layerable shall be deselected, either as consequence of a user interaction or a call to QCustomPlot::deselectAll. Subclasses should react to it by unsetting their selection appropriately.

                    -

                    just as in selectEvent, the output parameter selectionStateChanged (if non-null), must return true or false when the selection state of this layerable has changed or not changed, respectively.

                    -
                    See Also
                    selectTest, selectEvent
                    - -

                    Reimplemented from QCPLayerable.

                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - - - - - - - - - - - - - - - - - - -
                    double QCPAbstractItem::distSqrToLine (const QPointF & start,
                    const QPointF & end,
                    const QPointF & point 
                    ) const
                    -
                    -protectedinherited
                    -
                    -

                    Finds the shortest squared distance of point to the line segment defined by start and end.

                    -

                    This function may be used to help with the implementation of the selectTest function for specific items.

                    -
                    Note
                    This function is identical to QCPAbstractPlottable::distSqrToLine
                    -
                    See Also
                    rectSelectTest
                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - - - - - - - - - - - - - - - - - - -
                    double QCPAbstractItem::rectSelectTest (const QRectF & rect,
                    const QPointF & pos,
                    bool filledRect 
                    ) const
                    -
                    -protectedinherited
                    -
                    -

                    A convenience function which returns the selectTest value for a specified rect and a specified click position pos. filledRect defines whether a click inside the rect should also be considered a hit or whether only the rect border is sensitive to hits.

                    -

                    This function may be used to help with the implementation of the selectTest function for specific items.

                    -

                    For example, if your item consists of four rects, call this function four times, once for each rect, in your selectTest reimplementation. Finally, return the minimum of all four returned values which were greater or equal to zero. (Because this function may return -1.0 when pos doesn't hit rect at all). If all calls returned -1.0, return -1.0, too, because your item wasn't hit.

                    -
                    See Also
                    distSqrToLine
                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - - -
                    QCPItemPosition * QCPAbstractItem::createPosition (const QString & name)
                    -
                    -protectedinherited
                    -
                    -

                    Creates a QCPItemPosition, registers it with this item and returns a pointer to it. The specified name must be a unique string that is usually identical to the variable name of the position member (This is needed to provide the name-based position access to positions).

                    -

                    Don't delete positions created by this function manually, as the item will take care of it.

                    -

                    Use this function in the constructor (initialization list) of the specific item subclass to create each position member. Don't create QCPItemPositions with new yourself, because they won't be registered with the item properly.

                    -
                    See Also
                    createAnchor
                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - - - - - - - - - - - - -
                    QCPItemAnchor * QCPAbstractItem::createAnchor (const QString & name,
                    int anchorId 
                    )
                    -
                    -protectedinherited
                    -
                    -

                    Creates a QCPItemAnchor, registers it with this item and returns a pointer to it. The specified name must be a unique string that is usually identical to the variable name of the anchor member (This is needed to provide the name based anchor access to anchors).

                    -

                    The anchorId must be a number identifying the created anchor. It is recommended to create an enum (e.g. "AnchorIndex") for this on each item that uses anchors. This id is used by the anchor to identify itself when it calls QCPAbstractItem::anchorPixelPoint. That function then returns the correct pixel coordinates for the passed anchor id.

                    -

                    Don't delete anchors created by this function manually, as the item will take care of it.

                    -

                    Use this function in the constructor (initialization list) of the specific item subclass to create each anchor member. Don't create QCPItemAnchors with new yourself, because then they won't be registered with the item properly.

                    -
                    See Also
                    createPosition
                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - -
                    QCPLayerable * QCPLayerable::parentLayerable () const
                    -
                    -inlineinherited
                    -
                    -

                    Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.

                    -

                    Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.

                    -

                    A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.

                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - - -
                    void QCPLayerable::setVisible (bool on)
                    -
                    -inherited
                    -
                    -

                    Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.

                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - - -
                    bool QCPLayerable::setLayer (QCPLayerlayer)
                    -
                    -inherited
                    -
                    -

                    Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.

                    -

                    Returns true on success, i.e. if layer is a valid layer.

                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - - -
                    bool QCPLayerable::setLayer (const QString & layerName)
                    -
                    -inherited
                    -
                    -

                    This is an overloaded function.

                    -

                    Sets the layer of this layerable object by name

                    -

                    Returns true on success, i.e. if layerName is a valid layer name.

                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - - -
                    void QCPLayerable::setAntialiased (bool enabled)
                    -
                    -inherited
                    -
                    -

                    Sets whether this object will be drawn antialiased or not.

                    -

                    Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - -
                    bool QCPLayerable::realVisibility () const
                    -
                    -inherited
                    -
                    -

                    Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.

                    -

                    If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.

                    -

                    If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.

                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - - -
                    void QCPLayerable::parentPlotInitialized (QCustomPlotparentPlot)
                    -
                    -protectedvirtualinherited
                    -
                    -

                    This function is called by initializeParentPlot, to allow subclasses to react on the setting of a parent plot. This is the case when 0 was passed as parent plot in the constructor, and the parent plot is set at a later time.

                    -

                    For example, QCPLayoutElement/QCPLayout hierarchies may be created independently of any QCustomPlot at first. When they are then added to a layout inside the QCustomPlot, the top level element of the hierarchy gets its parent plot initialized with initializeParentPlot. To propagate the parent plot to all the children of the hierarchy, the top level element then uses this function to pass the parent plot on to its child elements.

                    -

                    The default implementation does nothing.

                    -
                    See Also
                    initializeParentPlot
                    - -

                    Reimplemented in QCPLegend, and QCPLayoutElement.

                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - - -
                    void QCPLayerable::initializeParentPlot (QCustomPlotparentPlot)
                    -
                    -protectedinherited
                    -
                    -

                    Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.

                    -

                    Note that, unlike when passing a non-null parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.

                    -

                    Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.

                    -

                    The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).

                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - - -
                    void QCPLayerable::setParentLayerable (QCPLayerableparentLayerable)
                    -
                    -protectedinherited
                    -
                    -

                    Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.

                    -

                    The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.

                    -
                    See Also
                    realVisibility
                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - - - - - - - - - - - - -
                    bool QCPLayerable::moveToLayer (QCPLayerlayer,
                    bool prepend 
                    )
                    -
                    -protectedinherited
                    -
                    -

                    Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.

                    -

                    Returns true on success, i.e. if layer is a valid layer.

                    - -
                    -
                    - -
                    -
                    - - - - - -
                    - - - - - - - - - - - - - - - - - - - - - - - - -
                    void QCPLayerable::applyAntialiasingHint (QCPPainterpainter,
                    bool localAntialiased,
                    QCP::AntialiasedElement overrideElement 
                    ) const
                    -
                    -protectedinherited
                    -
                    -

                    Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.

                    - -
                    -

                    The documentation for this class was generated from the following files:
                    • src/items/item-bracket.h
                    • src/items/item-bracket.cpp
                    • diff -Nru qcustomplot-1.1.0/documentation/html/classQCPItemCurve.html qcustomplot-1.2.0/documentation/html/classQCPItemCurve.html --- qcustomplot-1.1.0/documentation/html/classQCPItemCurve.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPItemCurve.html 2014-03-14 21:11:27.000000000 +0000 @@ -18,7 +18,6 @@
                      QCPItemCurve Class Reference
                      @@ -51,37 +50,41 @@ void setHead (const QCPLineEnding &head) void setTail (const QCPLineEnding &tail) virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const - +- Public Functions inherited from QCPAbstractItemQCPAbstractItem (QCustomPlot *parentPlot) + bool clipToAxisRect () const - + QCPAxisRectclipAxisRect () const - + bool selectable () const - + bool selected () const -void setClipToAxisRect (bool clip) -void setClipAxisRect (QCPAxisRect *rect) -void setSelectable (bool selectable) -void setSelected (bool selected) -QList< QCPItemPosition * > positions () const -QList< QCPItemAnchor * > anchors () const -QCPItemPositionposition (const QString &name) const -QCPItemAnchoranchor (const QString &name) const -bool hasAnchor (const QString &name) const - +void setClipToAxisRect (bool clip) +void setClipAxisRect (QCPAxisRect *rect) +Q_SLOT void setSelectable (bool selectable) +Q_SLOT void setSelected (bool selected) +QList< QCPItemPosition * > positions () const +QList< QCPItemAnchor * > anchors () const +QCPItemPositionposition (const QString &name) const +QCPItemAnchoranchor (const QString &name) const +bool hasAnchor (const QString &name) const +- Public Functions inherited from QCPLayerableQCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0) + bool visible () const - + QCustomPlotparentPlot () const -QCPLayerableparentLayerable () const - +QCPLayerableparentLayerable () const + QCPLayerlayer () const - + bool antialiased () const -void setVisible (bool on) -bool setLayer (QCPLayer *layer) -bool setLayer (const QString &layerName) -void setAntialiased (bool enabled) -bool realVisibility () const +void setVisible (bool on) +Q_SLOT bool setLayer (QCPLayer *layer) +bool setLayer (const QString &layerName) +void setAntialiased (bool enabled) +bool realVisibility () const @@ -94,29 +97,34 @@

                      Public Members

                      QCPItemPosition *const end
                      - - -

                      -Signals

                      void selectionChanged (bool selected)
                      - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + +

                      Protected Functions

                      virtual void draw (QCPPainter *painter)
                      QPen mainPen () const
                      virtual QCP::Interaction selectionCategory () const
                      virtual QRect clipRect () const
                      virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
                      virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                      virtual void deselectEvent (bool *selectionStateChanged)
                      virtual QPointF anchorPixelPoint (int anchorId) const
                      double distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const
                      double rectSelectTest (const QRectF &rect, const QPointF &pos, bool filledRect) const
                      QCPItemPositioncreatePosition (const QString &name)
                      QCPItemAnchorcreateAnchor (const QString &name, int anchorId)
                      virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                      void initializeParentPlot (QCustomPlot *parentPlot)
                      void setParentLayerable (QCPLayerable *parentLayerable)
                      bool moveToLayer (QCPLayer *layer, bool prepend)
                      void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                      - Protected Functions inherited from QCPAbstractItem
                      virtual QCP::Interaction selectionCategory () const
                      virtual QRect clipRect () const
                      virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
                      virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                      virtual void deselectEvent (bool *selectionStateChanged)
                      virtual QPointF anchorPixelPoint (int anchorId) const
                      double distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const
                      double rectSelectTest (const QRectF &rect, const QPointF &pos, bool filledRect) const
                      QCPItemPositioncreatePosition (const QString &name)
                      QCPItemAnchorcreateAnchor (const QString &name, int anchorId)
                      - Protected Functions inherited from QCPLayerable
                      virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                      void initializeParentPlot (QCustomPlot *parentPlot)
                      void setParentLayerable (QCPLayerable *parentLayerable)
                      bool moveToLayer (QCPLayer *layer, bool prepend)
                      void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                      + + + +

                      +Additional Inherited Members

                      - Signals inherited from QCPAbstractItem
                      void selectionChanged (bool selected)
                      +void selectableChanged (bool selectable)

                      Detailed Description

                      A curved line from one point to another.

                      @@ -325,940 +333,6 @@
                      - -
                      -
                      - - - - - -
                      - - - - - - - - -
                      void QCPAbstractItem::setClipToAxisRect (bool clip)
                      -
                      -inherited
                      -
                      -

                      Sets whether the item shall be clipped to an axis rect or whether it shall be visible on the entire QCustomPlot. The axis rect can be set with setClipAxisRect.

                      -
                      See Also
                      setClipAxisRect
                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - - -
                      void QCPAbstractItem::setClipAxisRect (QCPAxisRectrect)
                      -
                      -inherited
                      -
                      -

                      Sets the clip axis rect. It defines the rect that will be used to clip the item when setClipToAxisRect is set to true.

                      -
                      See Also
                      setClipToAxisRect
                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - - -
                      void QCPAbstractItem::setSelectable (bool selectable)
                      -
                      -inherited
                      -
                      -

                      Sets whether the user can (de-)select this item by clicking on the QCustomPlot surface. (When QCustomPlot::setInteractions contains QCustomPlot::iSelectItems.)

                      -

                      However, even when selectable was set to false, it is possible to set the selection manually, by calling setSelected.

                      -
                      See Also
                      QCustomPlot::setInteractions, setSelected
                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - - -
                      void QCPAbstractItem::setSelected (bool selected)
                      -
                      -inherited
                      -
                      -

                      Sets whether this item is selected or not. When selected, it might use a different visual appearance (e.g. pen and brush), this depends on the specific item though.

                      -

                      The entire selection mechanism for items is handled automatically when QCustomPlot::setInteractions contains QCustomPlot::iSelectItems. You only need to call this function when you wish to change the selection state manually.

                      -

                      This function can change the selection state even when setSelectable was set to false.

                      -

                      emits the selectionChanged signal when selected is different from the previous selection state.

                      -
                      See Also
                      setSelectable, selectTest
                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - -
                      QList< QCPItemPosition * > QCPAbstractItem::positions () const
                      -
                      -inlineinherited
                      -
                      -

                      Returns all positions of the item in a list.

                      -
                      See Also
                      anchors, position
                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - -
                      QList< QCPItemAnchor * > QCPAbstractItem::anchors () const
                      -
                      -inlineinherited
                      -
                      -

                      Returns all anchors of the item in a list. Note that since a position (QCPItemPosition) is always also an anchor, the list will also contain the positions of this item.

                      -
                      See Also
                      positions, anchor
                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - - -
                      QCPItemPosition * QCPAbstractItem::position (const QString & name) const
                      -
                      -inherited
                      -
                      -

                      Returns the QCPItemPosition with the specified name. If this item doesn't have a position by that name, returns 0.

                      -

                      This function provides an alternative way to access item positions. Normally, you access positions direcly by their member pointers (which typically have the same variable name as name).

                      -
                      See Also
                      positions, anchor
                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - - -
                      QCPItemAnchor * QCPAbstractItem::anchor (const QString & name) const
                      -
                      -inherited
                      -
                      -

                      Returns the QCPItemAnchor with the specified name. If this item doesn't have an anchor by that name, returns 0.

                      -

                      This function provides an alternative way to access item anchors. Normally, you access anchors direcly by their member pointers (which typically have the same variable name as name).

                      -
                      See Also
                      anchors, position
                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - - -
                      bool QCPAbstractItem::hasAnchor (const QString & name) const
                      -
                      -inherited
                      -
                      -

                      Returns whether this item has an anchor with the specified name.

                      -

                      Note that you can check for positions with this function, too. This is because every position is also an anchor (QCPItemPosition inherits from QCPItemAnchor).

                      -
                      See Also
                      anchor, position
                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - - -
                      void QCPAbstractItem::selectionChanged (bool selected)
                      -
                      -signalinherited
                      -
                      -

                      This signal is emitted when the selection state of this item has changed, either by user interaction or by a direct call to setSelected.

                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - -
                      QCP::Interaction QCPAbstractItem::selectionCategory () const
                      -
                      -protectedvirtualinherited
                      -
                      -

                      Returns the selection category this layerable shall belong to. The selection category is used in conjunction with QCustomPlot::setInteractions to control which objects are selectable and which aren't.

                      -

                      Subclasses that don't fit any of the normal QCP::Interaction values can use QCP::iSelectOther. This is what the default implementation returns.

                      -
                      See Also
                      QCustomPlot::setInteractions
                      - -

                      Reimplemented from QCPLayerable.

                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - -
                      QRect QCPAbstractItem::clipRect () const
                      -
                      -protectedvirtualinherited
                      -
                      -

                      Returns the rect the visual representation of this item is clipped to. This depends on the current setting of setClipToAxisRect as well as the axis rect set with setClipAxisRect.

                      -

                      If the item is not clipped to an axis rect, the QCustomPlot::viewport rect is returned.

                      -
                      See Also
                      draw
                      - -

                      Reimplemented from QCPLayerable.

                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - - -
                      void QCPAbstractItem::applyDefaultAntialiasingHint (QCPPainterpainter) const
                      -
                      -protectedvirtualinherited
                      -
                      -

                      A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing item lines.

                      -

                      This is the antialiasing state the painter passed to the draw method is in by default.

                      -

                      This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                      -
                      See Also
                      setAntialiased
                      - -

                      Implements QCPLayerable.

                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                      void QCPAbstractItem::selectEvent (QMouseEvent * event,
                      bool additive,
                      const QVariant & details,
                      bool * selectionStateChanged 
                      )
                      -
                      -protectedvirtualinherited
                      -
                      -

                      This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

                      -

                      event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

                      -

                      Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

                      -

                      selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

                      -
                      See Also
                      selectTest, deselectEvent
                      - -

                      Reimplemented from QCPLayerable.

                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - - -
                      void QCPAbstractItem::deselectEvent (bool * selectionStateChanged)
                      -
                      -protectedvirtualinherited
                      -
                      -

                      This event is called when the layerable shall be deselected, either as consequence of a user interaction or a call to QCustomPlot::deselectAll. Subclasses should react to it by unsetting their selection appropriately.

                      -

                      just as in selectEvent, the output parameter selectionStateChanged (if non-null), must return true or false when the selection state of this layerable has changed or not changed, respectively.

                      -
                      See Also
                      selectTest, selectEvent
                      - -

                      Reimplemented from QCPLayerable.

                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - - -
                      QPointF QCPAbstractItem::anchorPixelPoint (int anchorId) const
                      -
                      -protectedvirtualinherited
                      -
                      -

                      Returns the pixel position of the anchor with Id anchorId. This function must be reimplemented in item subclasses if they want to provide anchors (QCPItemAnchor).

                      -

                      For example, if the item has two anchors with id 0 and 1, this function takes one of these anchor ids and returns the respective pixel points of the specified anchor.

                      -
                      See Also
                      createAnchor
                      - -

                      Reimplemented in QCPItemText, QCPItemPixmap, QCPItemEllipse, QCPItemBracket, and QCPItemRect.

                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - - - - - - - - - - - - - - - - - - -
                      double QCPAbstractItem::distSqrToLine (const QPointF & start,
                      const QPointF & end,
                      const QPointF & point 
                      ) const
                      -
                      -protectedinherited
                      -
                      -

                      Finds the shortest squared distance of point to the line segment defined by start and end.

                      -

                      This function may be used to help with the implementation of the selectTest function for specific items.

                      -
                      Note
                      This function is identical to QCPAbstractPlottable::distSqrToLine
                      -
                      See Also
                      rectSelectTest
                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - - - - - - - - - - - - - - - - - - -
                      double QCPAbstractItem::rectSelectTest (const QRectF & rect,
                      const QPointF & pos,
                      bool filledRect 
                      ) const
                      -
                      -protectedinherited
                      -
                      -

                      A convenience function which returns the selectTest value for a specified rect and a specified click position pos. filledRect defines whether a click inside the rect should also be considered a hit or whether only the rect border is sensitive to hits.

                      -

                      This function may be used to help with the implementation of the selectTest function for specific items.

                      -

                      For example, if your item consists of four rects, call this function four times, once for each rect, in your selectTest reimplementation. Finally, return the minimum of all four returned values which were greater or equal to zero. (Because this function may return -1.0 when pos doesn't hit rect at all). If all calls returned -1.0, return -1.0, too, because your item wasn't hit.

                      -
                      See Also
                      distSqrToLine
                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - - -
                      QCPItemPosition * QCPAbstractItem::createPosition (const QString & name)
                      -
                      -protectedinherited
                      -
                      -

                      Creates a QCPItemPosition, registers it with this item and returns a pointer to it. The specified name must be a unique string that is usually identical to the variable name of the position member (This is needed to provide the name-based position access to positions).

                      -

                      Don't delete positions created by this function manually, as the item will take care of it.

                      -

                      Use this function in the constructor (initialization list) of the specific item subclass to create each position member. Don't create QCPItemPositions with new yourself, because they won't be registered with the item properly.

                      -
                      See Also
                      createAnchor
                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - - - - - - - - - - - - -
                      QCPItemAnchor * QCPAbstractItem::createAnchor (const QString & name,
                      int anchorId 
                      )
                      -
                      -protectedinherited
                      -
                      -

                      Creates a QCPItemAnchor, registers it with this item and returns a pointer to it. The specified name must be a unique string that is usually identical to the variable name of the anchor member (This is needed to provide the name based anchor access to anchors).

                      -

                      The anchorId must be a number identifying the created anchor. It is recommended to create an enum (e.g. "AnchorIndex") for this on each item that uses anchors. This id is used by the anchor to identify itself when it calls QCPAbstractItem::anchorPixelPoint. That function then returns the correct pixel coordinates for the passed anchor id.

                      -

                      Don't delete anchors created by this function manually, as the item will take care of it.

                      -

                      Use this function in the constructor (initialization list) of the specific item subclass to create each anchor member. Don't create QCPItemAnchors with new yourself, because then they won't be registered with the item properly.

                      -
                      See Also
                      createPosition
                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - -
                      QCPLayerable * QCPLayerable::parentLayerable () const
                      -
                      -inlineinherited
                      -
                      -

                      Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.

                      -

                      Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.

                      -

                      A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.

                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - - -
                      void QCPLayerable::setVisible (bool on)
                      -
                      -inherited
                      -
                      -

                      Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.

                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - - -
                      bool QCPLayerable::setLayer (QCPLayerlayer)
                      -
                      -inherited
                      -
                      -

                      Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.

                      -

                      Returns true on success, i.e. if layer is a valid layer.

                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - - -
                      bool QCPLayerable::setLayer (const QString & layerName)
                      -
                      -inherited
                      -
                      -

                      This is an overloaded function.

                      -

                      Sets the layer of this layerable object by name

                      -

                      Returns true on success, i.e. if layerName is a valid layer name.

                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - - -
                      void QCPLayerable::setAntialiased (bool enabled)
                      -
                      -inherited
                      -
                      -

                      Sets whether this object will be drawn antialiased or not.

                      -

                      Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - -
                      bool QCPLayerable::realVisibility () const
                      -
                      -inherited
                      -
                      -

                      Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.

                      -

                      If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.

                      -

                      If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.

                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - - -
                      void QCPLayerable::parentPlotInitialized (QCustomPlotparentPlot)
                      -
                      -protectedvirtualinherited
                      -
                      -

                      This function is called by initializeParentPlot, to allow subclasses to react on the setting of a parent plot. This is the case when 0 was passed as parent plot in the constructor, and the parent plot is set at a later time.

                      -

                      For example, QCPLayoutElement/QCPLayout hierarchies may be created independently of any QCustomPlot at first. When they are then added to a layout inside the QCustomPlot, the top level element of the hierarchy gets its parent plot initialized with initializeParentPlot. To propagate the parent plot to all the children of the hierarchy, the top level element then uses this function to pass the parent plot on to its child elements.

                      -

                      The default implementation does nothing.

                      -
                      See Also
                      initializeParentPlot
                      - -

                      Reimplemented in QCPLegend, and QCPLayoutElement.

                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - - -
                      void QCPLayerable::initializeParentPlot (QCustomPlotparentPlot)
                      -
                      -protectedinherited
                      -
                      -

                      Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.

                      -

                      Note that, unlike when passing a non-null parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.

                      -

                      Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.

                      -

                      The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).

                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - - -
                      void QCPLayerable::setParentLayerable (QCPLayerableparentLayerable)
                      -
                      -protectedinherited
                      -
                      -

                      Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.

                      -

                      The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.

                      -
                      See Also
                      realVisibility
                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - - - - - - - - - - - - -
                      bool QCPLayerable::moveToLayer (QCPLayerlayer,
                      bool prepend 
                      )
                      -
                      -protectedinherited
                      -
                      -

                      Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.

                      -

                      Returns true on success, i.e. if layer is a valid layer.

                      - -
                      -
                      - -
                      -
                      - - - - - -
                      - - - - - - - - - - - - - - - - - - - - - - - - -
                      void QCPLayerable::applyAntialiasingHint (QCPPainterpainter,
                      bool localAntialiased,
                      QCP::AntialiasedElement overrideElement 
                      ) const
                      -
                      -protectedinherited
                      -
                      -

                      Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.

                      - -
                      -

                      The documentation for this class was generated from the following files:
                      • src/items/item-curve.h
                      • src/items/item-curve.cpp
                      • diff -Nru qcustomplot-1.1.0/documentation/html/classQCPItemEllipse.html qcustomplot-1.2.0/documentation/html/classQCPItemEllipse.html --- qcustomplot-1.1.0/documentation/html/classQCPItemEllipse.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPItemEllipse.html 2014-03-14 21:11:27.000000000 +0000 @@ -18,7 +18,6 @@
                        @@ -52,37 +51,41 @@ void setBrush (const QBrush &brush) void setSelectedBrush (const QBrush &brush) virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const - +- Public Functions inherited from QCPAbstractItemQCPAbstractItem (QCustomPlot *parentPlot) + bool clipToAxisRect () const - + QCPAxisRectclipAxisRect () const - + bool selectable () const - + bool selected () const -void setClipToAxisRect (bool clip) -void setClipAxisRect (QCPAxisRect *rect) -void setSelectable (bool selectable) -void setSelected (bool selected) -QList< QCPItemPosition * > positions () const -QList< QCPItemAnchor * > anchors () const -QCPItemPositionposition (const QString &name) const -QCPItemAnchoranchor (const QString &name) const -bool hasAnchor (const QString &name) const - +void setClipToAxisRect (bool clip) +void setClipAxisRect (QCPAxisRect *rect) +Q_SLOT void setSelectable (bool selectable) +Q_SLOT void setSelected (bool selected) +QList< QCPItemPosition * > positions () const +QList< QCPItemAnchor * > anchors () const +QCPItemPositionposition (const QString &name) const +QCPItemAnchoranchor (const QString &name) const +bool hasAnchor (const QString &name) const +- Public Functions inherited from QCPLayerableQCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0) + bool visible () const - + QCustomPlotparentPlot () const -QCPLayerableparentLayerable () const - +QCPLayerableparentLayerable () const + QCPLayerlayer () const - + bool antialiased () const -void setVisible (bool on) -bool setLayer (QCPLayer *layer) -bool setLayer (const QString &layerName) -void setAntialiased (bool enabled) -bool realVisibility () const +void setVisible (bool on) +Q_SLOT bool setLayer (QCPLayer *layer) +bool setLayer (const QString &layerName) +void setAntialiased (bool enabled) +bool realVisibility () const @@ -109,10 +112,6 @@

                        Public Members

                        QCPItemAnchor *const center
                        - - -

                        -Signals

                        void selectionChanged (bool selected)
                        @@ -123,20 +122,29 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + +

                        Protected Types

                        enum  AnchorIndex
                        virtual QPointF anchorPixelPoint (int anchorId) const
                        QPen mainPen () const
                        QBrush mainBrush () const
                        virtual QCP::Interaction selectionCategory () const
                        virtual QRect clipRect () const
                        virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
                        virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                        virtual void deselectEvent (bool *selectionStateChanged)
                        double distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const
                        double rectSelectTest (const QRectF &rect, const QPointF &pos, bool filledRect) const
                        QCPItemPositioncreatePosition (const QString &name)
                        QCPItemAnchorcreateAnchor (const QString &name, int anchorId)
                        virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                        void initializeParentPlot (QCustomPlot *parentPlot)
                        void setParentLayerable (QCPLayerable *parentLayerable)
                        bool moveToLayer (QCPLayer *layer, bool prepend)
                        void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                        - Protected Functions inherited from QCPAbstractItem
                        virtual QCP::Interaction selectionCategory () const
                        virtual QRect clipRect () const
                        virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
                        virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                        virtual void deselectEvent (bool *selectionStateChanged)
                        double distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const
                        double rectSelectTest (const QRectF &rect, const QPointF &pos, bool filledRect) const
                        QCPItemPositioncreatePosition (const QString &name)
                        QCPItemAnchorcreateAnchor (const QString &name, int anchorId)
                        - Protected Functions inherited from QCPLayerable
                        virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                        void initializeParentPlot (QCustomPlot *parentPlot)
                        void setParentLayerable (QCPLayerable *parentLayerable)
                        bool moveToLayer (QCPLayer *layer, bool prepend)
                        void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                        + + + +

                        +Additional Inherited Members

                        - Signals inherited from QCPAbstractItem
                        void selectionChanged (bool selected)
                        +void selectableChanged (bool selectable)

                        Detailed Description

                        An ellipse.

                        @@ -392,911 +400,6 @@
                        - -
                        -
                        - - - - - -
                        - - - - - - - - -
                        void QCPAbstractItem::setClipToAxisRect (bool clip)
                        -
                        -inherited
                        -
                        -

                        Sets whether the item shall be clipped to an axis rect or whether it shall be visible on the entire QCustomPlot. The axis rect can be set with setClipAxisRect.

                        -
                        See Also
                        setClipAxisRect
                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - - -
                        void QCPAbstractItem::setClipAxisRect (QCPAxisRectrect)
                        -
                        -inherited
                        -
                        -

                        Sets the clip axis rect. It defines the rect that will be used to clip the item when setClipToAxisRect is set to true.

                        -
                        See Also
                        setClipToAxisRect
                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - - -
                        void QCPAbstractItem::setSelectable (bool selectable)
                        -
                        -inherited
                        -
                        -

                        Sets whether the user can (de-)select this item by clicking on the QCustomPlot surface. (When QCustomPlot::setInteractions contains QCustomPlot::iSelectItems.)

                        -

                        However, even when selectable was set to false, it is possible to set the selection manually, by calling setSelected.

                        -
                        See Also
                        QCustomPlot::setInteractions, setSelected
                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - - -
                        void QCPAbstractItem::setSelected (bool selected)
                        -
                        -inherited
                        -
                        -

                        Sets whether this item is selected or not. When selected, it might use a different visual appearance (e.g. pen and brush), this depends on the specific item though.

                        -

                        The entire selection mechanism for items is handled automatically when QCustomPlot::setInteractions contains QCustomPlot::iSelectItems. You only need to call this function when you wish to change the selection state manually.

                        -

                        This function can change the selection state even when setSelectable was set to false.

                        -

                        emits the selectionChanged signal when selected is different from the previous selection state.

                        -
                        See Also
                        setSelectable, selectTest
                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - -
                        QList< QCPItemPosition * > QCPAbstractItem::positions () const
                        -
                        -inlineinherited
                        -
                        -

                        Returns all positions of the item in a list.

                        -
                        See Also
                        anchors, position
                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - -
                        QList< QCPItemAnchor * > QCPAbstractItem::anchors () const
                        -
                        -inlineinherited
                        -
                        -

                        Returns all anchors of the item in a list. Note that since a position (QCPItemPosition) is always also an anchor, the list will also contain the positions of this item.

                        -
                        See Also
                        positions, anchor
                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - - -
                        QCPItemPosition * QCPAbstractItem::position (const QString & name) const
                        -
                        -inherited
                        -
                        -

                        Returns the QCPItemPosition with the specified name. If this item doesn't have a position by that name, returns 0.

                        -

                        This function provides an alternative way to access item positions. Normally, you access positions direcly by their member pointers (which typically have the same variable name as name).

                        -
                        See Also
                        positions, anchor
                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - - -
                        QCPItemAnchor * QCPAbstractItem::anchor (const QString & name) const
                        -
                        -inherited
                        -
                        -

                        Returns the QCPItemAnchor with the specified name. If this item doesn't have an anchor by that name, returns 0.

                        -

                        This function provides an alternative way to access item anchors. Normally, you access anchors direcly by their member pointers (which typically have the same variable name as name).

                        -
                        See Also
                        anchors, position
                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - - -
                        bool QCPAbstractItem::hasAnchor (const QString & name) const
                        -
                        -inherited
                        -
                        -

                        Returns whether this item has an anchor with the specified name.

                        -

                        Note that you can check for positions with this function, too. This is because every position is also an anchor (QCPItemPosition inherits from QCPItemAnchor).

                        -
                        See Also
                        anchor, position
                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - - -
                        void QCPAbstractItem::selectionChanged (bool selected)
                        -
                        -signalinherited
                        -
                        -

                        This signal is emitted when the selection state of this item has changed, either by user interaction or by a direct call to setSelected.

                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - -
                        QCP::Interaction QCPAbstractItem::selectionCategory () const
                        -
                        -protectedvirtualinherited
                        -
                        -

                        Returns the selection category this layerable shall belong to. The selection category is used in conjunction with QCustomPlot::setInteractions to control which objects are selectable and which aren't.

                        -

                        Subclasses that don't fit any of the normal QCP::Interaction values can use QCP::iSelectOther. This is what the default implementation returns.

                        -
                        See Also
                        QCustomPlot::setInteractions
                        - -

                        Reimplemented from QCPLayerable.

                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - -
                        QRect QCPAbstractItem::clipRect () const
                        -
                        -protectedvirtualinherited
                        -
                        -

                        Returns the rect the visual representation of this item is clipped to. This depends on the current setting of setClipToAxisRect as well as the axis rect set with setClipAxisRect.

                        -

                        If the item is not clipped to an axis rect, the QCustomPlot::viewport rect is returned.

                        -
                        See Also
                        draw
                        - -

                        Reimplemented from QCPLayerable.

                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - - -
                        void QCPAbstractItem::applyDefaultAntialiasingHint (QCPPainterpainter) const
                        -
                        -protectedvirtualinherited
                        -
                        -

                        A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing item lines.

                        -

                        This is the antialiasing state the painter passed to the draw method is in by default.

                        -

                        This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                        -
                        See Also
                        setAntialiased
                        - -

                        Implements QCPLayerable.

                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                        void QCPAbstractItem::selectEvent (QMouseEvent * event,
                        bool additive,
                        const QVariant & details,
                        bool * selectionStateChanged 
                        )
                        -
                        -protectedvirtualinherited
                        -
                        -

                        This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

                        -

                        event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

                        -

                        Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

                        -

                        selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

                        -
                        See Also
                        selectTest, deselectEvent
                        - -

                        Reimplemented from QCPLayerable.

                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - - -
                        void QCPAbstractItem::deselectEvent (bool * selectionStateChanged)
                        -
                        -protectedvirtualinherited
                        -
                        -

                        This event is called when the layerable shall be deselected, either as consequence of a user interaction or a call to QCustomPlot::deselectAll. Subclasses should react to it by unsetting their selection appropriately.

                        -

                        just as in selectEvent, the output parameter selectionStateChanged (if non-null), must return true or false when the selection state of this layerable has changed or not changed, respectively.

                        -
                        See Also
                        selectTest, selectEvent
                        - -

                        Reimplemented from QCPLayerable.

                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - - - - - - - - - - - - - - - - - - -
                        double QCPAbstractItem::distSqrToLine (const QPointF & start,
                        const QPointF & end,
                        const QPointF & point 
                        ) const
                        -
                        -protectedinherited
                        -
                        -

                        Finds the shortest squared distance of point to the line segment defined by start and end.

                        -

                        This function may be used to help with the implementation of the selectTest function for specific items.

                        -
                        Note
                        This function is identical to QCPAbstractPlottable::distSqrToLine
                        -
                        See Also
                        rectSelectTest
                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - - - - - - - - - - - - - - - - - - -
                        double QCPAbstractItem::rectSelectTest (const QRectF & rect,
                        const QPointF & pos,
                        bool filledRect 
                        ) const
                        -
                        -protectedinherited
                        -
                        -

                        A convenience function which returns the selectTest value for a specified rect and a specified click position pos. filledRect defines whether a click inside the rect should also be considered a hit or whether only the rect border is sensitive to hits.

                        -

                        This function may be used to help with the implementation of the selectTest function for specific items.

                        -

                        For example, if your item consists of four rects, call this function four times, once for each rect, in your selectTest reimplementation. Finally, return the minimum of all four returned values which were greater or equal to zero. (Because this function may return -1.0 when pos doesn't hit rect at all). If all calls returned -1.0, return -1.0, too, because your item wasn't hit.

                        -
                        See Also
                        distSqrToLine
                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - - -
                        QCPItemPosition * QCPAbstractItem::createPosition (const QString & name)
                        -
                        -protectedinherited
                        -
                        -

                        Creates a QCPItemPosition, registers it with this item and returns a pointer to it. The specified name must be a unique string that is usually identical to the variable name of the position member (This is needed to provide the name-based position access to positions).

                        -

                        Don't delete positions created by this function manually, as the item will take care of it.

                        -

                        Use this function in the constructor (initialization list) of the specific item subclass to create each position member. Don't create QCPItemPositions with new yourself, because they won't be registered with the item properly.

                        -
                        See Also
                        createAnchor
                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - - - - - - - - - - - - -
                        QCPItemAnchor * QCPAbstractItem::createAnchor (const QString & name,
                        int anchorId 
                        )
                        -
                        -protectedinherited
                        -
                        -

                        Creates a QCPItemAnchor, registers it with this item and returns a pointer to it. The specified name must be a unique string that is usually identical to the variable name of the anchor member (This is needed to provide the name based anchor access to anchors).

                        -

                        The anchorId must be a number identifying the created anchor. It is recommended to create an enum (e.g. "AnchorIndex") for this on each item that uses anchors. This id is used by the anchor to identify itself when it calls QCPAbstractItem::anchorPixelPoint. That function then returns the correct pixel coordinates for the passed anchor id.

                        -

                        Don't delete anchors created by this function manually, as the item will take care of it.

                        -

                        Use this function in the constructor (initialization list) of the specific item subclass to create each anchor member. Don't create QCPItemAnchors with new yourself, because then they won't be registered with the item properly.

                        -
                        See Also
                        createPosition
                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - -
                        QCPLayerable * QCPLayerable::parentLayerable () const
                        -
                        -inlineinherited
                        -
                        -

                        Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.

                        -

                        Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.

                        -

                        A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.

                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - - -
                        void QCPLayerable::setVisible (bool on)
                        -
                        -inherited
                        -
                        -

                        Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.

                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - - -
                        bool QCPLayerable::setLayer (QCPLayerlayer)
                        -
                        -inherited
                        -
                        -

                        Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.

                        -

                        Returns true on success, i.e. if layer is a valid layer.

                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - - -
                        bool QCPLayerable::setLayer (const QString & layerName)
                        -
                        -inherited
                        -
                        -

                        This is an overloaded function.

                        -

                        Sets the layer of this layerable object by name

                        -

                        Returns true on success, i.e. if layerName is a valid layer name.

                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - - -
                        void QCPLayerable::setAntialiased (bool enabled)
                        -
                        -inherited
                        -
                        -

                        Sets whether this object will be drawn antialiased or not.

                        -

                        Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - -
                        bool QCPLayerable::realVisibility () const
                        -
                        -inherited
                        -
                        -

                        Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.

                        -

                        If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.

                        -

                        If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.

                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - - -
                        void QCPLayerable::parentPlotInitialized (QCustomPlotparentPlot)
                        -
                        -protectedvirtualinherited
                        -
                        -

                        This function is called by initializeParentPlot, to allow subclasses to react on the setting of a parent plot. This is the case when 0 was passed as parent plot in the constructor, and the parent plot is set at a later time.

                        -

                        For example, QCPLayoutElement/QCPLayout hierarchies may be created independently of any QCustomPlot at first. When they are then added to a layout inside the QCustomPlot, the top level element of the hierarchy gets its parent plot initialized with initializeParentPlot. To propagate the parent plot to all the children of the hierarchy, the top level element then uses this function to pass the parent plot on to its child elements.

                        -

                        The default implementation does nothing.

                        -
                        See Also
                        initializeParentPlot
                        - -

                        Reimplemented in QCPLegend, and QCPLayoutElement.

                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - - -
                        void QCPLayerable::initializeParentPlot (QCustomPlotparentPlot)
                        -
                        -protectedinherited
                        -
                        -

                        Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.

                        -

                        Note that, unlike when passing a non-null parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.

                        -

                        Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.

                        -

                        The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).

                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - - -
                        void QCPLayerable::setParentLayerable (QCPLayerableparentLayerable)
                        -
                        -protectedinherited
                        -
                        -

                        Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.

                        -

                        The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.

                        -
                        See Also
                        realVisibility
                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - - - - - - - - - - - - -
                        bool QCPLayerable::moveToLayer (QCPLayerlayer,
                        bool prepend 
                        )
                        -
                        -protectedinherited
                        -
                        -

                        Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.

                        -

                        Returns true on success, i.e. if layer is a valid layer.

                        - -
                        -
                        - -
                        -
                        - - - - - -
                        - - - - - - - - - - - - - - - - - - - - - - - - -
                        void QCPLayerable::applyAntialiasingHint (QCPPainterpainter,
                        bool localAntialiased,
                        QCP::AntialiasedElement overrideElement 
                        ) const
                        -
                        -protectedinherited
                        -
                        -

                        Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.

                        - -
                        -

                        The documentation for this class was generated from the following files:
                        • src/items/item-ellipse.h
                        • src/items/item-ellipse.cpp
                        • diff -Nru qcustomplot-1.1.0/documentation/html/classQCPItemLine.html qcustomplot-1.2.0/documentation/html/classQCPItemLine.html --- qcustomplot-1.1.0/documentation/html/classQCPItemLine.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPItemLine.html 2014-03-14 21:11:27.000000000 +0000 @@ -18,7 +18,6 @@
                          QCPItemLine Class Reference
                          @@ -51,37 +50,41 @@ void setHead (const QCPLineEnding &head) void setTail (const QCPLineEnding &tail) virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const - +- Public Functions inherited from QCPAbstractItemQCPAbstractItem (QCustomPlot *parentPlot) + bool clipToAxisRect () const - + QCPAxisRectclipAxisRect () const - + bool selectable () const - + bool selected () const -void setClipToAxisRect (bool clip) -void setClipAxisRect (QCPAxisRect *rect) -void setSelectable (bool selectable) -void setSelected (bool selected) -QList< QCPItemPosition * > positions () const -QList< QCPItemAnchor * > anchors () const -QCPItemPositionposition (const QString &name) const -QCPItemAnchoranchor (const QString &name) const -bool hasAnchor (const QString &name) const - +void setClipToAxisRect (bool clip) +void setClipAxisRect (QCPAxisRect *rect) +Q_SLOT void setSelectable (bool selectable) +Q_SLOT void setSelected (bool selected) +QList< QCPItemPosition * > positions () const +QList< QCPItemAnchor * > anchors () const +QCPItemPositionposition (const QString &name) const +QCPItemAnchoranchor (const QString &name) const +bool hasAnchor (const QString &name) const +- Public Functions inherited from QCPLayerableQCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0) + bool visible () const - + QCustomPlotparentPlot () const -QCPLayerableparentLayerable () const - +QCPLayerableparentLayerable () const + QCPLayerlayer () const - + bool antialiased () const -void setVisible (bool on) -bool setLayer (QCPLayer *layer) -bool setLayer (const QString &layerName) -void setAntialiased (bool enabled) -bool realVisibility () const +void setVisible (bool on) +Q_SLOT bool setLayer (QCPLayer *layer) +bool setLayer (const QString &layerName) +void setAntialiased (bool enabled) +bool realVisibility () const @@ -90,30 +93,35 @@

                          Public Members

                          QCPItemPosition *const end
                          - - -

                          -Signals

                          void selectionChanged (bool selected)
                          - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + +

                          Protected Functions

                          virtual void draw (QCPPainter *painter)
                          QLineF getRectClippedLine (const QVector2D &start, const QVector2D &end, const QRect &rect) const
                          QPen mainPen () const
                          virtual QCP::Interaction selectionCategory () const
                          virtual QRect clipRect () const
                          virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
                          virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                          virtual void deselectEvent (bool *selectionStateChanged)
                          virtual QPointF anchorPixelPoint (int anchorId) const
                          double distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const
                          double rectSelectTest (const QRectF &rect, const QPointF &pos, bool filledRect) const
                          QCPItemPositioncreatePosition (const QString &name)
                          QCPItemAnchorcreateAnchor (const QString &name, int anchorId)
                          virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                          void initializeParentPlot (QCustomPlot *parentPlot)
                          void setParentLayerable (QCPLayerable *parentLayerable)
                          bool moveToLayer (QCPLayer *layer, bool prepend)
                          void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                          - Protected Functions inherited from QCPAbstractItem
                          virtual QCP::Interaction selectionCategory () const
                          virtual QRect clipRect () const
                          virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
                          virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                          virtual void deselectEvent (bool *selectionStateChanged)
                          virtual QPointF anchorPixelPoint (int anchorId) const
                          double distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const
                          double rectSelectTest (const QRectF &rect, const QPointF &pos, bool filledRect) const
                          QCPItemPositioncreatePosition (const QString &name)
                          QCPItemAnchorcreateAnchor (const QString &name, int anchorId)
                          - Protected Functions inherited from QCPLayerable
                          virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                          void initializeParentPlot (QCustomPlot *parentPlot)
                          void setParentLayerable (QCPLayerable *parentLayerable)
                          bool moveToLayer (QCPLayer *layer, bool prepend)
                          void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                          + + + +

                          +Additional Inherited Members

                          - Signals inherited from QCPAbstractItem
                          void selectionChanged (bool selected)
                          +void selectableChanged (bool selectable)

                          Detailed Description

                          A line from one point to another.

                          @@ -363,940 +371,6 @@
                          - -
                          -
                          - - - - - -
                          - - - - - - - - -
                          void QCPAbstractItem::setClipToAxisRect (bool clip)
                          -
                          -inherited
                          -
                          -

                          Sets whether the item shall be clipped to an axis rect or whether it shall be visible on the entire QCustomPlot. The axis rect can be set with setClipAxisRect.

                          -
                          See Also
                          setClipAxisRect
                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - - -
                          void QCPAbstractItem::setClipAxisRect (QCPAxisRectrect)
                          -
                          -inherited
                          -
                          -

                          Sets the clip axis rect. It defines the rect that will be used to clip the item when setClipToAxisRect is set to true.

                          -
                          See Also
                          setClipToAxisRect
                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - - -
                          void QCPAbstractItem::setSelectable (bool selectable)
                          -
                          -inherited
                          -
                          -

                          Sets whether the user can (de-)select this item by clicking on the QCustomPlot surface. (When QCustomPlot::setInteractions contains QCustomPlot::iSelectItems.)

                          -

                          However, even when selectable was set to false, it is possible to set the selection manually, by calling setSelected.

                          -
                          See Also
                          QCustomPlot::setInteractions, setSelected
                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - - -
                          void QCPAbstractItem::setSelected (bool selected)
                          -
                          -inherited
                          -
                          -

                          Sets whether this item is selected or not. When selected, it might use a different visual appearance (e.g. pen and brush), this depends on the specific item though.

                          -

                          The entire selection mechanism for items is handled automatically when QCustomPlot::setInteractions contains QCustomPlot::iSelectItems. You only need to call this function when you wish to change the selection state manually.

                          -

                          This function can change the selection state even when setSelectable was set to false.

                          -

                          emits the selectionChanged signal when selected is different from the previous selection state.

                          -
                          See Also
                          setSelectable, selectTest
                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - -
                          QList< QCPItemPosition * > QCPAbstractItem::positions () const
                          -
                          -inlineinherited
                          -
                          -

                          Returns all positions of the item in a list.

                          -
                          See Also
                          anchors, position
                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - -
                          QList< QCPItemAnchor * > QCPAbstractItem::anchors () const
                          -
                          -inlineinherited
                          -
                          -

                          Returns all anchors of the item in a list. Note that since a position (QCPItemPosition) is always also an anchor, the list will also contain the positions of this item.

                          -
                          See Also
                          positions, anchor
                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - - -
                          QCPItemPosition * QCPAbstractItem::position (const QString & name) const
                          -
                          -inherited
                          -
                          -

                          Returns the QCPItemPosition with the specified name. If this item doesn't have a position by that name, returns 0.

                          -

                          This function provides an alternative way to access item positions. Normally, you access positions direcly by their member pointers (which typically have the same variable name as name).

                          -
                          See Also
                          positions, anchor
                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - - -
                          QCPItemAnchor * QCPAbstractItem::anchor (const QString & name) const
                          -
                          -inherited
                          -
                          -

                          Returns the QCPItemAnchor with the specified name. If this item doesn't have an anchor by that name, returns 0.

                          -

                          This function provides an alternative way to access item anchors. Normally, you access anchors direcly by their member pointers (which typically have the same variable name as name).

                          -
                          See Also
                          anchors, position
                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - - -
                          bool QCPAbstractItem::hasAnchor (const QString & name) const
                          -
                          -inherited
                          -
                          -

                          Returns whether this item has an anchor with the specified name.

                          -

                          Note that you can check for positions with this function, too. This is because every position is also an anchor (QCPItemPosition inherits from QCPItemAnchor).

                          -
                          See Also
                          anchor, position
                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - - -
                          void QCPAbstractItem::selectionChanged (bool selected)
                          -
                          -signalinherited
                          -
                          -

                          This signal is emitted when the selection state of this item has changed, either by user interaction or by a direct call to setSelected.

                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - -
                          QCP::Interaction QCPAbstractItem::selectionCategory () const
                          -
                          -protectedvirtualinherited
                          -
                          -

                          Returns the selection category this layerable shall belong to. The selection category is used in conjunction with QCustomPlot::setInteractions to control which objects are selectable and which aren't.

                          -

                          Subclasses that don't fit any of the normal QCP::Interaction values can use QCP::iSelectOther. This is what the default implementation returns.

                          -
                          See Also
                          QCustomPlot::setInteractions
                          - -

                          Reimplemented from QCPLayerable.

                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - -
                          QRect QCPAbstractItem::clipRect () const
                          -
                          -protectedvirtualinherited
                          -
                          -

                          Returns the rect the visual representation of this item is clipped to. This depends on the current setting of setClipToAxisRect as well as the axis rect set with setClipAxisRect.

                          -

                          If the item is not clipped to an axis rect, the QCustomPlot::viewport rect is returned.

                          -
                          See Also
                          draw
                          - -

                          Reimplemented from QCPLayerable.

                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - - -
                          void QCPAbstractItem::applyDefaultAntialiasingHint (QCPPainterpainter) const
                          -
                          -protectedvirtualinherited
                          -
                          -

                          A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing item lines.

                          -

                          This is the antialiasing state the painter passed to the draw method is in by default.

                          -

                          This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                          -
                          See Also
                          setAntialiased
                          - -

                          Implements QCPLayerable.

                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                          void QCPAbstractItem::selectEvent (QMouseEvent * event,
                          bool additive,
                          const QVariant & details,
                          bool * selectionStateChanged 
                          )
                          -
                          -protectedvirtualinherited
                          -
                          -

                          This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

                          -

                          event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

                          -

                          Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

                          -

                          selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

                          -
                          See Also
                          selectTest, deselectEvent
                          - -

                          Reimplemented from QCPLayerable.

                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - - -
                          void QCPAbstractItem::deselectEvent (bool * selectionStateChanged)
                          -
                          -protectedvirtualinherited
                          -
                          -

                          This event is called when the layerable shall be deselected, either as consequence of a user interaction or a call to QCustomPlot::deselectAll. Subclasses should react to it by unsetting their selection appropriately.

                          -

                          just as in selectEvent, the output parameter selectionStateChanged (if non-null), must return true or false when the selection state of this layerable has changed or not changed, respectively.

                          -
                          See Also
                          selectTest, selectEvent
                          - -

                          Reimplemented from QCPLayerable.

                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - - -
                          QPointF QCPAbstractItem::anchorPixelPoint (int anchorId) const
                          -
                          -protectedvirtualinherited
                          -
                          -

                          Returns the pixel position of the anchor with Id anchorId. This function must be reimplemented in item subclasses if they want to provide anchors (QCPItemAnchor).

                          -

                          For example, if the item has two anchors with id 0 and 1, this function takes one of these anchor ids and returns the respective pixel points of the specified anchor.

                          -
                          See Also
                          createAnchor
                          - -

                          Reimplemented in QCPItemText, QCPItemPixmap, QCPItemEllipse, QCPItemBracket, and QCPItemRect.

                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - - - - - - - - - - - - - - - - - - -
                          double QCPAbstractItem::distSqrToLine (const QPointF & start,
                          const QPointF & end,
                          const QPointF & point 
                          ) const
                          -
                          -protectedinherited
                          -
                          -

                          Finds the shortest squared distance of point to the line segment defined by start and end.

                          -

                          This function may be used to help with the implementation of the selectTest function for specific items.

                          -
                          Note
                          This function is identical to QCPAbstractPlottable::distSqrToLine
                          -
                          See Also
                          rectSelectTest
                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - - - - - - - - - - - - - - - - - - -
                          double QCPAbstractItem::rectSelectTest (const QRectF & rect,
                          const QPointF & pos,
                          bool filledRect 
                          ) const
                          -
                          -protectedinherited
                          -
                          -

                          A convenience function which returns the selectTest value for a specified rect and a specified click position pos. filledRect defines whether a click inside the rect should also be considered a hit or whether only the rect border is sensitive to hits.

                          -

                          This function may be used to help with the implementation of the selectTest function for specific items.

                          -

                          For example, if your item consists of four rects, call this function four times, once for each rect, in your selectTest reimplementation. Finally, return the minimum of all four returned values which were greater or equal to zero. (Because this function may return -1.0 when pos doesn't hit rect at all). If all calls returned -1.0, return -1.0, too, because your item wasn't hit.

                          -
                          See Also
                          distSqrToLine
                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - - -
                          QCPItemPosition * QCPAbstractItem::createPosition (const QString & name)
                          -
                          -protectedinherited
                          -
                          -

                          Creates a QCPItemPosition, registers it with this item and returns a pointer to it. The specified name must be a unique string that is usually identical to the variable name of the position member (This is needed to provide the name-based position access to positions).

                          -

                          Don't delete positions created by this function manually, as the item will take care of it.

                          -

                          Use this function in the constructor (initialization list) of the specific item subclass to create each position member. Don't create QCPItemPositions with new yourself, because they won't be registered with the item properly.

                          -
                          See Also
                          createAnchor
                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - - - - - - - - - - - - -
                          QCPItemAnchor * QCPAbstractItem::createAnchor (const QString & name,
                          int anchorId 
                          )
                          -
                          -protectedinherited
                          -
                          -

                          Creates a QCPItemAnchor, registers it with this item and returns a pointer to it. The specified name must be a unique string that is usually identical to the variable name of the anchor member (This is needed to provide the name based anchor access to anchors).

                          -

                          The anchorId must be a number identifying the created anchor. It is recommended to create an enum (e.g. "AnchorIndex") for this on each item that uses anchors. This id is used by the anchor to identify itself when it calls QCPAbstractItem::anchorPixelPoint. That function then returns the correct pixel coordinates for the passed anchor id.

                          -

                          Don't delete anchors created by this function manually, as the item will take care of it.

                          -

                          Use this function in the constructor (initialization list) of the specific item subclass to create each anchor member. Don't create QCPItemAnchors with new yourself, because then they won't be registered with the item properly.

                          -
                          See Also
                          createPosition
                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - -
                          QCPLayerable * QCPLayerable::parentLayerable () const
                          -
                          -inlineinherited
                          -
                          -

                          Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.

                          -

                          Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.

                          -

                          A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.

                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - - -
                          void QCPLayerable::setVisible (bool on)
                          -
                          -inherited
                          -
                          -

                          Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.

                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - - -
                          bool QCPLayerable::setLayer (QCPLayerlayer)
                          -
                          -inherited
                          -
                          -

                          Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.

                          -

                          Returns true on success, i.e. if layer is a valid layer.

                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - - -
                          bool QCPLayerable::setLayer (const QString & layerName)
                          -
                          -inherited
                          -
                          -

                          This is an overloaded function.

                          -

                          Sets the layer of this layerable object by name

                          -

                          Returns true on success, i.e. if layerName is a valid layer name.

                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - - -
                          void QCPLayerable::setAntialiased (bool enabled)
                          -
                          -inherited
                          -
                          -

                          Sets whether this object will be drawn antialiased or not.

                          -

                          Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - -
                          bool QCPLayerable::realVisibility () const
                          -
                          -inherited
                          -
                          -

                          Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.

                          -

                          If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.

                          -

                          If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.

                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - - -
                          void QCPLayerable::parentPlotInitialized (QCustomPlotparentPlot)
                          -
                          -protectedvirtualinherited
                          -
                          -

                          This function is called by initializeParentPlot, to allow subclasses to react on the setting of a parent plot. This is the case when 0 was passed as parent plot in the constructor, and the parent plot is set at a later time.

                          -

                          For example, QCPLayoutElement/QCPLayout hierarchies may be created independently of any QCustomPlot at first. When they are then added to a layout inside the QCustomPlot, the top level element of the hierarchy gets its parent plot initialized with initializeParentPlot. To propagate the parent plot to all the children of the hierarchy, the top level element then uses this function to pass the parent plot on to its child elements.

                          -

                          The default implementation does nothing.

                          -
                          See Also
                          initializeParentPlot
                          - -

                          Reimplemented in QCPLegend, and QCPLayoutElement.

                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - - -
                          void QCPLayerable::initializeParentPlot (QCustomPlotparentPlot)
                          -
                          -protectedinherited
                          -
                          -

                          Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.

                          -

                          Note that, unlike when passing a non-null parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.

                          -

                          Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.

                          -

                          The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).

                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - - -
                          void QCPLayerable::setParentLayerable (QCPLayerableparentLayerable)
                          -
                          -protectedinherited
                          -
                          -

                          Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.

                          -

                          The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.

                          -
                          See Also
                          realVisibility
                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - - - - - - - - - - - - -
                          bool QCPLayerable::moveToLayer (QCPLayerlayer,
                          bool prepend 
                          )
                          -
                          -protectedinherited
                          -
                          -

                          Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.

                          -

                          Returns true on success, i.e. if layer is a valid layer.

                          - -
                          -
                          - -
                          -
                          - - - - - -
                          - - - - - - - - - - - - - - - - - - - - - - - - -
                          void QCPLayerable::applyAntialiasingHint (QCPPainterpainter,
                          bool localAntialiased,
                          QCP::AntialiasedElement overrideElement 
                          ) const
                          -
                          -protectedinherited
                          -
                          -

                          Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.

                          - -
                          -

                          The documentation for this class was generated from the following files:
                          • src/items/item-line.h
                          • src/items/item-line.cpp
                          • diff -Nru qcustomplot-1.1.0/documentation/html/classQCPItemPixmap.html qcustomplot-1.2.0/documentation/html/classQCPItemPixmap.html --- qcustomplot-1.1.0/documentation/html/classQCPItemPixmap.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPItemPixmap.html 2014-03-14 21:11:27.000000000 +0000 @@ -18,7 +18,6 @@
                            @@ -54,37 +53,41 @@ void setPen (const QPen &pen) void setSelectedPen (const QPen &pen) virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const - +- Public Functions inherited from QCPAbstractItemQCPAbstractItem (QCustomPlot *parentPlot) + bool clipToAxisRect () const - + QCPAxisRectclipAxisRect () const - + bool selectable () const - + bool selected () const -void setClipToAxisRect (bool clip) -void setClipAxisRect (QCPAxisRect *rect) -void setSelectable (bool selectable) -void setSelected (bool selected) -QList< QCPItemPosition * > positions () const -QList< QCPItemAnchor * > anchors () const -QCPItemPositionposition (const QString &name) const -QCPItemAnchoranchor (const QString &name) const -bool hasAnchor (const QString &name) const - +void setClipToAxisRect (bool clip) +void setClipAxisRect (QCPAxisRect *rect) +Q_SLOT void setSelectable (bool selectable) +Q_SLOT void setSelected (bool selected) +QList< QCPItemPosition * > positions () const +QList< QCPItemAnchor * > anchors () const +QCPItemPositionposition (const QString &name) const +QCPItemAnchoranchor (const QString &name) const +bool hasAnchor (const QString &name) const +- Public Functions inherited from QCPLayerableQCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0) + bool visible () const - + QCustomPlotparentPlot () const -QCPLayerableparentLayerable () const - +QCPLayerableparentLayerable () const + QCPLayerlayer () const - + bool antialiased () const -void setVisible (bool on) -bool setLayer (QCPLayer *layer) -bool setLayer (const QString &layerName) -void setAntialiased (bool enabled) -bool realVisibility () const +void setVisible (bool on) +Q_SLOT bool setLayer (QCPLayer *layer) +bool setLayer (const QString &layerName) +void setAntialiased (bool enabled) +bool realVisibility () const @@ -105,10 +108,6 @@

                            Public Members

                            QCPItemAnchor *const left
                            - - -

                            -Signals

                            void selectionChanged (bool selected)
                            @@ -120,20 +119,29 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + +

                            Protected Types

                            enum  AnchorIndex
                            void updateScaledPixmap (QRect finalRect=QRect(), bool flipHorz=false, bool flipVert=false)
                            QRect getFinalRect (bool *flippedHorz=0, bool *flippedVert=0) const
                            QPen mainPen () const
                            virtual QCP::Interaction selectionCategory () const
                            virtual QRect clipRect () const
                            virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
                            virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                            virtual void deselectEvent (bool *selectionStateChanged)
                            double distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const
                            double rectSelectTest (const QRectF &rect, const QPointF &pos, bool filledRect) const
                            QCPItemPositioncreatePosition (const QString &name)
                            QCPItemAnchorcreateAnchor (const QString &name, int anchorId)
                            virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                            void initializeParentPlot (QCustomPlot *parentPlot)
                            void setParentLayerable (QCPLayerable *parentLayerable)
                            bool moveToLayer (QCPLayer *layer, bool prepend)
                            void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                            - Protected Functions inherited from QCPAbstractItem
                            virtual QCP::Interaction selectionCategory () const
                            virtual QRect clipRect () const
                            virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
                            virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                            virtual void deselectEvent (bool *selectionStateChanged)
                            double distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const
                            double rectSelectTest (const QRectF &rect, const QPointF &pos, bool filledRect) const
                            QCPItemPositioncreatePosition (const QString &name)
                            QCPItemAnchorcreateAnchor (const QString &name, int anchorId)
                            - Protected Functions inherited from QCPLayerable
                            virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                            void initializeParentPlot (QCustomPlot *parentPlot)
                            void setParentLayerable (QCPLayerable *parentLayerable)
                            bool moveToLayer (QCPLayer *layer, bool prepend)
                            void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                            + + + +

                            +Additional Inherited Members

                            - Signals inherited from QCPAbstractItem
                            void selectionChanged (bool selected)
                            +void selectableChanged (bool selectable)

                            Detailed Description

                            An arbitrary pixmap.

                            @@ -454,911 +462,6 @@
                            - -
                            -
                            - - - - - -
                            - - - - - - - - -
                            void QCPAbstractItem::setClipToAxisRect (bool clip)
                            -
                            -inherited
                            -
                            -

                            Sets whether the item shall be clipped to an axis rect or whether it shall be visible on the entire QCustomPlot. The axis rect can be set with setClipAxisRect.

                            -
                            See Also
                            setClipAxisRect
                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - - -
                            void QCPAbstractItem::setClipAxisRect (QCPAxisRectrect)
                            -
                            -inherited
                            -
                            -

                            Sets the clip axis rect. It defines the rect that will be used to clip the item when setClipToAxisRect is set to true.

                            -
                            See Also
                            setClipToAxisRect
                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - - -
                            void QCPAbstractItem::setSelectable (bool selectable)
                            -
                            -inherited
                            -
                            -

                            Sets whether the user can (de-)select this item by clicking on the QCustomPlot surface. (When QCustomPlot::setInteractions contains QCustomPlot::iSelectItems.)

                            -

                            However, even when selectable was set to false, it is possible to set the selection manually, by calling setSelected.

                            -
                            See Also
                            QCustomPlot::setInteractions, setSelected
                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - - -
                            void QCPAbstractItem::setSelected (bool selected)
                            -
                            -inherited
                            -
                            -

                            Sets whether this item is selected or not. When selected, it might use a different visual appearance (e.g. pen and brush), this depends on the specific item though.

                            -

                            The entire selection mechanism for items is handled automatically when QCustomPlot::setInteractions contains QCustomPlot::iSelectItems. You only need to call this function when you wish to change the selection state manually.

                            -

                            This function can change the selection state even when setSelectable was set to false.

                            -

                            emits the selectionChanged signal when selected is different from the previous selection state.

                            -
                            See Also
                            setSelectable, selectTest
                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - -
                            QList< QCPItemPosition * > QCPAbstractItem::positions () const
                            -
                            -inlineinherited
                            -
                            -

                            Returns all positions of the item in a list.

                            -
                            See Also
                            anchors, position
                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - -
                            QList< QCPItemAnchor * > QCPAbstractItem::anchors () const
                            -
                            -inlineinherited
                            -
                            -

                            Returns all anchors of the item in a list. Note that since a position (QCPItemPosition) is always also an anchor, the list will also contain the positions of this item.

                            -
                            See Also
                            positions, anchor
                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - - -
                            QCPItemPosition * QCPAbstractItem::position (const QString & name) const
                            -
                            -inherited
                            -
                            -

                            Returns the QCPItemPosition with the specified name. If this item doesn't have a position by that name, returns 0.

                            -

                            This function provides an alternative way to access item positions. Normally, you access positions direcly by their member pointers (which typically have the same variable name as name).

                            -
                            See Also
                            positions, anchor
                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - - -
                            QCPItemAnchor * QCPAbstractItem::anchor (const QString & name) const
                            -
                            -inherited
                            -
                            -

                            Returns the QCPItemAnchor with the specified name. If this item doesn't have an anchor by that name, returns 0.

                            -

                            This function provides an alternative way to access item anchors. Normally, you access anchors direcly by their member pointers (which typically have the same variable name as name).

                            -
                            See Also
                            anchors, position
                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - - -
                            bool QCPAbstractItem::hasAnchor (const QString & name) const
                            -
                            -inherited
                            -
                            -

                            Returns whether this item has an anchor with the specified name.

                            -

                            Note that you can check for positions with this function, too. This is because every position is also an anchor (QCPItemPosition inherits from QCPItemAnchor).

                            -
                            See Also
                            anchor, position
                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - - -
                            void QCPAbstractItem::selectionChanged (bool selected)
                            -
                            -signalinherited
                            -
                            -

                            This signal is emitted when the selection state of this item has changed, either by user interaction or by a direct call to setSelected.

                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - -
                            QCP::Interaction QCPAbstractItem::selectionCategory () const
                            -
                            -protectedvirtualinherited
                            -
                            -

                            Returns the selection category this layerable shall belong to. The selection category is used in conjunction with QCustomPlot::setInteractions to control which objects are selectable and which aren't.

                            -

                            Subclasses that don't fit any of the normal QCP::Interaction values can use QCP::iSelectOther. This is what the default implementation returns.

                            -
                            See Also
                            QCustomPlot::setInteractions
                            - -

                            Reimplemented from QCPLayerable.

                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - -
                            QRect QCPAbstractItem::clipRect () const
                            -
                            -protectedvirtualinherited
                            -
                            -

                            Returns the rect the visual representation of this item is clipped to. This depends on the current setting of setClipToAxisRect as well as the axis rect set with setClipAxisRect.

                            -

                            If the item is not clipped to an axis rect, the QCustomPlot::viewport rect is returned.

                            -
                            See Also
                            draw
                            - -

                            Reimplemented from QCPLayerable.

                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - - -
                            void QCPAbstractItem::applyDefaultAntialiasingHint (QCPPainterpainter) const
                            -
                            -protectedvirtualinherited
                            -
                            -

                            A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing item lines.

                            -

                            This is the antialiasing state the painter passed to the draw method is in by default.

                            -

                            This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                            -
                            See Also
                            setAntialiased
                            - -

                            Implements QCPLayerable.

                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                            void QCPAbstractItem::selectEvent (QMouseEvent * event,
                            bool additive,
                            const QVariant & details,
                            bool * selectionStateChanged 
                            )
                            -
                            -protectedvirtualinherited
                            -
                            -

                            This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

                            -

                            event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

                            -

                            Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

                            -

                            selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

                            -
                            See Also
                            selectTest, deselectEvent
                            - -

                            Reimplemented from QCPLayerable.

                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - - -
                            void QCPAbstractItem::deselectEvent (bool * selectionStateChanged)
                            -
                            -protectedvirtualinherited
                            -
                            -

                            This event is called when the layerable shall be deselected, either as consequence of a user interaction or a call to QCustomPlot::deselectAll. Subclasses should react to it by unsetting their selection appropriately.

                            -

                            just as in selectEvent, the output parameter selectionStateChanged (if non-null), must return true or false when the selection state of this layerable has changed or not changed, respectively.

                            -
                            See Also
                            selectTest, selectEvent
                            - -

                            Reimplemented from QCPLayerable.

                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - - - - - - - - - - - - - - - - - - -
                            double QCPAbstractItem::distSqrToLine (const QPointF & start,
                            const QPointF & end,
                            const QPointF & point 
                            ) const
                            -
                            -protectedinherited
                            -
                            -

                            Finds the shortest squared distance of point to the line segment defined by start and end.

                            -

                            This function may be used to help with the implementation of the selectTest function for specific items.

                            -
                            Note
                            This function is identical to QCPAbstractPlottable::distSqrToLine
                            -
                            See Also
                            rectSelectTest
                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - - - - - - - - - - - - - - - - - - -
                            double QCPAbstractItem::rectSelectTest (const QRectF & rect,
                            const QPointF & pos,
                            bool filledRect 
                            ) const
                            -
                            -protectedinherited
                            -
                            -

                            A convenience function which returns the selectTest value for a specified rect and a specified click position pos. filledRect defines whether a click inside the rect should also be considered a hit or whether only the rect border is sensitive to hits.

                            -

                            This function may be used to help with the implementation of the selectTest function for specific items.

                            -

                            For example, if your item consists of four rects, call this function four times, once for each rect, in your selectTest reimplementation. Finally, return the minimum of all four returned values which were greater or equal to zero. (Because this function may return -1.0 when pos doesn't hit rect at all). If all calls returned -1.0, return -1.0, too, because your item wasn't hit.

                            -
                            See Also
                            distSqrToLine
                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - - -
                            QCPItemPosition * QCPAbstractItem::createPosition (const QString & name)
                            -
                            -protectedinherited
                            -
                            -

                            Creates a QCPItemPosition, registers it with this item and returns a pointer to it. The specified name must be a unique string that is usually identical to the variable name of the position member (This is needed to provide the name-based position access to positions).

                            -

                            Don't delete positions created by this function manually, as the item will take care of it.

                            -

                            Use this function in the constructor (initialization list) of the specific item subclass to create each position member. Don't create QCPItemPositions with new yourself, because they won't be registered with the item properly.

                            -
                            See Also
                            createAnchor
                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - - - - - - - - - - - - -
                            QCPItemAnchor * QCPAbstractItem::createAnchor (const QString & name,
                            int anchorId 
                            )
                            -
                            -protectedinherited
                            -
                            -

                            Creates a QCPItemAnchor, registers it with this item and returns a pointer to it. The specified name must be a unique string that is usually identical to the variable name of the anchor member (This is needed to provide the name based anchor access to anchors).

                            -

                            The anchorId must be a number identifying the created anchor. It is recommended to create an enum (e.g. "AnchorIndex") for this on each item that uses anchors. This id is used by the anchor to identify itself when it calls QCPAbstractItem::anchorPixelPoint. That function then returns the correct pixel coordinates for the passed anchor id.

                            -

                            Don't delete anchors created by this function manually, as the item will take care of it.

                            -

                            Use this function in the constructor (initialization list) of the specific item subclass to create each anchor member. Don't create QCPItemAnchors with new yourself, because then they won't be registered with the item properly.

                            -
                            See Also
                            createPosition
                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - -
                            QCPLayerable * QCPLayerable::parentLayerable () const
                            -
                            -inlineinherited
                            -
                            -

                            Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.

                            -

                            Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.

                            -

                            A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.

                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - - -
                            void QCPLayerable::setVisible (bool on)
                            -
                            -inherited
                            -
                            -

                            Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.

                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - - -
                            bool QCPLayerable::setLayer (QCPLayerlayer)
                            -
                            -inherited
                            -
                            -

                            Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.

                            -

                            Returns true on success, i.e. if layer is a valid layer.

                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - - -
                            bool QCPLayerable::setLayer (const QString & layerName)
                            -
                            -inherited
                            -
                            -

                            This is an overloaded function.

                            -

                            Sets the layer of this layerable object by name

                            -

                            Returns true on success, i.e. if layerName is a valid layer name.

                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - - -
                            void QCPLayerable::setAntialiased (bool enabled)
                            -
                            -inherited
                            -
                            -

                            Sets whether this object will be drawn antialiased or not.

                            -

                            Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - -
                            bool QCPLayerable::realVisibility () const
                            -
                            -inherited
                            -
                            -

                            Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.

                            -

                            If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.

                            -

                            If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.

                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - - -
                            void QCPLayerable::parentPlotInitialized (QCustomPlotparentPlot)
                            -
                            -protectedvirtualinherited
                            -
                            -

                            This function is called by initializeParentPlot, to allow subclasses to react on the setting of a parent plot. This is the case when 0 was passed as parent plot in the constructor, and the parent plot is set at a later time.

                            -

                            For example, QCPLayoutElement/QCPLayout hierarchies may be created independently of any QCustomPlot at first. When they are then added to a layout inside the QCustomPlot, the top level element of the hierarchy gets its parent plot initialized with initializeParentPlot. To propagate the parent plot to all the children of the hierarchy, the top level element then uses this function to pass the parent plot on to its child elements.

                            -

                            The default implementation does nothing.

                            -
                            See Also
                            initializeParentPlot
                            - -

                            Reimplemented in QCPLegend, and QCPLayoutElement.

                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - - -
                            void QCPLayerable::initializeParentPlot (QCustomPlotparentPlot)
                            -
                            -protectedinherited
                            -
                            -

                            Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.

                            -

                            Note that, unlike when passing a non-null parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.

                            -

                            Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.

                            -

                            The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).

                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - - -
                            void QCPLayerable::setParentLayerable (QCPLayerableparentLayerable)
                            -
                            -protectedinherited
                            -
                            -

                            Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.

                            -

                            The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.

                            -
                            See Also
                            realVisibility
                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - - - - - - - - - - - - -
                            bool QCPLayerable::moveToLayer (QCPLayerlayer,
                            bool prepend 
                            )
                            -
                            -protectedinherited
                            -
                            -

                            Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.

                            -

                            Returns true on success, i.e. if layer is a valid layer.

                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - - - - - - - - - - - - - - - - - - -
                            void QCPLayerable::applyAntialiasingHint (QCPPainterpainter,
                            bool localAntialiased,
                            QCP::AntialiasedElement overrideElement 
                            ) const
                            -
                            -protectedinherited
                            -
                            -

                            Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.

                            - -
                            -

                            The documentation for this class was generated from the following files:
                            • src/items/item-pixmap.h
                            • src/items/item-pixmap.cpp
                            • diff -Nru qcustomplot-1.1.0/documentation/html/classQCPItemPosition.html qcustomplot-1.2.0/documentation/html/classQCPItemPosition.html --- qcustomplot-1.1.0/documentation/html/classQCPItemPosition.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPItemPosition.html 2014-03-14 21:11:27.000000000 +0000 @@ -65,14 +65,17 @@ void setAxes (QCPAxis *keyAxis, QCPAxis *valueAxis) void setAxisRect (QCPAxisRect *axisRect) void setPixelPoint (const QPointF &pixelPoint) - +- Public Functions inherited from QCPItemAnchorQCPItemAnchor (QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString name, int anchorId=-1) + QString name () const - - + + +

                              Protected Functions

                              virtual QCPItemPositiontoQCPItemPosition ()
                              void addChild (QCPItemPosition *pos)
                              void removeChild (QCPItemPosition *pos)
                              - Protected Functions inherited from QCPItemAnchor
                              void addChild (QCPItemPosition *pos)
                              void removeChild (QCPItemPosition *pos)

                              Detailed Description

                              Manages the position of an item.

                              @@ -97,10 +100,10 @@

                              Static positioning in pixels, starting from the top left corner of the viewport/widget.

                              ptViewportRatio  -

                              Static positioning given by a fraction of the viewport size.

                              +

                              Static positioning given by a fraction of the viewport size. For example, if you call setCoords(0, 0), the position will be at the top left corner of the viewport/widget. setCoords(1, 1) will be at the bottom right corner, setCoords(0.5, 0) will be horizontally centered and vertically at the top of the viewport/widget, etc.

                              ptAxisRectRatio  -

                              Static positioning given by a fraction of the axis rect size (see setAxisRect).

                              +

                              Static positioning given by a fraction of the axis rect size (see setAxisRect). For example, if you call setCoords(0, 0), the position will be at the top left corner of the axis rect. setCoords(1, 1) will be at the bottom right corner, setCoords(0.5, 0) will be horizontally centered and vertically at the top of the axis rect, etc. You can also go beyond the axis rect by providing negative coordinates or coordinates larger than 1.

                              ptPlotCoords 

                              Dynamic positioning at a plot coordinate defined by two axes (see setAxes).

                              @@ -192,7 +195,7 @@
                            • The position is regarded as a point in plot coordinates. This corresponds to ptPlotCoords and requires two axes that define the plot coordinate system. They can be specified with setAxes. By default, the QCustomPlot's x- and yAxis are used.
                              -
                            • The position is fixed on the QCustomPlot surface, i.e. independent of axis ranges. This corresponds to all other types, i.e. ptAbsolute, ptViewportRatio and ptAxisRectRatio. They differ only in the way the absolute position is described, see the documentation of PositionType for details. For ptAxisRectRatio, note that you can specify the axis rect with setAxisRect. By default this is set to the main axis rect.
                            • +
                            • The position is fixed on the QCustomPlot surface, i.e. independent of axis ranges. This corresponds to all other types, i.e. ptAbsolute, ptViewportRatio and ptAxisRectRatio. They differ only in the way the absolute position is described, see the documentation of PositionType for details. For ptAxisRectRatio, note that you can specify the axis rect with setAxisRect. By default this is set to the main axis rect.

                            Note that the position type ptPlotCoords is only available (and sensible) when the position has no parent anchor (setParentAnchor).

                            If the type is changed, the apparent pixel position on the plot is preserved. This means the coordinates as retrieved with coords() and set with setCoords may change in the process.

                            @@ -366,58 +369,6 @@ - -
                            -
                            - - - - - -
                            - - - - - - - - -
                            void QCPItemAnchor::addChild (QCPItemPositionpos)
                            -
                            -protectedinherited
                            -
                            -

                            Adds pos to the child list of this anchor. This is necessary to notify the children prior to destruction of the anchor.

                            -

                            Note that this function does not change the parent setting in pos.

                            - -
                            -
                            - -
                            -
                            - - - - - -
                            - - - - - - - - -
                            void QCPItemAnchor::removeChild (QCPItemPositionpos)
                            -
                            -protectedinherited
                            -
                            -

                            Removes pos from the child list of this anchor.

                            -

                            Note that this function does not change the parent setting in pos.

                            - -
                            -

                            The documentation for this class was generated from the following files:
                            • src/item.h
                            • src/item.cpp
                            • diff -Nru qcustomplot-1.1.0/documentation/html/classQCPItemRect.html qcustomplot-1.2.0/documentation/html/classQCPItemRect.html --- qcustomplot-1.1.0/documentation/html/classQCPItemRect.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPItemRect.html 2014-03-14 21:11:27.000000000 +0000 @@ -18,7 +18,6 @@
                              @@ -52,37 +51,41 @@ void setBrush (const QBrush &brush) void setSelectedBrush (const QBrush &brush) virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const - +- Public Functions inherited from QCPAbstractItemQCPAbstractItem (QCustomPlot *parentPlot) + bool clipToAxisRect () const - + QCPAxisRectclipAxisRect () const - + bool selectable () const - + bool selected () const -void setClipToAxisRect (bool clip) -void setClipAxisRect (QCPAxisRect *rect) -void setSelectable (bool selectable) -void setSelected (bool selected) -QList< QCPItemPosition * > positions () const -QList< QCPItemAnchor * > anchors () const -QCPItemPositionposition (const QString &name) const -QCPItemAnchoranchor (const QString &name) const -bool hasAnchor (const QString &name) const - +void setClipToAxisRect (bool clip) +void setClipAxisRect (QCPAxisRect *rect) +Q_SLOT void setSelectable (bool selectable) +Q_SLOT void setSelected (bool selected) +QList< QCPItemPosition * > positions () const +QList< QCPItemAnchor * > anchors () const +QCPItemPositionposition (const QString &name) const +QCPItemAnchoranchor (const QString &name) const +bool hasAnchor (const QString &name) const +- Public Functions inherited from QCPLayerableQCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0) + bool visible () const - + QCustomPlotparentPlot () const -QCPLayerableparentLayerable () const - +QCPLayerableparentLayerable () const + QCPLayerlayer () const - + bool antialiased () const -void setVisible (bool on) -bool setLayer (QCPLayer *layer) -bool setLayer (const QString &layerName) -void setAntialiased (bool enabled) -bool realVisibility () const +void setVisible (bool on) +Q_SLOT bool setLayer (QCPLayer *layer) +bool setLayer (const QString &layerName) +void setAntialiased (bool enabled) +bool realVisibility () const @@ -103,10 +106,6 @@

                              Public Members

                              QCPItemAnchor *const left
                              - - -

                              -Signals

                              void selectionChanged (bool selected)
                              @@ -117,20 +116,29 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + +

                              Protected Types

                              enum  AnchorIndex
                              virtual QPointF anchorPixelPoint (int anchorId) const
                              QPen mainPen () const
                              QBrush mainBrush () const
                              virtual QCP::Interaction selectionCategory () const
                              virtual QRect clipRect () const
                              virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
                              virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                              virtual void deselectEvent (bool *selectionStateChanged)
                              double distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const
                              double rectSelectTest (const QRectF &rect, const QPointF &pos, bool filledRect) const
                              QCPItemPositioncreatePosition (const QString &name)
                              QCPItemAnchorcreateAnchor (const QString &name, int anchorId)
                              virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                              void initializeParentPlot (QCustomPlot *parentPlot)
                              void setParentLayerable (QCPLayerable *parentLayerable)
                              bool moveToLayer (QCPLayer *layer, bool prepend)
                              void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                              - Protected Functions inherited from QCPAbstractItem
                              virtual QCP::Interaction selectionCategory () const
                              virtual QRect clipRect () const
                              virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
                              virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                              virtual void deselectEvent (bool *selectionStateChanged)
                              double distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const
                              double rectSelectTest (const QRectF &rect, const QPointF &pos, bool filledRect) const
                              QCPItemPositioncreatePosition (const QString &name)
                              QCPItemAnchorcreateAnchor (const QString &name, int anchorId)
                              - Protected Functions inherited from QCPLayerable
                              virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                              void initializeParentPlot (QCustomPlot *parentPlot)
                              void setParentLayerable (QCPLayerable *parentLayerable)
                              bool moveToLayer (QCPLayer *layer, bool prepend)
                              void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                              + + + +

                              +Additional Inherited Members

                              - Signals inherited from QCPAbstractItem
                              void selectionChanged (bool selected)
                              +void selectableChanged (bool selectable)

                              Detailed Description

                              A rectangle.

                              @@ -386,911 +394,6 @@
                              - -
                              -
                              - - - - - -
                              - - - - - - - - -
                              void QCPAbstractItem::setClipToAxisRect (bool clip)
                              -
                              -inherited
                              -
                              -

                              Sets whether the item shall be clipped to an axis rect or whether it shall be visible on the entire QCustomPlot. The axis rect can be set with setClipAxisRect.

                              -
                              See Also
                              setClipAxisRect
                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - - -
                              void QCPAbstractItem::setClipAxisRect (QCPAxisRectrect)
                              -
                              -inherited
                              -
                              -

                              Sets the clip axis rect. It defines the rect that will be used to clip the item when setClipToAxisRect is set to true.

                              -
                              See Also
                              setClipToAxisRect
                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - - -
                              void QCPAbstractItem::setSelectable (bool selectable)
                              -
                              -inherited
                              -
                              -

                              Sets whether the user can (de-)select this item by clicking on the QCustomPlot surface. (When QCustomPlot::setInteractions contains QCustomPlot::iSelectItems.)

                              -

                              However, even when selectable was set to false, it is possible to set the selection manually, by calling setSelected.

                              -
                              See Also
                              QCustomPlot::setInteractions, setSelected
                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - - -
                              void QCPAbstractItem::setSelected (bool selected)
                              -
                              -inherited
                              -
                              -

                              Sets whether this item is selected or not. When selected, it might use a different visual appearance (e.g. pen and brush), this depends on the specific item though.

                              -

                              The entire selection mechanism for items is handled automatically when QCustomPlot::setInteractions contains QCustomPlot::iSelectItems. You only need to call this function when you wish to change the selection state manually.

                              -

                              This function can change the selection state even when setSelectable was set to false.

                              -

                              emits the selectionChanged signal when selected is different from the previous selection state.

                              -
                              See Also
                              setSelectable, selectTest
                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - -
                              QList< QCPItemPosition * > QCPAbstractItem::positions () const
                              -
                              -inlineinherited
                              -
                              -

                              Returns all positions of the item in a list.

                              -
                              See Also
                              anchors, position
                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - -
                              QList< QCPItemAnchor * > QCPAbstractItem::anchors () const
                              -
                              -inlineinherited
                              -
                              -

                              Returns all anchors of the item in a list. Note that since a position (QCPItemPosition) is always also an anchor, the list will also contain the positions of this item.

                              -
                              See Also
                              positions, anchor
                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - - -
                              QCPItemPosition * QCPAbstractItem::position (const QString & name) const
                              -
                              -inherited
                              -
                              -

                              Returns the QCPItemPosition with the specified name. If this item doesn't have a position by that name, returns 0.

                              -

                              This function provides an alternative way to access item positions. Normally, you access positions direcly by their member pointers (which typically have the same variable name as name).

                              -
                              See Also
                              positions, anchor
                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - - -
                              QCPItemAnchor * QCPAbstractItem::anchor (const QString & name) const
                              -
                              -inherited
                              -
                              -

                              Returns the QCPItemAnchor with the specified name. If this item doesn't have an anchor by that name, returns 0.

                              -

                              This function provides an alternative way to access item anchors. Normally, you access anchors direcly by their member pointers (which typically have the same variable name as name).

                              -
                              See Also
                              anchors, position
                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - - -
                              bool QCPAbstractItem::hasAnchor (const QString & name) const
                              -
                              -inherited
                              -
                              -

                              Returns whether this item has an anchor with the specified name.

                              -

                              Note that you can check for positions with this function, too. This is because every position is also an anchor (QCPItemPosition inherits from QCPItemAnchor).

                              -
                              See Also
                              anchor, position
                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - - -
                              void QCPAbstractItem::selectionChanged (bool selected)
                              -
                              -signalinherited
                              -
                              -

                              This signal is emitted when the selection state of this item has changed, either by user interaction or by a direct call to setSelected.

                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - -
                              QCP::Interaction QCPAbstractItem::selectionCategory () const
                              -
                              -protectedvirtualinherited
                              -
                              -

                              Returns the selection category this layerable shall belong to. The selection category is used in conjunction with QCustomPlot::setInteractions to control which objects are selectable and which aren't.

                              -

                              Subclasses that don't fit any of the normal QCP::Interaction values can use QCP::iSelectOther. This is what the default implementation returns.

                              -
                              See Also
                              QCustomPlot::setInteractions
                              - -

                              Reimplemented from QCPLayerable.

                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - -
                              QRect QCPAbstractItem::clipRect () const
                              -
                              -protectedvirtualinherited
                              -
                              -

                              Returns the rect the visual representation of this item is clipped to. This depends on the current setting of setClipToAxisRect as well as the axis rect set with setClipAxisRect.

                              -

                              If the item is not clipped to an axis rect, the QCustomPlot::viewport rect is returned.

                              -
                              See Also
                              draw
                              - -

                              Reimplemented from QCPLayerable.

                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - - -
                              void QCPAbstractItem::applyDefaultAntialiasingHint (QCPPainterpainter) const
                              -
                              -protectedvirtualinherited
                              -
                              -

                              A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing item lines.

                              -

                              This is the antialiasing state the painter passed to the draw method is in by default.

                              -

                              This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                              -
                              See Also
                              setAntialiased
                              - -

                              Implements QCPLayerable.

                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                              void QCPAbstractItem::selectEvent (QMouseEvent * event,
                              bool additive,
                              const QVariant & details,
                              bool * selectionStateChanged 
                              )
                              -
                              -protectedvirtualinherited
                              -
                              -

                              This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

                              -

                              event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

                              -

                              Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

                              -

                              selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

                              -
                              See Also
                              selectTest, deselectEvent
                              - -

                              Reimplemented from QCPLayerable.

                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - - -
                              void QCPAbstractItem::deselectEvent (bool * selectionStateChanged)
                              -
                              -protectedvirtualinherited
                              -
                              -

                              This event is called when the layerable shall be deselected, either as consequence of a user interaction or a call to QCustomPlot::deselectAll. Subclasses should react to it by unsetting their selection appropriately.

                              -

                              just as in selectEvent, the output parameter selectionStateChanged (if non-null), must return true or false when the selection state of this layerable has changed or not changed, respectively.

                              -
                              See Also
                              selectTest, selectEvent
                              - -

                              Reimplemented from QCPLayerable.

                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - - - - - - - - - - - - - - - - - - -
                              double QCPAbstractItem::distSqrToLine (const QPointF & start,
                              const QPointF & end,
                              const QPointF & point 
                              ) const
                              -
                              -protectedinherited
                              -
                              -

                              Finds the shortest squared distance of point to the line segment defined by start and end.

                              -

                              This function may be used to help with the implementation of the selectTest function for specific items.

                              -
                              Note
                              This function is identical to QCPAbstractPlottable::distSqrToLine
                              -
                              See Also
                              rectSelectTest
                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - - - - - - - - - - - - - - - - - - -
                              double QCPAbstractItem::rectSelectTest (const QRectF & rect,
                              const QPointF & pos,
                              bool filledRect 
                              ) const
                              -
                              -protectedinherited
                              -
                              -

                              A convenience function which returns the selectTest value for a specified rect and a specified click position pos. filledRect defines whether a click inside the rect should also be considered a hit or whether only the rect border is sensitive to hits.

                              -

                              This function may be used to help with the implementation of the selectTest function for specific items.

                              -

                              For example, if your item consists of four rects, call this function four times, once for each rect, in your selectTest reimplementation. Finally, return the minimum of all four returned values which were greater or equal to zero. (Because this function may return -1.0 when pos doesn't hit rect at all). If all calls returned -1.0, return -1.0, too, because your item wasn't hit.

                              -
                              See Also
                              distSqrToLine
                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - - -
                              QCPItemPosition * QCPAbstractItem::createPosition (const QString & name)
                              -
                              -protectedinherited
                              -
                              -

                              Creates a QCPItemPosition, registers it with this item and returns a pointer to it. The specified name must be a unique string that is usually identical to the variable name of the position member (This is needed to provide the name-based position access to positions).

                              -

                              Don't delete positions created by this function manually, as the item will take care of it.

                              -

                              Use this function in the constructor (initialization list) of the specific item subclass to create each position member. Don't create QCPItemPositions with new yourself, because they won't be registered with the item properly.

                              -
                              See Also
                              createAnchor
                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - - - - - - - - - - - - -
                              QCPItemAnchor * QCPAbstractItem::createAnchor (const QString & name,
                              int anchorId 
                              )
                              -
                              -protectedinherited
                              -
                              -

                              Creates a QCPItemAnchor, registers it with this item and returns a pointer to it. The specified name must be a unique string that is usually identical to the variable name of the anchor member (This is needed to provide the name based anchor access to anchors).

                              -

                              The anchorId must be a number identifying the created anchor. It is recommended to create an enum (e.g. "AnchorIndex") for this on each item that uses anchors. This id is used by the anchor to identify itself when it calls QCPAbstractItem::anchorPixelPoint. That function then returns the correct pixel coordinates for the passed anchor id.

                              -

                              Don't delete anchors created by this function manually, as the item will take care of it.

                              -

                              Use this function in the constructor (initialization list) of the specific item subclass to create each anchor member. Don't create QCPItemAnchors with new yourself, because then they won't be registered with the item properly.

                              -
                              See Also
                              createPosition
                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - -
                              QCPLayerable * QCPLayerable::parentLayerable () const
                              -
                              -inlineinherited
                              -
                              -

                              Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.

                              -

                              Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.

                              -

                              A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.

                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - - -
                              void QCPLayerable::setVisible (bool on)
                              -
                              -inherited
                              -
                              -

                              Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.

                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - - -
                              bool QCPLayerable::setLayer (QCPLayerlayer)
                              -
                              -inherited
                              -
                              -

                              Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.

                              -

                              Returns true on success, i.e. if layer is a valid layer.

                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - - -
                              bool QCPLayerable::setLayer (const QString & layerName)
                              -
                              -inherited
                              -
                              -

                              This is an overloaded function.

                              -

                              Sets the layer of this layerable object by name

                              -

                              Returns true on success, i.e. if layerName is a valid layer name.

                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - - -
                              void QCPLayerable::setAntialiased (bool enabled)
                              -
                              -inherited
                              -
                              -

                              Sets whether this object will be drawn antialiased or not.

                              -

                              Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - -
                              bool QCPLayerable::realVisibility () const
                              -
                              -inherited
                              -
                              -

                              Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.

                              -

                              If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.

                              -

                              If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.

                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - - -
                              void QCPLayerable::parentPlotInitialized (QCustomPlotparentPlot)
                              -
                              -protectedvirtualinherited
                              -
                              -

                              This function is called by initializeParentPlot, to allow subclasses to react on the setting of a parent plot. This is the case when 0 was passed as parent plot in the constructor, and the parent plot is set at a later time.

                              -

                              For example, QCPLayoutElement/QCPLayout hierarchies may be created independently of any QCustomPlot at first. When they are then added to a layout inside the QCustomPlot, the top level element of the hierarchy gets its parent plot initialized with initializeParentPlot. To propagate the parent plot to all the children of the hierarchy, the top level element then uses this function to pass the parent plot on to its child elements.

                              -

                              The default implementation does nothing.

                              -
                              See Also
                              initializeParentPlot
                              - -

                              Reimplemented in QCPLegend, and QCPLayoutElement.

                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - - -
                              void QCPLayerable::initializeParentPlot (QCustomPlotparentPlot)
                              -
                              -protectedinherited
                              -
                              -

                              Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.

                              -

                              Note that, unlike when passing a non-null parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.

                              -

                              Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.

                              -

                              The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).

                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - - -
                              void QCPLayerable::setParentLayerable (QCPLayerableparentLayerable)
                              -
                              -protectedinherited
                              -
                              -

                              Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.

                              -

                              The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.

                              -
                              See Also
                              realVisibility
                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - - - - - - - - - - - - -
                              bool QCPLayerable::moveToLayer (QCPLayerlayer,
                              bool prepend 
                              )
                              -
                              -protectedinherited
                              -
                              -

                              Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.

                              -

                              Returns true on success, i.e. if layer is a valid layer.

                              - -
                              -
                              - -
                              -
                              - - - - - -
                              - - - - - - - - - - - - - - - - - - - - - - - - -
                              void QCPLayerable::applyAntialiasingHint (QCPPainterpainter,
                              bool localAntialiased,
                              QCP::AntialiasedElement overrideElement 
                              ) const
                              -
                              -protectedinherited
                              -
                              -

                              Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.

                              - -
                              -

                              The documentation for this class was generated from the following files:
                              • src/items/item-rect.h
                              • src/items/item-rect.cpp
                              • diff -Nru qcustomplot-1.1.0/documentation/html/classQCPItemStraightLine.html qcustomplot-1.2.0/documentation/html/classQCPItemStraightLine.html --- qcustomplot-1.1.0/documentation/html/classQCPItemStraightLine.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPItemStraightLine.html 2014-03-14 21:11:27.000000000 +0000 @@ -18,7 +18,6 @@
                                QCPItemStraightLine Class Reference
                                @@ -45,37 +44,41 @@ void setPen (const QPen &pen) void setSelectedPen (const QPen &pen) virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const - +- Public Functions inherited from QCPAbstractItemQCPAbstractItem (QCustomPlot *parentPlot) + bool clipToAxisRect () const - + QCPAxisRectclipAxisRect () const - + bool selectable () const - + bool selected () const -void setClipToAxisRect (bool clip) -void setClipAxisRect (QCPAxisRect *rect) -void setSelectable (bool selectable) -void setSelected (bool selected) -QList< QCPItemPosition * > positions () const -QList< QCPItemAnchor * > anchors () const -QCPItemPositionposition (const QString &name) const -QCPItemAnchoranchor (const QString &name) const -bool hasAnchor (const QString &name) const - +void setClipToAxisRect (bool clip) +void setClipAxisRect (QCPAxisRect *rect) +Q_SLOT void setSelectable (bool selectable) +Q_SLOT void setSelected (bool selected) +QList< QCPItemPosition * > positions () const +QList< QCPItemAnchor * > anchors () const +QCPItemPositionposition (const QString &name) const +QCPItemAnchoranchor (const QString &name) const +bool hasAnchor (const QString &name) const +- Public Functions inherited from QCPLayerableQCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0) + bool visible () const - + QCustomPlotparentPlot () const -QCPLayerableparentLayerable () const - +QCPLayerableparentLayerable () const + QCPLayerlayer () const - + bool antialiased () const -void setVisible (bool on) -bool setLayer (QCPLayer *layer) -bool setLayer (const QString &layerName) -void setAntialiased (bool enabled) -bool realVisibility () const +void setVisible (bool on) +Q_SLOT bool setLayer (QCPLayer *layer) +bool setLayer (const QString &layerName) +void setAntialiased (bool enabled) +bool realVisibility () const @@ -84,31 +87,36 @@

                                Public Members

                                QCPItemPosition *const point2
                                - - -

                                -Signals

                                void selectionChanged (bool selected)
                                - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + +

                                Protected Functions

                                virtual void draw (QCPPainter *painter)
                                double distToStraightLine (const QVector2D &point1, const QVector2D &vec, const QVector2D &point) const
                                QLineF getRectClippedStraightLine (const QVector2D &point1, const QVector2D &vec, const QRect &rect) const
                                QPen mainPen () const
                                virtual QCP::Interaction selectionCategory () const
                                virtual QRect clipRect () const
                                virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
                                virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                                virtual void deselectEvent (bool *selectionStateChanged)
                                virtual QPointF anchorPixelPoint (int anchorId) const
                                double distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const
                                double rectSelectTest (const QRectF &rect, const QPointF &pos, bool filledRect) const
                                QCPItemPositioncreatePosition (const QString &name)
                                QCPItemAnchorcreateAnchor (const QString &name, int anchorId)
                                virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                                void initializeParentPlot (QCustomPlot *parentPlot)
                                void setParentLayerable (QCPLayerable *parentLayerable)
                                bool moveToLayer (QCPLayer *layer, bool prepend)
                                void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                                - Protected Functions inherited from QCPAbstractItem
                                virtual QCP::Interaction selectionCategory () const
                                virtual QRect clipRect () const
                                virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
                                virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                                virtual void deselectEvent (bool *selectionStateChanged)
                                virtual QPointF anchorPixelPoint (int anchorId) const
                                double distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const
                                double rectSelectTest (const QRectF &rect, const QPointF &pos, bool filledRect) const
                                QCPItemPositioncreatePosition (const QString &name)
                                QCPItemAnchorcreateAnchor (const QString &name, int anchorId)
                                - Protected Functions inherited from QCPLayerable
                                virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                                void initializeParentPlot (QCustomPlot *parentPlot)
                                void setParentLayerable (QCPLayerable *parentLayerable)
                                bool moveToLayer (QCPLayer *layer, bool prepend)
                                void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                                + + + +

                                +Additional Inherited Members

                                - Signals inherited from QCPAbstractItem
                                void selectionChanged (bool selected)
                                +void selectableChanged (bool selectable)

                                Detailed Description

                                A straight line that spans infinitely in both directions.

                                @@ -359,940 +367,6 @@
                                - -
                                -
                                - - - - - -
                                - - - - - - - - -
                                void QCPAbstractItem::setClipToAxisRect (bool clip)
                                -
                                -inherited
                                -
                                -

                                Sets whether the item shall be clipped to an axis rect or whether it shall be visible on the entire QCustomPlot. The axis rect can be set with setClipAxisRect.

                                -
                                See Also
                                setClipAxisRect
                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - - -
                                void QCPAbstractItem::setClipAxisRect (QCPAxisRectrect)
                                -
                                -inherited
                                -
                                -

                                Sets the clip axis rect. It defines the rect that will be used to clip the item when setClipToAxisRect is set to true.

                                -
                                See Also
                                setClipToAxisRect
                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - - -
                                void QCPAbstractItem::setSelectable (bool selectable)
                                -
                                -inherited
                                -
                                -

                                Sets whether the user can (de-)select this item by clicking on the QCustomPlot surface. (When QCustomPlot::setInteractions contains QCustomPlot::iSelectItems.)

                                -

                                However, even when selectable was set to false, it is possible to set the selection manually, by calling setSelected.

                                -
                                See Also
                                QCustomPlot::setInteractions, setSelected
                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - - -
                                void QCPAbstractItem::setSelected (bool selected)
                                -
                                -inherited
                                -
                                -

                                Sets whether this item is selected or not. When selected, it might use a different visual appearance (e.g. pen and brush), this depends on the specific item though.

                                -

                                The entire selection mechanism for items is handled automatically when QCustomPlot::setInteractions contains QCustomPlot::iSelectItems. You only need to call this function when you wish to change the selection state manually.

                                -

                                This function can change the selection state even when setSelectable was set to false.

                                -

                                emits the selectionChanged signal when selected is different from the previous selection state.

                                -
                                See Also
                                setSelectable, selectTest
                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - -
                                QList< QCPItemPosition * > QCPAbstractItem::positions () const
                                -
                                -inlineinherited
                                -
                                -

                                Returns all positions of the item in a list.

                                -
                                See Also
                                anchors, position
                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - -
                                QList< QCPItemAnchor * > QCPAbstractItem::anchors () const
                                -
                                -inlineinherited
                                -
                                -

                                Returns all anchors of the item in a list. Note that since a position (QCPItemPosition) is always also an anchor, the list will also contain the positions of this item.

                                -
                                See Also
                                positions, anchor
                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - - -
                                QCPItemPosition * QCPAbstractItem::position (const QString & name) const
                                -
                                -inherited
                                -
                                -

                                Returns the QCPItemPosition with the specified name. If this item doesn't have a position by that name, returns 0.

                                -

                                This function provides an alternative way to access item positions. Normally, you access positions direcly by their member pointers (which typically have the same variable name as name).

                                -
                                See Also
                                positions, anchor
                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - - -
                                QCPItemAnchor * QCPAbstractItem::anchor (const QString & name) const
                                -
                                -inherited
                                -
                                -

                                Returns the QCPItemAnchor with the specified name. If this item doesn't have an anchor by that name, returns 0.

                                -

                                This function provides an alternative way to access item anchors. Normally, you access anchors direcly by their member pointers (which typically have the same variable name as name).

                                -
                                See Also
                                anchors, position
                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - - -
                                bool QCPAbstractItem::hasAnchor (const QString & name) const
                                -
                                -inherited
                                -
                                -

                                Returns whether this item has an anchor with the specified name.

                                -

                                Note that you can check for positions with this function, too. This is because every position is also an anchor (QCPItemPosition inherits from QCPItemAnchor).

                                -
                                See Also
                                anchor, position
                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - - -
                                void QCPAbstractItem::selectionChanged (bool selected)
                                -
                                -signalinherited
                                -
                                -

                                This signal is emitted when the selection state of this item has changed, either by user interaction or by a direct call to setSelected.

                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - -
                                QCP::Interaction QCPAbstractItem::selectionCategory () const
                                -
                                -protectedvirtualinherited
                                -
                                -

                                Returns the selection category this layerable shall belong to. The selection category is used in conjunction with QCustomPlot::setInteractions to control which objects are selectable and which aren't.

                                -

                                Subclasses that don't fit any of the normal QCP::Interaction values can use QCP::iSelectOther. This is what the default implementation returns.

                                -
                                See Also
                                QCustomPlot::setInteractions
                                - -

                                Reimplemented from QCPLayerable.

                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - -
                                QRect QCPAbstractItem::clipRect () const
                                -
                                -protectedvirtualinherited
                                -
                                -

                                Returns the rect the visual representation of this item is clipped to. This depends on the current setting of setClipToAxisRect as well as the axis rect set with setClipAxisRect.

                                -

                                If the item is not clipped to an axis rect, the QCustomPlot::viewport rect is returned.

                                -
                                See Also
                                draw
                                - -

                                Reimplemented from QCPLayerable.

                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - - -
                                void QCPAbstractItem::applyDefaultAntialiasingHint (QCPPainterpainter) const
                                -
                                -protectedvirtualinherited
                                -
                                -

                                A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing item lines.

                                -

                                This is the antialiasing state the painter passed to the draw method is in by default.

                                -

                                This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                                -
                                See Also
                                setAntialiased
                                - -

                                Implements QCPLayerable.

                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                                void QCPAbstractItem::selectEvent (QMouseEvent * event,
                                bool additive,
                                const QVariant & details,
                                bool * selectionStateChanged 
                                )
                                -
                                -protectedvirtualinherited
                                -
                                -

                                This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

                                -

                                event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

                                -

                                Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

                                -

                                selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

                                -
                                See Also
                                selectTest, deselectEvent
                                - -

                                Reimplemented from QCPLayerable.

                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - - -
                                void QCPAbstractItem::deselectEvent (bool * selectionStateChanged)
                                -
                                -protectedvirtualinherited
                                -
                                -

                                This event is called when the layerable shall be deselected, either as consequence of a user interaction or a call to QCustomPlot::deselectAll. Subclasses should react to it by unsetting their selection appropriately.

                                -

                                just as in selectEvent, the output parameter selectionStateChanged (if non-null), must return true or false when the selection state of this layerable has changed or not changed, respectively.

                                -
                                See Also
                                selectTest, selectEvent
                                - -

                                Reimplemented from QCPLayerable.

                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - - -
                                QPointF QCPAbstractItem::anchorPixelPoint (int anchorId) const
                                -
                                -protectedvirtualinherited
                                -
                                -

                                Returns the pixel position of the anchor with Id anchorId. This function must be reimplemented in item subclasses if they want to provide anchors (QCPItemAnchor).

                                -

                                For example, if the item has two anchors with id 0 and 1, this function takes one of these anchor ids and returns the respective pixel points of the specified anchor.

                                -
                                See Also
                                createAnchor
                                - -

                                Reimplemented in QCPItemText, QCPItemPixmap, QCPItemEllipse, QCPItemBracket, and QCPItemRect.

                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - - - - - - - - - - - - - - - - - - -
                                double QCPAbstractItem::distSqrToLine (const QPointF & start,
                                const QPointF & end,
                                const QPointF & point 
                                ) const
                                -
                                -protectedinherited
                                -
                                -

                                Finds the shortest squared distance of point to the line segment defined by start and end.

                                -

                                This function may be used to help with the implementation of the selectTest function for specific items.

                                -
                                Note
                                This function is identical to QCPAbstractPlottable::distSqrToLine
                                -
                                See Also
                                rectSelectTest
                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - - - - - - - - - - - - - - - - - - -
                                double QCPAbstractItem::rectSelectTest (const QRectF & rect,
                                const QPointF & pos,
                                bool filledRect 
                                ) const
                                -
                                -protectedinherited
                                -
                                -

                                A convenience function which returns the selectTest value for a specified rect and a specified click position pos. filledRect defines whether a click inside the rect should also be considered a hit or whether only the rect border is sensitive to hits.

                                -

                                This function may be used to help with the implementation of the selectTest function for specific items.

                                -

                                For example, if your item consists of four rects, call this function four times, once for each rect, in your selectTest reimplementation. Finally, return the minimum of all four returned values which were greater or equal to zero. (Because this function may return -1.0 when pos doesn't hit rect at all). If all calls returned -1.0, return -1.0, too, because your item wasn't hit.

                                -
                                See Also
                                distSqrToLine
                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - - -
                                QCPItemPosition * QCPAbstractItem::createPosition (const QString & name)
                                -
                                -protectedinherited
                                -
                                -

                                Creates a QCPItemPosition, registers it with this item and returns a pointer to it. The specified name must be a unique string that is usually identical to the variable name of the position member (This is needed to provide the name-based position access to positions).

                                -

                                Don't delete positions created by this function manually, as the item will take care of it.

                                -

                                Use this function in the constructor (initialization list) of the specific item subclass to create each position member. Don't create QCPItemPositions with new yourself, because they won't be registered with the item properly.

                                -
                                See Also
                                createAnchor
                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - - - - - - - - - - - - -
                                QCPItemAnchor * QCPAbstractItem::createAnchor (const QString & name,
                                int anchorId 
                                )
                                -
                                -protectedinherited
                                -
                                -

                                Creates a QCPItemAnchor, registers it with this item and returns a pointer to it. The specified name must be a unique string that is usually identical to the variable name of the anchor member (This is needed to provide the name based anchor access to anchors).

                                -

                                The anchorId must be a number identifying the created anchor. It is recommended to create an enum (e.g. "AnchorIndex") for this on each item that uses anchors. This id is used by the anchor to identify itself when it calls QCPAbstractItem::anchorPixelPoint. That function then returns the correct pixel coordinates for the passed anchor id.

                                -

                                Don't delete anchors created by this function manually, as the item will take care of it.

                                -

                                Use this function in the constructor (initialization list) of the specific item subclass to create each anchor member. Don't create QCPItemAnchors with new yourself, because then they won't be registered with the item properly.

                                -
                                See Also
                                createPosition
                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - -
                                QCPLayerable * QCPLayerable::parentLayerable () const
                                -
                                -inlineinherited
                                -
                                -

                                Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.

                                -

                                Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.

                                -

                                A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.

                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - - -
                                void QCPLayerable::setVisible (bool on)
                                -
                                -inherited
                                -
                                -

                                Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.

                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - - -
                                bool QCPLayerable::setLayer (QCPLayerlayer)
                                -
                                -inherited
                                -
                                -

                                Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.

                                -

                                Returns true on success, i.e. if layer is a valid layer.

                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - - -
                                bool QCPLayerable::setLayer (const QString & layerName)
                                -
                                -inherited
                                -
                                -

                                This is an overloaded function.

                                -

                                Sets the layer of this layerable object by name

                                -

                                Returns true on success, i.e. if layerName is a valid layer name.

                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - - -
                                void QCPLayerable::setAntialiased (bool enabled)
                                -
                                -inherited
                                -
                                -

                                Sets whether this object will be drawn antialiased or not.

                                -

                                Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - -
                                bool QCPLayerable::realVisibility () const
                                -
                                -inherited
                                -
                                -

                                Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.

                                -

                                If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.

                                -

                                If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.

                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - - -
                                void QCPLayerable::parentPlotInitialized (QCustomPlotparentPlot)
                                -
                                -protectedvirtualinherited
                                -
                                -

                                This function is called by initializeParentPlot, to allow subclasses to react on the setting of a parent plot. This is the case when 0 was passed as parent plot in the constructor, and the parent plot is set at a later time.

                                -

                                For example, QCPLayoutElement/QCPLayout hierarchies may be created independently of any QCustomPlot at first. When they are then added to a layout inside the QCustomPlot, the top level element of the hierarchy gets its parent plot initialized with initializeParentPlot. To propagate the parent plot to all the children of the hierarchy, the top level element then uses this function to pass the parent plot on to its child elements.

                                -

                                The default implementation does nothing.

                                -
                                See Also
                                initializeParentPlot
                                - -

                                Reimplemented in QCPLegend, and QCPLayoutElement.

                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - - -
                                void QCPLayerable::initializeParentPlot (QCustomPlotparentPlot)
                                -
                                -protectedinherited
                                -
                                -

                                Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.

                                -

                                Note that, unlike when passing a non-null parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.

                                -

                                Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.

                                -

                                The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).

                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - - -
                                void QCPLayerable::setParentLayerable (QCPLayerableparentLayerable)
                                -
                                -protectedinherited
                                -
                                -

                                Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.

                                -

                                The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.

                                -
                                See Also
                                realVisibility
                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - - - - - - - - - - - - -
                                bool QCPLayerable::moveToLayer (QCPLayerlayer,
                                bool prepend 
                                )
                                -
                                -protectedinherited
                                -
                                -

                                Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.

                                -

                                Returns true on success, i.e. if layer is a valid layer.

                                - -
                                -
                                - -
                                -
                                - - - - - -
                                - - - - - - - - - - - - - - - - - - - - - - - - -
                                void QCPLayerable::applyAntialiasingHint (QCPPainterpainter,
                                bool localAntialiased,
                                QCP::AntialiasedElement overrideElement 
                                ) const
                                -
                                -protectedinherited
                                -
                                -

                                Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.

                                - -
                                -

                                The documentation for this class was generated from the following files:
                                • src/items/item-straightline.h
                                • src/items/item-straightline.cpp
                                • diff -Nru qcustomplot-1.1.0/documentation/html/classQCPItemText.html qcustomplot-1.2.0/documentation/html/classQCPItemText.html --- qcustomplot-1.1.0/documentation/html/classQCPItemText.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPItemText.html 2014-03-14 21:11:27.000000000 +0000 @@ -18,7 +18,6 @@
                                  @@ -79,37 +78,41 @@ void setRotation (double degrees) void setPadding (const QMargins &padding) virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const - +- Public Functions inherited from QCPAbstractItemQCPAbstractItem (QCustomPlot *parentPlot) + bool clipToAxisRect () const - + QCPAxisRectclipAxisRect () const - + bool selectable () const - + bool selected () const -void setClipToAxisRect (bool clip) -void setClipAxisRect (QCPAxisRect *rect) -void setSelectable (bool selectable) -void setSelected (bool selected) -QList< QCPItemPosition * > positions () const -QList< QCPItemAnchor * > anchors () const -QCPItemPositionposition (const QString &name) const -QCPItemAnchoranchor (const QString &name) const -bool hasAnchor (const QString &name) const - +void setClipToAxisRect (bool clip) +void setClipAxisRect (QCPAxisRect *rect) +Q_SLOT void setSelectable (bool selectable) +Q_SLOT void setSelected (bool selected) +QList< QCPItemPosition * > positions () const +QList< QCPItemAnchor * > anchors () const +QCPItemPositionposition (const QString &name) const +QCPItemAnchoranchor (const QString &name) const +bool hasAnchor (const QString &name) const +- Public Functions inherited from QCPLayerableQCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0) + bool visible () const - + QCustomPlotparentPlot () const -QCPLayerableparentLayerable () const - +QCPLayerableparentLayerable () const + QCPLayerlayer () const - + bool antialiased () const -void setVisible (bool on) -bool setLayer (QCPLayer *layer) -bool setLayer (const QString &layerName) -void setAntialiased (bool enabled) -bool realVisibility () const +void setVisible (bool on) +Q_SLOT bool setLayer (QCPLayer *layer) +bool setLayer (const QString &layerName) +void setAntialiased (bool enabled) +bool realVisibility () const @@ -132,10 +135,6 @@

                                  Public Members

                                  QCPItemAnchor *const left
                                  - - -

                                  -Signals

                                  void selectionChanged (bool selected)
                                  @@ -149,20 +148,29 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + +

                                  Protected Types

                                  enum  AnchorIndex
                                  QColor mainColor () const
                                  QPen mainPen () const
                                  QBrush mainBrush () const
                                  virtual QCP::Interaction selectionCategory () const
                                  virtual QRect clipRect () const
                                  virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
                                  virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                                  virtual void deselectEvent (bool *selectionStateChanged)
                                  double distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const
                                  double rectSelectTest (const QRectF &rect, const QPointF &pos, bool filledRect) const
                                  QCPItemPositioncreatePosition (const QString &name)
                                  QCPItemAnchorcreateAnchor (const QString &name, int anchorId)
                                  virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                                  void initializeParentPlot (QCustomPlot *parentPlot)
                                  void setParentLayerable (QCPLayerable *parentLayerable)
                                  bool moveToLayer (QCPLayer *layer, bool prepend)
                                  void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                                  - Protected Functions inherited from QCPAbstractItem
                                  virtual QCP::Interaction selectionCategory () const
                                  virtual QRect clipRect () const
                                  virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
                                  virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                                  virtual void deselectEvent (bool *selectionStateChanged)
                                  double distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const
                                  double rectSelectTest (const QRectF &rect, const QPointF &pos, bool filledRect) const
                                  QCPItemPositioncreatePosition (const QString &name)
                                  QCPItemAnchorcreateAnchor (const QString &name, int anchorId)
                                  - Protected Functions inherited from QCPLayerable
                                  virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                                  void initializeParentPlot (QCustomPlot *parentPlot)
                                  void setParentLayerable (QCPLayerable *parentLayerable)
                                  bool moveToLayer (QCPLayer *layer, bool prepend)
                                  void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                                  + + + +

                                  +Additional Inherited Members

                                  - Signals inherited from QCPAbstractItem
                                  void selectionChanged (bool selected)
                                  +void selectableChanged (bool selectable)

                                  Detailed Description

                                  A text label.

                                  @@ -673,911 +681,6 @@
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - - -
                                  void QCPAbstractItem::setClipToAxisRect (bool clip)
                                  -
                                  -inherited
                                  -
                                  -

                                  Sets whether the item shall be clipped to an axis rect or whether it shall be visible on the entire QCustomPlot. The axis rect can be set with setClipAxisRect.

                                  -
                                  See Also
                                  setClipAxisRect
                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - - -
                                  void QCPAbstractItem::setClipAxisRect (QCPAxisRectrect)
                                  -
                                  -inherited
                                  -
                                  -

                                  Sets the clip axis rect. It defines the rect that will be used to clip the item when setClipToAxisRect is set to true.

                                  -
                                  See Also
                                  setClipToAxisRect
                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - - -
                                  void QCPAbstractItem::setSelectable (bool selectable)
                                  -
                                  -inherited
                                  -
                                  -

                                  Sets whether the user can (de-)select this item by clicking on the QCustomPlot surface. (When QCustomPlot::setInteractions contains QCustomPlot::iSelectItems.)

                                  -

                                  However, even when selectable was set to false, it is possible to set the selection manually, by calling setSelected.

                                  -
                                  See Also
                                  QCustomPlot::setInteractions, setSelected
                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - - -
                                  void QCPAbstractItem::setSelected (bool selected)
                                  -
                                  -inherited
                                  -
                                  -

                                  Sets whether this item is selected or not. When selected, it might use a different visual appearance (e.g. pen and brush), this depends on the specific item though.

                                  -

                                  The entire selection mechanism for items is handled automatically when QCustomPlot::setInteractions contains QCustomPlot::iSelectItems. You only need to call this function when you wish to change the selection state manually.

                                  -

                                  This function can change the selection state even when setSelectable was set to false.

                                  -

                                  emits the selectionChanged signal when selected is different from the previous selection state.

                                  -
                                  See Also
                                  setSelectable, selectTest
                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - -
                                  QList< QCPItemPosition * > QCPAbstractItem::positions () const
                                  -
                                  -inlineinherited
                                  -
                                  -

                                  Returns all positions of the item in a list.

                                  -
                                  See Also
                                  anchors, position
                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - -
                                  QList< QCPItemAnchor * > QCPAbstractItem::anchors () const
                                  -
                                  -inlineinherited
                                  -
                                  -

                                  Returns all anchors of the item in a list. Note that since a position (QCPItemPosition) is always also an anchor, the list will also contain the positions of this item.

                                  -
                                  See Also
                                  positions, anchor
                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - - -
                                  QCPItemPosition * QCPAbstractItem::position (const QString & name) const
                                  -
                                  -inherited
                                  -
                                  -

                                  Returns the QCPItemPosition with the specified name. If this item doesn't have a position by that name, returns 0.

                                  -

                                  This function provides an alternative way to access item positions. Normally, you access positions direcly by their member pointers (which typically have the same variable name as name).

                                  -
                                  See Also
                                  positions, anchor
                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - - -
                                  QCPItemAnchor * QCPAbstractItem::anchor (const QString & name) const
                                  -
                                  -inherited
                                  -
                                  -

                                  Returns the QCPItemAnchor with the specified name. If this item doesn't have an anchor by that name, returns 0.

                                  -

                                  This function provides an alternative way to access item anchors. Normally, you access anchors direcly by their member pointers (which typically have the same variable name as name).

                                  -
                                  See Also
                                  anchors, position
                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - - -
                                  bool QCPAbstractItem::hasAnchor (const QString & name) const
                                  -
                                  -inherited
                                  -
                                  -

                                  Returns whether this item has an anchor with the specified name.

                                  -

                                  Note that you can check for positions with this function, too. This is because every position is also an anchor (QCPItemPosition inherits from QCPItemAnchor).

                                  -
                                  See Also
                                  anchor, position
                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - - -
                                  void QCPAbstractItem::selectionChanged (bool selected)
                                  -
                                  -signalinherited
                                  -
                                  -

                                  This signal is emitted when the selection state of this item has changed, either by user interaction or by a direct call to setSelected.

                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - -
                                  QCP::Interaction QCPAbstractItem::selectionCategory () const
                                  -
                                  -protectedvirtualinherited
                                  -
                                  -

                                  Returns the selection category this layerable shall belong to. The selection category is used in conjunction with QCustomPlot::setInteractions to control which objects are selectable and which aren't.

                                  -

                                  Subclasses that don't fit any of the normal QCP::Interaction values can use QCP::iSelectOther. This is what the default implementation returns.

                                  -
                                  See Also
                                  QCustomPlot::setInteractions
                                  - -

                                  Reimplemented from QCPLayerable.

                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - -
                                  QRect QCPAbstractItem::clipRect () const
                                  -
                                  -protectedvirtualinherited
                                  -
                                  -

                                  Returns the rect the visual representation of this item is clipped to. This depends on the current setting of setClipToAxisRect as well as the axis rect set with setClipAxisRect.

                                  -

                                  If the item is not clipped to an axis rect, the QCustomPlot::viewport rect is returned.

                                  -
                                  See Also
                                  draw
                                  - -

                                  Reimplemented from QCPLayerable.

                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - - -
                                  void QCPAbstractItem::applyDefaultAntialiasingHint (QCPPainterpainter) const
                                  -
                                  -protectedvirtualinherited
                                  -
                                  -

                                  A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing item lines.

                                  -

                                  This is the antialiasing state the painter passed to the draw method is in by default.

                                  -

                                  This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                                  -
                                  See Also
                                  setAntialiased
                                  - -

                                  Implements QCPLayerable.

                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                                  void QCPAbstractItem::selectEvent (QMouseEvent * event,
                                  bool additive,
                                  const QVariant & details,
                                  bool * selectionStateChanged 
                                  )
                                  -
                                  -protectedvirtualinherited
                                  -
                                  -

                                  This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

                                  -

                                  event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

                                  -

                                  Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

                                  -

                                  selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

                                  -
                                  See Also
                                  selectTest, deselectEvent
                                  - -

                                  Reimplemented from QCPLayerable.

                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - - -
                                  void QCPAbstractItem::deselectEvent (bool * selectionStateChanged)
                                  -
                                  -protectedvirtualinherited
                                  -
                                  -

                                  This event is called when the layerable shall be deselected, either as consequence of a user interaction or a call to QCustomPlot::deselectAll. Subclasses should react to it by unsetting their selection appropriately.

                                  -

                                  just as in selectEvent, the output parameter selectionStateChanged (if non-null), must return true or false when the selection state of this layerable has changed or not changed, respectively.

                                  -
                                  See Also
                                  selectTest, selectEvent
                                  - -

                                  Reimplemented from QCPLayerable.

                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - - - - - - - - - - - - - - - - - - -
                                  double QCPAbstractItem::distSqrToLine (const QPointF & start,
                                  const QPointF & end,
                                  const QPointF & point 
                                  ) const
                                  -
                                  -protectedinherited
                                  -
                                  -

                                  Finds the shortest squared distance of point to the line segment defined by start and end.

                                  -

                                  This function may be used to help with the implementation of the selectTest function for specific items.

                                  -
                                  Note
                                  This function is identical to QCPAbstractPlottable::distSqrToLine
                                  -
                                  See Also
                                  rectSelectTest
                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - - - - - - - - - - - - - - - - - - -
                                  double QCPAbstractItem::rectSelectTest (const QRectF & rect,
                                  const QPointF & pos,
                                  bool filledRect 
                                  ) const
                                  -
                                  -protectedinherited
                                  -
                                  -

                                  A convenience function which returns the selectTest value for a specified rect and a specified click position pos. filledRect defines whether a click inside the rect should also be considered a hit or whether only the rect border is sensitive to hits.

                                  -

                                  This function may be used to help with the implementation of the selectTest function for specific items.

                                  -

                                  For example, if your item consists of four rects, call this function four times, once for each rect, in your selectTest reimplementation. Finally, return the minimum of all four returned values which were greater or equal to zero. (Because this function may return -1.0 when pos doesn't hit rect at all). If all calls returned -1.0, return -1.0, too, because your item wasn't hit.

                                  -
                                  See Also
                                  distSqrToLine
                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - - -
                                  QCPItemPosition * QCPAbstractItem::createPosition (const QString & name)
                                  -
                                  -protectedinherited
                                  -
                                  -

                                  Creates a QCPItemPosition, registers it with this item and returns a pointer to it. The specified name must be a unique string that is usually identical to the variable name of the position member (This is needed to provide the name-based position access to positions).

                                  -

                                  Don't delete positions created by this function manually, as the item will take care of it.

                                  -

                                  Use this function in the constructor (initialization list) of the specific item subclass to create each position member. Don't create QCPItemPositions with new yourself, because they won't be registered with the item properly.

                                  -
                                  See Also
                                  createAnchor
                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - - - - - - - - - - - - -
                                  QCPItemAnchor * QCPAbstractItem::createAnchor (const QString & name,
                                  int anchorId 
                                  )
                                  -
                                  -protectedinherited
                                  -
                                  -

                                  Creates a QCPItemAnchor, registers it with this item and returns a pointer to it. The specified name must be a unique string that is usually identical to the variable name of the anchor member (This is needed to provide the name based anchor access to anchors).

                                  -

                                  The anchorId must be a number identifying the created anchor. It is recommended to create an enum (e.g. "AnchorIndex") for this on each item that uses anchors. This id is used by the anchor to identify itself when it calls QCPAbstractItem::anchorPixelPoint. That function then returns the correct pixel coordinates for the passed anchor id.

                                  -

                                  Don't delete anchors created by this function manually, as the item will take care of it.

                                  -

                                  Use this function in the constructor (initialization list) of the specific item subclass to create each anchor member. Don't create QCPItemAnchors with new yourself, because then they won't be registered with the item properly.

                                  -
                                  See Also
                                  createPosition
                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - -
                                  QCPLayerable * QCPLayerable::parentLayerable () const
                                  -
                                  -inlineinherited
                                  -
                                  -

                                  Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.

                                  -

                                  Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.

                                  -

                                  A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.

                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - - -
                                  void QCPLayerable::setVisible (bool on)
                                  -
                                  -inherited
                                  -
                                  -

                                  Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.

                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - - -
                                  bool QCPLayerable::setLayer (QCPLayerlayer)
                                  -
                                  -inherited
                                  -
                                  -

                                  Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.

                                  -

                                  Returns true on success, i.e. if layer is a valid layer.

                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - - -
                                  bool QCPLayerable::setLayer (const QString & layerName)
                                  -
                                  -inherited
                                  -
                                  -

                                  This is an overloaded function.

                                  -

                                  Sets the layer of this layerable object by name

                                  -

                                  Returns true on success, i.e. if layerName is a valid layer name.

                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - - -
                                  void QCPLayerable::setAntialiased (bool enabled)
                                  -
                                  -inherited
                                  -
                                  -

                                  Sets whether this object will be drawn antialiased or not.

                                  -

                                  Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - -
                                  bool QCPLayerable::realVisibility () const
                                  -
                                  -inherited
                                  -
                                  -

                                  Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.

                                  -

                                  If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.

                                  -

                                  If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.

                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - - -
                                  void QCPLayerable::parentPlotInitialized (QCustomPlotparentPlot)
                                  -
                                  -protectedvirtualinherited
                                  -
                                  -

                                  This function is called by initializeParentPlot, to allow subclasses to react on the setting of a parent plot. This is the case when 0 was passed as parent plot in the constructor, and the parent plot is set at a later time.

                                  -

                                  For example, QCPLayoutElement/QCPLayout hierarchies may be created independently of any QCustomPlot at first. When they are then added to a layout inside the QCustomPlot, the top level element of the hierarchy gets its parent plot initialized with initializeParentPlot. To propagate the parent plot to all the children of the hierarchy, the top level element then uses this function to pass the parent plot on to its child elements.

                                  -

                                  The default implementation does nothing.

                                  -
                                  See Also
                                  initializeParentPlot
                                  - -

                                  Reimplemented in QCPLegend, and QCPLayoutElement.

                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - - -
                                  void QCPLayerable::initializeParentPlot (QCustomPlotparentPlot)
                                  -
                                  -protectedinherited
                                  -
                                  -

                                  Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.

                                  -

                                  Note that, unlike when passing a non-null parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.

                                  -

                                  Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.

                                  -

                                  The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).

                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - - -
                                  void QCPLayerable::setParentLayerable (QCPLayerableparentLayerable)
                                  -
                                  -protectedinherited
                                  -
                                  -

                                  Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.

                                  -

                                  The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.

                                  -
                                  See Also
                                  realVisibility
                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - - - - - - - - - - - - -
                                  bool QCPLayerable::moveToLayer (QCPLayerlayer,
                                  bool prepend 
                                  )
                                  -
                                  -protectedinherited
                                  -
                                  -

                                  Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.

                                  -

                                  Returns true on success, i.e. if layer is a valid layer.

                                  - -
                                  -
                                  - -
                                  -
                                  - - - - - -
                                  - - - - - - - - - - - - - - - - - - - - - - - - -
                                  void QCPLayerable::applyAntialiasingHint (QCPPainterpainter,
                                  bool localAntialiased,
                                  QCP::AntialiasedElement overrideElement 
                                  ) const
                                  -
                                  -protectedinherited
                                  -
                                  -

                                  Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.

                                  - -
                                  -

                                  The documentation for this class was generated from the following files:
                                  • src/items/item-text.h
                                  • src/items/item-text.cpp
                                  • diff -Nru qcustomplot-1.1.0/documentation/html/classQCPItemTracer.html qcustomplot-1.2.0/documentation/html/classQCPItemTracer.html --- qcustomplot-1.1.0/documentation/html/classQCPItemTracer.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPItemTracer.html 2014-03-14 21:11:27.000000000 +0000 @@ -19,7 +19,6 @@ Public Types | Public Functions | Public Members | -Signals | Protected Functions
                                    QCPItemTracer Class Reference
                                    @@ -72,67 +71,76 @@ void setInterpolating (bool enabled) virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const void updatePosition () - +- Public Functions inherited from QCPAbstractItemQCPAbstractItem (QCustomPlot *parentPlot) + bool clipToAxisRect () const - + QCPAxisRectclipAxisRect () const - + bool selectable () const - + bool selected () const -void setClipToAxisRect (bool clip) -void setClipAxisRect (QCPAxisRect *rect) -void setSelectable (bool selectable) -void setSelected (bool selected) -QList< QCPItemPosition * > positions () const -QList< QCPItemAnchor * > anchors () const -QCPItemPositionposition (const QString &name) const -QCPItemAnchoranchor (const QString &name) const -bool hasAnchor (const QString &name) const - +void setClipToAxisRect (bool clip) +void setClipAxisRect (QCPAxisRect *rect) +Q_SLOT void setSelectable (bool selectable) +Q_SLOT void setSelected (bool selected) +QList< QCPItemPosition * > positions () const +QList< QCPItemAnchor * > anchors () const +QCPItemPositionposition (const QString &name) const +QCPItemAnchoranchor (const QString &name) const +bool hasAnchor (const QString &name) const +- Public Functions inherited from QCPLayerableQCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0) + bool visible () const - + QCustomPlotparentPlot () const -QCPLayerableparentLayerable () const - +QCPLayerableparentLayerable () const + QCPLayerlayer () const - + bool antialiased () const -void setVisible (bool on) -bool setLayer (QCPLayer *layer) -bool setLayer (const QString &layerName) -void setAntialiased (bool enabled) -bool realVisibility () const +void setVisible (bool on) +Q_SLOT bool setLayer (QCPLayer *layer) +bool setLayer (const QString &layerName) +void setAntialiased (bool enabled) +bool realVisibility () const

                                    Public Members

                                    QCPItemPosition *const position
                                    - - -

                                    -Signals

                                    void selectionChanged (bool selected)
                                    - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + +

                                    Protected Functions

                                    virtual void draw (QCPPainter *painter)
                                    QPen mainPen () const
                                    QBrush mainBrush () const
                                    virtual QCP::Interaction selectionCategory () const
                                    virtual QRect clipRect () const
                                    virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
                                    virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                                    virtual void deselectEvent (bool *selectionStateChanged)
                                    virtual QPointF anchorPixelPoint (int anchorId) const
                                    double distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const
                                    double rectSelectTest (const QRectF &rect, const QPointF &pos, bool filledRect) const
                                    QCPItemPositioncreatePosition (const QString &name)
                                    QCPItemAnchorcreateAnchor (const QString &name, int anchorId)
                                    virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                                    void initializeParentPlot (QCustomPlot *parentPlot)
                                    void setParentLayerable (QCPLayerable *parentLayerable)
                                    bool moveToLayer (QCPLayer *layer, bool prepend)
                                    void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                                    - Protected Functions inherited from QCPAbstractItem
                                    virtual QCP::Interaction selectionCategory () const
                                    virtual QRect clipRect () const
                                    virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
                                    virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                                    virtual void deselectEvent (bool *selectionStateChanged)
                                    virtual QPointF anchorPixelPoint (int anchorId) const
                                    double distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const
                                    double rectSelectTest (const QRectF &rect, const QPointF &pos, bool filledRect) const
                                    QCPItemPositioncreatePosition (const QString &name)
                                    QCPItemAnchorcreateAnchor (const QString &name, int anchorId)
                                    - Protected Functions inherited from QCPLayerable
                                    virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                                    void initializeParentPlot (QCustomPlot *parentPlot)
                                    void setParentLayerable (QCPLayerable *parentLayerable)
                                    bool moveToLayer (QCPLayer *layer, bool prepend)
                                    void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                                    + + + +

                                    +Additional Inherited Members

                                    - Signals inherited from QCPAbstractItem
                                    void selectionChanged (bool selected)
                                    +void selectableChanged (bool selectable)

                                    Detailed Description

                                    Item that sticks to QCPGraph data points.

                                    @@ -507,940 +515,6 @@
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - - -
                                    void QCPAbstractItem::setClipToAxisRect (bool clip)
                                    -
                                    -inherited
                                    -
                                    -

                                    Sets whether the item shall be clipped to an axis rect or whether it shall be visible on the entire QCustomPlot. The axis rect can be set with setClipAxisRect.

                                    -
                                    See Also
                                    setClipAxisRect
                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - - -
                                    void QCPAbstractItem::setClipAxisRect (QCPAxisRectrect)
                                    -
                                    -inherited
                                    -
                                    -

                                    Sets the clip axis rect. It defines the rect that will be used to clip the item when setClipToAxisRect is set to true.

                                    -
                                    See Also
                                    setClipToAxisRect
                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - - -
                                    void QCPAbstractItem::setSelectable (bool selectable)
                                    -
                                    -inherited
                                    -
                                    -

                                    Sets whether the user can (de-)select this item by clicking on the QCustomPlot surface. (When QCustomPlot::setInteractions contains QCustomPlot::iSelectItems.)

                                    -

                                    However, even when selectable was set to false, it is possible to set the selection manually, by calling setSelected.

                                    -
                                    See Also
                                    QCustomPlot::setInteractions, setSelected
                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - - -
                                    void QCPAbstractItem::setSelected (bool selected)
                                    -
                                    -inherited
                                    -
                                    -

                                    Sets whether this item is selected or not. When selected, it might use a different visual appearance (e.g. pen and brush), this depends on the specific item though.

                                    -

                                    The entire selection mechanism for items is handled automatically when QCustomPlot::setInteractions contains QCustomPlot::iSelectItems. You only need to call this function when you wish to change the selection state manually.

                                    -

                                    This function can change the selection state even when setSelectable was set to false.

                                    -

                                    emits the selectionChanged signal when selected is different from the previous selection state.

                                    -
                                    See Also
                                    setSelectable, selectTest
                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - -
                                    QList< QCPItemPosition * > QCPAbstractItem::positions () const
                                    -
                                    -inlineinherited
                                    -
                                    -

                                    Returns all positions of the item in a list.

                                    -
                                    See Also
                                    anchors, position
                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - -
                                    QList< QCPItemAnchor * > QCPAbstractItem::anchors () const
                                    -
                                    -inlineinherited
                                    -
                                    -

                                    Returns all anchors of the item in a list. Note that since a position (QCPItemPosition) is always also an anchor, the list will also contain the positions of this item.

                                    -
                                    See Also
                                    positions, anchor
                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - - -
                                    QCPItemPosition * QCPAbstractItem::position (const QString & name) const
                                    -
                                    -inherited
                                    -
                                    -

                                    Returns the QCPItemPosition with the specified name. If this item doesn't have a position by that name, returns 0.

                                    -

                                    This function provides an alternative way to access item positions. Normally, you access positions direcly by their member pointers (which typically have the same variable name as name).

                                    -
                                    See Also
                                    positions, anchor
                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - - -
                                    QCPItemAnchor * QCPAbstractItem::anchor (const QString & name) const
                                    -
                                    -inherited
                                    -
                                    -

                                    Returns the QCPItemAnchor with the specified name. If this item doesn't have an anchor by that name, returns 0.

                                    -

                                    This function provides an alternative way to access item anchors. Normally, you access anchors direcly by their member pointers (which typically have the same variable name as name).

                                    -
                                    See Also
                                    anchors, position
                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - - -
                                    bool QCPAbstractItem::hasAnchor (const QString & name) const
                                    -
                                    -inherited
                                    -
                                    -

                                    Returns whether this item has an anchor with the specified name.

                                    -

                                    Note that you can check for positions with this function, too. This is because every position is also an anchor (QCPItemPosition inherits from QCPItemAnchor).

                                    -
                                    See Also
                                    anchor, position
                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - - -
                                    void QCPAbstractItem::selectionChanged (bool selected)
                                    -
                                    -signalinherited
                                    -
                                    -

                                    This signal is emitted when the selection state of this item has changed, either by user interaction or by a direct call to setSelected.

                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - -
                                    QCP::Interaction QCPAbstractItem::selectionCategory () const
                                    -
                                    -protectedvirtualinherited
                                    -
                                    -

                                    Returns the selection category this layerable shall belong to. The selection category is used in conjunction with QCustomPlot::setInteractions to control which objects are selectable and which aren't.

                                    -

                                    Subclasses that don't fit any of the normal QCP::Interaction values can use QCP::iSelectOther. This is what the default implementation returns.

                                    -
                                    See Also
                                    QCustomPlot::setInteractions
                                    - -

                                    Reimplemented from QCPLayerable.

                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - -
                                    QRect QCPAbstractItem::clipRect () const
                                    -
                                    -protectedvirtualinherited
                                    -
                                    -

                                    Returns the rect the visual representation of this item is clipped to. This depends on the current setting of setClipToAxisRect as well as the axis rect set with setClipAxisRect.

                                    -

                                    If the item is not clipped to an axis rect, the QCustomPlot::viewport rect is returned.

                                    -
                                    See Also
                                    draw
                                    - -

                                    Reimplemented from QCPLayerable.

                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - - -
                                    void QCPAbstractItem::applyDefaultAntialiasingHint (QCPPainterpainter) const
                                    -
                                    -protectedvirtualinherited
                                    -
                                    -

                                    A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing item lines.

                                    -

                                    This is the antialiasing state the painter passed to the draw method is in by default.

                                    -

                                    This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                                    -
                                    See Also
                                    setAntialiased
                                    - -

                                    Implements QCPLayerable.

                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                                    void QCPAbstractItem::selectEvent (QMouseEvent * event,
                                    bool additive,
                                    const QVariant & details,
                                    bool * selectionStateChanged 
                                    )
                                    -
                                    -protectedvirtualinherited
                                    -
                                    -

                                    This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

                                    -

                                    event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

                                    -

                                    Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

                                    -

                                    selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

                                    -
                                    See Also
                                    selectTest, deselectEvent
                                    - -

                                    Reimplemented from QCPLayerable.

                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - - -
                                    void QCPAbstractItem::deselectEvent (bool * selectionStateChanged)
                                    -
                                    -protectedvirtualinherited
                                    -
                                    -

                                    This event is called when the layerable shall be deselected, either as consequence of a user interaction or a call to QCustomPlot::deselectAll. Subclasses should react to it by unsetting their selection appropriately.

                                    -

                                    just as in selectEvent, the output parameter selectionStateChanged (if non-null), must return true or false when the selection state of this layerable has changed or not changed, respectively.

                                    -
                                    See Also
                                    selectTest, selectEvent
                                    - -

                                    Reimplemented from QCPLayerable.

                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - - -
                                    QPointF QCPAbstractItem::anchorPixelPoint (int anchorId) const
                                    -
                                    -protectedvirtualinherited
                                    -
                                    -

                                    Returns the pixel position of the anchor with Id anchorId. This function must be reimplemented in item subclasses if they want to provide anchors (QCPItemAnchor).

                                    -

                                    For example, if the item has two anchors with id 0 and 1, this function takes one of these anchor ids and returns the respective pixel points of the specified anchor.

                                    -
                                    See Also
                                    createAnchor
                                    - -

                                    Reimplemented in QCPItemText, QCPItemPixmap, QCPItemEllipse, QCPItemBracket, and QCPItemRect.

                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - - - - - - - - - - - - - - - - - - -
                                    double QCPAbstractItem::distSqrToLine (const QPointF & start,
                                    const QPointF & end,
                                    const QPointF & point 
                                    ) const
                                    -
                                    -protectedinherited
                                    -
                                    -

                                    Finds the shortest squared distance of point to the line segment defined by start and end.

                                    -

                                    This function may be used to help with the implementation of the selectTest function for specific items.

                                    -
                                    Note
                                    This function is identical to QCPAbstractPlottable::distSqrToLine
                                    -
                                    See Also
                                    rectSelectTest
                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - - - - - - - - - - - - - - - - - - -
                                    double QCPAbstractItem::rectSelectTest (const QRectF & rect,
                                    const QPointF & pos,
                                    bool filledRect 
                                    ) const
                                    -
                                    -protectedinherited
                                    -
                                    -

                                    A convenience function which returns the selectTest value for a specified rect and a specified click position pos. filledRect defines whether a click inside the rect should also be considered a hit or whether only the rect border is sensitive to hits.

                                    -

                                    This function may be used to help with the implementation of the selectTest function for specific items.

                                    -

                                    For example, if your item consists of four rects, call this function four times, once for each rect, in your selectTest reimplementation. Finally, return the minimum of all four returned values which were greater or equal to zero. (Because this function may return -1.0 when pos doesn't hit rect at all). If all calls returned -1.0, return -1.0, too, because your item wasn't hit.

                                    -
                                    See Also
                                    distSqrToLine
                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - - -
                                    QCPItemPosition * QCPAbstractItem::createPosition (const QString & name)
                                    -
                                    -protectedinherited
                                    -
                                    -

                                    Creates a QCPItemPosition, registers it with this item and returns a pointer to it. The specified name must be a unique string that is usually identical to the variable name of the position member (This is needed to provide the name-based position access to positions).

                                    -

                                    Don't delete positions created by this function manually, as the item will take care of it.

                                    -

                                    Use this function in the constructor (initialization list) of the specific item subclass to create each position member. Don't create QCPItemPositions with new yourself, because they won't be registered with the item properly.

                                    -
                                    See Also
                                    createAnchor
                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - - - - - - - - - - - - -
                                    QCPItemAnchor * QCPAbstractItem::createAnchor (const QString & name,
                                    int anchorId 
                                    )
                                    -
                                    -protectedinherited
                                    -
                                    -

                                    Creates a QCPItemAnchor, registers it with this item and returns a pointer to it. The specified name must be a unique string that is usually identical to the variable name of the anchor member (This is needed to provide the name based anchor access to anchors).

                                    -

                                    The anchorId must be a number identifying the created anchor. It is recommended to create an enum (e.g. "AnchorIndex") for this on each item that uses anchors. This id is used by the anchor to identify itself when it calls QCPAbstractItem::anchorPixelPoint. That function then returns the correct pixel coordinates for the passed anchor id.

                                    -

                                    Don't delete anchors created by this function manually, as the item will take care of it.

                                    -

                                    Use this function in the constructor (initialization list) of the specific item subclass to create each anchor member. Don't create QCPItemAnchors with new yourself, because then they won't be registered with the item properly.

                                    -
                                    See Also
                                    createPosition
                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - -
                                    QCPLayerable * QCPLayerable::parentLayerable () const
                                    -
                                    -inlineinherited
                                    -
                                    -

                                    Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.

                                    -

                                    Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.

                                    -

                                    A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.

                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - - -
                                    void QCPLayerable::setVisible (bool on)
                                    -
                                    -inherited
                                    -
                                    -

                                    Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.

                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - - -
                                    bool QCPLayerable::setLayer (QCPLayerlayer)
                                    -
                                    -inherited
                                    -
                                    -

                                    Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.

                                    -

                                    Returns true on success, i.e. if layer is a valid layer.

                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - - -
                                    bool QCPLayerable::setLayer (const QString & layerName)
                                    -
                                    -inherited
                                    -
                                    -

                                    This is an overloaded function.

                                    -

                                    Sets the layer of this layerable object by name

                                    -

                                    Returns true on success, i.e. if layerName is a valid layer name.

                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - - -
                                    void QCPLayerable::setAntialiased (bool enabled)
                                    -
                                    -inherited
                                    -
                                    -

                                    Sets whether this object will be drawn antialiased or not.

                                    -

                                    Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - -
                                    bool QCPLayerable::realVisibility () const
                                    -
                                    -inherited
                                    -
                                    -

                                    Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.

                                    -

                                    If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.

                                    -

                                    If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.

                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - - -
                                    void QCPLayerable::parentPlotInitialized (QCustomPlotparentPlot)
                                    -
                                    -protectedvirtualinherited
                                    -
                                    -

                                    This function is called by initializeParentPlot, to allow subclasses to react on the setting of a parent plot. This is the case when 0 was passed as parent plot in the constructor, and the parent plot is set at a later time.

                                    -

                                    For example, QCPLayoutElement/QCPLayout hierarchies may be created independently of any QCustomPlot at first. When they are then added to a layout inside the QCustomPlot, the top level element of the hierarchy gets its parent plot initialized with initializeParentPlot. To propagate the parent plot to all the children of the hierarchy, the top level element then uses this function to pass the parent plot on to its child elements.

                                    -

                                    The default implementation does nothing.

                                    -
                                    See Also
                                    initializeParentPlot
                                    - -

                                    Reimplemented in QCPLegend, and QCPLayoutElement.

                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - - -
                                    void QCPLayerable::initializeParentPlot (QCustomPlotparentPlot)
                                    -
                                    -protectedinherited
                                    -
                                    -

                                    Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.

                                    -

                                    Note that, unlike when passing a non-null parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.

                                    -

                                    Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.

                                    -

                                    The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).

                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - - -
                                    void QCPLayerable::setParentLayerable (QCPLayerableparentLayerable)
                                    -
                                    -protectedinherited
                                    -
                                    -

                                    Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.

                                    -

                                    The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.

                                    -
                                    See Also
                                    realVisibility
                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - - - - - - - - - - - - -
                                    bool QCPLayerable::moveToLayer (QCPLayerlayer,
                                    bool prepend 
                                    )
                                    -
                                    -protectedinherited
                                    -
                                    -

                                    Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.

                                    -

                                    Returns true on success, i.e. if layer is a valid layer.

                                    - -
                                    -
                                    - -
                                    -
                                    - - - - - -
                                    - - - - - - - - - - - - - - - - - - - - - - - - -
                                    void QCPLayerable::applyAntialiasingHint (QCPPainterpainter,
                                    bool localAntialiased,
                                    QCP::AntialiasedElement overrideElement 
                                    ) const
                                    -
                                    -protectedinherited
                                    -
                                    -

                                    Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.

                                    - -
                                    -

                                    The documentation for this class was generated from the following files:
                                    • src/items/item-tracer.h
                                    • src/items/item-tracer.cpp
                                    • diff -Nru qcustomplot-1.1.0/documentation/html/classQCPLayerable.html qcustomplot-1.2.0/documentation/html/classQCPLayerable.html --- qcustomplot-1.1.0/documentation/html/classQCPLayerable.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPLayerable.html 2014-03-14 21:11:27.000000000 +0000 @@ -17,6 +17,7 @@
                                      QCPLayerable Class Reference
                                      @@ -30,7 +31,7 @@
                                      Inheritance graph
                                      - +
                                      - +

                                      @@ -46,12 +47,16 @@

                                      bool antialiased () const
                                      void setVisible (bool on)
                                      bool setLayer (QCPLayer *layer)
                                      Q_SLOT bool setLayer (QCPLayer *layer)
                                      bool setLayer (const QString &layerName)
                                      void setAntialiased (bool enabled)
                                      virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const
                                      bool realVisibility () const
                                      + + +

                                      +Signals

                                      void layerChanged (QCPLayer *newLayer)
                                      @@ -254,7 +259,7 @@

                                      You may pass 0 as details to indicate that you are not interested in those selection details.

                                      See Also
                                      selectEvent, deselectEvent, QCustomPlot::setInteractions
                                      -

                                      Reimplemented in QCPAxis, QCPLayoutInset, QCPLegend, QCPAbstractItem, QCPGraph, QCPLayoutElement, QCPCurve, QCPBars, QCPStatisticalBox, QCPItemTracer, QCPItemText, QCPAbstractPlottable, QCPAbstractLegendItem, QCPPlotTitle, QCPItemBracket, QCPItemPixmap, QCPItemCurve, QCPItemLine, QCPItemEllipse, QCPItemRect, and QCPItemStraightLine.

                                      +

                                      Reimplemented in QCPAxis, QCPLayoutInset, QCPLegend, QCPAbstractItem, QCPGraph, QCPColorMap, QCPLayoutElement, QCPCurve, QCPBars, QCPStatisticalBox, QCPItemTracer, QCPItemText, QCPAbstractPlottable, QCPAbstractLegendItem, QCPPlotTitle, QCPItemBracket, QCPItemPixmap, QCPItemCurve, QCPItemLine, QCPItemEllipse, QCPItemRect, and QCPItemStraightLine.

                                      @@ -270,12 +275,38 @@

                                      Protected Functions

                                      virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                                      -

                                      Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.

                                      +

                                      Returns whether this layerable is visible, taking the visibility of the layerable parent and the visibility of the layer this layerable is on into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.

                                      If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.

                                      If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.

                                      + +
                                      +
                                      + + + + + +
                                      + + + + + + + + +
                                      void QCPLayerable::layerChanged (QCPLayernewLayer)
                                      +
                                      +signal
                                      +
                                      +

                                      This signal is emitted when the layer of this layerable changes, i.e. this layerable is moved to a different layer.

                                      +
                                      See Also
                                      setLayer
                                      + +
                                      +
                                      @@ -386,7 +417,7 @@

                                      First example: QCPGraph has multiple entities that have an antialiasing setting: The graph line, fills, scatters and error bars. Those can be configured via QCPGraph::setAntialiased, QCPGraph::setAntialiasedFill, QCPGraph::setAntialiasedScatters etc. Consequently, there isn't only the QCPGraph::applyDefaultAntialiasingHint function (which corresponds to the graph line's antialiasing), but specialized ones like QCPGraph::applyFillAntialiasingHint and QCPGraph::applyScattersAntialiasingHint. So before drawing one of those entities, QCPGraph::draw calls the respective specialized applyAntialiasingHint function.

                                      Second example: QCPItemLine consists only of a line so there is only one antialiasing setting which can be controlled with QCPItemLine::setAntialiased. (This function is inherited by all layerables. The specialized functions, as seen on QCPGraph, must be added explicitly to the respective layerable subclass.) Consequently it only has the normal QCPItemLine::applyDefaultAntialiasingHint. The QCPItemLine::draw function doesn't need to care about setting any antialiasing states, because the default antialiasing hint is already set on the painter when the draw function is called, and that's the state it wants to draw the line with.

                                      -

                                      Implemented in QCPAxis, QCPLegend, QCPAbstractItem, QCPLayoutElement, QCPAxisRect, QCPAbstractPlottable, QCPAbstractLegendItem, QCPPlotTitle, and QCPGrid.

                                      +

                                      Implemented in QCPAxis, QCPLegend, QCPAbstractItem, QCPLayoutElement, QCPAxisRect, QCPColorScale, QCPAbstractPlottable, QCPAbstractLegendItem, QCPPlotTitle, and QCPGrid.

                                      @@ -414,7 +445,7 @@

                                      This function draws the layerable with the specified painter. It is only called by QCustomPlot, if the layerable is visible (setVisible).

                                      Before this function is called, the painter's antialiasing state is set via applyDefaultAntialiasingHint, see the documentation there. Further, the clipping rectangle was set to clipRect.

                                      -

                                      Implemented in QCPAxis, QCPLegend, QCPAbstractItem, QCPGraph, QCPLayoutElement, QCPAxisRect, QCPAbstractPlottable, QCPItemText, QCPPlottableLegendItem, QCPCurve, QCPItemTracer, QCPBars, QCPStatisticalBox, QCPAbstractLegendItem, QCPPlotTitle, QCPItemPixmap, QCPGrid, QCPItemEllipse, QCPItemBracket, QCPItemRect, QCPItemCurve, QCPItemLine, and QCPItemStraightLine.

                                      +

                                      Implemented in QCPAxis, QCPLegend, QCPAbstractItem, QCPGraph, QCPColorMap, QCPLayoutElement, QCPAxisRect, QCPAbstractPlottable, QCPPlottableLegendItem, QCPItemText, QCPCurve, QCPItemTracer, QCPBars, QCPStatisticalBox, QCPAbstractLegendItem, QCPPlotTitle, QCPItemPixmap, QCPGrid, QCPItemEllipse, QCPItemBracket, QCPItemRect, QCPItemCurve, QCPItemLine, and QCPItemStraightLine.

                                      @@ -463,7 +494,7 @@

                                      This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

                                      event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

                                      -

                                      Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

                                      +

                                      Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is fed back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

                                      selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

                                      See Also
                                      selectTest, deselectEvent
                                      Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/classQCPLayerable__inherit__graph.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/classQCPLayerable__inherit__graph.png differ diff -Nru qcustomplot-1.1.0/documentation/html/classQCPLayer.html qcustomplot-1.2.0/documentation/html/classQCPLayer.html --- qcustomplot-1.1.0/documentation/html/classQCPLayer.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPLayer.html 2014-03-14 21:11:26.000000000 +0000 @@ -35,6 +35,9 @@ QString name () const int index () const QList< QCPLayerable * > children () const + +bool visible () const +void setVisible (bool visible) @@ -131,6 +134,24 @@ + +
                                      +
                                      +

                                      Protected Functions

                                      + + + + + + + +
                                      void QCPLayer::setVisible (bool visible)
                                      +
                                      +

                                      Sets whether this layer is visible or not. If visible is set to false, all layerables on this layer will be invisible.

                                      +

                                      This function doesn't change the visibility property of the layerables (QCPLayerable::setVisible), but the QCPLayerable::realVisibility of each layerable takes the visibility of the parent layer into account.

                                      + +
                                      +
                                      diff -Nru qcustomplot-1.1.0/documentation/html/classQCPLayoutElement.html qcustomplot-1.2.0/documentation/html/classQCPLayoutElement.html --- qcustomplot-1.1.0/documentation/html/classQCPLayoutElement.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPLayoutElement.html 2014-03-14 21:11:27.000000000 +0000 @@ -16,6 +16,7 @@
                                      @@ -30,9 +31,13 @@
                                      Inheritance graph
                                      - +
                                      + + +

                                      +Public Types

                                      enum  UpdatePhase
                                      @@ -64,25 +69,27 @@ - + - + + - - - + - - - - - - + + + + +

                                      Public Functions

                                       QCPLayoutElement (QCustomPlot *parentPlot=0)
                                      void setMaximumSize (const QSize &size)
                                      void setMaximumSize (int width, int height)
                                      void setMarginGroup (QCP::MarginSides sides, QCPMarginGroup *group)
                                      virtual void update ()
                                      virtual void update (UpdatePhase phase)
                                      virtual QSize minimumSizeHint () const
                                      virtual QSize maximumSizeHint () const
                                      virtual QList< QCPLayoutElement * > elements (bool recursive) const
                                      virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const
                                      +
                                      - Public Functions inherited from QCPLayerable
                                       QCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0)
                                      bool visible () const
                                      +
                                      QCustomPlotparentPlot () const
                                      QCPLayerableparentLayerable () const
                                      +
                                      QCPLayerableparentLayerable () const
                                      QCPLayerlayer () const
                                      +
                                      bool antialiased () const
                                      void setVisible (bool on)
                                      bool setLayer (QCPLayer *layer)
                                      bool setLayer (const QString &layerName)
                                      void setAntialiased (bool enabled)
                                      bool realVisibility () const
                                      void setVisible (bool on)
                                      Q_SLOT bool setLayer (QCPLayer *layer)
                                      bool setLayer (const QString &layerName)
                                      void setAntialiased (bool enabled)
                                      bool realVisibility () const
                                      @@ -95,14 +102,20 @@ - - - - - - - - + + + + + + + + + +

                                      Protected Functions

                                      virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
                                      virtual void draw (QCPPainter *painter)
                                      virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                                      virtual QCP::Interaction selectionCategory () const
                                      virtual QRect clipRect () const
                                      virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                                      virtual void deselectEvent (bool *selectionStateChanged)
                                      void initializeParentPlot (QCustomPlot *parentPlot)
                                      void setParentLayerable (QCPLayerable *parentLayerable)
                                      bool moveToLayer (QCPLayer *layer, bool prepend)
                                      void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                                      - Protected Functions inherited from QCPLayerable
                                      virtual QCP::Interaction selectionCategory () const
                                      virtual QRect clipRect () const
                                      virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                                      virtual void deselectEvent (bool *selectionStateChanged)
                                      void initializeParentPlot (QCustomPlot *parentPlot)
                                      void setParentLayerable (QCPLayerable *parentLayerable)
                                      bool moveToLayer (QCPLayer *layer, bool prepend)
                                      void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                                      + + +

                                      +Additional Inherited Members

                                      - Signals inherited from QCPLayerable
                                      void layerChanged (QCPLayer *newLayer)

                                      Detailed Description

                                      The abstract base class for all objects that form the layout system.

                                      @@ -110,7 +123,34 @@

                                      A Layout element is a rectangular object which can be placed in layouts. It has an outer rect (QCPLayoutElement::outerRect) and an inner rect (QCPLayoutElement::rect). The difference between outer and inner rect is called its margin. The margin can either be set to automatic or manual (setAutoMargins) on a per-side basis. If a side is set to manual, that margin can be set explicitly with setMargins and will stay fixed at that value. If it's set to automatic, the layout element subclass will control the value itself (via calculateAutoMargin).

                                      Layout elements can be placed in layouts (base class QCPLayout) like QCPLayoutGrid. The top level layout is reachable via QCustomPlot::plotLayout, and is a QCPLayoutGrid. Since QCPLayout itself derives from QCPLayoutElement, layouts can be nested.

                                      Thus in QCustomPlot one can divide layout elements into two categories: The ones that are invisible by themselves, because they don't draw anything. Their only purpose is to manage the position and size of other layout elements. This category of layout elements usually use QCPLayout as base class. Then there is the category of layout elements which actually draw something. For example, QCPAxisRect, QCPLegend and QCPPlotTitle are of this category. This does not necessarily mean that the latter category can't have child layout elements. QCPLegend for instance, actually derives from QCPLayoutGrid and the individual legend items are child layout elements in the grid layout.

                                      -

                                      Constructor & Destructor Documentation

                                      +

                                      Member Enumeration Documentation

                                      + +
                                      +
                                      +

                                      Defines the phases of the update process, that happens just before a replot. At each phase, update is called with the according UpdatePhase value.

                                      +
                                      Enumerator:
                                      + + + +
                                      upPreparation  +

                                      Phase used for any type of preparation that needs to be done before margin calculation and layout.

                                      +
                                      upMargins  +

                                      Phase in which the margins are calculated and set.

                                      +
                                      upLayout  +

                                      Final phase in which the layout system places the rects of the elements.

                                      +
                                      +
                                      +
                                      + +
                                      +
                                      +

                                      Constructor & Destructor Documentation

                                      @@ -384,7 +424,7 @@
                                      - +
                                      @@ -394,7 +434,8 @@ - + +
                                      void QCPLayoutElement::update ()UpdatePhase phase)
                                      @@ -404,11 +445,11 @@
                                      -

                                      Updates the layout element and sub-elements. This function is automatically called upon replot by the parent layout element.

                                      -

                                      Layout elements that have child elements should call the update method of their child elements.

                                      -

                                      The default implementation executes the automatic margin mechanism, so subclasses should make sure to call the base class implementation.

                                      +

                                      Updates the layout element and sub-elements. This function is automatically called before every replot by the parent layout element. It is called multiple times, once for every UpdatePhase. The phases are run through in the order of the enum values. For details about what happens at the different phases, see the documentation of UpdatePhase.

                                      +

                                      Layout elements that have child elements should call the update method of their child elements, and pass the current phase unchanged.

                                      +

                                      The default implementation executes the automatic margin mechanism in the upMargins phase. Subclasses should make sure to call the base class implementation.

                                      -

                                      Reimplemented in QCPLayout, and QCPAxisRect.

                                      +

                                      Reimplemented in QCPLayout, QCPColorScale, and QCPAxisRect.

                                      @@ -488,7 +529,7 @@

                                      Returns a list of all child elements in this layout element. If recursive is true, all sub-child elements are included in the list, too.

                                      -

                                      Note that there may be entries with value 0 in the returned list. (For example, QCPLayoutGrid may have empty cells which yield 0 at the respective index.)

                                      +
                                      Warning
                                      There may be entries with value 0 in the returned list. (For example, QCPLayoutGrid may have empty cells which yield 0 at the respective index.)

                                      Reimplemented in QCPLayoutGrid, QCPLayout, and QCPAxisRect.

                                      @@ -592,7 +633,7 @@

                                      This event is called, if the mouse was pressed while being inside the outer rect of this layout element.

                                      -

                                      Reimplemented in QCPAxisRect.

                                      +

                                      Reimplemented in QCPAxisRect, and QCPColorScale.

                                      @@ -619,7 +660,7 @@

                                      This event is called, if the mouse is moved inside the outer rect of this layout element.

                                      -

                                      Reimplemented in QCPAxisRect.

                                      +

                                      Reimplemented in QCPAxisRect, and QCPColorScale.

                                      @@ -646,7 +687,7 @@

                                      This event is called, if the mouse was previously pressed inside the outer rect of this layout element and is now released.

                                      -

                                      Reimplemented in QCPAxisRect.

                                      +

                                      Reimplemented in QCPAxisRect, and QCPColorScale.

                                      @@ -698,7 +739,7 @@

                                      This event is called, if the mouse wheel is scrolled while the cursor is inside the rect of this layout element.

                                      -

                                      Reimplemented in QCPAxisRect.

                                      +

                                      Reimplemented in QCPAxisRect, and QCPColorScale.

                                      @@ -729,7 +770,7 @@

                                      Implements QCPLayerable.

                                      -

                                      Reimplemented in QCPLegend, QCPAxisRect, QCPAbstractLegendItem, and QCPPlotTitle.

                                      +

                                      Reimplemented in QCPLegend, QCPAxisRect, QCPColorScale, QCPAbstractLegendItem, and QCPPlotTitle.

                                      @@ -792,431 +833,6 @@ - -
                                      -
                                      - - - - - -
                                      - - - - - - - -
                                      QCPLayerable * QCPLayerable::parentLayerable () const
                                      -
                                      -inlineinherited
                                      -
                                      -

                                      Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.

                                      -

                                      Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.

                                      -

                                      A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.

                                      - -
                                      -
                                      - -
                                      -
                                      - - - - - -
                                      - - - - - - - - -
                                      void QCPLayerable::setVisible (bool on)
                                      -
                                      -inherited
                                      -
                                      -

                                      Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.

                                      - -
                                      -
                                      - -
                                      -
                                      - - - - - -
                                      - - - - - - - - -
                                      bool QCPLayerable::setLayer (QCPLayerlayer)
                                      -
                                      -inherited
                                      -
                                      -

                                      Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.

                                      -

                                      Returns true on success, i.e. if layer is a valid layer.

                                      - -
                                      -
                                      - -
                                      -
                                      - - - - - -
                                      - - - - - - - - -
                                      bool QCPLayerable::setLayer (const QString & layerName)
                                      -
                                      -inherited
                                      -
                                      -

                                      This is an overloaded function.

                                      -

                                      Sets the layer of this layerable object by name

                                      -

                                      Returns true on success, i.e. if layerName is a valid layer name.

                                      - -
                                      -
                                      - -
                                      -
                                      - - - - - -
                                      - - - - - - - - -
                                      void QCPLayerable::setAntialiased (bool enabled)
                                      -
                                      -inherited
                                      -
                                      -

                                      Sets whether this object will be drawn antialiased or not.

                                      -

                                      Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                                      - -
                                      -
                                      - -
                                      -
                                      - - - - - -
                                      - - - - - - - -
                                      bool QCPLayerable::realVisibility () const
                                      -
                                      -inherited
                                      -
                                      -

                                      Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.

                                      -

                                      If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.

                                      -

                                      If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.

                                      - -
                                      -
                                      - -
                                      -
                                      - - - - - -
                                      - - - - - - - -
                                      QCP::Interaction QCPLayerable::selectionCategory () const
                                      -
                                      -protectedvirtualinherited
                                      -
                                      -

                                      Returns the selection category this layerable shall belong to. The selection category is used in conjunction with QCustomPlot::setInteractions to control which objects are selectable and which aren't.

                                      -

                                      Subclasses that don't fit any of the normal QCP::Interaction values can use QCP::iSelectOther. This is what the default implementation returns.

                                      -
                                      See Also
                                      QCustomPlot::setInteractions
                                      - -

                                      Reimplemented in QCPAxis, QCPLegend, QCPAbstractItem, QCPAbstractPlottable, and QCPAbstractLegendItem.

                                      - -
                                      -
                                      - -
                                      -
                                      - - - - - -
                                      - - - - - - - -
                                      QRect QCPLayerable::clipRect () const
                                      -
                                      -protectedvirtualinherited
                                      -
                                      -

                                      Returns the clipping rectangle of this layerable object. By default, this is the viewport of the parent QCustomPlot. Specific subclasses may reimplement this function to provide different clipping rects.

                                      -

                                      The returned clipping rect is set on the painter before the draw function of the respective object is called.

                                      - -

                                      Reimplemented in QCPAbstractItem, QCPAbstractPlottable, and QCPAbstractLegendItem.

                                      - -
                                      -
                                      - -
                                      -
                                      - - - - - -
                                      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                                      void QCPLayerable::selectEvent (QMouseEvent * event,
                                      bool additive,
                                      const QVariant & details,
                                      bool * selectionStateChanged 
                                      )
                                      -
                                      -protectedvirtualinherited
                                      -
                                      -

                                      This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

                                      -

                                      event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

                                      -

                                      Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

                                      -

                                      selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

                                      -
                                      See Also
                                      selectTest, deselectEvent
                                      - -

                                      Reimplemented in QCPAxis, QCPLegend, QCPAbstractItem, QCPAbstractPlottable, QCPPlotTitle, and QCPAbstractLegendItem.

                                      - -
                                      -
                                      - -
                                      -
                                      - - - - - -
                                      - - - - - - - - -
                                      void QCPLayerable::deselectEvent (bool * selectionStateChanged)
                                      -
                                      -protectedvirtualinherited
                                      -
                                      -

                                      This event is called when the layerable shall be deselected, either as consequence of a user interaction or a call to QCustomPlot::deselectAll. Subclasses should react to it by unsetting their selection appropriately.

                                      -

                                      just as in selectEvent, the output parameter selectionStateChanged (if non-null), must return true or false when the selection state of this layerable has changed or not changed, respectively.

                                      -
                                      See Also
                                      selectTest, selectEvent
                                      - -

                                      Reimplemented in QCPAxis, QCPLegend, QCPAbstractItem, QCPAbstractPlottable, QCPPlotTitle, and QCPAbstractLegendItem.

                                      - -
                                      -
                                      - -
                                      -
                                      - - - - - -
                                      - - - - - - - - -
                                      void QCPLayerable::initializeParentPlot (QCustomPlotparentPlot)
                                      -
                                      -protectedinherited
                                      -
                                      -

                                      Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.

                                      -

                                      Note that, unlike when passing a non-null parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.

                                      -

                                      Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.

                                      -

                                      The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).

                                      - -
                                      -
                                      - -
                                      -
                                      - - - - - -
                                      - - - - - - - - -
                                      void QCPLayerable::setParentLayerable (QCPLayerableparentLayerable)
                                      -
                                      -protectedinherited
                                      -
                                      -

                                      Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.

                                      -

                                      The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.

                                      -
                                      See Also
                                      realVisibility
                                      - -
                                      -
                                      - -
                                      -
                                      - - - - - -
                                      - - - - - - - - - - - - - - - - - - -
                                      bool QCPLayerable::moveToLayer (QCPLayerlayer,
                                      bool prepend 
                                      )
                                      -
                                      -protectedinherited
                                      -
                                      -

                                      Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.

                                      -

                                      Returns true on success, i.e. if layer is a valid layer.

                                      - -
                                      -
                                      - -
                                      -
                                      - - - - - -
                                      - - - - - - - - - - - - - - - - - - - - - - - - -
                                      void QCPLayerable::applyAntialiasingHint (QCPPainterpainter,
                                      bool localAntialiased,
                                      QCP::AntialiasedElement overrideElement 
                                      ) const
                                      -
                                      -protectedinherited
                                      -
                                      -

                                      Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.

                                      - -
                                      -

                                      The documentation for this class was generated from the following files:
                                      • src/layout.h
                                      • src/layout.cpp
                                      • Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/classQCPLayoutElement__inherit__graph.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/classQCPLayoutElement__inherit__graph.png differ diff -Nru qcustomplot-1.1.0/documentation/html/classQCPLayoutGrid.html qcustomplot-1.2.0/documentation/html/classQCPLayoutGrid.html --- qcustomplot-1.1.0/documentation/html/classQCPLayoutGrid.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPLayoutGrid.html 2014-03-14 21:11:27.000000000 +0000 @@ -67,79 +67,95 @@ void expandTo (int newRowCount, int newColumnCount) void insertRow (int newIndex) void insertColumn (int newIndex) -virtual void update () -bool removeAt (int index) -bool remove (QCPLayoutElement *element) -void clear () -QCPLayoutlayout () const -QRect rect () const - +- Public Functions inherited from QCPLayoutQCPLayout () +virtual void update (UpdatePhase phase) +bool removeAt (int index) +bool remove (QCPLayoutElement *element) +void clear () +- Public Functions inherited from QCPLayoutElementQCPLayoutElement (QCustomPlot *parentPlot=0) +QCPLayoutlayout () const +QRect rect () const + QRect outerRect () const - + QMargins margins () const - + QMargins minimumMargins () const - + QCP::MarginSides autoMargins () const - + QSize minimumSize () const - + QSize maximumSize () const - + QCPMarginGroupmarginGroup (QCP::MarginSide side) const - + QHash< QCP::MarginSide,
                                        QCPMarginGroup * > marginGroups () const -void setOuterRect (const QRect &rect) -void setMargins (const QMargins &margins) -void setMinimumMargins (const QMargins &margins) -void setAutoMargins (QCP::MarginSides sides) -void setMinimumSize (const QSize &size) -void setMinimumSize (int width, int height) -void setMaximumSize (const QSize &size) -void setMaximumSize (int width, int height) -void setMarginGroup (QCP::MarginSides sides, QCPMarginGroup *group) -virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const - +void setOuterRect (const QRect &rect) +void setMargins (const QMargins &margins) +void setMinimumMargins (const QMargins &margins) +void setAutoMargins (QCP::MarginSides sides) +void setMinimumSize (const QSize &size) +void setMinimumSize (int width, int height) +void setMaximumSize (const QSize &size) +void setMaximumSize (int width, int height) +void setMarginGroup (QCP::MarginSides sides, QCPMarginGroup *group) +virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const +- Public Functions inherited from QCPLayerableQCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0) + bool visible () const - + QCustomPlotparentPlot () const -QCPLayerableparentLayerable () const - +QCPLayerableparentLayerable () const + QCPLayerlayer () const - + bool antialiased () const -void setVisible (bool on) -bool setLayer (QCPLayer *layer) -bool setLayer (const QString &layerName) -void setAntialiased (bool enabled) -bool realVisibility () const +void setVisible (bool on) +Q_SLOT bool setLayer (QCPLayer *layer) +bool setLayer (const QString &layerName) +void setAntialiased (bool enabled) +bool realVisibility () const - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + +

                                        Protected Functions

                                        void getMinimumRowColSizes (QVector< int > *minColWidths, QVector< int > *minRowHeights) const
                                        void getMaximumRowColSizes (QVector< int > *maxColWidths, QVector< int > *maxRowHeights) const
                                        void sizeConstraintsChanged () const
                                        void adoptElement (QCPLayoutElement *el)
                                        void releaseElement (QCPLayoutElement *el)
                                        QVector< int > getSectionSizes (QVector< int > maxSizes, QVector< int > minSizes, QVector< double > stretchFactors, int totalSize) const
                                        virtual int calculateAutoMargin (QCP::MarginSide side)
                                        virtual void mousePressEvent (QMouseEvent *event)
                                        virtual void mouseMoveEvent (QMouseEvent *event)
                                        virtual void mouseReleaseEvent (QMouseEvent *event)
                                        virtual void mouseDoubleClickEvent (QMouseEvent *event)
                                        virtual void wheelEvent (QWheelEvent *event)
                                        virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
                                        virtual void draw (QCPPainter *painter)
                                        virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                                        virtual QCP::Interaction selectionCategory () const
                                        virtual QRect clipRect () const
                                        virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                                        virtual void deselectEvent (bool *selectionStateChanged)
                                        void initializeParentPlot (QCustomPlot *parentPlot)
                                        void setParentLayerable (QCPLayerable *parentLayerable)
                                        bool moveToLayer (QCPLayer *layer, bool prepend)
                                        void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                                        - Protected Functions inherited from QCPLayout
                                        void sizeConstraintsChanged () const
                                        void adoptElement (QCPLayoutElement *el)
                                        void releaseElement (QCPLayoutElement *el)
                                        QVector< int > getSectionSizes (QVector< int > maxSizes, QVector< int > minSizes, QVector< double > stretchFactors, int totalSize) const
                                        - Protected Functions inherited from QCPLayoutElement
                                        virtual int calculateAutoMargin (QCP::MarginSide side)
                                        virtual void mousePressEvent (QMouseEvent *event)
                                        virtual void mouseMoveEvent (QMouseEvent *event)
                                        virtual void mouseReleaseEvent (QMouseEvent *event)
                                        virtual void mouseDoubleClickEvent (QMouseEvent *event)
                                        virtual void wheelEvent (QWheelEvent *event)
                                        virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
                                        virtual void draw (QCPPainter *painter)
                                        virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                                        - Protected Functions inherited from QCPLayerable
                                        virtual QCP::Interaction selectionCategory () const
                                        virtual QRect clipRect () const
                                        virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                                        virtual void deselectEvent (bool *selectionStateChanged)
                                        void initializeParentPlot (QCustomPlot *parentPlot)
                                        void setParentLayerable (QCPLayerable *parentLayerable)
                                        bool moveToLayer (QCPLayer *layer, bool prepend)
                                        void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                                        + + + + +

                                        +Additional Inherited Members

                                        - Public Types inherited from QCPLayoutElement
                                        enum  UpdatePhase
                                        - Signals inherited from QCPLayerable
                                        void layerChanged (QCPLayer *newLayer)

                                        Detailed Description

                                        A layout that arranges child elements in a grid.

                                        @@ -365,7 +381,7 @@

                                        Subclasses reimplement this method to update the position and sizes of the child elements/cells via calling their QCPLayoutElement::setOuterRect. The default implementation does nothing.

                                        The geometry used as a reference is the inner rect of this layout. Child elements should stay within that rect.

                                        getSectionSizes may help with the reimplementation of this function.

                                        -
                                        See Also
                                        update
                                        +
                                        See Also
                                        update

                                        Reimplemented from QCPLayout.

                                        @@ -509,7 +525,7 @@

                                        Returns a list of all child elements in this layout element. If recursive is true, all sub-child elements are included in the list, too.

                                        -

                                        Note that there may be entries with value 0 in the returned list. (For example, QCPLayoutGrid may have empty cells which yield 0 at the respective index.)

                                        +
                                        Warning
                                        There may be entries with value 0 in the returned list. (For example, QCPLayoutGrid may have empty cells which yield 0 at the respective index.)

                                        Reimplemented from QCPLayout.

                                        @@ -830,1287 +846,6 @@
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - -
                                        void QCPLayout::update ()
                                        -
                                        -virtualinherited
                                        -
                                        -

                                        First calls the QCPLayoutElement::update base class implementation to update the margins on this layout.

                                        -

                                        Then calls updateLayout which subclasses reimplement to reposition and resize their cells.

                                        -

                                        Finally, update is called on all child elements.

                                        - -

                                        Reimplemented from QCPLayoutElement.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - -
                                        bool QCPLayout::removeAt (int index)
                                        -
                                        -inherited
                                        -
                                        -

                                        Removes and deletes the element at the provided index. Returns true on success. If index is invalid or points to an empty cell, returns false.

                                        -

                                        This function internally uses takeAt to remove the element from the layout and then deletes the returned element.

                                        -
                                        See Also
                                        remove, takeAt
                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - -
                                        bool QCPLayout::remove (QCPLayoutElementelement)
                                        -
                                        -inherited
                                        -
                                        -

                                        Removes and deletes the provided element. Returns true on success. If element is not in the layout, returns false.

                                        -

                                        This function internally uses takeAt to remove the element from the layout and then deletes the element.

                                        -
                                        See Also
                                        removeAt, take
                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - -
                                        void QCPLayout::clear ()
                                        -
                                        -inherited
                                        -
                                        -

                                        Removes and deletes all layout elements in this layout.

                                        -
                                        See Also
                                        remove, removeAt
                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - -
                                        void QCPLayout::sizeConstraintsChanged () const
                                        -
                                        -protectedinherited
                                        -
                                        -

                                        Subclasses call this method to report changed (minimum/maximum) size constraints.

                                        -

                                        If the parent of this layout is again a QCPLayout, forwards the call to the parent's sizeConstraintsChanged. If the parent is a QWidget (i.e. is the QCustomPlot::plotLayout of QCustomPlot), calls QWidget::updateGeometry, so if the QCustomPlot widget is inside a Qt QLayout, it may update itself and resize cells accordingly.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - -
                                        void QCPLayout::adoptElement (QCPLayoutElementel)
                                        -
                                        -protectedinherited
                                        -
                                        -

                                        Associates el with this layout. This is done by setting the QCPLayoutElement::layout, the QCPLayerable::parentLayerable and the QObject parent to this layout.

                                        -

                                        Further, if el didn't previously have a parent plot, calls QCPLayerable::initializeParentPlot on el to set the paret plot.

                                        -

                                        This method is used by subclass specific methods that add elements to the layout. Note that this method only changes properties in el. The removal from the old layout and the insertion into the new layout must be done additionally.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - -
                                        void QCPLayout::releaseElement (QCPLayoutElementel)
                                        -
                                        -protectedinherited
                                        -
                                        -

                                        Disassociates el from this layout. This is done by setting the QCPLayoutElement::layout and the QCPLayerable::parentLayerable to zero. The QObject parent is set to the parent QCustomPlot.

                                        -

                                        This method is used by subclass specific methods that remove elements from the layout (e.g. take or takeAt). Note that this method only changes properties in el. The removal from the old layout must be done additionally.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                                        QVector< int > QCPLayout::getSectionSizes (QVector< int > maxSizes,
                                        QVector< int > minSizes,
                                        QVector< double > stretchFactors,
                                        int totalSize 
                                        ) const
                                        -
                                        -protectedinherited
                                        -
                                        -

                                        This is a helper function for the implementation of updateLayout in subclasses.

                                        -

                                        It calculates the sizes of one-dimensional sections with provided constraints on maximum section sizes, minimum section sizes, relative stretch factors and the final total size of all sections.

                                        -

                                        The QVector entries refer to the sections. Thus all QVectors must have the same size.

                                        -

                                        maxSizes gives the maximum allowed size of each section. If there shall be no maximum size imposed, set all vector values to Qt's QWIDGETSIZE_MAX.

                                        -

                                        minSizes gives the minimum allowed size of each section. If there shall be no minimum size imposed, set all vector values to zero. If the minSizes entries add up to a value greater than totalSize, sections will be scaled smaller than the proposed minimum sizes. (In other words, not exceeding the allowed total size is taken to be more important than not going below minimum section sizes.)

                                        -

                                        stretchFactors give the relative proportions of the sections to each other. If all sections shall be scaled equally, set all values equal. If the first section shall be double the size of each individual other section, set the first number of stretchFactors to double the value of the other individual values (e.g. {2, 1, 1, 1}).

                                        -

                                        totalSize is the value that the final section sizes will add up to. Due to rounding, the actual sum may differ slightly. If you want the section sizes to sum up to exactly that value, you could distribute the remaining difference on the sections.

                                        -

                                        The return value is a QVector containing the section sizes.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - -
                                        QCPLayout * QCPLayoutElement::layout () const
                                        -
                                        -inlineinherited
                                        -
                                        -

                                        Returns the parent layout of this layout element.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - -
                                        QRect QCPLayoutElement::rect () const
                                        -
                                        -inlineinherited
                                        -
                                        -

                                        Returns the inner rect of this layout element. The inner rect is the outer rect (setOuterRect) shrinked by the margins (setMargins, setAutoMargins).

                                        -

                                        In some cases, the area between outer and inner rect is left blank. In other cases the margin area is used to display peripheral graphics while the main content is in the inner rect. This is where automatic margin calculation becomes interesting because it allows the layout element to adapt the margins to the peripheral graphics it wants to draw. For example, QCPAxisRect draws the axis labels and tick labels in the margin area, thus needs to adjust the margins (if setAutoMargins is enabled) according to the space required by the labels of the axes.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - -
                                        void QCPLayoutElement::setOuterRect (const QRect & rect)
                                        -
                                        -inherited
                                        -
                                        -

                                        Sets the outer rect of this layout element. If the layout element is inside a layout, the layout sets the position and size of this layout element using this function.

                                        -

                                        Calling this function externally has no effect, since the layout will overwrite any changes to the outer rect upon the next replot.

                                        -

                                        The layout element will adapt its inner rect by applying the margins inward to the outer rect.

                                        -
                                        See Also
                                        rect
                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - -
                                        void QCPLayoutElement::setMargins (const QMargins & margins)
                                        -
                                        -inherited
                                        -
                                        -

                                        Sets the margins of this layout element. If setAutoMargins is disabled for some or all sides, this function is used to manually set the margin on those sides. Sides that are still set to be handled automatically are ignored and may have any value in margins.

                                        -

                                        The margin is the distance between the outer rect (controlled by the parent layout via setOuterRect) and the inner rect (which usually contains the main content of this layout element).

                                        -
                                        See Also
                                        setAutoMargins
                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - -
                                        void QCPLayoutElement::setMinimumMargins (const QMargins & margins)
                                        -
                                        -inherited
                                        -
                                        -

                                        If setAutoMargins is enabled on some or all margins, this function is used to provide minimum values for those margins.

                                        -

                                        The minimum values are not enforced on margin sides that were set to be under manual control via setAutoMargins.

                                        -
                                        See Also
                                        setAutoMargins
                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - -
                                        void QCPLayoutElement::setAutoMargins (QCP::MarginSides sides)
                                        -
                                        -inherited
                                        -
                                        -

                                        Sets on which sides the margin shall be calculated automatically. If a side is calculated automatically, a minimum margin value may be provided with setMinimumMargins. If a side is set to be controlled manually, the value may be specified with setMargins.

                                        -

                                        Margin sides that are under automatic control may participate in a QCPMarginGroup (see setMarginGroup), to synchronize (align) it with other layout elements in the plot.

                                        -
                                        See Also
                                        setMinimumMargins, setMargins
                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - -
                                        void QCPLayoutElement::setMinimumSize (const QSize & size)
                                        -
                                        -inherited
                                        -
                                        -

                                        Sets the minimum size for the inner rect of this layout element. A parent layout tries to respect the size here by changing row/column sizes in the layout accordingly.

                                        -

                                        If the parent layout size is not sufficient to satisfy all minimum size constraints of its child layout elements, the layout may set a size that is actually smaller than size. QCustomPlot propagates the layout's size constraints to the outside by setting its own minimum QWidget size accordingly, so violations of size should be exceptions.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - - - - - - - - - - - -
                                        void QCPLayoutElement::setMinimumSize (int width,
                                        int height 
                                        )
                                        -
                                        -inherited
                                        -
                                        -

                                        This is an overloaded function.

                                        -

                                        Sets the minimum size for the inner rect of this layout element.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - -
                                        void QCPLayoutElement::setMaximumSize (const QSize & size)
                                        -
                                        -inherited
                                        -
                                        -

                                        Sets the maximum size for the inner rect of this layout element. A parent layout tries to respect the size here by changing row/column sizes in the layout accordingly.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - - - - - - - - - - - -
                                        void QCPLayoutElement::setMaximumSize (int width,
                                        int height 
                                        )
                                        -
                                        -inherited
                                        -
                                        -

                                        This is an overloaded function.

                                        -

                                        Sets the maximum size for the inner rect of this layout element.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - - - - - - - - - - - -
                                        void QCPLayoutElement::setMarginGroup (QCP::MarginSides sides,
                                        QCPMarginGroupgroup 
                                        )
                                        -
                                        -inherited
                                        -
                                        -

                                        Sets the margin group of the specified margin sides.

                                        -

                                        Margin groups allow synchronizing specified margins across layout elements, see the documentation of QCPMarginGroup.

                                        -

                                        To unset the margin group of sides, set group to 0.

                                        -

                                        Note that margin groups only work for margin sides that are set to automatic (setAutoMargins).

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - - - - - - - - - - - - - - - - - -
                                        double QCPLayoutElement::selectTest (const QPointF & pos,
                                        bool onlySelectable,
                                        QVariant * details = 0 
                                        ) const
                                        -
                                        -virtualinherited
                                        -
                                        -

                                        Layout elements are sensitive to events inside their outer rect. If pos is within the outer rect, this method returns a value corresponding to 0.99 times the parent plot's selection tolerance. However, layout elements are not selectable by default. So if onlySelectable is true, -1.0 is returned.

                                        -

                                        See QCPLayerable::selectTest for a general explanation of this virtual method.

                                        -

                                        QCPLayoutElement subclasses may reimplement this method to provide more specific selection test behaviour.

                                        - -

                                        Reimplemented from QCPLayerable.

                                        - -

                                        Reimplemented in QCPLayoutInset, QCPLegend, QCPAbstractLegendItem, and QCPPlotTitle.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - -
                                        int QCPLayoutElement::calculateAutoMargin (QCP::MarginSide side)
                                        -
                                        -protectedvirtualinherited
                                        -
                                        -

                                        Returns the margin size for this side. It is used if automatic margins is enabled for this side (see setAutoMargins). If a minimum margin was set with setMinimumMargins, the returned value will not be smaller than the specified minimum margin.

                                        -

                                        The default implementation just returns the respective manual margin (setMargins) or the minimum margin, whichever is larger.

                                        - -

                                        Reimplemented in QCPAxisRect.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - -
                                        void QCPLayoutElement::mousePressEvent (QMouseEvent * event)
                                        -
                                        -inlineprotectedvirtualinherited
                                        -
                                        -

                                        This event is called, if the mouse was pressed while being inside the outer rect of this layout element.

                                        - -

                                        Reimplemented in QCPAxisRect.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - -
                                        void QCPLayoutElement::mouseMoveEvent (QMouseEvent * event)
                                        -
                                        -inlineprotectedvirtualinherited
                                        -
                                        -

                                        This event is called, if the mouse is moved inside the outer rect of this layout element.

                                        - -

                                        Reimplemented in QCPAxisRect.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - -
                                        void QCPLayoutElement::mouseReleaseEvent (QMouseEvent * event)
                                        -
                                        -inlineprotectedvirtualinherited
                                        -
                                        -

                                        This event is called, if the mouse was previously pressed inside the outer rect of this layout element and is now released.

                                        - -

                                        Reimplemented in QCPAxisRect.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - -
                                        void QCPLayoutElement::mouseDoubleClickEvent (QMouseEvent * event)
                                        -
                                        -inlineprotectedvirtualinherited
                                        -
                                        -

                                        This event is called, if the mouse is double-clicked inside the outer rect of this layout element.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - -
                                        void QCPLayoutElement::wheelEvent (QWheelEvent * event)
                                        -
                                        -inlineprotectedvirtualinherited
                                        -
                                        -

                                        This event is called, if the mouse wheel is scrolled while the cursor is inside the rect of this layout element.

                                        - -

                                        Reimplemented in QCPAxisRect.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - -
                                        virtual void QCPLayoutElement::applyDefaultAntialiasingHint (QCPPainterpainter) const
                                        -
                                        -inlineprotectedvirtualinherited
                                        -
                                        -

                                        This function applies the default antialiasing setting to the specified painter, using the function applyAntialiasingHint. It is the antialiasing state the painter is put in, when draw is called on the layerable. If the layerable has multiple entities whose antialiasing setting may be specified individually, this function should set the antialiasing state of the most prominent entity. In this case however, the draw function usually calls the specialized versions of this function before drawing each entity, effectively overriding the setting of the default antialiasing hint.

                                        -

                                        First example: QCPGraph has multiple entities that have an antialiasing setting: The graph line, fills, scatters and error bars. Those can be configured via QCPGraph::setAntialiased, QCPGraph::setAntialiasedFill, QCPGraph::setAntialiasedScatters etc. Consequently, there isn't only the QCPGraph::applyDefaultAntialiasingHint function (which corresponds to the graph line's antialiasing), but specialized ones like QCPGraph::applyFillAntialiasingHint and QCPGraph::applyScattersAntialiasingHint. So before drawing one of those entities, QCPGraph::draw calls the respective specialized applyAntialiasingHint function.

                                        -

                                        Second example: QCPItemLine consists only of a line so there is only one antialiasing setting which can be controlled with QCPItemLine::setAntialiased. (This function is inherited by all layerables. The specialized functions, as seen on QCPGraph, must be added explicitly to the respective layerable subclass.) Consequently it only has the normal QCPItemLine::applyDefaultAntialiasingHint. The QCPItemLine::draw function doesn't need to care about setting any antialiasing states, because the default antialiasing hint is already set on the painter when the draw function is called, and that's the state it wants to draw the line with.

                                        - -

                                        Implements QCPLayerable.

                                        - -

                                        Reimplemented in QCPLegend, QCPAxisRect, QCPAbstractLegendItem, and QCPPlotTitle.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - -
                                        virtual void QCPLayoutElement::draw (QCPPainterpainter)
                                        -
                                        -inlineprotectedvirtualinherited
                                        -
                                        -

                                        This function draws the layerable with the specified painter. It is only called by QCustomPlot, if the layerable is visible (setVisible).

                                        -

                                        Before this function is called, the painter's antialiasing state is set via applyDefaultAntialiasingHint, see the documentation there. Further, the clipping rectangle was set to clipRect.

                                        - -

                                        Implements QCPLayerable.

                                        - -

                                        Reimplemented in QCPLegend, QCPAxisRect, QCPPlottableLegendItem, QCPAbstractLegendItem, and QCPPlotTitle.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - -
                                        void QCPLayoutElement::parentPlotInitialized (QCustomPlotparentPlot)
                                        -
                                        -protectedvirtualinherited
                                        -
                                        -

                                        propagates the parent plot initialization to all child elements, by calling QCPLayerable::initializeParentPlot on them.

                                        - -

                                        Reimplemented from QCPLayerable.

                                        - -

                                        Reimplemented in QCPLegend.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - -
                                        QCPLayerable * QCPLayerable::parentLayerable () const
                                        -
                                        -inlineinherited
                                        -
                                        -

                                        Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.

                                        -

                                        Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.

                                        -

                                        A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - -
                                        void QCPLayerable::setVisible (bool on)
                                        -
                                        -inherited
                                        -
                                        -

                                        Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - -
                                        bool QCPLayerable::setLayer (QCPLayerlayer)
                                        -
                                        -inherited
                                        -
                                        -

                                        Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.

                                        -

                                        Returns true on success, i.e. if layer is a valid layer.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - -
                                        bool QCPLayerable::setLayer (const QString & layerName)
                                        -
                                        -inherited
                                        -
                                        -

                                        This is an overloaded function.

                                        -

                                        Sets the layer of this layerable object by name

                                        -

                                        Returns true on success, i.e. if layerName is a valid layer name.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - -
                                        void QCPLayerable::setAntialiased (bool enabled)
                                        -
                                        -inherited
                                        -
                                        -

                                        Sets whether this object will be drawn antialiased or not.

                                        -

                                        Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - -
                                        bool QCPLayerable::realVisibility () const
                                        -
                                        -inherited
                                        -
                                        -

                                        Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.

                                        -

                                        If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.

                                        -

                                        If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - -
                                        QCP::Interaction QCPLayerable::selectionCategory () const
                                        -
                                        -protectedvirtualinherited
                                        -
                                        -

                                        Returns the selection category this layerable shall belong to. The selection category is used in conjunction with QCustomPlot::setInteractions to control which objects are selectable and which aren't.

                                        -

                                        Subclasses that don't fit any of the normal QCP::Interaction values can use QCP::iSelectOther. This is what the default implementation returns.

                                        -
                                        See Also
                                        QCustomPlot::setInteractions
                                        - -

                                        Reimplemented in QCPAxis, QCPLegend, QCPAbstractItem, QCPAbstractPlottable, and QCPAbstractLegendItem.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - -
                                        QRect QCPLayerable::clipRect () const
                                        -
                                        -protectedvirtualinherited
                                        -
                                        -

                                        Returns the clipping rectangle of this layerable object. By default, this is the viewport of the parent QCustomPlot. Specific subclasses may reimplement this function to provide different clipping rects.

                                        -

                                        The returned clipping rect is set on the painter before the draw function of the respective object is called.

                                        - -

                                        Reimplemented in QCPAbstractItem, QCPAbstractPlottable, and QCPAbstractLegendItem.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                                        void QCPLayerable::selectEvent (QMouseEvent * event,
                                        bool additive,
                                        const QVariant & details,
                                        bool * selectionStateChanged 
                                        )
                                        -
                                        -protectedvirtualinherited
                                        -
                                        -

                                        This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

                                        -

                                        event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

                                        -

                                        Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

                                        -

                                        selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

                                        -
                                        See Also
                                        selectTest, deselectEvent
                                        - -

                                        Reimplemented in QCPAxis, QCPLegend, QCPAbstractItem, QCPAbstractPlottable, QCPPlotTitle, and QCPAbstractLegendItem.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - -
                                        void QCPLayerable::deselectEvent (bool * selectionStateChanged)
                                        -
                                        -protectedvirtualinherited
                                        -
                                        -

                                        This event is called when the layerable shall be deselected, either as consequence of a user interaction or a call to QCustomPlot::deselectAll. Subclasses should react to it by unsetting their selection appropriately.

                                        -

                                        just as in selectEvent, the output parameter selectionStateChanged (if non-null), must return true or false when the selection state of this layerable has changed or not changed, respectively.

                                        -
                                        See Also
                                        selectTest, selectEvent
                                        - -

                                        Reimplemented in QCPAxis, QCPLegend, QCPAbstractItem, QCPAbstractPlottable, QCPPlotTitle, and QCPAbstractLegendItem.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - -
                                        void QCPLayerable::initializeParentPlot (QCustomPlotparentPlot)
                                        -
                                        -protectedinherited
                                        -
                                        -

                                        Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.

                                        -

                                        Note that, unlike when passing a non-null parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.

                                        -

                                        Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.

                                        -

                                        The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - -
                                        void QCPLayerable::setParentLayerable (QCPLayerableparentLayerable)
                                        -
                                        -protectedinherited
                                        -
                                        -

                                        Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.

                                        -

                                        The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.

                                        -
                                        See Also
                                        realVisibility
                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - - - - - - - - - - - -
                                        bool QCPLayerable::moveToLayer (QCPLayerlayer,
                                        bool prepend 
                                        )
                                        -
                                        -protectedinherited
                                        -
                                        -

                                        Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.

                                        -

                                        Returns true on success, i.e. if layer is a valid layer.

                                        - -
                                        -
                                        - -
                                        -
                                        - - - - - -
                                        - - - - - - - - - - - - - - - - - - - - - - - - -
                                        void QCPLayerable::applyAntialiasingHint (QCPPainterpainter,
                                        bool localAntialiased,
                                        QCP::AntialiasedElement overrideElement 
                                        ) const
                                        -
                                        -protectedinherited
                                        -
                                        -

                                        Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.

                                        - -
                                        -

                                        The documentation for this class was generated from the following files:
                                        • src/layout.h
                                        • src/layout.cpp
                                        • diff -Nru qcustomplot-1.1.0/documentation/html/classQCPLayout.html qcustomplot-1.2.0/documentation/html/classQCPLayout.html --- qcustomplot-1.1.0/documentation/html/classQCPLayout.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPLayout.html 2014-03-14 21:11:27.000000000 +0000 @@ -36,7 +36,7 @@

                                          Public Functions

                                           QCPLayout () -virtual void update () +virtual void update (UpdatePhase phase) virtual QList< QCPLayoutElement * > elements (bool recursive) const virtual int elementCount () const =0 virtual QCPLayoutElementelementAt (int index) const =0 @@ -46,51 +46,55 @@ bool removeAt (int index) bool remove (QCPLayoutElement *element) void clear () -QCPLayoutlayout () const -QRect rect () const - +- Public Functions inherited from QCPLayoutElementQCPLayoutElement (QCustomPlot *parentPlot=0) +QCPLayoutlayout () const +QRect rect () const + QRect outerRect () const - + QMargins margins () const - + QMargins minimumMargins () const - + QCP::MarginSides autoMargins () const - + QSize minimumSize () const - + QSize maximumSize () const - + QCPMarginGroupmarginGroup (QCP::MarginSide side) const - + QHash< QCP::MarginSide,
                                          QCPMarginGroup * > marginGroups () const -void setOuterRect (const QRect &rect) -void setMargins (const QMargins &margins) -void setMinimumMargins (const QMargins &margins) -void setAutoMargins (QCP::MarginSides sides) -void setMinimumSize (const QSize &size) -void setMinimumSize (int width, int height) -void setMaximumSize (const QSize &size) -void setMaximumSize (int width, int height) -void setMarginGroup (QCP::MarginSides sides, QCPMarginGroup *group) -virtual QSize minimumSizeHint () const -virtual QSize maximumSizeHint () const -virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const - +void setOuterRect (const QRect &rect) +void setMargins (const QMargins &margins) +void setMinimumMargins (const QMargins &margins) +void setAutoMargins (QCP::MarginSides sides) +void setMinimumSize (const QSize &size) +void setMinimumSize (int width, int height) +void setMaximumSize (const QSize &size) +void setMaximumSize (int width, int height) +void setMarginGroup (QCP::MarginSides sides, QCPMarginGroup *group) +virtual QSize minimumSizeHint () const +virtual QSize maximumSizeHint () const +virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const +- Public Functions inherited from QCPLayerableQCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0) + bool visible () const - + QCustomPlotparentPlot () const -QCPLayerableparentLayerable () const - +QCPLayerableparentLayerable () const + QCPLayerlayer () const - + bool antialiased () const -void setVisible (bool on) -bool setLayer (QCPLayer *layer) -bool setLayer (const QString &layerName) -void setAntialiased (bool enabled) -bool realVisibility () const +void setVisible (bool on) +Q_SLOT bool setLayer (QCPLayer *layer) +bool setLayer (const QString &layerName) +void setAntialiased (bool enabled) +bool realVisibility () const @@ -99,23 +103,32 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + +

                                          Protected Functions

                                          void adoptElement (QCPLayoutElement *el)
                                          void releaseElement (QCPLayoutElement *el)
                                          QVector< int > getSectionSizes (QVector< int > maxSizes, QVector< int > minSizes, QVector< double > stretchFactors, int totalSize) const
                                          virtual int calculateAutoMargin (QCP::MarginSide side)
                                          virtual void mousePressEvent (QMouseEvent *event)
                                          virtual void mouseMoveEvent (QMouseEvent *event)
                                          virtual void mouseReleaseEvent (QMouseEvent *event)
                                          virtual void mouseDoubleClickEvent (QMouseEvent *event)
                                          virtual void wheelEvent (QWheelEvent *event)
                                          virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
                                          virtual void draw (QCPPainter *painter)
                                          virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                                          virtual QCP::Interaction selectionCategory () const
                                          virtual QRect clipRect () const
                                          virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                                          virtual void deselectEvent (bool *selectionStateChanged)
                                          void initializeParentPlot (QCustomPlot *parentPlot)
                                          void setParentLayerable (QCPLayerable *parentLayerable)
                                          bool moveToLayer (QCPLayer *layer, bool prepend)
                                          void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                                          - Protected Functions inherited from QCPLayoutElement
                                          virtual int calculateAutoMargin (QCP::MarginSide side)
                                          virtual void mousePressEvent (QMouseEvent *event)
                                          virtual void mouseMoveEvent (QMouseEvent *event)
                                          virtual void mouseReleaseEvent (QMouseEvent *event)
                                          virtual void mouseDoubleClickEvent (QMouseEvent *event)
                                          virtual void wheelEvent (QWheelEvent *event)
                                          virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
                                          virtual void draw (QCPPainter *painter)
                                          virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                                          - Protected Functions inherited from QCPLayerable
                                          virtual QCP::Interaction selectionCategory () const
                                          virtual QRect clipRect () const
                                          virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                                          virtual void deselectEvent (bool *selectionStateChanged)
                                          void initializeParentPlot (QCustomPlot *parentPlot)
                                          void setParentLayerable (QCPLayerable *parentLayerable)
                                          bool moveToLayer (QCPLayer *layer, bool prepend)
                                          void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                                          + + + + +

                                          +Additional Inherited Members

                                          - Public Types inherited from QCPLayoutElement
                                          enum  UpdatePhase
                                          - Signals inherited from QCPLayerable
                                          void layerChanged (QCPLayer *newLayer)

                                          Detailed Description

                                          The abstract base class for layouts.

                                          @@ -145,12 +158,12 @@
                                          -

                                          Creates an instance of QCPLayoutElement and sets default values. Note that since QCPLayoutElement is an abstract base class, it can't be instantiated directly.

                                          +

                                          Creates an instance of QCPLayout and sets default values. Note that since QCPLayout is an abstract base class, it can't be instantiated directly.

                                          Member Function Documentation

                                          - +
                                          @@ -160,7 +173,8 @@ - + +
                                          void QCPLayout::update ()UpdatePhase phase)
                                          @@ -170,11 +184,11 @@
                                          -

                                          First calls the QCPLayoutElement::update base class implementation to update the margins on this layout.

                                          +

                                          First calls the QCPLayoutElement::update base class implementation to update the margins on this layout.

                                          Then calls updateLayout which subclasses reimplement to reposition and resize their cells.

                                          -

                                          Finally, update is called on all child elements.

                                          +

                                          Finally, update is called on all child elements.

                                          -

                                          Reimplemented from QCPLayoutElement.

                                          +

                                          Reimplemented from QCPLayoutElement.

                                          @@ -200,7 +214,7 @@

                                          Returns a list of all child elements in this layout element. If recursive is true, all sub-child elements are included in the list, too.

                                          -

                                          Note that there may be entries with value 0 in the returned list. (For example, QCPLayoutGrid may have empty cells which yield 0 at the respective index.)

                                          +
                                          Warning
                                          There may be entries with value 0 in the returned list. (For example, QCPLayoutGrid may have empty cells which yield 0 at the respective index.)

                                          Reimplemented from QCPLayoutElement.

                                          @@ -429,7 +443,7 @@

                                          Subclasses reimplement this method to update the position and sizes of the child elements/cells via calling their QCPLayoutElement::setOuterRect. The default implementation does nothing.

                                          The geometry used as a reference is the inner rect of this layout. Child elements should stay within that rect.

                                          getSectionSizes may help with the reimplementation of this function.

                                          -
                                          See Also
                                          update
                                          +
                                          See Also
                                          update

                                          Reimplemented in QCPLayoutInset, and QCPLayoutGrid.

                                          @@ -567,1102 +581,6 @@
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - -
                                          QCPLayout * QCPLayoutElement::layout () const
                                          -
                                          -inlineinherited
                                          -
                                          -

                                          Returns the parent layout of this layout element.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - -
                                          QRect QCPLayoutElement::rect () const
                                          -
                                          -inlineinherited
                                          -
                                          -

                                          Returns the inner rect of this layout element. The inner rect is the outer rect (setOuterRect) shrinked by the margins (setMargins, setAutoMargins).

                                          -

                                          In some cases, the area between outer and inner rect is left blank. In other cases the margin area is used to display peripheral graphics while the main content is in the inner rect. This is where automatic margin calculation becomes interesting because it allows the layout element to adapt the margins to the peripheral graphics it wants to draw. For example, QCPAxisRect draws the axis labels and tick labels in the margin area, thus needs to adjust the margins (if setAutoMargins is enabled) according to the space required by the labels of the axes.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - -
                                          void QCPLayoutElement::setOuterRect (const QRect & rect)
                                          -
                                          -inherited
                                          -
                                          -

                                          Sets the outer rect of this layout element. If the layout element is inside a layout, the layout sets the position and size of this layout element using this function.

                                          -

                                          Calling this function externally has no effect, since the layout will overwrite any changes to the outer rect upon the next replot.

                                          -

                                          The layout element will adapt its inner rect by applying the margins inward to the outer rect.

                                          -
                                          See Also
                                          rect
                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - -
                                          void QCPLayoutElement::setMargins (const QMargins & margins)
                                          -
                                          -inherited
                                          -
                                          -

                                          Sets the margins of this layout element. If setAutoMargins is disabled for some or all sides, this function is used to manually set the margin on those sides. Sides that are still set to be handled automatically are ignored and may have any value in margins.

                                          -

                                          The margin is the distance between the outer rect (controlled by the parent layout via setOuterRect) and the inner rect (which usually contains the main content of this layout element).

                                          -
                                          See Also
                                          setAutoMargins
                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - -
                                          void QCPLayoutElement::setMinimumMargins (const QMargins & margins)
                                          -
                                          -inherited
                                          -
                                          -

                                          If setAutoMargins is enabled on some or all margins, this function is used to provide minimum values for those margins.

                                          -

                                          The minimum values are not enforced on margin sides that were set to be under manual control via setAutoMargins.

                                          -
                                          See Also
                                          setAutoMargins
                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - -
                                          void QCPLayoutElement::setAutoMargins (QCP::MarginSides sides)
                                          -
                                          -inherited
                                          -
                                          -

                                          Sets on which sides the margin shall be calculated automatically. If a side is calculated automatically, a minimum margin value may be provided with setMinimumMargins. If a side is set to be controlled manually, the value may be specified with setMargins.

                                          -

                                          Margin sides that are under automatic control may participate in a QCPMarginGroup (see setMarginGroup), to synchronize (align) it with other layout elements in the plot.

                                          -
                                          See Also
                                          setMinimumMargins, setMargins
                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - -
                                          void QCPLayoutElement::setMinimumSize (const QSize & size)
                                          -
                                          -inherited
                                          -
                                          -

                                          Sets the minimum size for the inner rect of this layout element. A parent layout tries to respect the size here by changing row/column sizes in the layout accordingly.

                                          -

                                          If the parent layout size is not sufficient to satisfy all minimum size constraints of its child layout elements, the layout may set a size that is actually smaller than size. QCustomPlot propagates the layout's size constraints to the outside by setting its own minimum QWidget size accordingly, so violations of size should be exceptions.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - - - - - - - - - - - -
                                          void QCPLayoutElement::setMinimumSize (int width,
                                          int height 
                                          )
                                          -
                                          -inherited
                                          -
                                          -

                                          This is an overloaded function.

                                          -

                                          Sets the minimum size for the inner rect of this layout element.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - -
                                          void QCPLayoutElement::setMaximumSize (const QSize & size)
                                          -
                                          -inherited
                                          -
                                          -

                                          Sets the maximum size for the inner rect of this layout element. A parent layout tries to respect the size here by changing row/column sizes in the layout accordingly.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - - - - - - - - - - - -
                                          void QCPLayoutElement::setMaximumSize (int width,
                                          int height 
                                          )
                                          -
                                          -inherited
                                          -
                                          -

                                          This is an overloaded function.

                                          -

                                          Sets the maximum size for the inner rect of this layout element.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - - - - - - - - - - - -
                                          void QCPLayoutElement::setMarginGroup (QCP::MarginSides sides,
                                          QCPMarginGroupgroup 
                                          )
                                          -
                                          -inherited
                                          -
                                          -

                                          Sets the margin group of the specified margin sides.

                                          -

                                          Margin groups allow synchronizing specified margins across layout elements, see the documentation of QCPMarginGroup.

                                          -

                                          To unset the margin group of sides, set group to 0.

                                          -

                                          Note that margin groups only work for margin sides that are set to automatic (setAutoMargins).

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - -
                                          QSize QCPLayoutElement::minimumSizeHint () const
                                          -
                                          -virtualinherited
                                          -
                                          -

                                          Returns the minimum size this layout element (the inner rect) may be compressed to.

                                          -

                                          if a minimum size (setMinimumSize) was not set manually, parent layouts consult this function to determine the minimum allowed size of this layout element. (A manual minimum size is considered set if it is non-zero.)

                                          - -

                                          Reimplemented in QCPLayoutGrid, QCPPlottableLegendItem, and QCPPlotTitle.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - -
                                          QSize QCPLayoutElement::maximumSizeHint () const
                                          -
                                          -virtualinherited
                                          -
                                          -

                                          Returns the maximum size this layout element (the inner rect) may be expanded to.

                                          -

                                          if a maximum size (setMaximumSize) was not set manually, parent layouts consult this function to determine the maximum allowed size of this layout element. (A manual maximum size is considered set if it is smaller than Qt's QWIDGETSIZE_MAX.)

                                          - -

                                          Reimplemented in QCPLayoutGrid, and QCPPlotTitle.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - - - - - - - - - - - - - - - - - -
                                          double QCPLayoutElement::selectTest (const QPointF & pos,
                                          bool onlySelectable,
                                          QVariant * details = 0 
                                          ) const
                                          -
                                          -virtualinherited
                                          -
                                          -

                                          Layout elements are sensitive to events inside their outer rect. If pos is within the outer rect, this method returns a value corresponding to 0.99 times the parent plot's selection tolerance. However, layout elements are not selectable by default. So if onlySelectable is true, -1.0 is returned.

                                          -

                                          See QCPLayerable::selectTest for a general explanation of this virtual method.

                                          -

                                          QCPLayoutElement subclasses may reimplement this method to provide more specific selection test behaviour.

                                          - -

                                          Reimplemented from QCPLayerable.

                                          - -

                                          Reimplemented in QCPLayoutInset, QCPLegend, QCPAbstractLegendItem, and QCPPlotTitle.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - -
                                          int QCPLayoutElement::calculateAutoMargin (QCP::MarginSide side)
                                          -
                                          -protectedvirtualinherited
                                          -
                                          -

                                          Returns the margin size for this side. It is used if automatic margins is enabled for this side (see setAutoMargins). If a minimum margin was set with setMinimumMargins, the returned value will not be smaller than the specified minimum margin.

                                          -

                                          The default implementation just returns the respective manual margin (setMargins) or the minimum margin, whichever is larger.

                                          - -

                                          Reimplemented in QCPAxisRect.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - -
                                          void QCPLayoutElement::mousePressEvent (QMouseEvent * event)
                                          -
                                          -inlineprotectedvirtualinherited
                                          -
                                          -

                                          This event is called, if the mouse was pressed while being inside the outer rect of this layout element.

                                          - -

                                          Reimplemented in QCPAxisRect.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - -
                                          void QCPLayoutElement::mouseMoveEvent (QMouseEvent * event)
                                          -
                                          -inlineprotectedvirtualinherited
                                          -
                                          -

                                          This event is called, if the mouse is moved inside the outer rect of this layout element.

                                          - -

                                          Reimplemented in QCPAxisRect.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - -
                                          void QCPLayoutElement::mouseReleaseEvent (QMouseEvent * event)
                                          -
                                          -inlineprotectedvirtualinherited
                                          -
                                          -

                                          This event is called, if the mouse was previously pressed inside the outer rect of this layout element and is now released.

                                          - -

                                          Reimplemented in QCPAxisRect.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - -
                                          void QCPLayoutElement::mouseDoubleClickEvent (QMouseEvent * event)
                                          -
                                          -inlineprotectedvirtualinherited
                                          -
                                          -

                                          This event is called, if the mouse is double-clicked inside the outer rect of this layout element.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - -
                                          void QCPLayoutElement::wheelEvent (QWheelEvent * event)
                                          -
                                          -inlineprotectedvirtualinherited
                                          -
                                          -

                                          This event is called, if the mouse wheel is scrolled while the cursor is inside the rect of this layout element.

                                          - -

                                          Reimplemented in QCPAxisRect.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - -
                                          virtual void QCPLayoutElement::applyDefaultAntialiasingHint (QCPPainterpainter) const
                                          -
                                          -inlineprotectedvirtualinherited
                                          -
                                          -

                                          This function applies the default antialiasing setting to the specified painter, using the function applyAntialiasingHint. It is the antialiasing state the painter is put in, when draw is called on the layerable. If the layerable has multiple entities whose antialiasing setting may be specified individually, this function should set the antialiasing state of the most prominent entity. In this case however, the draw function usually calls the specialized versions of this function before drawing each entity, effectively overriding the setting of the default antialiasing hint.

                                          -

                                          First example: QCPGraph has multiple entities that have an antialiasing setting: The graph line, fills, scatters and error bars. Those can be configured via QCPGraph::setAntialiased, QCPGraph::setAntialiasedFill, QCPGraph::setAntialiasedScatters etc. Consequently, there isn't only the QCPGraph::applyDefaultAntialiasingHint function (which corresponds to the graph line's antialiasing), but specialized ones like QCPGraph::applyFillAntialiasingHint and QCPGraph::applyScattersAntialiasingHint. So before drawing one of those entities, QCPGraph::draw calls the respective specialized applyAntialiasingHint function.

                                          -

                                          Second example: QCPItemLine consists only of a line so there is only one antialiasing setting which can be controlled with QCPItemLine::setAntialiased. (This function is inherited by all layerables. The specialized functions, as seen on QCPGraph, must be added explicitly to the respective layerable subclass.) Consequently it only has the normal QCPItemLine::applyDefaultAntialiasingHint. The QCPItemLine::draw function doesn't need to care about setting any antialiasing states, because the default antialiasing hint is already set on the painter when the draw function is called, and that's the state it wants to draw the line with.

                                          - -

                                          Implements QCPLayerable.

                                          - -

                                          Reimplemented in QCPLegend, QCPAxisRect, QCPAbstractLegendItem, and QCPPlotTitle.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - -
                                          virtual void QCPLayoutElement::draw (QCPPainterpainter)
                                          -
                                          -inlineprotectedvirtualinherited
                                          -
                                          -

                                          This function draws the layerable with the specified painter. It is only called by QCustomPlot, if the layerable is visible (setVisible).

                                          -

                                          Before this function is called, the painter's antialiasing state is set via applyDefaultAntialiasingHint, see the documentation there. Further, the clipping rectangle was set to clipRect.

                                          - -

                                          Implements QCPLayerable.

                                          - -

                                          Reimplemented in QCPLegend, QCPAxisRect, QCPPlottableLegendItem, QCPAbstractLegendItem, and QCPPlotTitle.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - -
                                          void QCPLayoutElement::parentPlotInitialized (QCustomPlotparentPlot)
                                          -
                                          -protectedvirtualinherited
                                          -
                                          -

                                          propagates the parent plot initialization to all child elements, by calling QCPLayerable::initializeParentPlot on them.

                                          - -

                                          Reimplemented from QCPLayerable.

                                          - -

                                          Reimplemented in QCPLegend.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - -
                                          QCPLayerable * QCPLayerable::parentLayerable () const
                                          -
                                          -inlineinherited
                                          -
                                          -

                                          Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.

                                          -

                                          Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.

                                          -

                                          A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - -
                                          void QCPLayerable::setVisible (bool on)
                                          -
                                          -inherited
                                          -
                                          -

                                          Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - -
                                          bool QCPLayerable::setLayer (QCPLayerlayer)
                                          -
                                          -inherited
                                          -
                                          -

                                          Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.

                                          -

                                          Returns true on success, i.e. if layer is a valid layer.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - -
                                          bool QCPLayerable::setLayer (const QString & layerName)
                                          -
                                          -inherited
                                          -
                                          -

                                          This is an overloaded function.

                                          -

                                          Sets the layer of this layerable object by name

                                          -

                                          Returns true on success, i.e. if layerName is a valid layer name.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - -
                                          void QCPLayerable::setAntialiased (bool enabled)
                                          -
                                          -inherited
                                          -
                                          -

                                          Sets whether this object will be drawn antialiased or not.

                                          -

                                          Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - -
                                          bool QCPLayerable::realVisibility () const
                                          -
                                          -inherited
                                          -
                                          -

                                          Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.

                                          -

                                          If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.

                                          -

                                          If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - -
                                          QCP::Interaction QCPLayerable::selectionCategory () const
                                          -
                                          -protectedvirtualinherited
                                          -
                                          -

                                          Returns the selection category this layerable shall belong to. The selection category is used in conjunction with QCustomPlot::setInteractions to control which objects are selectable and which aren't.

                                          -

                                          Subclasses that don't fit any of the normal QCP::Interaction values can use QCP::iSelectOther. This is what the default implementation returns.

                                          -
                                          See Also
                                          QCustomPlot::setInteractions
                                          - -

                                          Reimplemented in QCPAxis, QCPLegend, QCPAbstractItem, QCPAbstractPlottable, and QCPAbstractLegendItem.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - -
                                          QRect QCPLayerable::clipRect () const
                                          -
                                          -protectedvirtualinherited
                                          -
                                          -

                                          Returns the clipping rectangle of this layerable object. By default, this is the viewport of the parent QCustomPlot. Specific subclasses may reimplement this function to provide different clipping rects.

                                          -

                                          The returned clipping rect is set on the painter before the draw function of the respective object is called.

                                          - -

                                          Reimplemented in QCPAbstractItem, QCPAbstractPlottable, and QCPAbstractLegendItem.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                                          void QCPLayerable::selectEvent (QMouseEvent * event,
                                          bool additive,
                                          const QVariant & details,
                                          bool * selectionStateChanged 
                                          )
                                          -
                                          -protectedvirtualinherited
                                          -
                                          -

                                          This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

                                          -

                                          event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

                                          -

                                          Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

                                          -

                                          selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

                                          -
                                          See Also
                                          selectTest, deselectEvent
                                          - -

                                          Reimplemented in QCPAxis, QCPLegend, QCPAbstractItem, QCPAbstractPlottable, QCPPlotTitle, and QCPAbstractLegendItem.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - -
                                          void QCPLayerable::deselectEvent (bool * selectionStateChanged)
                                          -
                                          -protectedvirtualinherited
                                          -
                                          -

                                          This event is called when the layerable shall be deselected, either as consequence of a user interaction or a call to QCustomPlot::deselectAll. Subclasses should react to it by unsetting their selection appropriately.

                                          -

                                          just as in selectEvent, the output parameter selectionStateChanged (if non-null), must return true or false when the selection state of this layerable has changed or not changed, respectively.

                                          -
                                          See Also
                                          selectTest, selectEvent
                                          - -

                                          Reimplemented in QCPAxis, QCPLegend, QCPAbstractItem, QCPAbstractPlottable, QCPPlotTitle, and QCPAbstractLegendItem.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - -
                                          void QCPLayerable::initializeParentPlot (QCustomPlotparentPlot)
                                          -
                                          -protectedinherited
                                          -
                                          -

                                          Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.

                                          -

                                          Note that, unlike when passing a non-null parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.

                                          -

                                          Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.

                                          -

                                          The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - -
                                          void QCPLayerable::setParentLayerable (QCPLayerableparentLayerable)
                                          -
                                          -protectedinherited
                                          -
                                          -

                                          Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.

                                          -

                                          The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.

                                          -
                                          See Also
                                          realVisibility
                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - - - - - - - - - - - -
                                          bool QCPLayerable::moveToLayer (QCPLayerlayer,
                                          bool prepend 
                                          )
                                          -
                                          -protectedinherited
                                          -
                                          -

                                          Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.

                                          -

                                          Returns true on success, i.e. if layer is a valid layer.

                                          - -
                                          -
                                          - -
                                          -
                                          - - - - - -
                                          - - - - - - - - - - - - - - - - - - - - - - - - -
                                          void QCPLayerable::applyAntialiasingHint (QCPPainterpainter,
                                          bool localAntialiased,
                                          QCP::AntialiasedElement overrideElement 
                                          ) const
                                          -
                                          -protectedinherited
                                          -
                                          -

                                          Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.

                                          - -
                                          -

                                          The documentation for this class was generated from the following files:
                                          • src/layout.h
                                          • src/layout.cpp
                                          • diff -Nru qcustomplot-1.1.0/documentation/html/classQCPLayoutInset.html qcustomplot-1.2.0/documentation/html/classQCPLayoutInset.html --- qcustomplot-1.1.0/documentation/html/classQCPLayoutInset.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPLayoutInset.html 2014-03-14 21:11:27.000000000 +0000 @@ -17,8 +17,7 @@
                                            QCPLayoutInset Class Reference
                                            @@ -56,79 +55,71 @@ virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const void addElement (QCPLayoutElement *element, Qt::Alignment alignment) void addElement (QCPLayoutElement *element, const QRectF &rect) -virtual void update () -virtual QList< QCPLayoutElement * > elements (bool recursive) const -bool removeAt (int index) -bool remove (QCPLayoutElement *element) -void clear () -QCPLayoutlayout () const -QRect rect () const - +- Public Functions inherited from QCPLayoutQCPLayout () +virtual void update (UpdatePhase phase) +virtual QList< QCPLayoutElement * > elements (bool recursive) const +bool removeAt (int index) +bool remove (QCPLayoutElement *element) +void clear () +- Public Functions inherited from QCPLayoutElementQCPLayoutElement (QCustomPlot *parentPlot=0) +QCPLayoutlayout () const +QRect rect () const + QRect outerRect () const - + QMargins margins () const - + QMargins minimumMargins () const - + QCP::MarginSides autoMargins () const - + QSize minimumSize () const - + QSize maximumSize () const - + QCPMarginGroupmarginGroup (QCP::MarginSide side) const - + QHash< QCP::MarginSide,
                                            QCPMarginGroup * > marginGroups () const -void setOuterRect (const QRect &rect) -void setMargins (const QMargins &margins) -void setMinimumMargins (const QMargins &margins) -void setAutoMargins (QCP::MarginSides sides) -void setMinimumSize (const QSize &size) -void setMinimumSize (int width, int height) -void setMaximumSize (const QSize &size) -void setMaximumSize (int width, int height) -void setMarginGroup (QCP::MarginSides sides, QCPMarginGroup *group) -virtual QSize minimumSizeHint () const -virtual QSize maximumSizeHint () const - +void setOuterRect (const QRect &rect) +void setMargins (const QMargins &margins) +void setMinimumMargins (const QMargins &margins) +void setAutoMargins (QCP::MarginSides sides) +void setMinimumSize (const QSize &size) +void setMinimumSize (int width, int height) +void setMaximumSize (const QSize &size) +void setMaximumSize (int width, int height) +void setMarginGroup (QCP::MarginSides sides, QCPMarginGroup *group) +virtual QSize minimumSizeHint () const +virtual QSize maximumSizeHint () const +- Public Functions inherited from QCPLayerableQCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0) + bool visible () const - + QCustomPlotparentPlot () const -QCPLayerableparentLayerable () const - +QCPLayerableparentLayerable () const + QCPLayerlayer () const - + bool antialiased () const -void setVisible (bool on) -bool setLayer (QCPLayer *layer) -bool setLayer (const QString &layerName) -void setAntialiased (bool enabled) -bool realVisibility () const +void setVisible (bool on) +Q_SLOT bool setLayer (QCPLayer *layer) +bool setLayer (const QString &layerName) +void setAntialiased (bool enabled) +bool realVisibility () const - - - - - - - - - - - - - - - - - - - - - - + + + + + + + +

                                            -Protected Functions

                                            void sizeConstraintsChanged () const
                                            void adoptElement (QCPLayoutElement *el)
                                            void releaseElement (QCPLayoutElement *el)
                                            QVector< int > getSectionSizes (QVector< int > maxSizes, QVector< int > minSizes, QVector< double > stretchFactors, int totalSize) const
                                            virtual int calculateAutoMargin (QCP::MarginSide side)
                                            virtual void mousePressEvent (QMouseEvent *event)
                                            virtual void mouseMoveEvent (QMouseEvent *event)
                                            virtual void mouseReleaseEvent (QMouseEvent *event)
                                            virtual void mouseDoubleClickEvent (QMouseEvent *event)
                                            virtual void wheelEvent (QWheelEvent *event)
                                            virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
                                            virtual void draw (QCPPainter *painter)
                                            virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                                            virtual QCP::Interaction selectionCategory () const
                                            virtual QRect clipRect () const
                                            virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                                            virtual void deselectEvent (bool *selectionStateChanged)
                                            void initializeParentPlot (QCustomPlot *parentPlot)
                                            void setParentLayerable (QCPLayerable *parentLayerable)
                                            bool moveToLayer (QCPLayer *layer, bool prepend)
                                            void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const

                                            +Additional Inherited Members

                                            - Signals inherited from QCPLayerable
                                            void layerChanged (QCPLayer *newLayer)
                                            - Protected Functions inherited from QCPLayout
                                            void sizeConstraintsChanged () const
                                            void adoptElement (QCPLayoutElement *el)
                                            void releaseElement (QCPLayoutElement *el)
                                            QVector< int > getSectionSizes (QVector< int > maxSizes, QVector< int > minSizes, QVector< double > stretchFactors, int totalSize) const

                                            Detailed Description

                                            A layout that places child elements aligned to the border or arbitrarily positioned.

                                            @@ -345,7 +336,7 @@

                                            Subclasses reimplement this method to update the position and sizes of the child elements/cells via calling their QCPLayoutElement::setOuterRect. The default implementation does nothing.

                                            The geometry used as a reference is the inner rect of this layout. Child elements should stay within that rect.

                                            getSectionSizes may help with the reimplementation of this function.

                                            -
                                            See Also
                                            update
                                            +
                                            See Also
                                            update

                                            Reimplemented from QCPLayout.

                                            @@ -530,7 +521,7 @@
                                            -

                                            The inset layout is sensitive to events only at areas where its child elements are sensitive. If the selectTest method of any of the child elements returns a positive number for pos, this method returns a value corresponding to 0.99 times the parent plot's selection tolerance. The inset layout is not selectable itself by default. So if onlySelectable is true, -1.0 is returned.

                                            +

                                            The inset layout is sensitive to events only at areas where its (visible) child elements are sensitive. If the selectTest method of any of the child elements returns a positive number for pos, this method returns a value corresponding to 0.99 times the parent plot's selection tolerance. The inset layout is not selectable itself by default. So if onlySelectable is true, -1.0 is returned.

                                            See QCPLayerable::selectTest for a general explanation of this virtual method.

                                            Reimplemented from QCPLayoutElement.

                                            @@ -595,1324 +586,6 @@
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - -
                                            void QCPLayout::update ()
                                            -
                                            -virtualinherited
                                            -
                                            -

                                            First calls the QCPLayoutElement::update base class implementation to update the margins on this layout.

                                            -

                                            Then calls updateLayout which subclasses reimplement to reposition and resize their cells.

                                            -

                                            Finally, update is called on all child elements.

                                            - -

                                            Reimplemented from QCPLayoutElement.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - -
                                            QList< QCPLayoutElement * > QCPLayout::elements (bool recursive) const
                                            -
                                            -virtualinherited
                                            -
                                            -

                                            Returns a list of all child elements in this layout element. If recursive is true, all sub-child elements are included in the list, too.

                                            -

                                            Note that there may be entries with value 0 in the returned list. (For example, QCPLayoutGrid may have empty cells which yield 0 at the respective index.)

                                            - -

                                            Reimplemented from QCPLayoutElement.

                                            - -

                                            Reimplemented in QCPLayoutGrid.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - -
                                            bool QCPLayout::removeAt (int index)
                                            -
                                            -inherited
                                            -
                                            -

                                            Removes and deletes the element at the provided index. Returns true on success. If index is invalid or points to an empty cell, returns false.

                                            -

                                            This function internally uses takeAt to remove the element from the layout and then deletes the returned element.

                                            -
                                            See Also
                                            remove, takeAt
                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - -
                                            bool QCPLayout::remove (QCPLayoutElementelement)
                                            -
                                            -inherited
                                            -
                                            -

                                            Removes and deletes the provided element. Returns true on success. If element is not in the layout, returns false.

                                            -

                                            This function internally uses takeAt to remove the element from the layout and then deletes the element.

                                            -
                                            See Also
                                            removeAt, take
                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - -
                                            void QCPLayout::clear ()
                                            -
                                            -inherited
                                            -
                                            -

                                            Removes and deletes all layout elements in this layout.

                                            -
                                            See Also
                                            remove, removeAt
                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - -
                                            void QCPLayout::sizeConstraintsChanged () const
                                            -
                                            -protectedinherited
                                            -
                                            -

                                            Subclasses call this method to report changed (minimum/maximum) size constraints.

                                            -

                                            If the parent of this layout is again a QCPLayout, forwards the call to the parent's sizeConstraintsChanged. If the parent is a QWidget (i.e. is the QCustomPlot::plotLayout of QCustomPlot), calls QWidget::updateGeometry, so if the QCustomPlot widget is inside a Qt QLayout, it may update itself and resize cells accordingly.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - -
                                            void QCPLayout::adoptElement (QCPLayoutElementel)
                                            -
                                            -protectedinherited
                                            -
                                            -

                                            Associates el with this layout. This is done by setting the QCPLayoutElement::layout, the QCPLayerable::parentLayerable and the QObject parent to this layout.

                                            -

                                            Further, if el didn't previously have a parent plot, calls QCPLayerable::initializeParentPlot on el to set the paret plot.

                                            -

                                            This method is used by subclass specific methods that add elements to the layout. Note that this method only changes properties in el. The removal from the old layout and the insertion into the new layout must be done additionally.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - -
                                            void QCPLayout::releaseElement (QCPLayoutElementel)
                                            -
                                            -protectedinherited
                                            -
                                            -

                                            Disassociates el from this layout. This is done by setting the QCPLayoutElement::layout and the QCPLayerable::parentLayerable to zero. The QObject parent is set to the parent QCustomPlot.

                                            -

                                            This method is used by subclass specific methods that remove elements from the layout (e.g. take or takeAt). Note that this method only changes properties in el. The removal from the old layout must be done additionally.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                                            QVector< int > QCPLayout::getSectionSizes (QVector< int > maxSizes,
                                            QVector< int > minSizes,
                                            QVector< double > stretchFactors,
                                            int totalSize 
                                            ) const
                                            -
                                            -protectedinherited
                                            -
                                            -

                                            This is a helper function for the implementation of updateLayout in subclasses.

                                            -

                                            It calculates the sizes of one-dimensional sections with provided constraints on maximum section sizes, minimum section sizes, relative stretch factors and the final total size of all sections.

                                            -

                                            The QVector entries refer to the sections. Thus all QVectors must have the same size.

                                            -

                                            maxSizes gives the maximum allowed size of each section. If there shall be no maximum size imposed, set all vector values to Qt's QWIDGETSIZE_MAX.

                                            -

                                            minSizes gives the minimum allowed size of each section. If there shall be no minimum size imposed, set all vector values to zero. If the minSizes entries add up to a value greater than totalSize, sections will be scaled smaller than the proposed minimum sizes. (In other words, not exceeding the allowed total size is taken to be more important than not going below minimum section sizes.)

                                            -

                                            stretchFactors give the relative proportions of the sections to each other. If all sections shall be scaled equally, set all values equal. If the first section shall be double the size of each individual other section, set the first number of stretchFactors to double the value of the other individual values (e.g. {2, 1, 1, 1}).

                                            -

                                            totalSize is the value that the final section sizes will add up to. Due to rounding, the actual sum may differ slightly. If you want the section sizes to sum up to exactly that value, you could distribute the remaining difference on the sections.

                                            -

                                            The return value is a QVector containing the section sizes.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - -
                                            QCPLayout * QCPLayoutElement::layout () const
                                            -
                                            -inlineinherited
                                            -
                                            -

                                            Returns the parent layout of this layout element.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - -
                                            QRect QCPLayoutElement::rect () const
                                            -
                                            -inlineinherited
                                            -
                                            -

                                            Returns the inner rect of this layout element. The inner rect is the outer rect (setOuterRect) shrinked by the margins (setMargins, setAutoMargins).

                                            -

                                            In some cases, the area between outer and inner rect is left blank. In other cases the margin area is used to display peripheral graphics while the main content is in the inner rect. This is where automatic margin calculation becomes interesting because it allows the layout element to adapt the margins to the peripheral graphics it wants to draw. For example, QCPAxisRect draws the axis labels and tick labels in the margin area, thus needs to adjust the margins (if setAutoMargins is enabled) according to the space required by the labels of the axes.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - -
                                            void QCPLayoutElement::setOuterRect (const QRect & rect)
                                            -
                                            -inherited
                                            -
                                            -

                                            Sets the outer rect of this layout element. If the layout element is inside a layout, the layout sets the position and size of this layout element using this function.

                                            -

                                            Calling this function externally has no effect, since the layout will overwrite any changes to the outer rect upon the next replot.

                                            -

                                            The layout element will adapt its inner rect by applying the margins inward to the outer rect.

                                            -
                                            See Also
                                            rect
                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - -
                                            void QCPLayoutElement::setMargins (const QMargins & margins)
                                            -
                                            -inherited
                                            -
                                            -

                                            Sets the margins of this layout element. If setAutoMargins is disabled for some or all sides, this function is used to manually set the margin on those sides. Sides that are still set to be handled automatically are ignored and may have any value in margins.

                                            -

                                            The margin is the distance between the outer rect (controlled by the parent layout via setOuterRect) and the inner rect (which usually contains the main content of this layout element).

                                            -
                                            See Also
                                            setAutoMargins
                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - -
                                            void QCPLayoutElement::setMinimumMargins (const QMargins & margins)
                                            -
                                            -inherited
                                            -
                                            -

                                            If setAutoMargins is enabled on some or all margins, this function is used to provide minimum values for those margins.

                                            -

                                            The minimum values are not enforced on margin sides that were set to be under manual control via setAutoMargins.

                                            -
                                            See Also
                                            setAutoMargins
                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - -
                                            void QCPLayoutElement::setAutoMargins (QCP::MarginSides sides)
                                            -
                                            -inherited
                                            -
                                            -

                                            Sets on which sides the margin shall be calculated automatically. If a side is calculated automatically, a minimum margin value may be provided with setMinimumMargins. If a side is set to be controlled manually, the value may be specified with setMargins.

                                            -

                                            Margin sides that are under automatic control may participate in a QCPMarginGroup (see setMarginGroup), to synchronize (align) it with other layout elements in the plot.

                                            -
                                            See Also
                                            setMinimumMargins, setMargins
                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - -
                                            void QCPLayoutElement::setMinimumSize (const QSize & size)
                                            -
                                            -inherited
                                            -
                                            -

                                            Sets the minimum size for the inner rect of this layout element. A parent layout tries to respect the size here by changing row/column sizes in the layout accordingly.

                                            -

                                            If the parent layout size is not sufficient to satisfy all minimum size constraints of its child layout elements, the layout may set a size that is actually smaller than size. QCustomPlot propagates the layout's size constraints to the outside by setting its own minimum QWidget size accordingly, so violations of size should be exceptions.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - - - - - - - - - - - -
                                            void QCPLayoutElement::setMinimumSize (int width,
                                            int height 
                                            )
                                            -
                                            -inherited
                                            -
                                            -

                                            This is an overloaded function.

                                            -

                                            Sets the minimum size for the inner rect of this layout element.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - -
                                            void QCPLayoutElement::setMaximumSize (const QSize & size)
                                            -
                                            -inherited
                                            -
                                            -

                                            Sets the maximum size for the inner rect of this layout element. A parent layout tries to respect the size here by changing row/column sizes in the layout accordingly.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - - - - - - - - - - - -
                                            void QCPLayoutElement::setMaximumSize (int width,
                                            int height 
                                            )
                                            -
                                            -inherited
                                            -
                                            -

                                            This is an overloaded function.

                                            -

                                            Sets the maximum size for the inner rect of this layout element.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - - - - - - - - - - - -
                                            void QCPLayoutElement::setMarginGroup (QCP::MarginSides sides,
                                            QCPMarginGroupgroup 
                                            )
                                            -
                                            -inherited
                                            -
                                            -

                                            Sets the margin group of the specified margin sides.

                                            -

                                            Margin groups allow synchronizing specified margins across layout elements, see the documentation of QCPMarginGroup.

                                            -

                                            To unset the margin group of sides, set group to 0.

                                            -

                                            Note that margin groups only work for margin sides that are set to automatic (setAutoMargins).

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - -
                                            QSize QCPLayoutElement::minimumSizeHint () const
                                            -
                                            -virtualinherited
                                            -
                                            -

                                            Returns the minimum size this layout element (the inner rect) may be compressed to.

                                            -

                                            if a minimum size (setMinimumSize) was not set manually, parent layouts consult this function to determine the minimum allowed size of this layout element. (A manual minimum size is considered set if it is non-zero.)

                                            - -

                                            Reimplemented in QCPLayoutGrid, QCPPlottableLegendItem, and QCPPlotTitle.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - -
                                            QSize QCPLayoutElement::maximumSizeHint () const
                                            -
                                            -virtualinherited
                                            -
                                            -

                                            Returns the maximum size this layout element (the inner rect) may be expanded to.

                                            -

                                            if a maximum size (setMaximumSize) was not set manually, parent layouts consult this function to determine the maximum allowed size of this layout element. (A manual maximum size is considered set if it is smaller than Qt's QWIDGETSIZE_MAX.)

                                            - -

                                            Reimplemented in QCPLayoutGrid, and QCPPlotTitle.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - -
                                            int QCPLayoutElement::calculateAutoMargin (QCP::MarginSide side)
                                            -
                                            -protectedvirtualinherited
                                            -
                                            -

                                            Returns the margin size for this side. It is used if automatic margins is enabled for this side (see setAutoMargins). If a minimum margin was set with setMinimumMargins, the returned value will not be smaller than the specified minimum margin.

                                            -

                                            The default implementation just returns the respective manual margin (setMargins) or the minimum margin, whichever is larger.

                                            - -

                                            Reimplemented in QCPAxisRect.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - -
                                            void QCPLayoutElement::mousePressEvent (QMouseEvent * event)
                                            -
                                            -inlineprotectedvirtualinherited
                                            -
                                            -

                                            This event is called, if the mouse was pressed while being inside the outer rect of this layout element.

                                            - -

                                            Reimplemented in QCPAxisRect.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - -
                                            void QCPLayoutElement::mouseMoveEvent (QMouseEvent * event)
                                            -
                                            -inlineprotectedvirtualinherited
                                            -
                                            -

                                            This event is called, if the mouse is moved inside the outer rect of this layout element.

                                            - -

                                            Reimplemented in QCPAxisRect.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - -
                                            void QCPLayoutElement::mouseReleaseEvent (QMouseEvent * event)
                                            -
                                            -inlineprotectedvirtualinherited
                                            -
                                            -

                                            This event is called, if the mouse was previously pressed inside the outer rect of this layout element and is now released.

                                            - -

                                            Reimplemented in QCPAxisRect.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - -
                                            void QCPLayoutElement::mouseDoubleClickEvent (QMouseEvent * event)
                                            -
                                            -inlineprotectedvirtualinherited
                                            -
                                            -

                                            This event is called, if the mouse is double-clicked inside the outer rect of this layout element.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - -
                                            void QCPLayoutElement::wheelEvent (QWheelEvent * event)
                                            -
                                            -inlineprotectedvirtualinherited
                                            -
                                            -

                                            This event is called, if the mouse wheel is scrolled while the cursor is inside the rect of this layout element.

                                            - -

                                            Reimplemented in QCPAxisRect.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - -
                                            virtual void QCPLayoutElement::applyDefaultAntialiasingHint (QCPPainterpainter) const
                                            -
                                            -inlineprotectedvirtualinherited
                                            -
                                            -

                                            This function applies the default antialiasing setting to the specified painter, using the function applyAntialiasingHint. It is the antialiasing state the painter is put in, when draw is called on the layerable. If the layerable has multiple entities whose antialiasing setting may be specified individually, this function should set the antialiasing state of the most prominent entity. In this case however, the draw function usually calls the specialized versions of this function before drawing each entity, effectively overriding the setting of the default antialiasing hint.

                                            -

                                            First example: QCPGraph has multiple entities that have an antialiasing setting: The graph line, fills, scatters and error bars. Those can be configured via QCPGraph::setAntialiased, QCPGraph::setAntialiasedFill, QCPGraph::setAntialiasedScatters etc. Consequently, there isn't only the QCPGraph::applyDefaultAntialiasingHint function (which corresponds to the graph line's antialiasing), but specialized ones like QCPGraph::applyFillAntialiasingHint and QCPGraph::applyScattersAntialiasingHint. So before drawing one of those entities, QCPGraph::draw calls the respective specialized applyAntialiasingHint function.

                                            -

                                            Second example: QCPItemLine consists only of a line so there is only one antialiasing setting which can be controlled with QCPItemLine::setAntialiased. (This function is inherited by all layerables. The specialized functions, as seen on QCPGraph, must be added explicitly to the respective layerable subclass.) Consequently it only has the normal QCPItemLine::applyDefaultAntialiasingHint. The QCPItemLine::draw function doesn't need to care about setting any antialiasing states, because the default antialiasing hint is already set on the painter when the draw function is called, and that's the state it wants to draw the line with.

                                            - -

                                            Implements QCPLayerable.

                                            - -

                                            Reimplemented in QCPLegend, QCPAxisRect, QCPAbstractLegendItem, and QCPPlotTitle.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - -
                                            virtual void QCPLayoutElement::draw (QCPPainterpainter)
                                            -
                                            -inlineprotectedvirtualinherited
                                            -
                                            -

                                            This function draws the layerable with the specified painter. It is only called by QCustomPlot, if the layerable is visible (setVisible).

                                            -

                                            Before this function is called, the painter's antialiasing state is set via applyDefaultAntialiasingHint, see the documentation there. Further, the clipping rectangle was set to clipRect.

                                            - -

                                            Implements QCPLayerable.

                                            - -

                                            Reimplemented in QCPLegend, QCPAxisRect, QCPPlottableLegendItem, QCPAbstractLegendItem, and QCPPlotTitle.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - -
                                            void QCPLayoutElement::parentPlotInitialized (QCustomPlotparentPlot)
                                            -
                                            -protectedvirtualinherited
                                            -
                                            -

                                            propagates the parent plot initialization to all child elements, by calling QCPLayerable::initializeParentPlot on them.

                                            - -

                                            Reimplemented from QCPLayerable.

                                            - -

                                            Reimplemented in QCPLegend.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - -
                                            QCPLayerable * QCPLayerable::parentLayerable () const
                                            -
                                            -inlineinherited
                                            -
                                            -

                                            Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.

                                            -

                                            Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.

                                            -

                                            A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - -
                                            void QCPLayerable::setVisible (bool on)
                                            -
                                            -inherited
                                            -
                                            -

                                            Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - -
                                            bool QCPLayerable::setLayer (QCPLayerlayer)
                                            -
                                            -inherited
                                            -
                                            -

                                            Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.

                                            -

                                            Returns true on success, i.e. if layer is a valid layer.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - -
                                            bool QCPLayerable::setLayer (const QString & layerName)
                                            -
                                            -inherited
                                            -
                                            -

                                            This is an overloaded function.

                                            -

                                            Sets the layer of this layerable object by name

                                            -

                                            Returns true on success, i.e. if layerName is a valid layer name.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - -
                                            void QCPLayerable::setAntialiased (bool enabled)
                                            -
                                            -inherited
                                            -
                                            -

                                            Sets whether this object will be drawn antialiased or not.

                                            -

                                            Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - -
                                            bool QCPLayerable::realVisibility () const
                                            -
                                            -inherited
                                            -
                                            -

                                            Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.

                                            -

                                            If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.

                                            -

                                            If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - -
                                            QCP::Interaction QCPLayerable::selectionCategory () const
                                            -
                                            -protectedvirtualinherited
                                            -
                                            -

                                            Returns the selection category this layerable shall belong to. The selection category is used in conjunction with QCustomPlot::setInteractions to control which objects are selectable and which aren't.

                                            -

                                            Subclasses that don't fit any of the normal QCP::Interaction values can use QCP::iSelectOther. This is what the default implementation returns.

                                            -
                                            See Also
                                            QCustomPlot::setInteractions
                                            - -

                                            Reimplemented in QCPAxis, QCPLegend, QCPAbstractItem, QCPAbstractPlottable, and QCPAbstractLegendItem.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - -
                                            QRect QCPLayerable::clipRect () const
                                            -
                                            -protectedvirtualinherited
                                            -
                                            -

                                            Returns the clipping rectangle of this layerable object. By default, this is the viewport of the parent QCustomPlot. Specific subclasses may reimplement this function to provide different clipping rects.

                                            -

                                            The returned clipping rect is set on the painter before the draw function of the respective object is called.

                                            - -

                                            Reimplemented in QCPAbstractItem, QCPAbstractPlottable, and QCPAbstractLegendItem.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                                            void QCPLayerable::selectEvent (QMouseEvent * event,
                                            bool additive,
                                            const QVariant & details,
                                            bool * selectionStateChanged 
                                            )
                                            -
                                            -protectedvirtualinherited
                                            -
                                            -

                                            This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

                                            -

                                            event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

                                            -

                                            Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

                                            -

                                            selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

                                            -
                                            See Also
                                            selectTest, deselectEvent
                                            - -

                                            Reimplemented in QCPAxis, QCPLegend, QCPAbstractItem, QCPAbstractPlottable, QCPPlotTitle, and QCPAbstractLegendItem.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - -
                                            void QCPLayerable::deselectEvent (bool * selectionStateChanged)
                                            -
                                            -protectedvirtualinherited
                                            -
                                            -

                                            This event is called when the layerable shall be deselected, either as consequence of a user interaction or a call to QCustomPlot::deselectAll. Subclasses should react to it by unsetting their selection appropriately.

                                            -

                                            just as in selectEvent, the output parameter selectionStateChanged (if non-null), must return true or false when the selection state of this layerable has changed or not changed, respectively.

                                            -
                                            See Also
                                            selectTest, selectEvent
                                            - -

                                            Reimplemented in QCPAxis, QCPLegend, QCPAbstractItem, QCPAbstractPlottable, QCPPlotTitle, and QCPAbstractLegendItem.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - -
                                            void QCPLayerable::initializeParentPlot (QCustomPlotparentPlot)
                                            -
                                            -protectedinherited
                                            -
                                            -

                                            Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.

                                            -

                                            Note that, unlike when passing a non-null parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.

                                            -

                                            Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.

                                            -

                                            The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - -
                                            void QCPLayerable::setParentLayerable (QCPLayerableparentLayerable)
                                            -
                                            -protectedinherited
                                            -
                                            -

                                            Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.

                                            -

                                            The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.

                                            -
                                            See Also
                                            realVisibility
                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - - - - - - - - - - - -
                                            bool QCPLayerable::moveToLayer (QCPLayerlayer,
                                            bool prepend 
                                            )
                                            -
                                            -protectedinherited
                                            -
                                            -

                                            Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.

                                            -

                                            Returns true on success, i.e. if layer is a valid layer.

                                            - -
                                            -
                                            - -
                                            -
                                            - - - - - -
                                            - - - - - - - - - - - - - - - - - - - - - - - - -
                                            void QCPLayerable::applyAntialiasingHint (QCPPainterpainter,
                                            bool localAntialiased,
                                            QCP::AntialiasedElement overrideElement 
                                            ) const
                                            -
                                            -protectedinherited
                                            -
                                            -

                                            Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.

                                            - -
                                            -

                                            The documentation for this class was generated from the following files:
                                            • src/layout.h
                                            • src/layout.cpp
                                            • diff -Nru qcustomplot-1.1.0/documentation/html/classQCPLegend.html qcustomplot-1.2.0/documentation/html/classQCPLegend.html --- qcustomplot-1.1.0/documentation/html/classQCPLegend.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPLegend.html 2014-03-14 21:11:27.000000000 +0000 @@ -78,8 +78,8 @@ void setIconSize (int width, int height) void setIconTextPadding (int padding) void setIconBorderPen (const QPen &pen) -void setSelectableParts (const SelectableParts &selectableParts) -void setSelectedParts (const SelectableParts &selectedParts) +Q_SLOT void setSelectableParts (const SelectableParts &selectableParts) +Q_SLOT void setSelectedParts (const SelectableParts &selectedParts) void setSelectedBorderPen (const QPen &pen) void setSelectedIconBorderPen (const QPen &pen) void setSelectedBrush (const QBrush &brush) @@ -96,87 +96,97 @@ bool removeItem (QCPAbstractLegendItem *item) void clearItems () QList< QCPAbstractLegendItem * > selectedItems () const -int rowCount () const -int columnCount () const - +- Public Functions inherited from QCPLayoutGridQCPLayoutGrid () +int rowCount () const +int columnCount () const + QList< double > columnStretchFactors () const - + QList< double > rowStretchFactors () const - + int columnSpacing () const - + int rowSpacing () const -void setColumnStretchFactor (int column, double factor) -void setColumnStretchFactors (const QList< double > &factors) -void setRowStretchFactor (int row, double factor) -void setRowStretchFactors (const QList< double > &factors) -void setColumnSpacing (int pixels) -void setRowSpacing (int pixels) -virtual void updateLayout () -virtual int elementCount () const -virtual QCPLayoutElementelementAt (int index) const -virtual QCPLayoutElementtakeAt (int index) -virtual bool take (QCPLayoutElement *element) -virtual QList< QCPLayoutElement * > elements (bool recursive) const -virtual void simplify () -virtual QSize minimumSizeHint () const -virtual QSize maximumSizeHint () const -QCPLayoutElementelement (int row, int column) const -bool addElement (int row, int column, QCPLayoutElement *element) -bool hasElement (int row, int column) -void expandTo (int newRowCount, int newColumnCount) -void insertRow (int newIndex) -void insertColumn (int newIndex) -virtual void update () -bool removeAt (int index) -bool remove (QCPLayoutElement *element) -void clear () -QCPLayoutlayout () const -QRect rect () const - +void setColumnStretchFactor (int column, double factor) +void setColumnStretchFactors (const QList< double > &factors) +void setRowStretchFactor (int row, double factor) +void setRowStretchFactors (const QList< double > &factors) +void setColumnSpacing (int pixels) +void setRowSpacing (int pixels) +virtual void updateLayout () +virtual int elementCount () const +virtual QCPLayoutElementelementAt (int index) const +virtual QCPLayoutElementtakeAt (int index) +virtual bool take (QCPLayoutElement *element) +virtual QList< QCPLayoutElement * > elements (bool recursive) const +virtual void simplify () +virtual QSize minimumSizeHint () const +virtual QSize maximumSizeHint () const +QCPLayoutElementelement (int row, int column) const +bool addElement (int row, int column, QCPLayoutElement *element) +bool hasElement (int row, int column) +void expandTo (int newRowCount, int newColumnCount) +void insertRow (int newIndex) +void insertColumn (int newIndex) +- Public Functions inherited from QCPLayoutQCPLayout () +virtual void update (UpdatePhase phase) +bool removeAt (int index) +bool remove (QCPLayoutElement *element) +void clear () +- Public Functions inherited from QCPLayoutElementQCPLayoutElement (QCustomPlot *parentPlot=0) +QCPLayoutlayout () const +QRect rect () const + QRect outerRect () const - + QMargins margins () const - + QMargins minimumMargins () const - + QCP::MarginSides autoMargins () const - + QSize minimumSize () const - + QSize maximumSize () const - + QCPMarginGroupmarginGroup (QCP::MarginSide side) const - + QHash< QCP::MarginSide,
                                              QCPMarginGroup * > marginGroups () const -void setOuterRect (const QRect &rect) -void setMargins (const QMargins &margins) -void setMinimumMargins (const QMargins &margins) -void setAutoMargins (QCP::MarginSides sides) -void setMinimumSize (const QSize &size) -void setMinimumSize (int width, int height) -void setMaximumSize (const QSize &size) -void setMaximumSize (int width, int height) -void setMarginGroup (QCP::MarginSides sides, QCPMarginGroup *group) - +void setOuterRect (const QRect &rect) +void setMargins (const QMargins &margins) +void setMinimumMargins (const QMargins &margins) +void setAutoMargins (QCP::MarginSides sides) +void setMinimumSize (const QSize &size) +void setMinimumSize (int width, int height) +void setMaximumSize (const QSize &size) +void setMaximumSize (int width, int height) +void setMarginGroup (QCP::MarginSides sides, QCPMarginGroup *group) +- Public Functions inherited from QCPLayerableQCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0) + bool visible () const - + QCustomPlotparentPlot () const -QCPLayerableparentLayerable () const - +QCPLayerableparentLayerable () const + QCPLayerlayer () const - + bool antialiased () const -void setVisible (bool on) -bool setLayer (QCPLayer *layer) -bool setLayer (const QString &layerName) -void setAntialiased (bool enabled) -bool realVisibility () const +void setVisible (bool on) +Q_SLOT bool setLayer (QCPLayer *layer) +bool setLayer (const QString &layerName) +void setAntialiased (bool enabled) +bool realVisibility () const - + +

                                              Signals

                                              void selectionChanged (QCPLegend::SelectableParts selection)
                                              void selectionChanged (QCPLegend::SelectableParts parts)
                                              +void selectableChanged (QCPLegend::SelectableParts parts)
                                              @@ -188,30 +198,34 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + +

                                              Protected Functions

                                              virtual void deselectEvent (bool *selectionStateChanged)
                                              QPen getBorderPen () const
                                              QBrush getBrush () const
                                              void getMinimumRowColSizes (QVector< int > *minColWidths, QVector< int > *minRowHeights) const
                                              void getMaximumRowColSizes (QVector< int > *maxColWidths, QVector< int > *maxRowHeights) const
                                              void sizeConstraintsChanged () const
                                              void adoptElement (QCPLayoutElement *el)
                                              void releaseElement (QCPLayoutElement *el)
                                              QVector< int > getSectionSizes (QVector< int > maxSizes, QVector< int > minSizes, QVector< double > stretchFactors, int totalSize) const
                                              virtual int calculateAutoMargin (QCP::MarginSide side)
                                              virtual void mousePressEvent (QMouseEvent *event)
                                              virtual void mouseMoveEvent (QMouseEvent *event)
                                              virtual void mouseReleaseEvent (QMouseEvent *event)
                                              virtual void mouseDoubleClickEvent (QMouseEvent *event)
                                              virtual void wheelEvent (QWheelEvent *event)
                                              virtual QRect clipRect () const
                                              void initializeParentPlot (QCustomPlot *parentPlot)
                                              void setParentLayerable (QCPLayerable *parentLayerable)
                                              bool moveToLayer (QCPLayer *layer, bool prepend)
                                              void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                                              - Protected Functions inherited from QCPLayoutGrid
                                              void getMinimumRowColSizes (QVector< int > *minColWidths, QVector< int > *minRowHeights) const
                                              void getMaximumRowColSizes (QVector< int > *maxColWidths, QVector< int > *maxRowHeights) const
                                              - Protected Functions inherited from QCPLayout
                                              void sizeConstraintsChanged () const
                                              void adoptElement (QCPLayoutElement *el)
                                              void releaseElement (QCPLayoutElement *el)
                                              QVector< int > getSectionSizes (QVector< int > maxSizes, QVector< int > minSizes, QVector< double > stretchFactors, int totalSize) const
                                              - Protected Functions inherited from QCPLayoutElement
                                              virtual int calculateAutoMargin (QCP::MarginSide side)
                                              virtual void mousePressEvent (QMouseEvent *event)
                                              virtual void mouseMoveEvent (QMouseEvent *event)
                                              virtual void mouseReleaseEvent (QMouseEvent *event)
                                              virtual void mouseDoubleClickEvent (QMouseEvent *event)
                                              virtual void wheelEvent (QWheelEvent *event)
                                              - Protected Functions inherited from QCPLayerable
                                              virtual QRect clipRect () const
                                              void initializeParentPlot (QCustomPlot *parentPlot)
                                              void setParentLayerable (QCPLayerable *parentLayerable)
                                              bool moveToLayer (QCPLayer *layer, bool prepend)
                                              void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const

                                              Detailed Description

                                              Manages a legend inside a QCustomPlot.

                                              A legend is a small box somewhere in the plot which lists plottables with their name and icon.

                                              Normally, the legend is populated by calling QCPAbstractPlottable::addToLegend. The respective legend item can be removed with QCPAbstractPlottable::removeFromLegend. However, QCPLegend also offers an interface to add and manipulate legend items directly: item, itemWithPlottable, itemCount, addItem, removeItem, etc.

                                              The QCPLegend derives from QCPLayoutGrid and as such can be placed in any position a QCPLayoutElement may be positioned. The legend items are themselves QCPLayoutElements which are placed in the grid layout of the legend. QCPLegend only adds an interface specialized for handling child elements of type QCPAbstractLegendItem, as mentioned above. In principle, any other layout elements may also be added to a legend via the normal QCPLayoutGrid interface. However, the QCPAbstractLegendItem-Interface will ignore those elements (e.g. itemCount will only return the number of items with QCPAbstractLegendItems type).

                                              -

                                              By default, every QCustomPlot has one legend (QCustomPlot::legend) which is placed in the inset layout of the main axis rect (QCPAxisRect::insetLayout). To move the legend to another position inside the axis rect, use the methods of the QCPLayoutInset. To move the legend outside of the axis rect, place it anywhere else with the QCPLayout/QCPLayoutElement interface.

                                              +

                                              By default, every QCustomPlot has one legend (QCustomPlot::legend) which is placed in the inset layout of the main axis rect (QCPAxisRect::insetLayout). To move the legend to another position inside the axis rect, use the methods of the QCPLayoutInset. To move the legend outside of the axis rect, place it anywhere else with the QCPLayout/QCPLayoutElement interface.

                                              Member Enumeration Documentation

                                              @@ -262,7 +276,7 @@

                                              Constructs a new QCPLegend instance with parentPlot as the containing plot and default values.

                                              -

                                              Note that by default, QCustomPlot already contains a legend ready to be used as QCustomPlot::legend

                                              +

                                              Note that by default, QCustomPlot already contains a legend ready to be used as QCustomPlot::legend

                                              @@ -431,7 +445,7 @@
                                              -

                                              Sets whether the user can (de-)select the parts in selectable by clicking on the QCustomPlot surface. (When QCustomPlot::setInteractions contains iSelectLegend.)

                                              +

                                              Sets whether the user can (de-)select the parts in selectable by clicking on the QCustomPlot surface. (When QCustomPlot::setInteractions contains QCP::iSelectLegend.)

                                              However, even when selectable is set to a value not allowing the selection of a specific part, it is still possible to set the selection of this part manually, by calling setSelectedParts directly.

                                              See Also
                                              SelectablePart, setSelectedParts
                                              @@ -453,7 +467,7 @@

                                              Sets the selected state of the respective legend parts described by SelectablePart. When a part is selected, it uses a different pen/font and brush. If some legend items are selected and selected doesn't contain spItems, those items become deselected.

                                              The entire selection mechanism is handled automatically when QCustomPlot::setInteractions contains iSelectLegend. You only need to call this function when you wish to change the selection state manually.

                                              This function can change the selection state of a part even when setSelectableParts was set to a value that actually excludes the part.

                                              -

                                              emits the selectionChanged signal when selected is different from the previous selection state.

                                              +

                                              emits the selectionChanged signal when selected is different from the previous selection state.

                                              Note that it doesn't make sense to set the selected state spItems here when it wasn't set before, because there's no way to specify which exact items to newly select. Do this by calling QCPAbstractLegendItem::setSelected directly on the legend item you wish to select.

                                              See Also
                                              SelectablePart, setSelectableParts, selectTest, setSelectedBorderPen, setSelectedIconBorderPen, setSelectedBrush, setSelectedFont
                                              @@ -775,7 +789,7 @@
                                              - +
                                              @@ -958,7 +972,7 @@

                                              This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

                                              event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

                                              -

                                              Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

                                              +

                                              Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is fed back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

                                              selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

                                              See Also
                                              selectTest, deselectEvent
                                              @@ -1043,1810 +1057,6 @@
                                              - -
                                              -
                                              -
                                              - - - - -
                                              - - - - - - - -
                                              int QCPLayoutGrid::rowCount () const
                                              -
                                              -inherited
                                              -
                                              -

                                              Returns the number of rows in the layout.

                                              -
                                              See Also
                                              columnCount
                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - -
                                              int QCPLayoutGrid::columnCount () const
                                              -
                                              -inherited
                                              -
                                              -

                                              Returns the number of columns in the layout.

                                              -
                                              See Also
                                              rowCount
                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - - - - - - - - - - - -
                                              void QCPLayoutGrid::setColumnStretchFactor (int column,
                                              double factor 
                                              )
                                              -
                                              -inherited
                                              -
                                              -

                                              Sets the stretch factor of column.

                                              -

                                              Stretch factors control the relative sizes of rows and columns. Cells will not be resized beyond their minimum and maximum widths/heights (QCPLayoutElement::setMinimumSize, QCPLayoutElement::setMaximumSize), regardless of the stretch factor.

                                              -

                                              The default stretch factor of newly created rows/columns is 1.

                                              -
                                              See Also
                                              setColumnStretchFactors, setRowStretchFactor
                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              void QCPLayoutGrid::setColumnStretchFactors (const QList< double > & factors)
                                              -
                                              -inherited
                                              -
                                              -

                                              Sets the stretch factors of all columns. factors must have the size columnCount.

                                              -

                                              Stretch factors control the relative sizes of rows and columns. Cells will not be resized beyond their minimum and maximum widths/heights (QCPLayoutElement::setMinimumSize, QCPLayoutElement::setMaximumSize), regardless of the stretch factor.

                                              -

                                              The default stretch factor of newly created rows/columns is 1.

                                              -
                                              See Also
                                              setColumnStretchFactor, setRowStretchFactors
                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - - - - - - - - - - - -
                                              void QCPLayoutGrid::setRowStretchFactor (int row,
                                              double factor 
                                              )
                                              -
                                              -inherited
                                              -
                                              -

                                              Sets the stretch factor of row.

                                              -

                                              Stretch factors control the relative sizes of rows and columns. Cells will not be resized beyond their minimum and maximum widths/heights (QCPLayoutElement::setMinimumSize, QCPLayoutElement::setMaximumSize), regardless of the stretch factor.

                                              -

                                              The default stretch factor of newly created rows/columns is 1.

                                              -
                                              See Also
                                              setColumnStretchFactors, setRowStretchFactor
                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              void QCPLayoutGrid::setRowStretchFactors (const QList< double > & factors)
                                              -
                                              -inherited
                                              -
                                              -

                                              Sets the stretch factors of all rows. factors must have the size rowCount.

                                              -

                                              Stretch factors control the relative sizes of rows and columns. Cells will not be resized beyond their minimum and maximum widths/heights (QCPLayoutElement::setMinimumSize, QCPLayoutElement::setMaximumSize), regardless of the stretch factor.

                                              -

                                              The default stretch factor of newly created rows/columns is 1.

                                              -
                                              See Also
                                              setRowStretchFactor, setColumnStretchFactors
                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              void QCPLayoutGrid::setColumnSpacing (int pixels)
                                              -
                                              -inherited
                                              -
                                              -

                                              Sets the gap that is left blank between columns to pixels.

                                              -
                                              See Also
                                              setRowSpacing
                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              void QCPLayoutGrid::setRowSpacing (int pixels)
                                              -
                                              -inherited
                                              -
                                              -

                                              Sets the gap that is left blank between rows to pixels.

                                              -
                                              See Also
                                              setColumnSpacing
                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - -
                                              void QCPLayoutGrid::updateLayout ()
                                              -
                                              -virtualinherited
                                              -
                                              -

                                              Subclasses reimplement this method to update the position and sizes of the child elements/cells via calling their QCPLayoutElement::setOuterRect. The default implementation does nothing.

                                              -

                                              The geometry used as a reference is the inner rect of this layout. Child elements should stay within that rect.

                                              -

                                              getSectionSizes may help with the reimplementation of this function.

                                              -
                                              See Also
                                              update
                                              - -

                                              Reimplemented from QCPLayout.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - -
                                              int QCPLayoutGrid::elementCount () const
                                              -
                                              -virtualinherited
                                              -
                                              -

                                              Returns the number of elements/cells in the layout.

                                              -
                                              See Also
                                              elements, elementAt
                                              - -

                                              Implements QCPLayout.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              QCPLayoutElement * QCPLayoutGrid::elementAt (int index) const
                                              -
                                              -virtualinherited
                                              -
                                              -

                                              Returns the element in the cell with the given index. If index is invalid, returns 0.

                                              -

                                              Note that even if index is valid, the respective cell may be empty in some layouts (e.g. QCPLayoutGrid), so this function may return 0 in those cases. You may use this function to check whether a cell is empty or not.

                                              -
                                              See Also
                                              elements, elementCount, takeAt
                                              - -

                                              Implements QCPLayout.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              QCPLayoutElement * QCPLayoutGrid::takeAt (int index)
                                              -
                                              -virtualinherited
                                              -
                                              -

                                              Removes the element with the given index from the layout and returns it.

                                              -

                                              If the index is invalid or the cell with that index is empty, returns 0.

                                              -

                                              Note that some layouts don't remove the respective cell right away but leave an empty cell after successful removal of the layout element. To collapse empty cells, use simplify.

                                              -
                                              See Also
                                              elementAt, take
                                              - -

                                              Implements QCPLayout.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              bool QCPLayoutGrid::take (QCPLayoutElementelement)
                                              -
                                              -virtualinherited
                                              -
                                              -

                                              Removes the specified element from the layout and returns true on success.

                                              -

                                              If the element isn't in this layout, returns false.

                                              -

                                              Note that some layouts don't remove the respective cell right away but leave an empty cell after successful removal of the layout element. To collapse empty cells, use simplify.

                                              -
                                              See Also
                                              takeAt
                                              - -

                                              Implements QCPLayout.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              QList< QCPLayoutElement * > QCPLayoutGrid::elements (bool recursive) const
                                              -
                                              -virtualinherited
                                              -
                                              -

                                              Returns a list of all child elements in this layout element. If recursive is true, all sub-child elements are included in the list, too.

                                              -

                                              Note that there may be entries with value 0 in the returned list. (For example, QCPLayoutGrid may have empty cells which yield 0 at the respective index.)

                                              - -

                                              Reimplemented from QCPLayout.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - -
                                              void QCPLayoutGrid::simplify ()
                                              -
                                              -virtualinherited
                                              -
                                              -

                                              Simplifies the layout by collapsing rows and columns which only contain empty cells.

                                              - -

                                              Reimplemented from QCPLayout.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - -
                                              QSize QCPLayoutGrid::minimumSizeHint () const
                                              -
                                              -virtualinherited
                                              -
                                              -

                                              Returns the minimum size this layout element (the inner rect) may be compressed to.

                                              -

                                              if a minimum size (setMinimumSize) was not set manually, parent layouts consult this function to determine the minimum allowed size of this layout element. (A manual minimum size is considered set if it is non-zero.)

                                              - -

                                              Reimplemented from QCPLayoutElement.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - -
                                              QSize QCPLayoutGrid::maximumSizeHint () const
                                              -
                                              -virtualinherited
                                              -
                                              -

                                              Returns the maximum size this layout element (the inner rect) may be expanded to.

                                              -

                                              if a maximum size (setMaximumSize) was not set manually, parent layouts consult this function to determine the maximum allowed size of this layout element. (A manual maximum size is considered set if it is smaller than Qt's QWIDGETSIZE_MAX.)

                                              - -

                                              Reimplemented from QCPLayoutElement.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - - - - - - - - - - - -
                                              QCPLayoutElement * QCPLayoutGrid::element (int row,
                                              int column 
                                              ) const
                                              -
                                              -inherited
                                              -
                                              -

                                              Returns the element in the cell in row and column.

                                              -

                                              Returns 0 if either the row/column is invalid or if the cell is empty. In those cases, a qDebug message is printed. To check whether a cell exists and isn't empty, use hasElement.

                                              -
                                              See Also
                                              addElement, hasElement
                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - - - - - - - - - - - - - - - - - -
                                              bool QCPLayoutGrid::addElement (int row,
                                              int column,
                                              QCPLayoutElementelement 
                                              )
                                              -
                                              -inherited
                                              -
                                              -

                                              Adds the element to cell with row and column. If element is already in a layout, it is first removed from there. If row or column don't exist yet, the layout is expanded accordingly.

                                              -

                                              Returns true if the element was added successfully, i.e. if the cell at row and column didn't already have an element.

                                              -
                                              See Also
                                              element, hasElement, take, remove
                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - - - - - - - - - - - -
                                              bool QCPLayoutGrid::hasElement (int row,
                                              int column 
                                              )
                                              -
                                              -inherited
                                              -
                                              -

                                              Returns whether the cell at row and column exists and contains a valid element, i.e. isn't empty.

                                              -
                                              See Also
                                              element
                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - - - - - - - - - - - -
                                              void QCPLayoutGrid::expandTo (int newRowCount,
                                              int newColumnCount 
                                              )
                                              -
                                              -inherited
                                              -
                                              -

                                              Expands the layout to have newRowCount rows and newColumnCount columns. So the last valid row index will be newRowCount-1, the last valid column index will be newColumnCount-1.

                                              -

                                              If the current column/row count is already larger or equal to newColumnCount/newRowCount, this function does nothing in that dimension.

                                              -

                                              Newly created cells are empty, new rows and columns have the stretch factor 1.

                                              -

                                              Note that upon a call to addElement, the layout is expanded automatically to contain the specified row and column, using this function.

                                              -
                                              See Also
                                              simplify
                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              void QCPLayoutGrid::insertRow (int newIndex)
                                              -
                                              -inherited
                                              -
                                              -

                                              Inserts a new row with empty cells at the row index newIndex. Valid values for newIndex range from 0 (inserts a row at the top) to rowCount (appends a row at the bottom).

                                              -
                                              See Also
                                              insertColumn
                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              void QCPLayoutGrid::insertColumn (int newIndex)
                                              -
                                              -inherited
                                              -
                                              -

                                              Inserts a new column with empty cells at the column index newIndex. Valid values for newIndex range from 0 (inserts a row at the left) to rowCount (appends a row at the right).

                                              -
                                              See Also
                                              insertRow
                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - - - - - - - - - - - -
                                              void QCPLayoutGrid::getMinimumRowColSizes (QVector< int > * minColWidths,
                                              QVector< int > * minRowHeights 
                                              ) const
                                              -
                                              -protectedinherited
                                              -
                                              -

                                              Places the minimum column widths and row heights into minColWidths and minRowHeights respectively.

                                              -

                                              The minimum height of a row is the largest minimum height of any element in that row. The minimum width of a column is the largest minimum width of any element in that column.

                                              -

                                              This is a helper function for updateLayout.

                                              -
                                              See Also
                                              getMaximumRowColSizes
                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - - - - - - - - - - - -
                                              void QCPLayoutGrid::getMaximumRowColSizes (QVector< int > * maxColWidths,
                                              QVector< int > * maxRowHeights 
                                              ) const
                                              -
                                              -protectedinherited
                                              -
                                              -

                                              Places the maximum column widths and row heights into maxColWidths and maxRowHeights respectively.

                                              -

                                              The maximum height of a row is the smallest maximum height of any element in that row. The maximum width of a column is the smallest maximum width of any element in that column.

                                              -

                                              This is a helper function for updateLayout.

                                              -
                                              See Also
                                              getMinimumRowColSizes
                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - -
                                              void QCPLayout::update ()
                                              -
                                              -virtualinherited
                                              -
                                              -

                                              First calls the QCPLayoutElement::update base class implementation to update the margins on this layout.

                                              -

                                              Then calls updateLayout which subclasses reimplement to reposition and resize their cells.

                                              -

                                              Finally, update is called on all child elements.

                                              - -

                                              Reimplemented from QCPLayoutElement.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              bool QCPLayout::removeAt (int index)
                                              -
                                              -inherited
                                              -
                                              -

                                              Removes and deletes the element at the provided index. Returns true on success. If index is invalid or points to an empty cell, returns false.

                                              -

                                              This function internally uses takeAt to remove the element from the layout and then deletes the returned element.

                                              -
                                              See Also
                                              remove, takeAt
                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              bool QCPLayout::remove (QCPLayoutElementelement)
                                              -
                                              -inherited
                                              -
                                              -

                                              Removes and deletes the provided element. Returns true on success. If element is not in the layout, returns false.

                                              -

                                              This function internally uses takeAt to remove the element from the layout and then deletes the element.

                                              -
                                              See Also
                                              removeAt, take
                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - -
                                              void QCPLayout::clear ()
                                              -
                                              -inherited
                                              -
                                              -

                                              Removes and deletes all layout elements in this layout.

                                              -
                                              See Also
                                              remove, removeAt
                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - -
                                              void QCPLayout::sizeConstraintsChanged () const
                                              -
                                              -protectedinherited
                                              -
                                              -

                                              Subclasses call this method to report changed (minimum/maximum) size constraints.

                                              -

                                              If the parent of this layout is again a QCPLayout, forwards the call to the parent's sizeConstraintsChanged. If the parent is a QWidget (i.e. is the QCustomPlot::plotLayout of QCustomPlot), calls QWidget::updateGeometry, so if the QCustomPlot widget is inside a Qt QLayout, it may update itself and resize cells accordingly.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              void QCPLayout::adoptElement (QCPLayoutElementel)
                                              -
                                              -protectedinherited
                                              -
                                              -

                                              Associates el with this layout. This is done by setting the QCPLayoutElement::layout, the QCPLayerable::parentLayerable and the QObject parent to this layout.

                                              -

                                              Further, if el didn't previously have a parent plot, calls QCPLayerable::initializeParentPlot on el to set the paret plot.

                                              -

                                              This method is used by subclass specific methods that add elements to the layout. Note that this method only changes properties in el. The removal from the old layout and the insertion into the new layout must be done additionally.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              void QCPLayout::releaseElement (QCPLayoutElementel)
                                              -
                                              -protectedinherited
                                              -
                                              -

                                              Disassociates el from this layout. This is done by setting the QCPLayoutElement::layout and the QCPLayerable::parentLayerable to zero. The QObject parent is set to the parent QCustomPlot.

                                              -

                                              This method is used by subclass specific methods that remove elements from the layout (e.g. take or takeAt). Note that this method only changes properties in el. The removal from the old layout must be done additionally.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                                              QVector< int > QCPLayout::getSectionSizes (QVector< int > maxSizes,
                                              QVector< int > minSizes,
                                              QVector< double > stretchFactors,
                                              int totalSize 
                                              ) const
                                              -
                                              -protectedinherited
                                              -
                                              -

                                              This is a helper function for the implementation of updateLayout in subclasses.

                                              -

                                              It calculates the sizes of one-dimensional sections with provided constraints on maximum section sizes, minimum section sizes, relative stretch factors and the final total size of all sections.

                                              -

                                              The QVector entries refer to the sections. Thus all QVectors must have the same size.

                                              -

                                              maxSizes gives the maximum allowed size of each section. If there shall be no maximum size imposed, set all vector values to Qt's QWIDGETSIZE_MAX.

                                              -

                                              minSizes gives the minimum allowed size of each section. If there shall be no minimum size imposed, set all vector values to zero. If the minSizes entries add up to a value greater than totalSize, sections will be scaled smaller than the proposed minimum sizes. (In other words, not exceeding the allowed total size is taken to be more important than not going below minimum section sizes.)

                                              -

                                              stretchFactors give the relative proportions of the sections to each other. If all sections shall be scaled equally, set all values equal. If the first section shall be double the size of each individual other section, set the first number of stretchFactors to double the value of the other individual values (e.g. {2, 1, 1, 1}).

                                              -

                                              totalSize is the value that the final section sizes will add up to. Due to rounding, the actual sum may differ slightly. If you want the section sizes to sum up to exactly that value, you could distribute the remaining difference on the sections.

                                              -

                                              The return value is a QVector containing the section sizes.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - -
                                              QCPLayout * QCPLayoutElement::layout () const
                                              -
                                              -inlineinherited
                                              -
                                              -

                                              Returns the parent layout of this layout element.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - -
                                              QRect QCPLayoutElement::rect () const
                                              -
                                              -inlineinherited
                                              -
                                              -

                                              Returns the inner rect of this layout element. The inner rect is the outer rect (setOuterRect) shrinked by the margins (setMargins, setAutoMargins).

                                              -

                                              In some cases, the area between outer and inner rect is left blank. In other cases the margin area is used to display peripheral graphics while the main content is in the inner rect. This is where automatic margin calculation becomes interesting because it allows the layout element to adapt the margins to the peripheral graphics it wants to draw. For example, QCPAxisRect draws the axis labels and tick labels in the margin area, thus needs to adjust the margins (if setAutoMargins is enabled) according to the space required by the labels of the axes.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              void QCPLayoutElement::setOuterRect (const QRect & rect)
                                              -
                                              -inherited
                                              -
                                              -

                                              Sets the outer rect of this layout element. If the layout element is inside a layout, the layout sets the position and size of this layout element using this function.

                                              -

                                              Calling this function externally has no effect, since the layout will overwrite any changes to the outer rect upon the next replot.

                                              -

                                              The layout element will adapt its inner rect by applying the margins inward to the outer rect.

                                              -
                                              See Also
                                              rect
                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              void QCPLayoutElement::setMargins (const QMargins & margins)
                                              -
                                              -inherited
                                              -
                                              -

                                              Sets the margins of this layout element. If setAutoMargins is disabled for some or all sides, this function is used to manually set the margin on those sides. Sides that are still set to be handled automatically are ignored and may have any value in margins.

                                              -

                                              The margin is the distance between the outer rect (controlled by the parent layout via setOuterRect) and the inner rect (which usually contains the main content of this layout element).

                                              -
                                              See Also
                                              setAutoMargins
                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              void QCPLayoutElement::setMinimumMargins (const QMargins & margins)
                                              -
                                              -inherited
                                              -
                                              -

                                              If setAutoMargins is enabled on some or all margins, this function is used to provide minimum values for those margins.

                                              -

                                              The minimum values are not enforced on margin sides that were set to be under manual control via setAutoMargins.

                                              -
                                              See Also
                                              setAutoMargins
                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              void QCPLayoutElement::setAutoMargins (QCP::MarginSides sides)
                                              -
                                              -inherited
                                              -
                                              -

                                              Sets on which sides the margin shall be calculated automatically. If a side is calculated automatically, a minimum margin value may be provided with setMinimumMargins. If a side is set to be controlled manually, the value may be specified with setMargins.

                                              -

                                              Margin sides that are under automatic control may participate in a QCPMarginGroup (see setMarginGroup), to synchronize (align) it with other layout elements in the plot.

                                              -
                                              See Also
                                              setMinimumMargins, setMargins
                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              void QCPLayoutElement::setMinimumSize (const QSize & size)
                                              -
                                              -inherited
                                              -
                                              -

                                              Sets the minimum size for the inner rect of this layout element. A parent layout tries to respect the size here by changing row/column sizes in the layout accordingly.

                                              -

                                              If the parent layout size is not sufficient to satisfy all minimum size constraints of its child layout elements, the layout may set a size that is actually smaller than size. QCustomPlot propagates the layout's size constraints to the outside by setting its own minimum QWidget size accordingly, so violations of size should be exceptions.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - - - - - - - - - - - -
                                              void QCPLayoutElement::setMinimumSize (int width,
                                              int height 
                                              )
                                              -
                                              -inherited
                                              -
                                              -

                                              This is an overloaded function.

                                              -

                                              Sets the minimum size for the inner rect of this layout element.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              void QCPLayoutElement::setMaximumSize (const QSize & size)
                                              -
                                              -inherited
                                              -
                                              -

                                              Sets the maximum size for the inner rect of this layout element. A parent layout tries to respect the size here by changing row/column sizes in the layout accordingly.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - - - - - - - - - - - -
                                              void QCPLayoutElement::setMaximumSize (int width,
                                              int height 
                                              )
                                              -
                                              -inherited
                                              -
                                              -

                                              This is an overloaded function.

                                              -

                                              Sets the maximum size for the inner rect of this layout element.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - - - - - - - - - - - -
                                              void QCPLayoutElement::setMarginGroup (QCP::MarginSides sides,
                                              QCPMarginGroupgroup 
                                              )
                                              -
                                              -inherited
                                              -
                                              -

                                              Sets the margin group of the specified margin sides.

                                              -

                                              Margin groups allow synchronizing specified margins across layout elements, see the documentation of QCPMarginGroup.

                                              -

                                              To unset the margin group of sides, set group to 0.

                                              -

                                              Note that margin groups only work for margin sides that are set to automatic (setAutoMargins).

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              int QCPLayoutElement::calculateAutoMargin (QCP::MarginSide side)
                                              -
                                              -protectedvirtualinherited
                                              -
                                              -

                                              Returns the margin size for this side. It is used if automatic margins is enabled for this side (see setAutoMargins). If a minimum margin was set with setMinimumMargins, the returned value will not be smaller than the specified minimum margin.

                                              -

                                              The default implementation just returns the respective manual margin (setMargins) or the minimum margin, whichever is larger.

                                              - -

                                              Reimplemented in QCPAxisRect.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              void QCPLayoutElement::mousePressEvent (QMouseEvent * event)
                                              -
                                              -inlineprotectedvirtualinherited
                                              -
                                              -

                                              This event is called, if the mouse was pressed while being inside the outer rect of this layout element.

                                              - -

                                              Reimplemented in QCPAxisRect.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              void QCPLayoutElement::mouseMoveEvent (QMouseEvent * event)
                                              -
                                              -inlineprotectedvirtualinherited
                                              -
                                              -

                                              This event is called, if the mouse is moved inside the outer rect of this layout element.

                                              - -

                                              Reimplemented in QCPAxisRect.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              void QCPLayoutElement::mouseReleaseEvent (QMouseEvent * event)
                                              -
                                              -inlineprotectedvirtualinherited
                                              -
                                              -

                                              This event is called, if the mouse was previously pressed inside the outer rect of this layout element and is now released.

                                              - -

                                              Reimplemented in QCPAxisRect.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              void QCPLayoutElement::mouseDoubleClickEvent (QMouseEvent * event)
                                              -
                                              -inlineprotectedvirtualinherited
                                              -
                                              -

                                              This event is called, if the mouse is double-clicked inside the outer rect of this layout element.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              void QCPLayoutElement::wheelEvent (QWheelEvent * event)
                                              -
                                              -inlineprotectedvirtualinherited
                                              -
                                              -

                                              This event is called, if the mouse wheel is scrolled while the cursor is inside the rect of this layout element.

                                              - -

                                              Reimplemented in QCPAxisRect.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - -
                                              QCPLayerable * QCPLayerable::parentLayerable () const
                                              -
                                              -inlineinherited
                                              -
                                              -

                                              Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.

                                              -

                                              Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.

                                              -

                                              A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              void QCPLayerable::setVisible (bool on)
                                              -
                                              -inherited
                                              -
                                              -

                                              Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              bool QCPLayerable::setLayer (QCPLayerlayer)
                                              -
                                              -inherited
                                              -
                                              -

                                              Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.

                                              -

                                              Returns true on success, i.e. if layer is a valid layer.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              bool QCPLayerable::setLayer (const QString & layerName)
                                              -
                                              -inherited
                                              -
                                              -

                                              This is an overloaded function.

                                              -

                                              Sets the layer of this layerable object by name

                                              -

                                              Returns true on success, i.e. if layerName is a valid layer name.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              void QCPLayerable::setAntialiased (bool enabled)
                                              -
                                              -inherited
                                              -
                                              -

                                              Sets whether this object will be drawn antialiased or not.

                                              -

                                              Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - -
                                              bool QCPLayerable::realVisibility () const
                                              -
                                              -inherited
                                              -
                                              -

                                              Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.

                                              -

                                              If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.

                                              -

                                              If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - -
                                              QRect QCPLayerable::clipRect () const
                                              -
                                              -protectedvirtualinherited
                                              -
                                              -

                                              Returns the clipping rectangle of this layerable object. By default, this is the viewport of the parent QCustomPlot. Specific subclasses may reimplement this function to provide different clipping rects.

                                              -

                                              The returned clipping rect is set on the painter before the draw function of the respective object is called.

                                              - -

                                              Reimplemented in QCPAbstractItem, QCPAbstractPlottable, and QCPAbstractLegendItem.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              void QCPLayerable::initializeParentPlot (QCustomPlotparentPlot)
                                              -
                                              -protectedinherited
                                              -
                                              -

                                              Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.

                                              -

                                              Note that, unlike when passing a non-null parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.

                                              -

                                              Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.

                                              -

                                              The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - -
                                              void QCPLayerable::setParentLayerable (QCPLayerableparentLayerable)
                                              -
                                              -protectedinherited
                                              -
                                              -

                                              Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.

                                              -

                                              The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.

                                              -
                                              See Also
                                              realVisibility
                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - - - - - - - - - - - -
                                              bool QCPLayerable::moveToLayer (QCPLayerlayer,
                                              bool prepend 
                                              )
                                              -
                                              -protectedinherited
                                              -
                                              -

                                              Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.

                                              -

                                              Returns true on success, i.e. if layer is a valid layer.

                                              - -
                                              -
                                              - -
                                              -
                                              - - - - - -
                                              - - - - - - - - - - - - - - - - - - - - - - - - -
                                              void QCPLayerable::applyAntialiasingHint (QCPPainterpainter,
                                              bool localAntialiased,
                                              QCP::AntialiasedElement overrideElement 
                                              ) const
                                              -
                                              -protectedinherited
                                              -
                                              -

                                              Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.

                                              - -
                                              -

                                              The documentation for this class was generated from the following files:
                                              • src/layoutelements/layoutelement-legend.h
                                              • src/layoutelements/layoutelement-legend.cpp
                                              • diff -Nru qcustomplot-1.1.0/documentation/html/classQCPLineEnding.html qcustomplot-1.2.0/documentation/html/classQCPLineEnding.html --- qcustomplot-1.1.0/documentation/html/classQCPLineEnding.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPLineEnding.html 2014-03-14 21:11:26.000000000 +0000 @@ -76,7 +76,7 @@ QCPLineEnding.png

                                                The width and length of these decorations can be controlled with the functions setWidth and setLength. Some decorations like esDisc, esSquare, esDiamond and esBar only support a width, the length property is ignored.

                                                -
                                                See Also
                                                QCPItemLine::setHead, QCPItemLine::setTail, QCPItemCurve::setHead, QCPItemCurve::setTail
                                                +
                                                See Also
                                                QCPItemLine::setHead, QCPItemLine::setTail, QCPItemCurve::setHead, QCPItemCurve::setTail, QCPAxis::setLowerEnding, QCPAxis::setUpperEnding
                                                Enumerator:
                                                esNone 

                                                No ending decoration.

                                                @@ -103,7 +103,7 @@

                                                A bar perpendicular to the line.

                                                esHalfBar  -

                                                A bar perpendicular to the line sticking out to one side.

                                                +

                                                A bar perpendicular to the line, pointing out to only one side (to which side can be changed with setInverted)

                                                esSkewedBar 

                                                A bar that is skewed (skew controllable via setLength)

                                                diff -Nru qcustomplot-1.1.0/documentation/html/classQCPPainter.html qcustomplot-1.2.0/documentation/html/classQCPPainter.html --- qcustomplot-1.1.0/documentation/html/classQCPPainter.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPPainter.html 2014-03-14 21:11:26.000000000 +0000 @@ -54,7 +54,7 @@

                                                Detailed Description

                                                QPainter subclass used internally.

                                                -

                                                This internal class is used to provide some extended functionality e.g. for tweaking position consistency between antialiased and non-antialiased painting. Further it provides workarounds for QPainter quirks.

                                                +

                                                This QPainter subclass is used to provide some extended functionality e.g. for tweaking position consistency between antialiased and non-antialiased painting. Further it provides workarounds for QPainter quirks.

                                                Warning
                                                This class intentionally hides non-virtual functions of QPainter, e.g. setPen, save and restore. So while it is possible to pass a QCPPainter instance to a function that expects a QPainter pointer, some of the workarounds and tweaks will be unavailable to the function (because it will call the base class implementations of the functions actually hidden by QCPPainter).

                                                Member Enumeration Documentation

                                                diff -Nru qcustomplot-1.1.0/documentation/html/classQCPPlottableLegendItem.html qcustomplot-1.2.0/documentation/html/classQCPPlottableLegendItem.html --- qcustomplot-1.1.0/documentation/html/classQCPPlottableLegendItem.html 2013-11-04 22:19:42.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPPlottableLegendItem.html 2014-03-14 21:11:27.000000000 +0000 @@ -17,7 +17,6 @@
                                                QCPPlottableLegendItem Class Reference
                                                @@ -39,76 +38,78 @@  QCPPlottableLegendItem (QCPLegend *parent, QCPAbstractPlottable *plottable) QCPAbstractPlottableplottable () - +- Public Functions inherited from QCPAbstractLegendItemQCPAbstractLegendItem (QCPLegend *parent) + QCPLegendparentLegend () const - + QFont font () const - + QColor textColor () const - + QFont selectedFont () const - + QColor selectedTextColor () const - + bool selectable () const - + bool selected () const -void setFont (const QFont &font) -void setTextColor (const QColor &color) -void setSelectedFont (const QFont &font) -void setSelectedTextColor (const QColor &color) -void setSelectable (bool selectable) -void setSelected (bool selected) -virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const -QCPLayoutlayout () const -QRect rect () const - +void setFont (const QFont &font) +void setTextColor (const QColor &color) +void setSelectedFont (const QFont &font) +void setSelectedTextColor (const QColor &color) +Q_SLOT void setSelectable (bool selectable) +Q_SLOT void setSelected (bool selected) +virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const +- Public Functions inherited from QCPLayoutElementQCPLayoutElement (QCustomPlot *parentPlot=0) +QCPLayoutlayout () const +QRect rect () const + QRect outerRect () const - + QMargins margins () const - + QMargins minimumMargins () const - + QCP::MarginSides autoMargins () const - + QSize minimumSize () const - + QSize maximumSize () const - + QCPMarginGroupmarginGroup (QCP::MarginSide side) const - + QHash< QCP::MarginSide,
                                                QCPMarginGroup * > marginGroups () const -void setOuterRect (const QRect &rect) -void setMargins (const QMargins &margins) -void setMinimumMargins (const QMargins &margins) -void setAutoMargins (QCP::MarginSides sides) -void setMinimumSize (const QSize &size) -void setMinimumSize (int width, int height) -void setMaximumSize (const QSize &size) -void setMaximumSize (int width, int height) -void setMarginGroup (QCP::MarginSides sides, QCPMarginGroup *group) -virtual void update () -virtual QSize maximumSizeHint () const -virtual QList< QCPLayoutElement * > elements (bool recursive) const - +void setOuterRect (const QRect &rect) +void setMargins (const QMargins &margins) +void setMinimumMargins (const QMargins &margins) +void setAutoMargins (QCP::MarginSides sides) +void setMinimumSize (const QSize &size) +void setMinimumSize (int width, int height) +void setMaximumSize (const QSize &size) +void setMaximumSize (int width, int height) +void setMarginGroup (QCP::MarginSides sides, QCPMarginGroup *group) +virtual void update (UpdatePhase phase) +virtual QSize maximumSizeHint () const +virtual QList< QCPLayoutElement * > elements (bool recursive) const +- Public Functions inherited from QCPLayerableQCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0) + bool visible () const - + QCustomPlotparentPlot () const -QCPLayerableparentLayerable () const - +QCPLayerableparentLayerable () const + QCPLayerlayer () const - + bool antialiased () const -void setVisible (bool on) -bool setLayer (QCPLayer *layer) -bool setLayer (const QString &layerName) -void setAntialiased (bool enabled) -bool realVisibility () const - - - + + + + +

                                                -Signals

                                                void selectionChanged (bool selected)
                                                void setVisible (bool on)
                                                Q_SLOT bool setLayer (QCPLayer *layer)
                                                bool setLayer (const QString &layerName)
                                                void setAntialiased (bool enabled)
                                                bool realVisibility () const
                                                @@ -117,22 +118,34 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + +

                                                Protected Functions

                                                QPen getIconBorderPen () const
                                                QColor getTextColor () const
                                                QFont getFont () const
                                                virtual QCP::Interaction selectionCategory () const
                                                virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
                                                virtual QRect clipRect () const
                                                virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                                                virtual void deselectEvent (bool *selectionStateChanged)
                                                virtual int calculateAutoMargin (QCP::MarginSide side)
                                                virtual void mousePressEvent (QMouseEvent *event)
                                                virtual void mouseMoveEvent (QMouseEvent *event)
                                                virtual void mouseReleaseEvent (QMouseEvent *event)
                                                virtual void mouseDoubleClickEvent (QMouseEvent *event)
                                                virtual void wheelEvent (QWheelEvent *event)
                                                virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                                                void initializeParentPlot (QCustomPlot *parentPlot)
                                                void setParentLayerable (QCPLayerable *parentLayerable)
                                                bool moveToLayer (QCPLayer *layer, bool prepend)
                                                void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                                                - Protected Functions inherited from QCPAbstractLegendItem
                                                virtual QCP::Interaction selectionCategory () const
                                                virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
                                                virtual QRect clipRect () const
                                                virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                                                virtual void deselectEvent (bool *selectionStateChanged)
                                                - Protected Functions inherited from QCPLayoutElement
                                                virtual int calculateAutoMargin (QCP::MarginSide side)
                                                virtual void mousePressEvent (QMouseEvent *event)
                                                virtual void mouseMoveEvent (QMouseEvent *event)
                                                virtual void mouseReleaseEvent (QMouseEvent *event)
                                                virtual void mouseDoubleClickEvent (QMouseEvent *event)
                                                virtual void wheelEvent (QWheelEvent *event)
                                                virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                                                - Protected Functions inherited from QCPLayerable
                                                void initializeParentPlot (QCustomPlot *parentPlot)
                                                void setParentLayerable (QCPLayerable *parentLayerable)
                                                bool moveToLayer (QCPLayer *layer, bool prepend)
                                                void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                                                + + + + + +

                                                +Additional Inherited Members

                                                - Public Types inherited from QCPLayoutElement
                                                enum  UpdatePhase
                                                - Signals inherited from QCPAbstractLegendItem
                                                void selectionChanged (bool selected)
                                                +void selectableChanged (bool selectable)

                                                Detailed Description

                                                A legend item representing a plottable with an icon and the plottable name.

                                                @@ -296,1279 +309,6 @@
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                void QCPAbstractLegendItem::setFont (const QFont & font)
                                                -
                                                -inherited
                                                -
                                                -

                                                Sets the default font of this specific legend item to font.

                                                -
                                                See Also
                                                setTextColor, QCPLegend::setFont
                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                void QCPAbstractLegendItem::setTextColor (const QColor & color)
                                                -
                                                -inherited
                                                -
                                                -

                                                Sets the default text color of this specific legend item to color.

                                                -
                                                See Also
                                                setFont, QCPLegend::setTextColor
                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                void QCPAbstractLegendItem::setSelectedFont (const QFont & font)
                                                -
                                                -inherited
                                                -
                                                -

                                                When this legend item is selected, font is used to draw generic text, instead of the normal font set with setFont.

                                                -
                                                See Also
                                                setFont, QCPLegend::setSelectedFont
                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                void QCPAbstractLegendItem::setSelectedTextColor (const QColor & color)
                                                -
                                                -inherited
                                                -
                                                -

                                                When this legend item is selected, color is used to draw generic text, instead of the normal color set with setTextColor.

                                                -
                                                See Also
                                                setTextColor, QCPLegend::setSelectedTextColor
                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                void QCPAbstractLegendItem::setSelectable (bool selectable)
                                                -
                                                -inherited
                                                -
                                                -

                                                Sets whether this specific legend item is selectable.

                                                -
                                                See Also
                                                setSelectedParts, QCustomPlot::setInteractions
                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                void QCPAbstractLegendItem::setSelected (bool selected)
                                                -
                                                -inherited
                                                -
                                                -

                                                Sets whether this specific legend item is selected.

                                                -

                                                It is possible to set the selection state of this item by calling this function directly, even if setSelectable is set to false.

                                                -
                                                See Also
                                                setSelectableParts, QCustomPlot::setInteractions
                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - - - - - - - - - - - - - - - - - -
                                                double QCPAbstractLegendItem::selectTest (const QPointF & pos,
                                                bool onlySelectable,
                                                QVariant * details = 0 
                                                ) const
                                                -
                                                -virtualinherited
                                                -
                                                -

                                                Layout elements are sensitive to events inside their outer rect. If pos is within the outer rect, this method returns a value corresponding to 0.99 times the parent plot's selection tolerance. However, layout elements are not selectable by default. So if onlySelectable is true, -1.0 is returned.

                                                -

                                                See QCPLayerable::selectTest for a general explanation of this virtual method.

                                                -

                                                QCPLayoutElement subclasses may reimplement this method to provide more specific selection test behaviour.

                                                - -

                                                Reimplemented from QCPLayoutElement.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                void QCPAbstractLegendItem::selectionChanged (bool selected)
                                                -
                                                -signalinherited
                                                -
                                                -

                                                This signal is emitted when the selection state of this legend item has changed, either by user interaction or by a direct call to setSelected.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - -
                                                QCP::Interaction QCPAbstractLegendItem::selectionCategory () const
                                                -
                                                -protectedvirtualinherited
                                                -
                                                -

                                                Returns the selection category this layerable shall belong to. The selection category is used in conjunction with QCustomPlot::setInteractions to control which objects are selectable and which aren't.

                                                -

                                                Subclasses that don't fit any of the normal QCP::Interaction values can use QCP::iSelectOther. This is what the default implementation returns.

                                                -
                                                See Also
                                                QCustomPlot::setInteractions
                                                - -

                                                Reimplemented from QCPLayerable.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                void QCPAbstractLegendItem::applyDefaultAntialiasingHint (QCPPainterpainter) const
                                                -
                                                -protectedvirtualinherited
                                                -
                                                -

                                                This function applies the default antialiasing setting to the specified painter, using the function applyAntialiasingHint. It is the antialiasing state the painter is put in, when draw is called on the layerable. If the layerable has multiple entities whose antialiasing setting may be specified individually, this function should set the antialiasing state of the most prominent entity. In this case however, the draw function usually calls the specialized versions of this function before drawing each entity, effectively overriding the setting of the default antialiasing hint.

                                                -

                                                First example: QCPGraph has multiple entities that have an antialiasing setting: The graph line, fills, scatters and error bars. Those can be configured via QCPGraph::setAntialiased, QCPGraph::setAntialiasedFill, QCPGraph::setAntialiasedScatters etc. Consequently, there isn't only the QCPGraph::applyDefaultAntialiasingHint function (which corresponds to the graph line's antialiasing), but specialized ones like QCPGraph::applyFillAntialiasingHint and QCPGraph::applyScattersAntialiasingHint. So before drawing one of those entities, QCPGraph::draw calls the respective specialized applyAntialiasingHint function.

                                                -

                                                Second example: QCPItemLine consists only of a line so there is only one antialiasing setting which can be controlled with QCPItemLine::setAntialiased. (This function is inherited by all layerables. The specialized functions, as seen on QCPGraph, must be added explicitly to the respective layerable subclass.) Consequently it only has the normal QCPItemLine::applyDefaultAntialiasingHint. The QCPItemLine::draw function doesn't need to care about setting any antialiasing states, because the default antialiasing hint is already set on the painter when the draw function is called, and that's the state it wants to draw the line with.

                                                - -

                                                Reimplemented from QCPLayoutElement.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - -
                                                QRect QCPAbstractLegendItem::clipRect () const
                                                -
                                                -protectedvirtualinherited
                                                -
                                                -

                                                Returns the clipping rectangle of this layerable object. By default, this is the viewport of the parent QCustomPlot. Specific subclasses may reimplement this function to provide different clipping rects.

                                                -

                                                The returned clipping rect is set on the painter before the draw function of the respective object is called.

                                                - -

                                                Reimplemented from QCPLayerable.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                                                void QCPAbstractLegendItem::selectEvent (QMouseEvent * event,
                                                bool additive,
                                                const QVariant & details,
                                                bool * selectionStateChanged 
                                                )
                                                -
                                                -protectedvirtualinherited
                                                -
                                                -

                                                This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

                                                -

                                                event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

                                                -

                                                Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

                                                -

                                                selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

                                                -
                                                See Also
                                                selectTest, deselectEvent
                                                - -

                                                Reimplemented from QCPLayerable.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                void QCPAbstractLegendItem::deselectEvent (bool * selectionStateChanged)
                                                -
                                                -protectedvirtualinherited
                                                -
                                                -

                                                This event is called when the layerable shall be deselected, either as consequence of a user interaction or a call to QCustomPlot::deselectAll. Subclasses should react to it by unsetting their selection appropriately.

                                                -

                                                just as in selectEvent, the output parameter selectionStateChanged (if non-null), must return true or false when the selection state of this layerable has changed or not changed, respectively.

                                                -
                                                See Also
                                                selectTest, selectEvent
                                                - -

                                                Reimplemented from QCPLayerable.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - -
                                                QCPLayout * QCPLayoutElement::layout () const
                                                -
                                                -inlineinherited
                                                -
                                                -

                                                Returns the parent layout of this layout element.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - -
                                                QRect QCPLayoutElement::rect () const
                                                -
                                                -inlineinherited
                                                -
                                                -

                                                Returns the inner rect of this layout element. The inner rect is the outer rect (setOuterRect) shrinked by the margins (setMargins, setAutoMargins).

                                                -

                                                In some cases, the area between outer and inner rect is left blank. In other cases the margin area is used to display peripheral graphics while the main content is in the inner rect. This is where automatic margin calculation becomes interesting because it allows the layout element to adapt the margins to the peripheral graphics it wants to draw. For example, QCPAxisRect draws the axis labels and tick labels in the margin area, thus needs to adjust the margins (if setAutoMargins is enabled) according to the space required by the labels of the axes.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                void QCPLayoutElement::setOuterRect (const QRect & rect)
                                                -
                                                -inherited
                                                -
                                                -

                                                Sets the outer rect of this layout element. If the layout element is inside a layout, the layout sets the position and size of this layout element using this function.

                                                -

                                                Calling this function externally has no effect, since the layout will overwrite any changes to the outer rect upon the next replot.

                                                -

                                                The layout element will adapt its inner rect by applying the margins inward to the outer rect.

                                                -
                                                See Also
                                                rect
                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                void QCPLayoutElement::setMargins (const QMargins & margins)
                                                -
                                                -inherited
                                                -
                                                -

                                                Sets the margins of this layout element. If setAutoMargins is disabled for some or all sides, this function is used to manually set the margin on those sides. Sides that are still set to be handled automatically are ignored and may have any value in margins.

                                                -

                                                The margin is the distance between the outer rect (controlled by the parent layout via setOuterRect) and the inner rect (which usually contains the main content of this layout element).

                                                -
                                                See Also
                                                setAutoMargins
                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                void QCPLayoutElement::setMinimumMargins (const QMargins & margins)
                                                -
                                                -inherited
                                                -
                                                -

                                                If setAutoMargins is enabled on some or all margins, this function is used to provide minimum values for those margins.

                                                -

                                                The minimum values are not enforced on margin sides that were set to be under manual control via setAutoMargins.

                                                -
                                                See Also
                                                setAutoMargins
                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                void QCPLayoutElement::setAutoMargins (QCP::MarginSides sides)
                                                -
                                                -inherited
                                                -
                                                -

                                                Sets on which sides the margin shall be calculated automatically. If a side is calculated automatically, a minimum margin value may be provided with setMinimumMargins. If a side is set to be controlled manually, the value may be specified with setMargins.

                                                -

                                                Margin sides that are under automatic control may participate in a QCPMarginGroup (see setMarginGroup), to synchronize (align) it with other layout elements in the plot.

                                                -
                                                See Also
                                                setMinimumMargins, setMargins
                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                void QCPLayoutElement::setMinimumSize (const QSize & size)
                                                -
                                                -inherited
                                                -
                                                -

                                                Sets the minimum size for the inner rect of this layout element. A parent layout tries to respect the size here by changing row/column sizes in the layout accordingly.

                                                -

                                                If the parent layout size is not sufficient to satisfy all minimum size constraints of its child layout elements, the layout may set a size that is actually smaller than size. QCustomPlot propagates the layout's size constraints to the outside by setting its own minimum QWidget size accordingly, so violations of size should be exceptions.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - - - - - - - - - - - -
                                                void QCPLayoutElement::setMinimumSize (int width,
                                                int height 
                                                )
                                                -
                                                -inherited
                                                -
                                                -

                                                This is an overloaded function.

                                                -

                                                Sets the minimum size for the inner rect of this layout element.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                void QCPLayoutElement::setMaximumSize (const QSize & size)
                                                -
                                                -inherited
                                                -
                                                -

                                                Sets the maximum size for the inner rect of this layout element. A parent layout tries to respect the size here by changing row/column sizes in the layout accordingly.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - - - - - - - - - - - -
                                                void QCPLayoutElement::setMaximumSize (int width,
                                                int height 
                                                )
                                                -
                                                -inherited
                                                -
                                                -

                                                This is an overloaded function.

                                                -

                                                Sets the maximum size for the inner rect of this layout element.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - - - - - - - - - - - -
                                                void QCPLayoutElement::setMarginGroup (QCP::MarginSides sides,
                                                QCPMarginGroupgroup 
                                                )
                                                -
                                                -inherited
                                                -
                                                -

                                                Sets the margin group of the specified margin sides.

                                                -

                                                Margin groups allow synchronizing specified margins across layout elements, see the documentation of QCPMarginGroup.

                                                -

                                                To unset the margin group of sides, set group to 0.

                                                -

                                                Note that margin groups only work for margin sides that are set to automatic (setAutoMargins).

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - -
                                                void QCPLayoutElement::update ()
                                                -
                                                -virtualinherited
                                                -
                                                -

                                                Updates the layout element and sub-elements. This function is automatically called upon replot by the parent layout element.

                                                -

                                                Layout elements that have child elements should call the update method of their child elements.

                                                -

                                                The default implementation executes the automatic margin mechanism, so subclasses should make sure to call the base class implementation.

                                                - -

                                                Reimplemented in QCPLayout, and QCPAxisRect.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - -
                                                QSize QCPLayoutElement::maximumSizeHint () const
                                                -
                                                -virtualinherited
                                                -
                                                -

                                                Returns the maximum size this layout element (the inner rect) may be expanded to.

                                                -

                                                if a maximum size (setMaximumSize) was not set manually, parent layouts consult this function to determine the maximum allowed size of this layout element. (A manual maximum size is considered set if it is smaller than Qt's QWIDGETSIZE_MAX.)

                                                - -

                                                Reimplemented in QCPLayoutGrid, and QCPPlotTitle.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                QList< QCPLayoutElement * > QCPLayoutElement::elements (bool recursive) const
                                                -
                                                -virtualinherited
                                                -
                                                -

                                                Returns a list of all child elements in this layout element. If recursive is true, all sub-child elements are included in the list, too.

                                                -

                                                Note that there may be entries with value 0 in the returned list. (For example, QCPLayoutGrid may have empty cells which yield 0 at the respective index.)

                                                - -

                                                Reimplemented in QCPLayoutGrid, QCPLayout, and QCPAxisRect.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                int QCPLayoutElement::calculateAutoMargin (QCP::MarginSide side)
                                                -
                                                -protectedvirtualinherited
                                                -
                                                -

                                                Returns the margin size for this side. It is used if automatic margins is enabled for this side (see setAutoMargins). If a minimum margin was set with setMinimumMargins, the returned value will not be smaller than the specified minimum margin.

                                                -

                                                The default implementation just returns the respective manual margin (setMargins) or the minimum margin, whichever is larger.

                                                - -

                                                Reimplemented in QCPAxisRect.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                void QCPLayoutElement::mousePressEvent (QMouseEvent * event)
                                                -
                                                -inlineprotectedvirtualinherited
                                                -
                                                -

                                                This event is called, if the mouse was pressed while being inside the outer rect of this layout element.

                                                - -

                                                Reimplemented in QCPAxisRect.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                void QCPLayoutElement::mouseMoveEvent (QMouseEvent * event)
                                                -
                                                -inlineprotectedvirtualinherited
                                                -
                                                -

                                                This event is called, if the mouse is moved inside the outer rect of this layout element.

                                                - -

                                                Reimplemented in QCPAxisRect.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                void QCPLayoutElement::mouseReleaseEvent (QMouseEvent * event)
                                                -
                                                -inlineprotectedvirtualinherited
                                                -
                                                -

                                                This event is called, if the mouse was previously pressed inside the outer rect of this layout element and is now released.

                                                - -

                                                Reimplemented in QCPAxisRect.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                void QCPLayoutElement::mouseDoubleClickEvent (QMouseEvent * event)
                                                -
                                                -inlineprotectedvirtualinherited
                                                -
                                                -

                                                This event is called, if the mouse is double-clicked inside the outer rect of this layout element.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                void QCPLayoutElement::wheelEvent (QWheelEvent * event)
                                                -
                                                -inlineprotectedvirtualinherited
                                                -
                                                -

                                                This event is called, if the mouse wheel is scrolled while the cursor is inside the rect of this layout element.

                                                - -

                                                Reimplemented in QCPAxisRect.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                void QCPLayoutElement::parentPlotInitialized (QCustomPlotparentPlot)
                                                -
                                                -protectedvirtualinherited
                                                -
                                                -

                                                propagates the parent plot initialization to all child elements, by calling QCPLayerable::initializeParentPlot on them.

                                                - -

                                                Reimplemented from QCPLayerable.

                                                - -

                                                Reimplemented in QCPLegend.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - -
                                                QCPLayerable * QCPLayerable::parentLayerable () const
                                                -
                                                -inlineinherited
                                                -
                                                -

                                                Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.

                                                -

                                                Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.

                                                -

                                                A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                void QCPLayerable::setVisible (bool on)
                                                -
                                                -inherited
                                                -
                                                -

                                                Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                bool QCPLayerable::setLayer (QCPLayerlayer)
                                                -
                                                -inherited
                                                -
                                                -

                                                Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.

                                                -

                                                Returns true on success, i.e. if layer is a valid layer.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                bool QCPLayerable::setLayer (const QString & layerName)
                                                -
                                                -inherited
                                                -
                                                -

                                                This is an overloaded function.

                                                -

                                                Sets the layer of this layerable object by name

                                                -

                                                Returns true on success, i.e. if layerName is a valid layer name.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                void QCPLayerable::setAntialiased (bool enabled)
                                                -
                                                -inherited
                                                -
                                                -

                                                Sets whether this object will be drawn antialiased or not.

                                                -

                                                Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - -
                                                bool QCPLayerable::realVisibility () const
                                                -
                                                -inherited
                                                -
                                                -

                                                Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.

                                                -

                                                If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.

                                                -

                                                If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                void QCPLayerable::initializeParentPlot (QCustomPlotparentPlot)
                                                -
                                                -protectedinherited
                                                -
                                                -

                                                Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.

                                                -

                                                Note that, unlike when passing a non-null parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.

                                                -

                                                Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.

                                                -

                                                The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - -
                                                void QCPLayerable::setParentLayerable (QCPLayerableparentLayerable)
                                                -
                                                -protectedinherited
                                                -
                                                -

                                                Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.

                                                -

                                                The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.

                                                -
                                                See Also
                                                realVisibility
                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - - - - - - - - - - - -
                                                bool QCPLayerable::moveToLayer (QCPLayerlayer,
                                                bool prepend 
                                                )
                                                -
                                                -protectedinherited
                                                -
                                                -

                                                Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.

                                                -

                                                Returns true on success, i.e. if layer is a valid layer.

                                                - -
                                                -
                                                - -
                                                -
                                                - - - - - -
                                                - - - - - - - - - - - - - - - - - - - - - - - - -
                                                void QCPLayerable::applyAntialiasingHint (QCPPainterpainter,
                                                bool localAntialiased,
                                                QCP::AntialiasedElement overrideElement 
                                                ) const
                                                -
                                                -protectedinherited
                                                -
                                                -

                                                Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.

                                                - -
                                                -

                                                The documentation for this class was generated from the following files:
                                                • src/layoutelements/layoutelement-legend.h
                                                • src/layoutelements/layoutelement-legend.cpp
                                                • diff -Nru qcustomplot-1.1.0/documentation/html/classQCPPlotTitle.html qcustomplot-1.2.0/documentation/html/classQCPPlotTitle.html --- qcustomplot-1.1.0/documentation/html/classQCPPlotTitle.html 2013-11-04 22:19:42.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPPlotTitle.html 2014-03-14 21:11:27.000000000 +0000 @@ -57,57 +57,63 @@ void setTextColor (const QColor &color) void setSelectedFont (const QFont &font) void setSelectedTextColor (const QColor &color) -void setSelectable (bool selectable) -void setSelected (bool selected) +Q_SLOT void setSelectable (bool selectable) +Q_SLOT void setSelected (bool selected) virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const -QCPLayoutlayout () const -QRect rect () const - +- Public Functions inherited from QCPLayoutElementQCPLayoutElement (QCustomPlot *parentPlot=0) +QCPLayoutlayout () const +QRect rect () const + QRect outerRect () const - + QMargins margins () const - + QMargins minimumMargins () const - + QCP::MarginSides autoMargins () const - + QSize minimumSize () const - + QSize maximumSize () const - + QCPMarginGroupmarginGroup (QCP::MarginSide side) const - + QHash< QCP::MarginSide,
                                                  QCPMarginGroup * > marginGroups () const -void setOuterRect (const QRect &rect) -void setMargins (const QMargins &margins) -void setMinimumMargins (const QMargins &margins) -void setAutoMargins (QCP::MarginSides sides) -void setMinimumSize (const QSize &size) -void setMinimumSize (int width, int height) -void setMaximumSize (const QSize &size) -void setMaximumSize (int width, int height) -void setMarginGroup (QCP::MarginSides sides, QCPMarginGroup *group) -virtual void update () -virtual QList< QCPLayoutElement * > elements (bool recursive) const - +void setOuterRect (const QRect &rect) +void setMargins (const QMargins &margins) +void setMinimumMargins (const QMargins &margins) +void setAutoMargins (QCP::MarginSides sides) +void setMinimumSize (const QSize &size) +void setMinimumSize (int width, int height) +void setMaximumSize (const QSize &size) +void setMaximumSize (int width, int height) +void setMarginGroup (QCP::MarginSides sides, QCPMarginGroup *group) +virtual void update (UpdatePhase phase) +virtual QList< QCPLayoutElement * > elements (bool recursive) const +- Public Functions inherited from QCPLayerableQCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0) + bool visible () const - + QCustomPlotparentPlot () const -QCPLayerableparentLayerable () const - +QCPLayerableparentLayerable () const + QCPLayerlayer () const - + bool antialiased () const -void setVisible (bool on) -bool setLayer (QCPLayer *layer) -bool setLayer (const QString &layerName) -void setAntialiased (bool enabled) -bool realVisibility () const +void setVisible (bool on) +Q_SLOT bool setLayer (QCPLayer *layer) +bool setLayer (const QString &layerName) +void setAntialiased (bool enabled) +bool realVisibility () const +

                                                  Signals

                                                  void selectionChanged (bool selected)
                                                  +void selectableChanged (bool selectable)
                                                  @@ -119,19 +125,26 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + + + +

                                                  Protected Functions

                                                  virtual void deselectEvent (bool *selectionStateChanged)
                                                  QFont mainFont () const
                                                  QColor mainTextColor () const
                                                  virtual int calculateAutoMargin (QCP::MarginSide side)
                                                  virtual void mousePressEvent (QMouseEvent *event)
                                                  virtual void mouseMoveEvent (QMouseEvent *event)
                                                  virtual void mouseReleaseEvent (QMouseEvent *event)
                                                  virtual void mouseDoubleClickEvent (QMouseEvent *event)
                                                  virtual void wheelEvent (QWheelEvent *event)
                                                  virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                                                  virtual QCP::Interaction selectionCategory () const
                                                  virtual QRect clipRect () const
                                                  void initializeParentPlot (QCustomPlot *parentPlot)
                                                  void setParentLayerable (QCPLayerable *parentLayerable)
                                                  bool moveToLayer (QCPLayer *layer, bool prepend)
                                                  void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                                                  - Protected Functions inherited from QCPLayoutElement
                                                  virtual int calculateAutoMargin (QCP::MarginSide side)
                                                  virtual void mousePressEvent (QMouseEvent *event)
                                                  virtual void mouseMoveEvent (QMouseEvent *event)
                                                  virtual void mouseReleaseEvent (QMouseEvent *event)
                                                  virtual void mouseDoubleClickEvent (QMouseEvent *event)
                                                  virtual void wheelEvent (QWheelEvent *event)
                                                  virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                                                  - Protected Functions inherited from QCPLayerable
                                                  virtual QCP::Interaction selectionCategory () const
                                                  virtual QRect clipRect () const
                                                  void initializeParentPlot (QCustomPlot *parentPlot)
                                                  void setParentLayerable (QCPLayerable *parentLayerable)
                                                  bool moveToLayer (QCPLayer *layer, bool prepend)
                                                  void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                                                  + + +

                                                  +Additional Inherited Members

                                                  - Public Types inherited from QCPLayoutElement
                                                  enum  UpdatePhase

                                                  Detailed Description

                                                  A layout element displaying a plot title text.

                                                  @@ -557,7 +570,7 @@

                                                  This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

                                                  event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

                                                  -

                                                  Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

                                                  +

                                                  Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is fed back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

                                                  selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

                                                  See Also
                                                  selectTest, deselectEvent
                                                  @@ -642,914 +655,6 @@
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - -
                                                  QCPLayout * QCPLayoutElement::layout () const
                                                  -
                                                  -inlineinherited
                                                  -
                                                  -

                                                  Returns the parent layout of this layout element.

                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - -
                                                  QRect QCPLayoutElement::rect () const
                                                  -
                                                  -inlineinherited
                                                  -
                                                  -

                                                  Returns the inner rect of this layout element. The inner rect is the outer rect (setOuterRect) shrinked by the margins (setMargins, setAutoMargins).

                                                  -

                                                  In some cases, the area between outer and inner rect is left blank. In other cases the margin area is used to display peripheral graphics while the main content is in the inner rect. This is where automatic margin calculation becomes interesting because it allows the layout element to adapt the margins to the peripheral graphics it wants to draw. For example, QCPAxisRect draws the axis labels and tick labels in the margin area, thus needs to adjust the margins (if setAutoMargins is enabled) according to the space required by the labels of the axes.

                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - - -
                                                  void QCPLayoutElement::setOuterRect (const QRect & rect)
                                                  -
                                                  -inherited
                                                  -
                                                  -

                                                  Sets the outer rect of this layout element. If the layout element is inside a layout, the layout sets the position and size of this layout element using this function.

                                                  -

                                                  Calling this function externally has no effect, since the layout will overwrite any changes to the outer rect upon the next replot.

                                                  -

                                                  The layout element will adapt its inner rect by applying the margins inward to the outer rect.

                                                  -
                                                  See Also
                                                  rect
                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - - -
                                                  void QCPLayoutElement::setMargins (const QMargins & margins)
                                                  -
                                                  -inherited
                                                  -
                                                  -

                                                  Sets the margins of this layout element. If setAutoMargins is disabled for some or all sides, this function is used to manually set the margin on those sides. Sides that are still set to be handled automatically are ignored and may have any value in margins.

                                                  -

                                                  The margin is the distance between the outer rect (controlled by the parent layout via setOuterRect) and the inner rect (which usually contains the main content of this layout element).

                                                  -
                                                  See Also
                                                  setAutoMargins
                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - - -
                                                  void QCPLayoutElement::setMinimumMargins (const QMargins & margins)
                                                  -
                                                  -inherited
                                                  -
                                                  -

                                                  If setAutoMargins is enabled on some or all margins, this function is used to provide minimum values for those margins.

                                                  -

                                                  The minimum values are not enforced on margin sides that were set to be under manual control via setAutoMargins.

                                                  -
                                                  See Also
                                                  setAutoMargins
                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - - -
                                                  void QCPLayoutElement::setAutoMargins (QCP::MarginSides sides)
                                                  -
                                                  -inherited
                                                  -
                                                  -

                                                  Sets on which sides the margin shall be calculated automatically. If a side is calculated automatically, a minimum margin value may be provided with setMinimumMargins. If a side is set to be controlled manually, the value may be specified with setMargins.

                                                  -

                                                  Margin sides that are under automatic control may participate in a QCPMarginGroup (see setMarginGroup), to synchronize (align) it with other layout elements in the plot.

                                                  -
                                                  See Also
                                                  setMinimumMargins, setMargins
                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - - -
                                                  void QCPLayoutElement::setMinimumSize (const QSize & size)
                                                  -
                                                  -inherited
                                                  -
                                                  -

                                                  Sets the minimum size for the inner rect of this layout element. A parent layout tries to respect the size here by changing row/column sizes in the layout accordingly.

                                                  -

                                                  If the parent layout size is not sufficient to satisfy all minimum size constraints of its child layout elements, the layout may set a size that is actually smaller than size. QCustomPlot propagates the layout's size constraints to the outside by setting its own minimum QWidget size accordingly, so violations of size should be exceptions.

                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - - - - - - - - - - - - -
                                                  void QCPLayoutElement::setMinimumSize (int width,
                                                  int height 
                                                  )
                                                  -
                                                  -inherited
                                                  -
                                                  -

                                                  This is an overloaded function.

                                                  -

                                                  Sets the minimum size for the inner rect of this layout element.

                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - - -
                                                  void QCPLayoutElement::setMaximumSize (const QSize & size)
                                                  -
                                                  -inherited
                                                  -
                                                  -

                                                  Sets the maximum size for the inner rect of this layout element. A parent layout tries to respect the size here by changing row/column sizes in the layout accordingly.

                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - - - - - - - - - - - - -
                                                  void QCPLayoutElement::setMaximumSize (int width,
                                                  int height 
                                                  )
                                                  -
                                                  -inherited
                                                  -
                                                  -

                                                  This is an overloaded function.

                                                  -

                                                  Sets the maximum size for the inner rect of this layout element.

                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - - - - - - - - - - - - -
                                                  void QCPLayoutElement::setMarginGroup (QCP::MarginSides sides,
                                                  QCPMarginGroupgroup 
                                                  )
                                                  -
                                                  -inherited
                                                  -
                                                  -

                                                  Sets the margin group of the specified margin sides.

                                                  -

                                                  Margin groups allow synchronizing specified margins across layout elements, see the documentation of QCPMarginGroup.

                                                  -

                                                  To unset the margin group of sides, set group to 0.

                                                  -

                                                  Note that margin groups only work for margin sides that are set to automatic (setAutoMargins).

                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - -
                                                  void QCPLayoutElement::update ()
                                                  -
                                                  -virtualinherited
                                                  -
                                                  -

                                                  Updates the layout element and sub-elements. This function is automatically called upon replot by the parent layout element.

                                                  -

                                                  Layout elements that have child elements should call the update method of their child elements.

                                                  -

                                                  The default implementation executes the automatic margin mechanism, so subclasses should make sure to call the base class implementation.

                                                  - -

                                                  Reimplemented in QCPLayout, and QCPAxisRect.

                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - - -
                                                  QList< QCPLayoutElement * > QCPLayoutElement::elements (bool recursive) const
                                                  -
                                                  -virtualinherited
                                                  -
                                                  -

                                                  Returns a list of all child elements in this layout element. If recursive is true, all sub-child elements are included in the list, too.

                                                  -

                                                  Note that there may be entries with value 0 in the returned list. (For example, QCPLayoutGrid may have empty cells which yield 0 at the respective index.)

                                                  - -

                                                  Reimplemented in QCPLayoutGrid, QCPLayout, and QCPAxisRect.

                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - - -
                                                  int QCPLayoutElement::calculateAutoMargin (QCP::MarginSide side)
                                                  -
                                                  -protectedvirtualinherited
                                                  -
                                                  -

                                                  Returns the margin size for this side. It is used if automatic margins is enabled for this side (see setAutoMargins). If a minimum margin was set with setMinimumMargins, the returned value will not be smaller than the specified minimum margin.

                                                  -

                                                  The default implementation just returns the respective manual margin (setMargins) or the minimum margin, whichever is larger.

                                                  - -

                                                  Reimplemented in QCPAxisRect.

                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - - -
                                                  void QCPLayoutElement::mousePressEvent (QMouseEvent * event)
                                                  -
                                                  -inlineprotectedvirtualinherited
                                                  -
                                                  -

                                                  This event is called, if the mouse was pressed while being inside the outer rect of this layout element.

                                                  - -

                                                  Reimplemented in QCPAxisRect.

                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - - -
                                                  void QCPLayoutElement::mouseMoveEvent (QMouseEvent * event)
                                                  -
                                                  -inlineprotectedvirtualinherited
                                                  -
                                                  -

                                                  This event is called, if the mouse is moved inside the outer rect of this layout element.

                                                  - -

                                                  Reimplemented in QCPAxisRect.

                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - - -
                                                  void QCPLayoutElement::mouseReleaseEvent (QMouseEvent * event)
                                                  -
                                                  -inlineprotectedvirtualinherited
                                                  -
                                                  -

                                                  This event is called, if the mouse was previously pressed inside the outer rect of this layout element and is now released.

                                                  - -

                                                  Reimplemented in QCPAxisRect.

                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - - -
                                                  void QCPLayoutElement::mouseDoubleClickEvent (QMouseEvent * event)
                                                  -
                                                  -inlineprotectedvirtualinherited
                                                  -
                                                  -

                                                  This event is called, if the mouse is double-clicked inside the outer rect of this layout element.

                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - - -
                                                  void QCPLayoutElement::wheelEvent (QWheelEvent * event)
                                                  -
                                                  -inlineprotectedvirtualinherited
                                                  -
                                                  -

                                                  This event is called, if the mouse wheel is scrolled while the cursor is inside the rect of this layout element.

                                                  - -

                                                  Reimplemented in QCPAxisRect.

                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - - -
                                                  void QCPLayoutElement::parentPlotInitialized (QCustomPlotparentPlot)
                                                  -
                                                  -protectedvirtualinherited
                                                  -
                                                  -

                                                  propagates the parent plot initialization to all child elements, by calling QCPLayerable::initializeParentPlot on them.

                                                  - -

                                                  Reimplemented from QCPLayerable.

                                                  - -

                                                  Reimplemented in QCPLegend.

                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - -
                                                  QCPLayerable * QCPLayerable::parentLayerable () const
                                                  -
                                                  -inlineinherited
                                                  -
                                                  -

                                                  Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.

                                                  -

                                                  Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.

                                                  -

                                                  A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.

                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - - -
                                                  void QCPLayerable::setVisible (bool on)
                                                  -
                                                  -inherited
                                                  -
                                                  -

                                                  Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.

                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - - -
                                                  bool QCPLayerable::setLayer (QCPLayerlayer)
                                                  -
                                                  -inherited
                                                  -
                                                  -

                                                  Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.

                                                  -

                                                  Returns true on success, i.e. if layer is a valid layer.

                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - - -
                                                  bool QCPLayerable::setLayer (const QString & layerName)
                                                  -
                                                  -inherited
                                                  -
                                                  -

                                                  This is an overloaded function.

                                                  -

                                                  Sets the layer of this layerable object by name

                                                  -

                                                  Returns true on success, i.e. if layerName is a valid layer name.

                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - - -
                                                  void QCPLayerable::setAntialiased (bool enabled)
                                                  -
                                                  -inherited
                                                  -
                                                  -

                                                  Sets whether this object will be drawn antialiased or not.

                                                  -

                                                  Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - -
                                                  bool QCPLayerable::realVisibility () const
                                                  -
                                                  -inherited
                                                  -
                                                  -

                                                  Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.

                                                  -

                                                  If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.

                                                  -

                                                  If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.

                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - -
                                                  QCP::Interaction QCPLayerable::selectionCategory () const
                                                  -
                                                  -protectedvirtualinherited
                                                  -
                                                  -

                                                  Returns the selection category this layerable shall belong to. The selection category is used in conjunction with QCustomPlot::setInteractions to control which objects are selectable and which aren't.

                                                  -

                                                  Subclasses that don't fit any of the normal QCP::Interaction values can use QCP::iSelectOther. This is what the default implementation returns.

                                                  -
                                                  See Also
                                                  QCustomPlot::setInteractions
                                                  - -

                                                  Reimplemented in QCPAxis, QCPLegend, QCPAbstractItem, QCPAbstractPlottable, and QCPAbstractLegendItem.

                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - -
                                                  QRect QCPLayerable::clipRect () const
                                                  -
                                                  -protectedvirtualinherited
                                                  -
                                                  -

                                                  Returns the clipping rectangle of this layerable object. By default, this is the viewport of the parent QCustomPlot. Specific subclasses may reimplement this function to provide different clipping rects.

                                                  -

                                                  The returned clipping rect is set on the painter before the draw function of the respective object is called.

                                                  - -

                                                  Reimplemented in QCPAbstractItem, QCPAbstractPlottable, and QCPAbstractLegendItem.

                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - - -
                                                  void QCPLayerable::initializeParentPlot (QCustomPlotparentPlot)
                                                  -
                                                  -protectedinherited
                                                  -
                                                  -

                                                  Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.

                                                  -

                                                  Note that, unlike when passing a non-null parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.

                                                  -

                                                  Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.

                                                  -

                                                  The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).

                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - - -
                                                  void QCPLayerable::setParentLayerable (QCPLayerableparentLayerable)
                                                  -
                                                  -protectedinherited
                                                  -
                                                  -

                                                  Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.

                                                  -

                                                  The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.

                                                  -
                                                  See Also
                                                  realVisibility
                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - - - - - - - - - - - - -
                                                  bool QCPLayerable::moveToLayer (QCPLayerlayer,
                                                  bool prepend 
                                                  )
                                                  -
                                                  -protectedinherited
                                                  -
                                                  -

                                                  Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.

                                                  -

                                                  Returns true on success, i.e. if layer is a valid layer.

                                                  - -
                                                  -
                                                  - -
                                                  -
                                                  - - - - - -
                                                  - - - - - - - - - - - - - - - - - - - - - - - - -
                                                  void QCPLayerable::applyAntialiasingHint (QCPPainterpainter,
                                                  bool localAntialiased,
                                                  QCP::AntialiasedElement overrideElement 
                                                  ) const
                                                  -
                                                  -protectedinherited
                                                  -
                                                  -

                                                  Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.

                                                  - -
                                                  -

                                                  The documentation for this class was generated from the following files:
                                                  • src/layoutelements/layoutelement-plottitle.h
                                                  • src/layoutelements/layoutelement-plottitle.cpp
                                                  • diff -Nru qcustomplot-1.1.0/documentation/html/classQCPRange.html qcustomplot-1.2.0/documentation/html/classQCPRange.html --- qcustomplot-1.1.0/documentation/html/classQCPRange.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPRange.html 2014-03-14 21:11:26.000000000 +0000 @@ -19,7 +19,8 @@ Public Functions | Public Members | Static Public Functions | -Static Public Members +Static Public Members | +Friends
                                                    QCPRange Class Reference
                                                    @@ -32,6 +33,14 @@ Public Functions  QCPRange ()  QCPRange (double lower, double upper) + +bool operator== (const QCPRange &other) + +bool operator!= (const QCPRange &other) +QCPRangeoperator+= (const double &value) +QCPRangeoperator-= (const double &value) +QCPRangeoperator*= (const double &value) +QCPRangeoperator/= (const double &value) double size () const double center () const void normalize () @@ -57,6 +66,15 @@ Static Public Members static const double minRange = 1e-280 static const double maxRange = 1e250 + + + + + + + +

                                                    +Friends

                                                    const QCPRange operator+ (const QCPRange &, double)
                                                    const QCPRange operator+ (double, const QCPRange &)
                                                    const QCPRange operator- (const QCPRange &range, double value)
                                                    const QCPRange operator* (const QCPRange &range, double value)
                                                    const QCPRange operator* (double value, const QCPRange &range)
                                                    const QCPRange operator/ (const QCPRange &range, double value)

                                                    Detailed Description

                                                    Represents the range an axis is encompassing.

                                                    @@ -108,6 +126,106 @@

                                                    Member Function Documentation

                                                    + +
                                                    +
                                                    + + + + + +
                                                    + + + + + + + + +
                                                    QCPRange & QCPRange::operator+= (const double & value)
                                                    +
                                                    +inline
                                                    +
                                                    +

                                                    Adds value to both boundaries of the range.

                                                    + +
                                                    +
                                                    + +
                                                    +
                                                    + + + + + +
                                                    + + + + + + + + +
                                                    QCPRange & QCPRange::operator-= (const double & value)
                                                    +
                                                    +inline
                                                    +
                                                    +

                                                    Subtracts value from both boundaries of the range.

                                                    + +
                                                    +
                                                    + +
                                                    +
                                                    + + + + + +
                                                    + + + + + + + + +
                                                    QCPRange & QCPRange::operator*= (const double & value)
                                                    +
                                                    +inline
                                                    +
                                                    +

                                                    Multiplies both boundaries of the range by value.

                                                    + +
                                                    +
                                                    + +
                                                    +
                                                    + + + + + +
                                                    + + + + + + + + +
                                                    QCPRange & QCPRange::operator/= (const double & value)
                                                    +
                                                    +inline
                                                    +
                                                    +

                                                    Divides both boundaries of the range by value.

                                                    + +
                                                    +
                                                    @@ -359,6 +477,217 @@
                                                    +

                                                    Friends And Related Function Documentation

                                                    + +
                                                    +
                                                    + + + + + +
                                                    + + + + + + + + + + + + + + + + + + +
                                                    const QCPRange operator+ (const QCPRangerange,
                                                    double value 
                                                    )
                                                    +
                                                    +friend
                                                    +
                                                    +

                                                    Adds value to both boundaries of the range.

                                                    + +
                                                    +
                                                    + +
                                                    +
                                                    + + + + + +
                                                    + + + + + + + + + + + + + + + + + + +
                                                    const QCPRange operator+ (double value,
                                                    const QCPRangerange 
                                                    )
                                                    +
                                                    +friend
                                                    +
                                                    +

                                                    Adds value to both boundaries of the range.

                                                    + +
                                                    +
                                                    + +
                                                    +
                                                    + + + + + +
                                                    + + + + + + + + + + + + + + + + + + +
                                                    const QCPRange operator- (const QCPRangerange,
                                                    double value 
                                                    )
                                                    +
                                                    +friend
                                                    +
                                                    +

                                                    Subtracts value from both boundaries of the range.

                                                    + +
                                                    +
                                                    + +
                                                    +
                                                    + + + + + +
                                                    + + + + + + + + + + + + + + + + + + +
                                                    const QCPRange operator* (const QCPRangerange,
                                                    double value 
                                                    )
                                                    +
                                                    +friend
                                                    +
                                                    +

                                                    Multiplies both boundaries of the range by value.

                                                    + +
                                                    +
                                                    + +
                                                    +
                                                    + + + + + +
                                                    + + + + + + + + + + + + + + + + + + +
                                                    const QCPRange operator* (double value,
                                                    const QCPRangerange 
                                                    )
                                                    +
                                                    +friend
                                                    +
                                                    +

                                                    Multiplies both boundaries of the range by value.

                                                    + +
                                                    +
                                                    + +
                                                    +
                                                    + + + + + +
                                                    + + + + + + + + + + + + + + + + + + +
                                                    const QCPRange operator/ (const QCPRangerange,
                                                    double value 
                                                    )
                                                    +
                                                    +friend
                                                    +
                                                    +

                                                    Divides both boundaries of the range by value.

                                                    + +
                                                    +

                                                    The documentation for this class was generated from the following files:
                                                    • src/range.h
                                                    • src/range.cpp
                                                    • diff -Nru qcustomplot-1.1.0/documentation/html/classQCPStatisticalBox.html qcustomplot-1.2.0/documentation/html/classQCPStatisticalBox.html --- qcustomplot-1.1.0/documentation/html/classQCPStatisticalBox.html 2013-11-04 22:19:42.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCPStatisticalBox.html 2014-03-14 21:11:27.000000000 +0000 @@ -17,8 +17,6 @@
                                                      QCPStatisticalBox Class Reference
                                                      @@ -80,107 +78,113 @@ void setOutlierStyle (const QCPScatterStyle &style) virtual void clearData () virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const - +- Public Functions inherited from QCPAbstractPlottableQCPAbstractPlottable (QCPAxis *keyAxis, QCPAxis *valueAxis) + QString name () const - + bool antialiasedFill () const - + bool antialiasedScatters () const - + bool antialiasedErrorBars () const - + QPen pen () const - + QPen selectedPen () const - + QBrush brush () const - + QBrush selectedBrush () const - + QCPAxiskeyAxis () const - + QCPAxisvalueAxis () const - + bool selectable () const - + bool selected () const -void setName (const QString &name) -void setAntialiasedFill (bool enabled) -void setAntialiasedScatters (bool enabled) -void setAntialiasedErrorBars (bool enabled) -void setPen (const QPen &pen) -void setSelectedPen (const QPen &pen) -void setBrush (const QBrush &brush) -void setSelectedBrush (const QBrush &brush) -void setKeyAxis (QCPAxis *axis) -void setValueAxis (QCPAxis *axis) -Q_SLOT void setSelectable (bool selectable) -Q_SLOT void setSelected (bool selected) -virtual bool addToLegend () -virtual bool removeFromLegend () const -void rescaleAxes (bool onlyEnlarge=false) const -void rescaleKeyAxis (bool onlyEnlarge=false) const -void rescaleValueAxis (bool onlyEnlarge=false) const - +void setName (const QString &name) +void setAntialiasedFill (bool enabled) +void setAntialiasedScatters (bool enabled) +void setAntialiasedErrorBars (bool enabled) +void setPen (const QPen &pen) +void setSelectedPen (const QPen &pen) +void setBrush (const QBrush &brush) +void setSelectedBrush (const QBrush &brush) +void setKeyAxis (QCPAxis *axis) +void setValueAxis (QCPAxis *axis) +Q_SLOT void setSelectable (bool selectable) +Q_SLOT void setSelected (bool selected) +virtual bool addToLegend () +virtual bool removeFromLegend () const +void rescaleAxes (bool onlyEnlarge=false) const +void rescaleKeyAxis (bool onlyEnlarge=false) const +void rescaleValueAxis (bool onlyEnlarge=false) const +- Public Functions inherited from QCPLayerableQCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0) + bool visible () const - + QCustomPlotparentPlot () const -QCPLayerableparentLayerable () const - +QCPLayerableparentLayerable () const + QCPLayerlayer () const - + bool antialiased () const -void setVisible (bool on) -bool setLayer (QCPLayer *layer) -bool setLayer (const QString &layerName) -void setAntialiased (bool enabled) -bool realVisibility () const - - - -

                                                      -Signals

                                                      void selectionChanged (bool selected)
                                                      - - + + + + +

                                                      -Protected Types

                                                      enum  SignDomain
                                                      void setVisible (bool on)
                                                      Q_SLOT bool setLayer (QCPLayer *layer)
                                                      bool setLayer (const QString &layerName)
                                                      void setAntialiased (bool enabled)
                                                      bool realVisibility () const
                                                      - - + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + +

                                                      Protected Functions

                                                      virtual void draw (QCPPainter *painter)
                                                      virtual void drawLegendIcon (QCPPainter *painter, const QRectF &rect) const
                                                      virtual QCPRange getKeyRange (bool &validRange, SignDomain inSignDomain=sdBoth) const
                                                      virtual QCPRange getValueRange (bool &validRange, SignDomain inSignDomain=sdBoth) const
                                                      virtual QCPRange getKeyRange (bool &foundRange, SignDomain inSignDomain=sdBoth) const
                                                      virtual QCPRange getValueRange (bool &foundRange, SignDomain inSignDomain=sdBoth) const
                                                      virtual void drawQuartileBox (QCPPainter *painter, QRectF *quartileBox=0) const
                                                      virtual void drawMedian (QCPPainter *painter) const
                                                      virtual void drawWhiskers (QCPPainter *painter) const
                                                      virtual void drawOutliers (QCPPainter *painter) const
                                                      virtual QRect clipRect () const
                                                      virtual QCP::Interaction selectionCategory () const
                                                      void applyDefaultAntialiasingHint (QCPPainter *painter) const
                                                      virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                                                      virtual void deselectEvent (bool *selectionStateChanged)
                                                      void coordsToPixels (double key, double value, double &x, double &y) const
                                                      const QPointF coordsToPixels (double key, double value) const
                                                      void pixelsToCoords (double x, double y, double &key, double &value) const
                                                      void pixelsToCoords (const QPointF &pixelPos, double &key, double &value) const
                                                      QPen mainPen () const
                                                      QBrush mainBrush () const
                                                      void applyFillAntialiasingHint (QCPPainter *painter) const
                                                      void applyScattersAntialiasingHint (QCPPainter *painter) const
                                                      void applyErrorBarsAntialiasingHint (QCPPainter *painter) const
                                                      double distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const
                                                      virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                                                      void initializeParentPlot (QCustomPlot *parentPlot)
                                                      void setParentLayerable (QCPLayerable *parentLayerable)
                                                      bool moveToLayer (QCPLayer *layer, bool prepend)
                                                      void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                                                      - Protected Functions inherited from QCPAbstractPlottable
                                                      virtual QRect clipRect () const
                                                      virtual QCP::Interaction selectionCategory () const
                                                      void applyDefaultAntialiasingHint (QCPPainter *painter) const
                                                      virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
                                                      virtual void deselectEvent (bool *selectionStateChanged)
                                                      void coordsToPixels (double key, double value, double &x, double &y) const
                                                      const QPointF coordsToPixels (double key, double value) const
                                                      void pixelsToCoords (double x, double y, double &key, double &value) const
                                                      void pixelsToCoords (const QPointF &pixelPos, double &key, double &value) const
                                                      QPen mainPen () const
                                                      QBrush mainBrush () const
                                                      void applyFillAntialiasingHint (QCPPainter *painter) const
                                                      void applyScattersAntialiasingHint (QCPPainter *painter) const
                                                      void applyErrorBarsAntialiasingHint (QCPPainter *painter) const
                                                      double distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const
                                                      - Protected Functions inherited from QCPLayerable
                                                      virtual void parentPlotInitialized (QCustomPlot *parentPlot)
                                                      void initializeParentPlot (QCustomPlot *parentPlot)
                                                      void setParentLayerable (QCPLayerable *parentLayerable)
                                                      bool moveToLayer (QCPLayer *layer, bool prepend)
                                                      void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
                                                      + + + + + +

                                                      +Additional Inherited Members

                                                      - Signals inherited from QCPAbstractPlottable
                                                      void selectionChanged (bool selected)
                                                      void selectableChanged (bool selectable)
                                                      - Protected Types inherited from QCPAbstractPlottable
                                                      enum  SignDomain

                                                      Detailed Description

                                                      A plottable representing a single statistical box in a plot.

                                                      QCPStatisticalBox.png
                                                      -

                                                      To plot data, assign it with the individual parameter functions or use setData to set all parameters at once. The individual funcions are:

                                                      +

                                                      To plot data, assign it with the individual parameter functions or use setData to set all parameters at once. The individual functions are:

                                                      -

                                                      Additionally you can define a list of outliers, drawn as circle datapoints:

                                                      +

                                                      Additionally you can define a list of outliers, drawn as scatter datapoints:

                                                      @@ -210,42 +214,7 @@
                                                      newBox->setName("Measurement Series 1");
                                                      newBox->setData(1, 3, 4, 5, 7);
                                                      newBox->setOutliers(QVector<double>() << 0.5 << 0.64 << 7.2 << 7.42);
                                                      -

                                                      Member Enumeration Documentation

                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - -
                                                      enum QCPAbstractPlottable::SignDomain
                                                      -
                                                      -protectedinherited
                                                      -
                                                      -

                                                      Represents negative and positive sign domain for passing to getKeyRange and getValueRange.

                                                      -
                                                      Enumerator:
                                                      - - - -
                                                      sdNegative  -

                                                      The negative sign domain, i.e. numbers smaller than zero.

                                                      -
                                                      sdBoth  -

                                                      Both sign domains, including zero, i.e. all (rational) numbers.

                                                      -
                                                      sdPositive  -

                                                      The positive sign domain, i.e. numbers greater than zero.

                                                      -
                                                      -
                                                      -
                                                      - -
                                                      -
                                                      -

                                                      Constructor & Destructor Documentation

                                                      +

                                                      Constructor & Destructor Documentation

                                                      @@ -403,7 +372,7 @@
                                                      -

                                                      Sets a vector of outlier values that will be drawn as circles. Any data points in the sample that are not within the whiskers (setMinimum, setMaximum) should be considered outliers and displayed as such.

                                                      +

                                                      Sets a vector of outlier values that will be drawn as scatters. Any data points in the sample that are not within the whiskers (setMinimum, setMaximum) should be considered outliers and displayed as such.

                                                      See Also
                                                      setOutlierStyle
                                                      @@ -709,7 +678,7 @@
                                                      - +
                                                      @@ -720,7 +689,7 @@ - + @@ -740,14 +709,15 @@
                                                      QCPRange QCPStatisticalBox::getKeyRange ( bool & validRange, foundRange,
                                                      -

                                                      called by rescaleAxes functions to get the full data key bounds. For logarithmic plots, one can set inSignDomain to either sdNegative or sdPositive in order to restrict the returned range to that sign domain. E.g. when only negative range is wanted, set inSignDomain to sdNegative and all positive points will be ignored for range calculation. For no restriction, just set inSignDomain to sdBoth (default). validRange is an output parameter that indicates whether a proper range could be found or not. If this is false, you shouldn't use the returned range (e.g. no points in data).

                                                      -
                                                      See Also
                                                      rescaleAxes, getValueRange
                                                      +

                                                      called by rescaleAxes functions to get the full data key bounds. For logarithmic plots, one can set inSignDomain to either sdNegative or sdPositive in order to restrict the returned range to that sign domain. E.g. when only negative range is wanted, set inSignDomain to sdNegative and all positive points will be ignored for range calculation. For no restriction, just set inSignDomain to sdBoth (default). foundRange is an output parameter that indicates whether a range could be found or not. If this is false, you shouldn't use the returned range (e.g. no points in data).

                                                      +

                                                      Note that foundRange is not the same as QCPRange::validRange, since the range returned by this function may have size zero, which wouldn't count as a valid range.

                                                      +
                                                      See Also
                                                      rescaleAxes, getValueRange
                                                      -

                                                      Implements QCPAbstractPlottable.

                                                      +

                                                      Implements QCPAbstractPlottable.

                                                      - +
                                                      @@ -758,7 +728,7 @@ - + @@ -778,10 +748,11 @@
                                                      QCPRange QCPStatisticalBox::getValueRange ( bool & validRange, foundRange,
                                                      -

                                                      called by rescaleAxes functions to get the full data value bounds. For logarithmic plots, one can set inSignDomain to either sdNegative or sdPositive in order to restrict the returned range to that sign domain. E.g. when only negative range is wanted, set inSignDomain to sdNegative and all positive points will be ignored for range calculation. For no restriction, just set inSignDomain to sdBoth (default). validRange is an output parameter that indicates whether a proper range could be found or not. If this is false, you shouldn't use the returned range (e.g. no points in data).

                                                      -
                                                      See Also
                                                      rescaleAxes, getKeyRange
                                                      +

                                                      called by rescaleAxes functions to get the full data value bounds. For logarithmic plots, one can set inSignDomain to either sdNegative or sdPositive in order to restrict the returned range to that sign domain. E.g. when only negative range is wanted, set inSignDomain to sdNegative and all positive points will be ignored for range calculation. For no restriction, just set inSignDomain to sdBoth (default). foundRange is an output parameter that indicates whether a range could be found or not. If this is false, you shouldn't use the returned range (e.g. no points in data).

                                                      +

                                                      Note that foundRange is not the same as QCPRange::validRange, since the range returned by this function may have size zero, which wouldn't count as a valid range.

                                                      +
                                                      See Also
                                                      rescaleAxes, getKeyRange
                                                      -

                                                      Implements QCPAbstractPlottable.

                                                      +

                                                      Implements QCPAbstractPlottable.

                                                      @@ -895,1316 +866,6 @@ - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - -
                                                      void QCPAbstractPlottable::setName (const QString & name)
                                                      -
                                                      -inherited
                                                      -
                                                      -

                                                      The name is the textual representation of this plottable as it is displayed in the legend (QCPLegend). It may contain any UTF-8 characters, including newlines.

                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - -
                                                      void QCPAbstractPlottable::setAntialiasedFill (bool enabled)
                                                      -
                                                      -inherited
                                                      -
                                                      -

                                                      Sets whether fills of this plottable is drawn antialiased or not.

                                                      -

                                                      Note that this setting may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - -
                                                      void QCPAbstractPlottable::setAntialiasedScatters (bool enabled)
                                                      -
                                                      -inherited
                                                      -
                                                      -

                                                      Sets whether the scatter symbols of this plottable are drawn antialiased or not.

                                                      -

                                                      Note that this setting may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - -
                                                      void QCPAbstractPlottable::setAntialiasedErrorBars (bool enabled)
                                                      -
                                                      -inherited
                                                      -
                                                      -

                                                      Sets whether the error bars of this plottable are drawn antialiased or not.

                                                      -

                                                      Note that this setting may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - -
                                                      void QCPAbstractPlottable::setPen (const QPen & pen)
                                                      -
                                                      -inherited
                                                      -
                                                      -

                                                      The pen is used to draw basic lines that make up the plottable representation in the plot.

                                                      -

                                                      For example, the QCPGraph subclass draws its graph lines and scatter points with this pen.

                                                      -
                                                      See Also
                                                      setBrush
                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - -
                                                      void QCPAbstractPlottable::setSelectedPen (const QPen & pen)
                                                      -
                                                      -inherited
                                                      -
                                                      -

                                                      When the plottable is selected, this pen is used to draw basic lines instead of the normal pen set via setPen.

                                                      -
                                                      See Also
                                                      setSelected, setSelectable, setSelectedBrush, selectTest
                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - -
                                                      void QCPAbstractPlottable::setBrush (const QBrush & brush)
                                                      -
                                                      -inherited
                                                      -
                                                      -

                                                      The brush is used to draw basic fills of the plottable representation in the plot. The Fill can be a color, gradient or texture, see the usage of QBrush.

                                                      -

                                                      For example, the QCPGraph subclass draws the fill under the graph with this brush, when it's not set to Qt::NoBrush.

                                                      -
                                                      See Also
                                                      setPen
                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - -
                                                      void QCPAbstractPlottable::setSelectedBrush (const QBrush & brush)
                                                      -
                                                      -inherited
                                                      -
                                                      -

                                                      When the plottable is selected, this brush is used to draw fills instead of the normal brush set via setBrush.

                                                      -
                                                      See Also
                                                      setSelected, setSelectable, setSelectedPen, selectTest
                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - -
                                                      void QCPAbstractPlottable::setKeyAxis (QCPAxisaxis)
                                                      -
                                                      -inherited
                                                      -
                                                      -

                                                      The key axis of a plottable can be set to any axis of a QCustomPlot, as long as it is orthogonal to the plottable's value axis. This function performs no checks to make sure this is the case. The typical mathematical choice is to use the x-axis (QCustomPlot::xAxis) as key axis and the y-axis (QCustomPlot::yAxis) as value axis.

                                                      -

                                                      Normally, the key and value axes are set in the constructor of the plottable (or QCustomPlot::addGraph when working with QCPGraphs through the dedicated graph interface).

                                                      -
                                                      See Also
                                                      setValueAxis
                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - -
                                                      void QCPAbstractPlottable::setValueAxis (QCPAxisaxis)
                                                      -
                                                      -inherited
                                                      -
                                                      -

                                                      The value axis of a plottable can be set to any axis of a QCustomPlot, as long as it is orthogonal to the plottable's key axis. This function performs no checks to make sure this is the case. The typical mathematical choice is to use the x-axis (QCustomPlot::xAxis) as key axis and the y-axis (QCustomPlot::yAxis) as value axis.

                                                      -

                                                      Normally, the key and value axes are set in the constructor of the plottable (or QCustomPlot::addGraph when working with QCPGraphs through the dedicated graph interface).

                                                      -
                                                      See Also
                                                      setKeyAxis
                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - -
                                                      void QCPAbstractPlottable::setSelectable (bool selectable)
                                                      -
                                                      -inherited
                                                      -
                                                      -

                                                      Sets whether the user can (de-)select this plottable by clicking on the QCustomPlot surface. (When QCustomPlot::setInteractions contains iSelectPlottables.)

                                                      -

                                                      However, even when selectable was set to false, it is possible to set the selection manually, by calling setSelected directly.

                                                      -
                                                      See Also
                                                      setSelected
                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - -
                                                      void QCPAbstractPlottable::setSelected (bool selected)
                                                      -
                                                      -inherited
                                                      -
                                                      -

                                                      Sets whether this plottable is selected or not. When selected, it uses a different pen and brush to draw its lines and fills, see setSelectedPen and setSelectedBrush.

                                                      -

                                                      The entire selection mechanism for plottables is handled automatically when QCustomPlot::setInteractions contains iSelectPlottables. You only need to call this function when you wish to change the selection state manually.

                                                      -

                                                      This function can change the selection state even when setSelectable was set to false.

                                                      -

                                                      emits the selectionChanged signal when selected is different from the previous selection state.

                                                      -
                                                      See Also
                                                      setSelectable, selectTest
                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - -
                                                      bool QCPAbstractPlottable::addToLegend ()
                                                      -
                                                      -virtualinherited
                                                      -
                                                      -

                                                      Adds this plottable to the legend of the parent QCustomPlot (QCustomPlot::legend).

                                                      -

                                                      Normally, a QCPPlottableLegendItem is created and inserted into the legend. If the plottable needs a more specialized representation in the legend, this function will take this into account and instead create the specialized subclass of QCPAbstractLegendItem.

                                                      -

                                                      Returns true on success, i.e. when the legend exists and a legend item associated with this plottable isn't already in the legend.

                                                      -
                                                      See Also
                                                      removeFromLegend, QCPLegend::addItem
                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - -
                                                      bool QCPAbstractPlottable::removeFromLegend () const
                                                      -
                                                      -virtualinherited
                                                      -
                                                      -

                                                      Removes the plottable from the legend of the parent QCustomPlot. This means the QCPAbstractLegendItem (usually a QCPPlottableLegendItem) that is associated with this plottable is removed.

                                                      -

                                                      Returns true on success, i.e. if the legend exists and a legend item associated with this plottable was found and removed.

                                                      -
                                                      See Also
                                                      addToLegend, QCPLegend::removeItem
                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - -
                                                      void QCPAbstractPlottable::rescaleAxes (bool onlyEnlarge = false) const
                                                      -
                                                      -inherited
                                                      -
                                                      -

                                                      Rescales the key and value axes associated with this plottable to contain all displayed data, so the whole plottable is visible. If the scaling of an axis is logarithmic, rescaleAxes will make sure not to rescale to an illegal range i.e. a range containing different signs and/or zero. Instead it will stay in the current sign domain and ignore all parts of the plottable that lie outside of that domain.

                                                      -

                                                      onlyEnlarge makes sure the ranges are only expanded, never reduced. So it's possible to show multiple plottables in their entirety by multiple calls to rescaleAxes where the first call has onlyEnlarge set to false (the default), and all subsequent set to true.

                                                      -
                                                      See Also
                                                      rescaleKeyAxis, rescaleValueAxis, QCustomPlot::rescaleAxes, QCPAxis::rescale
                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - -
                                                      void QCPAbstractPlottable::rescaleKeyAxis (bool onlyEnlarge = false) const
                                                      -
                                                      -inherited
                                                      -
                                                      -

                                                      Rescales the key axis of the plottable so the whole plottable is visible.

                                                      -

                                                      See rescaleAxes for detailed behaviour.

                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - -
                                                      void QCPAbstractPlottable::rescaleValueAxis (bool onlyEnlarge = false) const
                                                      -
                                                      -inherited
                                                      -
                                                      -

                                                      Rescales the value axis of the plottable so the whole plottable is visible.

                                                      -

                                                      Returns true if the axis was actually scaled. This might not be the case if this plottable has an invalid range, e.g. because it has no data points.

                                                      -

                                                      See rescaleAxes for detailed behaviour.

                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - -
                                                      void QCPAbstractPlottable::selectionChanged (bool selected)
                                                      -
                                                      -signalinherited
                                                      -
                                                      -

                                                      This signal is emitted when the selection state of this plottable has changed to selected, either by user interaction or by a direct call to setSelected.

                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - -
                                                      QRect QCPAbstractPlottable::clipRect () const
                                                      -
                                                      -protectedvirtualinherited
                                                      -
                                                      -

                                                      Returns the clipping rectangle of this layerable object. By default, this is the viewport of the parent QCustomPlot. Specific subclasses may reimplement this function to provide different clipping rects.

                                                      -

                                                      The returned clipping rect is set on the painter before the draw function of the respective object is called.

                                                      - -

                                                      Reimplemented from QCPLayerable.

                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - -
                                                      QCP::Interaction QCPAbstractPlottable::selectionCategory () const
                                                      -
                                                      -protectedvirtualinherited
                                                      -
                                                      -

                                                      Returns the selection category this layerable shall belong to. The selection category is used in conjunction with QCustomPlot::setInteractions to control which objects are selectable and which aren't.

                                                      -

                                                      Subclasses that don't fit any of the normal QCP::Interaction values can use QCP::iSelectOther. This is what the default implementation returns.

                                                      -
                                                      See Also
                                                      QCustomPlot::setInteractions
                                                      - -

                                                      Reimplemented from QCPLayerable.

                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - -
                                                      void QCPAbstractPlottable::applyDefaultAntialiasingHint (QCPPainterpainter) const
                                                      -
                                                      -protectedvirtualinherited
                                                      -
                                                      -

                                                      A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing plottable lines.

                                                      -

                                                      This is the antialiasing state the painter passed to the draw method is in by default.

                                                      -

                                                      This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                                                      -
                                                      See Also
                                                      setAntialiased, applyFillAntialiasingHint, applyScattersAntialiasingHint, applyErrorBarsAntialiasingHint
                                                      - -

                                                      Implements QCPLayerable.

                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                                                      void QCPAbstractPlottable::selectEvent (QMouseEvent * event,
                                                      bool additive,
                                                      const QVariant & details,
                                                      bool * selectionStateChanged 
                                                      )
                                                      -
                                                      -protectedvirtualinherited
                                                      -
                                                      -

                                                      This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

                                                      -

                                                      event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

                                                      -

                                                      Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

                                                      -

                                                      selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

                                                      -
                                                      See Also
                                                      selectTest, deselectEvent
                                                      - -

                                                      Reimplemented from QCPLayerable.

                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - -
                                                      void QCPAbstractPlottable::deselectEvent (bool * selectionStateChanged)
                                                      -
                                                      -protectedvirtualinherited
                                                      -
                                                      -

                                                      This event is called when the layerable shall be deselected, either as consequence of a user interaction or a call to QCustomPlot::deselectAll. Subclasses should react to it by unsetting their selection appropriately.

                                                      -

                                                      just as in selectEvent, the output parameter selectionStateChanged (if non-null), must return true or false when the selection state of this layerable has changed or not changed, respectively.

                                                      -
                                                      See Also
                                                      selectTest, selectEvent
                                                      - -

                                                      Reimplemented from QCPLayerable.

                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                                                      void QCPAbstractPlottable::coordsToPixels (double key,
                                                      double value,
                                                      double & x,
                                                      double & y 
                                                      ) const
                                                      -
                                                      -protectedinherited
                                                      -
                                                      -

                                                      Convenience function for transforming a key/value pair to pixels on the QCustomPlot surface, taking the orientations of the axes associated with this plottable into account (e.g. whether key represents x or y).

                                                      -

                                                      key and value are transformed to the coodinates in pixels and are written to x and y.

                                                      -
                                                      See Also
                                                      pixelsToCoords, QCPAxis::coordToPixel
                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - - - - - - - - - - - -
                                                      const QPointF QCPAbstractPlottable::coordsToPixels (double key,
                                                      double value 
                                                      ) const
                                                      -
                                                      -protectedinherited
                                                      -
                                                      -

                                                      This is an overloaded function.

                                                      -

                                                      Returns the input as pixel coordinates in a QPointF.

                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                                                      void QCPAbstractPlottable::pixelsToCoords (double x,
                                                      double y,
                                                      double & key,
                                                      double & value 
                                                      ) const
                                                      -
                                                      -protectedinherited
                                                      -
                                                      -

                                                      Convenience function for transforming a x/y pixel pair on the QCustomPlot surface to plot coordinates, taking the orientations of the axes associated with this plottable into account (e.g. whether key represents x or y).

                                                      -

                                                      x and y are transformed to the plot coodinates and are written to key and value.

                                                      -
                                                      See Also
                                                      coordsToPixels, QCPAxis::coordToPixel
                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - - - - - - - - - - - - - - - - - -
                                                      void QCPAbstractPlottable::pixelsToCoords (const QPointF & pixelPos,
                                                      double & key,
                                                      double & value 
                                                      ) const
                                                      -
                                                      -protectedinherited
                                                      -
                                                      -

                                                      This is an overloaded function.

                                                      -

                                                      Returns the pixel input pixelPos as plot coordinates key and value.

                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - -
                                                      QPen QCPAbstractPlottable::mainPen () const
                                                      -
                                                      -protectedinherited
                                                      -
                                                      -

                                                      Returns the pen that should be used for drawing lines of the plottable. Returns mPen when the graph is not selected and mSelectedPen when it is.

                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - -
                                                      QBrush QCPAbstractPlottable::mainBrush () const
                                                      -
                                                      -protectedinherited
                                                      -
                                                      -

                                                      Returns the brush that should be used for drawing fills of the plottable. Returns mBrush when the graph is not selected and mSelectedBrush when it is.

                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - -
                                                      void QCPAbstractPlottable::applyFillAntialiasingHint (QCPPainterpainter) const
                                                      -
                                                      -protectedinherited
                                                      -
                                                      -

                                                      A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing plottable fills.

                                                      -

                                                      This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                                                      -
                                                      See Also
                                                      setAntialiased, applyDefaultAntialiasingHint, applyScattersAntialiasingHint, applyErrorBarsAntialiasingHint
                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - -
                                                      void QCPAbstractPlottable::applyScattersAntialiasingHint (QCPPainterpainter) const
                                                      -
                                                      -protectedinherited
                                                      -
                                                      -

                                                      A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing plottable scatter points.

                                                      -

                                                      This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                                                      -
                                                      See Also
                                                      setAntialiased, applyFillAntialiasingHint, applyDefaultAntialiasingHint, applyErrorBarsAntialiasingHint
                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - -
                                                      void QCPAbstractPlottable::applyErrorBarsAntialiasingHint (QCPPainterpainter) const
                                                      -
                                                      -protectedinherited
                                                      -
                                                      -

                                                      A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing plottable error bars.

                                                      -

                                                      This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                                                      -
                                                      See Also
                                                      setAntialiased, applyFillAntialiasingHint, applyScattersAntialiasingHint, applyDefaultAntialiasingHint
                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - - - - - - - - - - - - - - - - - -
                                                      double QCPAbstractPlottable::distSqrToLine (const QPointF & start,
                                                      const QPointF & end,
                                                      const QPointF & point 
                                                      ) const
                                                      -
                                                      -protectedinherited
                                                      -
                                                      -

                                                      Finds the shortest squared distance of point to the line segment defined by start and end.

                                                      -

                                                      This function may be used to help with the implementation of the selectTest function for specific plottables.

                                                      -
                                                      Note
                                                      This function is identical to QCPAbstractItem::distSqrToLine
                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - -
                                                      QCPLayerable * QCPLayerable::parentLayerable () const
                                                      -
                                                      -inlineinherited
                                                      -
                                                      -

                                                      Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.

                                                      -

                                                      Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.

                                                      -

                                                      A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.

                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - -
                                                      void QCPLayerable::setVisible (bool on)
                                                      -
                                                      -inherited
                                                      -
                                                      -

                                                      Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.

                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - -
                                                      bool QCPLayerable::setLayer (QCPLayerlayer)
                                                      -
                                                      -inherited
                                                      -
                                                      -

                                                      Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.

                                                      -

                                                      Returns true on success, i.e. if layer is a valid layer.

                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - -
                                                      bool QCPLayerable::setLayer (const QString & layerName)
                                                      -
                                                      -inherited
                                                      -
                                                      -

                                                      This is an overloaded function.

                                                      -

                                                      Sets the layer of this layerable object by name

                                                      -

                                                      Returns true on success, i.e. if layerName is a valid layer name.

                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - -
                                                      void QCPLayerable::setAntialiased (bool enabled)
                                                      -
                                                      -inherited
                                                      -
                                                      -

                                                      Sets whether this object will be drawn antialiased or not.

                                                      -

                                                      Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - -
                                                      bool QCPLayerable::realVisibility () const
                                                      -
                                                      -inherited
                                                      -
                                                      -

                                                      Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.

                                                      -

                                                      If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.

                                                      -

                                                      If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.

                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - -
                                                      void QCPLayerable::parentPlotInitialized (QCustomPlotparentPlot)
                                                      -
                                                      -protectedvirtualinherited
                                                      -
                                                      -

                                                      This function is called by initializeParentPlot, to allow subclasses to react on the setting of a parent plot. This is the case when 0 was passed as parent plot in the constructor, and the parent plot is set at a later time.

                                                      -

                                                      For example, QCPLayoutElement/QCPLayout hierarchies may be created independently of any QCustomPlot at first. When they are then added to a layout inside the QCustomPlot, the top level element of the hierarchy gets its parent plot initialized with initializeParentPlot. To propagate the parent plot to all the children of the hierarchy, the top level element then uses this function to pass the parent plot on to its child elements.

                                                      -

                                                      The default implementation does nothing.

                                                      -
                                                      See Also
                                                      initializeParentPlot
                                                      - -

                                                      Reimplemented in QCPLegend, and QCPLayoutElement.

                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - -
                                                      void QCPLayerable::initializeParentPlot (QCustomPlotparentPlot)
                                                      -
                                                      -protectedinherited
                                                      -
                                                      -

                                                      Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.

                                                      -

                                                      Note that, unlike when passing a non-null parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.

                                                      -

                                                      Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.

                                                      -

                                                      The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).

                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - -
                                                      void QCPLayerable::setParentLayerable (QCPLayerableparentLayerable)
                                                      -
                                                      -protectedinherited
                                                      -
                                                      -

                                                      Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.

                                                      -

                                                      The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.

                                                      -
                                                      See Also
                                                      realVisibility
                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - - - - - - - - - - - -
                                                      bool QCPLayerable::moveToLayer (QCPLayerlayer,
                                                      bool prepend 
                                                      )
                                                      -
                                                      -protectedinherited
                                                      -
                                                      -

                                                      Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.

                                                      -

                                                      Returns true on success, i.e. if layer is a valid layer.

                                                      - -
                                                      -
                                                      - -
                                                      -
                                                      - - - - - -
                                                      - - - - - - - - - - - - - - - - - - - - - - - - -
                                                      void QCPLayerable::applyAntialiasingHint (QCPPainterpainter,
                                                      bool localAntialiased,
                                                      QCP::AntialiasedElement overrideElement 
                                                      ) const
                                                      -
                                                      -protectedinherited
                                                      -
                                                      -

                                                      Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.

                                                      - -
                                                      -

                                                      The documentation for this class was generated from the following files:
                                                      • src/plottables/plottable-statisticalbox.h
                                                      • src/plottables/plottable-statisticalbox.cpp
                                                      • diff -Nru qcustomplot-1.1.0/documentation/html/classQCustomPlot.html qcustomplot-1.2.0/documentation/html/classQCustomPlot.html --- qcustomplot-1.1.0/documentation/html/classQCustomPlot.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/classQCustomPlot.html 2014-03-14 21:11:26.000000000 +0000 @@ -32,6 +32,7 @@

                                                        Public Types

                                                        enum  LayerInsertMode +enum  RefreshPriority @@ -123,27 +124,22 @@ - + - +

                                                        Public Functions

                                                        QList< QCPAxis * > selectedAxes () const
                                                        QList< QCPLegend * > selectedLegends () const
                                                        Q_SLOT void deselectAll ()
                                                        bool savePdf (const QString &fileName, bool noCosmeticPen=false, int width=0, int height=0)
                                                        bool savePdf (const QString &fileName, bool noCosmeticPen=false, int width=0, int height=0, const QString &pdfCreator="", const QString &pdfTitle="")
                                                        bool savePng (const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1)
                                                        bool saveJpg (const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1)
                                                        bool saveBmp (const QString &fileName, int width=0, int height=0, double scale=1.0)
                                                        bool saveRastered (const QString &fileName, int width, int height, double scale, const char *format, int quality=-1)
                                                        QPixmap toPixmap (int width=0, int height=0, double scale=1.0)
                                                        void toPainter (QCPPainter *painter, int width=0, int height=0)
                                                        Q_SLOT void replot ()
                                                        Q_SLOT void replot (QCustomPlot::RefreshPriority refreshPriority=QCustomPlot::rpHint)
                                                        - - - - - + + + + +

                                                        Public Members

                                                        -QCPAxisxAxis
                                                        -QCPAxisyAxis
                                                        -QCPAxisxAxis2
                                                        -QCPAxisyAxis2
                                                        -QCPLegendlegend
                                                        QCPAxisxAxis
                                                        QCPAxisyAxis
                                                        QCPAxisxAxis2
                                                        QCPAxisyAxis2
                                                        QCPLegendlegend
                                                        @@ -158,8 +154,8 @@ - - + + @@ -179,7 +175,7 @@ - + @@ -213,6 +209,33 @@ + +
                                                        +
                                                        +

                                                        Signals

                                                        void itemDoubleClick (QCPAbstractItem *item, QMouseEvent *event)
                                                        void axisClick (QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event)
                                                        void axisDoubleClick (QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event)
                                                        void legendClick (QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event)
                                                        void legendDoubleClick (QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event)
                                                        void legendClick (QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event)
                                                        void legendDoubleClick (QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event)
                                                        void titleClick (QMouseEvent *event, QCPPlotTitle *title)
                                                        void titleDoubleClick (QMouseEvent *event, QCPPlotTitle *title)
                                                        void selectionChangedByUser ()
                                                        virtual void wheelEvent (QWheelEvent *event)
                                                        virtual void draw (QCPPainter *painter)
                                                        virtual void axisRemoved (QCPAxis *axis)
                                                        virtual void legendRemoved (QCPLegend *legend)
                                                        virtual void legendRemoved (QCPLegend *legend)
                                                        void updateLayerIndices () const
                                                        QCPLayerablelayerableAt (const QPointF &pos, bool onlySelectable, QVariant *selectionDetails=0) const
                                                        void drawBackground (QCPPainter *painter)
                                                        + + + +
                                                        enum QCustomPlot::RefreshPriority
                                                        +
                                                        +

                                                        Defines with what timing the QCustomPlot surface is refreshed after a replot.

                                                        +
                                                        See Also
                                                        replot
                                                        +
                                                        Enumerator:
                                                        + + + +
                                                        rpImmediate  +

                                                        The QCustomPlot surface is immediately refreshed, by calling QWidget::repaint() after the replot.

                                                        +
                                                        rpQueued  +

                                                        Queues the refresh such that it is performed at a slightly delayed point in time after the replot, by calling QWidget::update() after the replot.

                                                        +
                                                        rpHint  +

                                                        Whether to use immediate repaint or queued update depends on whether the plotting hint QCP::phForceRepaint is set, see setPlottingHints.

                                                        +
                                                        +
                                                        +
                                                        + +
                                                        +

                                                        Constructor & Destructor Documentation

                                                        @@ -304,7 +327,7 @@

                                                        Sets the viewport of this QCustomPlot. The Viewport is the area that the top level layout (QCustomPlot::plotLayout()) uses as its rect. Normally, the viewport is the entire widget rect.

                                                        -

                                                        This function is used to allow arbitrary size exports with toPixmap, savePng, savePdf, etc. by temporarily changing the viewport size.

                                                        +

                                                        This function is used to allow arbitrary size exports with toPixmap, savePng, savePdf, etc. by temporarily changing the viewport size.

                                                        @@ -533,7 +556,7 @@
                                                        -

                                                        If set to true, adding a plottable (e.g. a graph) to the QCustomPlot automatically also adds the plottable to the legend (QCustomPlot::legend).

                                                        +

                                                        If set to true, adding a plottable (e.g. a graph) to the QCustomPlot automatically also adds the plottable to the legend (QCustomPlot::legend).

                                                        See Also
                                                        addPlottable, addGraph, QCPLegend::addItem
                                                        @@ -747,7 +770,7 @@
                                                        -

                                                        Adds the specified plottable to the plot and, if setAutoAddPlottableToLegend is enabled, to the legend (QCustomPlot::legend). QCustomPlot takes ownership of the plottable.

                                                        +

                                                        Adds the specified plottable to the plot and, if setAutoAddPlottableToLegend is enabled, to the legend (QCustomPlot::legend). QCustomPlot takes ownership of the plottable.

                                                        Returns true on success, i.e. when plottable isn't already in the plot and the parent plot of plottable is this QCustomPlot (the latter is controlled by what axes were passed in the plottable's constructor).

                                                        See Also
                                                        plottable, plottableCount, removePlottable, clearPlottables
                                                        @@ -766,7 +789,7 @@
                                                        -

                                                        Removes the specified plottable from the plot and, if necessary, from the legend (QCustomPlot::legend).

                                                        +

                                                        Removes the specified plottable from the plot and, if necessary, from the legend (QCustomPlot::legend).

                                                        Returns true on success.

                                                        See Also
                                                        addPlottable, clearPlottables
                                                        @@ -802,7 +825,7 @@
                                                        -

                                                        Removes all plottables from the plot (and the QCustomPlot::legend, if necessary).

                                                        +

                                                        Removes all plottables from the plot (and the QCustomPlot::legend, if necessary).

                                                        Returns the number of plottables removed.

                                                        See Also
                                                        removePlottable
                                                        @@ -971,7 +994,7 @@
                                                        -

                                                        Removes the specified graph from the plot and, if necessary, from the QCustomPlot::legend. If any other graphs in the plot have a channel fill set towards the removed graph, the channel fill property of those graphs is reset to zero (no channel fill).

                                                        +

                                                        Removes the specified graph from the plot and, if necessary, from the QCustomPlot::legend. If any other graphs in the plot have a channel fill set towards the removed graph, the channel fill property of those graphs is reset to zero (no channel fill).

                                                        Returns true on success.

                                                        See Also
                                                        clearGraphs
                                                        @@ -1007,7 +1030,7 @@
                                                        -

                                                        Removes all graphs from the plot (and the QCustomPlot::legend, if necessary).

                                                        +

                                                        Removes all graphs from the plot (and the QCustomPlot::legend, if necessary).

                                                        Returns the number of graphs removed.

                                                        See Also
                                                        removeGraph
                                                        @@ -1590,7 +1613,7 @@
                                                        - +
                                                        @@ -1616,7 +1639,19 @@ - + + + + + + + + + + + + + @@ -1633,8 +1668,8 @@
                                                      • If you plan on editing the exported PDF file with a vector graphics editor like Inkscape, it is advised to set noCosmeticPen to true to avoid losing those cosmetic lines (which might be quite many, because cosmetic pens are the default for e.g. axes and tick marks).
                                                      • If calling this function inside the constructor of the parent of the QCustomPlot widget (i.e. the MainWindow constructor, if QCustomPlot is inside the MainWindow), always provide explicit non-zero widths and heights. If you leave width or height as 0 (default), this function uses the current width and height of the QCustomPlot widget. However, in Qt, these aren't defined yet inside the constructor, so you would get an image that has strange widths/heights.
                                                      • - -
                                                        Note
                                                        On Android systems, this method does nothing and issues an according qDebug warning message.
                                                        +pdfCreator and pdfTitle may be used to set the according metadata fields in the resulting PDF file. +
                                                        Note
                                                        On Android systems, this method does nothing and issues an according qDebug warning message. This is also the case if for other reasons the define flag QT_NO_PRINTER is set.
                                                        See Also
                                                        savePng, saveBmp, saveJpg, saveRastered
                                                        @@ -1688,7 +1723,7 @@

                                                        If you want the PNG to have a transparent background, call setBackground(const QBrush &brush) with no brush (Qt::NoBrush) or a transparent color (Qt::transparent), before saving.

                                                        PNG compression can be controlled with the quality parameter which must be between 0 and 100 or -1 to use the default setting.

                                                        Returns true on success. If this function fails, most likely the PNG format isn't supported by the system, see Qt docs about QImageWriter::supportedImageFormats().

                                                        -
                                                        See Also
                                                        savePdf, saveBmp, saveJpg, saveRastered
                                                        +
                                                        See Also
                                                        savePdf, saveBmp, saveJpg, saveRastered
                                                        @@ -1740,7 +1775,7 @@

                                                        The objects of the plot will appear in the current selection state. If you don't want any selected objects to be painted in their selected look, deselect everything with deselectAll before calling this function.

                                                        JPG compression can be controlled with the quality parameter which must be between 0 and 100 or -1 to use the default setting.

                                                        Returns true on success. If this function fails, most likely the JPG format isn't supported by the system, see Qt docs about QImageWriter::supportedImageFormats().

                                                        -
                                                        See Also
                                                        savePdf, savePng, saveBmp, saveRastered
                                                        +
                                                        See Also
                                                        savePdf, savePng, saveBmp, saveRastered
                                                        @@ -1785,7 +1820,7 @@
                                                        Warning
                                                        If calling this function inside the constructor of the parent of the QCustomPlot widget (i.e. the MainWindow constructor, if QCustomPlot is inside the MainWindow), always provide explicit non-zero widths and heights. If you leave width or height as 0 (default), this function uses the current width and height of the QCustomPlot widget. However, in Qt, these aren't defined yet inside the constructor, so you would get an image that has strange widths/heights.

                                                        The objects of the plot will appear in the current selection state. If you don't want any selected objects to be painted in their selected look, deselect everything with deselectAll before calling this function.

                                                        Returns true on success. If this function fails, most likely the BMP format isn't supported by the system, see Qt docs about QImageWriter::supportedImageFormats().

                                                        -
                                                        See Also
                                                        savePdf, savePng, saveJpg, saveRastered
                                                        +
                                                        See Also
                                                        savePdf, savePng, saveJpg, saveRastered
                                                        @@ -1838,7 +1873,7 @@

                                                        Saves the plot to a rastered image file fileName in the image format format. The plot is sized to width and height in pixels and scaled with scale. (width 100 and scale 2.0 lead to a full resolution file with width 200.) If the format supports compression, quality may be between 0 and 100 to control it.

                                                        Returns true on success. If this function fails, most likely the given format isn't supported by the system, see Qt docs about QImageWriter::supportedImageFormats().

                                                        -
                                                        See Also
                                                        saveBmp, saveJpg, savePng, savePdf
                                                        +
                                                        See Also
                                                        saveBmp, saveJpg, savePng, savePdf
                                                        @@ -1873,7 +1908,7 @@

                                                        Renders the plot to a pixmap and returns it.

                                                        The plot is sized to width and height in pixels and scaled with scale. (width 100 and scale 2.0 lead to a full resolution pixmap with width 200.)

                                                        -
                                                        See Also
                                                        toPainter, saveRastered, saveBmp, savePng, saveJpg, savePdf
                                                        +
                                                        See Also
                                                        toPainter, saveRastered, saveBmp, savePng, saveJpg, savePdf
                                                        @@ -1913,14 +1948,15 @@ - +
                                                        int height = 0 height = 0,
                                                        const QString & pdfCreator = "",
                                                        const QString & pdfTitle = "" 
                                                        - + +
                                                        void QCustomPlot::replot ()QCustomPlot::RefreshPriority refreshPriority = QCustomPlot::rpHint)
                                                        @@ -2502,9 +2538,9 @@
                                                        -

                                                        This signal is emitted immediately before a replot takes place (caused by a call to the slot replot).

                                                        +

                                                        This signal is emitted immediately before a replot takes place (caused by a call to the slot replot).

                                                        It is safe to mutually connect the replot slot with this signal on two QCustomPlots to make them replot synchronously, it won't cause an infinite recursion.

                                                        -
                                                        See Also
                                                        replot, afterReplot
                                                        +
                                                        See Also
                                                        replot, afterReplot
                                                        @@ -2528,9 +2564,9 @@
                                                        -

                                                        This signal is emitted immediately after a replot has taken place (caused by a call to the slot replot).

                                                        +

                                                        This signal is emitted immediately after a replot has taken place (caused by a call to the slot replot).

                                                        It is safe to mutually connect the replot slot with this signal on two QCustomPlots to make them replot synchronously, it won't cause an infinite recursion.

                                                        -
                                                        See Also
                                                        replot, beforeReplot
                                                        +
                                                        See Also
                                                        replot, beforeReplot
                                                        @@ -2603,7 +2639,7 @@
                                                        -

                                                        Event handler for when the QCustomPlot widget needs repainting. This does not cause a replot, but draws the internal buffer on the widget surface.

                                                        +

                                                        Event handler for when the QCustomPlot widget needs repainting. This does not cause a replot, but draws the internal buffer on the widget surface.

                                                        @@ -2628,7 +2664,7 @@
                                                        -

                                                        Event handler for a resize of the QCustomPlot widget. Causes the internal buffer to be resized to the new size. The viewport (which becomes the outer rect of mPlotLayout) is resized appropriately. Finally a replot is performed.

                                                        +

                                                        Event handler for a resize of the QCustomPlot widget. Causes the internal buffer to be resized to the new size. The viewport (which becomes the outer rect of mPlotLayout) is resized appropriately. Finally a replot is performed.

                                                        @@ -2785,7 +2821,7 @@
                                                        -

                                                        This is the main draw function. It draws the entire plot, including background pixmap, with the specified painter. Note that it does not fill the background with the background brush (as the user may specify with setBackground(const QBrush &brush)), this is up to the respective functions calling this method (e.g. replot, toPixmap and toPainter).

                                                        +

                                                        This is the main draw function. It draws the entire plot, including background pixmap, with the specified painter. Note that it does not fill the background with the background brush (as the user may specify with setBackground(const QBrush &brush)), this is up to the respective functions calling this method (e.g. replot, toPixmap and toPainter).

                                                        @@ -2810,7 +2846,7 @@
                                                        -

                                                        This method is used by QCPAxisRect::removeAxis to report removed axes to the QCustomPlot so it may clear its QCustomPlot::xAxis, yAxis, xAxis2 and yAxis2 members accordingly.

                                                        +

                                                        This method is used by QCPAxisRect::removeAxis to report removed axes to the QCustomPlot so it may clear its QCustomPlot::xAxis, yAxis, xAxis2 and yAxis2 members accordingly.

                                                        @@ -2835,7 +2871,7 @@
                                                        -

                                                        This method is used by the QCPLegend destructor to report legend removal to the QCustomPlot so it may clear its QCustomPlot::legend member accordingly.

                                                        +

                                                        This method is used by the QCPLegend destructor to report legend removal to the QCustomPlot so it may clear its QCustomPlot::legend member accordingly.

                                                        @@ -2927,12 +2963,83 @@

                                                        Draws the viewport background pixmap of the plot.

                                                        -

                                                        If a pixmap was provided via setBackground, this function buffers the scaled version depending on setBackgroundScaled and setBackgroundScaledMode and then draws it inside the viewport with the provided painter. The scaled version is buffered in mScaledBackgroundPixmap to prevent expensive rescaling at every redraw. It is only updated, when the axis rect has changed in a way that requires a rescale of the background pixmap (this is dependant on the setBackgroundScaledMode), or when a differend axis backgroud pixmap was set.

                                                        +

                                                        If a pixmap was provided via setBackground, this function buffers the scaled version depending on setBackgroundScaled and setBackgroundScaledMode and then draws it inside the viewport with the provided painter. The scaled version is buffered in mScaledBackgroundPixmap to prevent expensive rescaling at every redraw. It is only updated, when the axis rect has changed in a way that requires a rescale of the background pixmap (this is dependent on the setBackgroundScaledMode), or when a differend axis background pixmap was set.

                                                        Note that this function does not draw a fill with the background brush (setBackground(const QBrush &brush)) beneath the pixmap.

                                                        See Also
                                                        setBackground, setBackgroundScaled, setBackgroundScaledMode
                                                        +

                                                        Field Documentation

                                                        + +
                                                        +
                                                        + + + + +
                                                        QCPAxis * QCustomPlot::xAxis
                                                        +
                                                        +

                                                        A pointer to the primary x Axis (bottom) of the main axis rect of the plot.

                                                        +

                                                        QCustomPlot offers convenient pointers to the axes (xAxis, yAxis, xAxis2, yAxis2) and the legend. They make it very easy working with plots that only have a single axis rect and at most one axis at each axis rect side. If you use the layout system to add multiple axis rects or multiple axes to one side, use the QCPAxisRect::axis interface to access the new axes. If one of the four default axes or the default legend is removed due to manipulation of the layout system (e.g. by removing the main axis rect), the corresponding pointers become 0.

                                                        + +
                                                        +
                                                        + +
                                                        +
                                                        + + + + +
                                                        QCPAxis * QCustomPlot::yAxis
                                                        +
                                                        +

                                                        A pointer to the primary y Axis (left) of the main axis rect of the plot.

                                                        +

                                                        QCustomPlot offers convenient pointers to the axes (xAxis, yAxis, xAxis2, yAxis2) and the legend. They make it very easy working with plots that only have a single axis rect and at most one axis at each axis rect side. If you use the layout system to add multiple axis rects or multiple axes to one side, use the QCPAxisRect::axis interface to access the new axes. If one of the four default axes or the default legend is removed due to manipulation of the layout system (e.g. by removing the main axis rect), the corresponding pointers become 0.

                                                        + +
                                                        +
                                                        + +
                                                        +
                                                        + + + + +
                                                        QCPAxis * QCustomPlot::xAxis2
                                                        +
                                                        +

                                                        A pointer to the secondary x Axis (top) of the main axis rect of the plot. Secondary axes are invisible by default. Use QCPAxis::setVisible to change this (or use QCPAxisRect::setupFullAxesBox).

                                                        +

                                                        QCustomPlot offers convenient pointers to the axes (xAxis, yAxis, xAxis2, yAxis2) and the legend. They make it very easy working with plots that only have a single axis rect and at most one axis at each axis rect side. If you use the layout system to add multiple axis rects or multiple axes to one side, use the QCPAxisRect::axis interface to access the new axes. If one of the four default axes or the default legend is removed due to manipulation of the layout system (e.g. by removing the main axis rect), the corresponding pointers become 0.

                                                        + +
                                                        +
                                                        + +
                                                        +
                                                        + + + + +
                                                        QCPAxis * QCustomPlot::yAxis2
                                                        +
                                                        +

                                                        A pointer to the secondary y Axis (right) of the main axis rect of the plot. Secondary axes are invisible by default. Use QCPAxis::setVisible to change this (or use QCPAxisRect::setupFullAxesBox).

                                                        +

                                                        QCustomPlot offers convenient pointers to the axes (xAxis, yAxis, xAxis2, yAxis2) and the legend. They make it very easy working with plots that only have a single axis rect and at most one axis at each axis rect side. If you use the layout system to add multiple axis rects or multiple axes to one side, use the QCPAxisRect::axis interface to access the new axes. If one of the four default axes or the default legend is removed due to manipulation of the layout system (e.g. by removing the main axis rect), the corresponding pointers become 0.

                                                        + +
                                                        +
                                                        + +
                                                        +
                                                        + + + + +
                                                        QCPLegend * QCustomPlot::legend
                                                        +
                                                        +

                                                        A pointer to the default legend of the main axis rect. The legend is invisible by default. Use QCPLegend::setVisible to change this.

                                                        +

                                                        QCustomPlot offers convenient pointers to the axes (xAxis, yAxis, xAxis2, yAxis2) and the legend. They make it very easy working with plots that only have a single axis rect and at most one axis at each axis rect side. If you use the layout system to add multiple legends to the plot, use the layout system interface to access the new legend. For example, legends can be placed inside an axis rect's inset layout, and must then also be accessed via the inset layout. If the default legend is removed due to manipulation of the layout system (e.g. by removing the main axis rect), the corresponding pointer becomes 0.

                                                        + +
                                                        +

                                                        The documentation for this class was generated from the following files:
                                                        • src/core.h
                                                        • src/core.cpp
                                                        • diff -Nru qcustomplot-1.1.0/documentation/html/colorgradient_8h_source.html qcustomplot-1.2.0/documentation/html/colorgradient_8h_source.html --- qcustomplot-1.1.0/documentation/html/colorgradient_8h_source.html 1970-01-01 00:00:00.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/colorgradient_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -0,0 +1,124 @@ + + + + +src/colorgradient.h Source File + + + + + + + +
                                                          +
                                                          +
                                                          colorgradient.h
                                                          +
                                                          +
                                                          +
                                                          1 /***************************************************************************
                                                          +
                                                          2 ** **
                                                          +
                                                          3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                          +
                                                          4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                          +
                                                          5 ** **
                                                          +
                                                          6 ** This program is free software: you can redistribute it and/or modify **
                                                          +
                                                          7 ** it under the terms of the GNU General Public License as published by **
                                                          +
                                                          8 ** the Free Software Foundation, either version 3 of the License, or **
                                                          +
                                                          9 ** (at your option) any later version. **
                                                          +
                                                          10 ** **
                                                          +
                                                          11 ** This program is distributed in the hope that it will be useful, **
                                                          +
                                                          12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of **
                                                          +
                                                          13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
                                                          +
                                                          14 ** GNU General Public License for more details. **
                                                          +
                                                          15 ** **
                                                          +
                                                          16 ** You should have received a copy of the GNU General Public License **
                                                          +
                                                          17 ** along with this program. If not, see http://www.gnu.org/licenses/. **
                                                          +
                                                          18 ** **
                                                          +
                                                          19 ****************************************************************************
                                                          +
                                                          20 ** Author: Emanuel Eichhammer **
                                                          +
                                                          21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                          +
                                                          22 ** Date: 14.03.14 **
                                                          +
                                                          23 ** Version: 1.2.0 **
                                                          +
                                                          24 ****************************************************************************/
                                                          +
                                                          25 
                                                          +
                                                          26 #ifndef QCP_COLORGRADIENT_H
                                                          +
                                                          27 #define QCP_COLORGRADIENT_H
                                                          +
                                                          28 
                                                          +
                                                          29 #include "global.h"
                                                          +
                                                          30 #include "range.h"
                                                          +
                                                          31 
                                                          +
                                                          32 class QCP_LIB_DECL QCPColorGradient
                                                          +
                                                          33 {
                                                          +
                                                          34  Q_GADGET
                                                          +
                                                          35 public:
                                                          +
                                                          41  enum ColorInterpolation { ciRGB
                                                          +
                                                          42  ,ciHSV
                                                          +
                                                          43  };
                                                          +
                                                          44  Q_ENUMS(ColorInterpolation)
                                                          +
                                                          45 
                                                          +
                                                          46 
                                                          +
                                                          50  enum GradientPreset { gpGrayscale
                                                          +
                                                          51  ,gpHot
                                                          +
                                                          52  ,gpCold
                                                          +
                                                          53  ,gpNight
                                                          +
                                                          54  ,gpCandy
                                                          +
                                                          55  ,gpGeography
                                                          +
                                                          56  ,gpIon
                                                          +
                                                          57  ,gpThermal
                                                          +
                                                          58  ,gpPolar
                                                          +
                                                          59  ,gpSpectrum
                                                          +
                                                          60  ,gpJet
                                                          +
                                                          61  ,gpHues
                                                          +
                                                          62  };
                                                          +
                                                          63  Q_ENUMS(GradientPreset)
                                                          +
                                                          64 
                                                          +
                                                          65  QCPColorGradient(GradientPreset preset=gpCold);
                                                          +
                                                          66  bool operator==(const QCPColorGradient &other) const;
                                                          +
                                                          67  bool operator!=(const QCPColorGradient &other) const { return !(*this == other); }
                                                          +
                                                          68 
                                                          +
                                                          69  // getters:
                                                          +
                                                          70  int levelCount() const { return mLevelCount; }
                                                          +
                                                          71  QMap<double, QColor> colorStops() const { return mColorStops; }
                                                          +
                                                          72  ColorInterpolation colorInterpolation() const { return mColorInterpolation; }
                                                          +
                                                          73  bool periodic() const { return mPeriodic; }
                                                          +
                                                          74 
                                                          +
                                                          75  // setters:
                                                          +
                                                          76  void setLevelCount(int n);
                                                          +
                                                          77  void setColorStops(const QMap<double, QColor> &colorStops);
                                                          +
                                                          78  void setColorStopAt(double position, const QColor &color);
                                                          +
                                                          79  void setColorInterpolation(ColorInterpolation interpolation);
                                                          +
                                                          80  void setPeriodic(bool enabled);
                                                          +
                                                          81 
                                                          +
                                                          82  // non-property methods:
                                                          +
                                                          83  void colorize(const double *data, const QCPRange &range, QRgb *scanLine, int n, int dataIndexFactor=1, bool logarithmic=false);
                                                          +
                                                          84  QRgb color(double position, const QCPRange &range, bool logarithmic=false);
                                                          +
                                                          85  void loadPreset(GradientPreset preset);
                                                          +
                                                          86  void clearColorStops();
                                                          +
                                                          87  QCPColorGradient inverted() const;
                                                          +
                                                          88 
                                                          +
                                                          89 protected:
                                                          +
                                                          90  void updateColorBuffer();
                                                          +
                                                          91 
                                                          +
                                                          92  // property members:
                                                          +
                                                          93  int mLevelCount;
                                                          +
                                                          94  QMap<double, QColor> mColorStops;
                                                          +
                                                          95  ColorInterpolation mColorInterpolation;
                                                          +
                                                          96  bool mPeriodic;
                                                          +
                                                          97 
                                                          +
                                                          98  // non-property members:
                                                          +
                                                          99  QVector<QRgb> mColorBuffer;
                                                          +
                                                          100  bool mColorBufferInvalidated;
                                                          +
                                                          101 };
                                                          +
                                                          102 
                                                          +
                                                          103 #endif // QCP_COLORGRADIENT_H
                                                          +
                                                          + + + diff -Nru qcustomplot-1.1.0/documentation/html/core_8h_source.html qcustomplot-1.2.0/documentation/html/core_8h_source.html --- qcustomplot-1.1.0/documentation/html/core_8h_source.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/core_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -26,7 +26,7 @@
                                                          1 /***************************************************************************
                                                          2 ** **
                                                          3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                          -
                                                          4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
                                                          +
                                                          4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                          5 ** **
                                                          6 ** This program is free software: you can redistribute it and/or modify **
                                                          7 ** it under the terms of the GNU General Public License as published by **
                                                          @@ -44,8 +44,8 @@
                                                          19 ****************************************************************************
                                                          20 ** Author: Emanuel Eichhammer **
                                                          21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                          -
                                                          22 ** Date: 04.11.13 **
                                                          -
                                                          23 ** Version: 1.1.0 **
                                                          +
                                                          22 ** Date: 14.03.14 **
                                                          +
                                                          23 ** Version: 1.2.0 **
                                                          24 ****************************************************************************/
                                                          25 
                                                          26 #ifndef QCP_CORE_H
                                                          @@ -82,191 +82,197 @@
                                                          64  };
                                                          65  Q_ENUMS(LayerInsertMode)
                                                          66 
                                                          -
                                                          67  explicit QCustomPlot(QWidget *parent = 0);
                                                          -
                                                          68  virtual ~QCustomPlot();
                                                          -
                                                          69 
                                                          -
                                                          70  // getters:
                                                          -
                                                          71  QRect viewport() const { return mViewport; }
                                                          -
                                                          72  QPixmap background() const { return mBackgroundPixmap; }
                                                          -
                                                          73  bool backgroundScaled() const { return mBackgroundScaled; }
                                                          -
                                                          74  Qt::AspectRatioMode backgroundScaledMode() const { return mBackgroundScaledMode; }
                                                          -
                                                          75  QCPLayoutGrid *plotLayout() const { return mPlotLayout; }
                                                          -
                                                          76  QCP::AntialiasedElements antialiasedElements() const { return mAntialiasedElements; }
                                                          -
                                                          77  QCP::AntialiasedElements notAntialiasedElements() const { return mNotAntialiasedElements; }
                                                          -
                                                          78  bool autoAddPlottableToLegend() const { return mAutoAddPlottableToLegend; }
                                                          -
                                                          79  const QCP::Interactions interactions() const { return mInteractions; }
                                                          -
                                                          80  int selectionTolerance() const { return mSelectionTolerance; }
                                                          -
                                                          81  bool noAntialiasingOnDrag() const { return mNoAntialiasingOnDrag; }
                                                          -
                                                          82  QCP::PlottingHints plottingHints() const { return mPlottingHints; }
                                                          -
                                                          83  Qt::KeyboardModifier multiSelectModifier() const { return mMultiSelectModifier; }
                                                          -
                                                          84 
                                                          -
                                                          85  // setters:
                                                          -
                                                          86  void setViewport(const QRect &rect);
                                                          -
                                                          87  void setBackground(const QPixmap &pm);
                                                          -
                                                          88  void setBackground(const QPixmap &pm, bool scaled, Qt::AspectRatioMode mode=Qt::KeepAspectRatioByExpanding);
                                                          -
                                                          89  void setBackground(const QBrush &brush);
                                                          -
                                                          90  void setBackgroundScaled(bool scaled);
                                                          -
                                                          91  void setBackgroundScaledMode(Qt::AspectRatioMode mode);
                                                          -
                                                          92  void setAntialiasedElements(const QCP::AntialiasedElements &antialiasedElements);
                                                          -
                                                          93  void setAntialiasedElement(QCP::AntialiasedElement antialiasedElement, bool enabled=true);
                                                          -
                                                          94  void setNotAntialiasedElements(const QCP::AntialiasedElements &notAntialiasedElements);
                                                          -
                                                          95  void setNotAntialiasedElement(QCP::AntialiasedElement notAntialiasedElement, bool enabled=true);
                                                          -
                                                          96  void setAutoAddPlottableToLegend(bool on);
                                                          -
                                                          97  void setInteractions(const QCP::Interactions &interactions);
                                                          -
                                                          98  void setInteraction(const QCP::Interaction &interaction, bool enabled=true);
                                                          -
                                                          99  void setSelectionTolerance(int pixels);
                                                          -
                                                          100  void setNoAntialiasingOnDrag(bool enabled);
                                                          -
                                                          101  void setPlottingHints(const QCP::PlottingHints &hints);
                                                          -
                                                          102  void setPlottingHint(QCP::PlottingHint hint, bool enabled=true);
                                                          -
                                                          103  void setMultiSelectModifier(Qt::KeyboardModifier modifier);
                                                          -
                                                          104 
                                                          -
                                                          105  // non-property methods:
                                                          -
                                                          106  // plottable interface:
                                                          -
                                                          107  QCPAbstractPlottable *plottable(int index);
                                                          -
                                                          108  QCPAbstractPlottable *plottable();
                                                          -
                                                          109  bool addPlottable(QCPAbstractPlottable *plottable);
                                                          -
                                                          110  bool removePlottable(QCPAbstractPlottable *plottable);
                                                          -
                                                          111  bool removePlottable(int index);
                                                          -
                                                          112  int clearPlottables();
                                                          -
                                                          113  int plottableCount() const;
                                                          -
                                                          114  QList<QCPAbstractPlottable*> selectedPlottables() const;
                                                          -
                                                          115  QCPAbstractPlottable *plottableAt(const QPointF &pos, bool onlySelectable=false) const;
                                                          -
                                                          116  bool hasPlottable(QCPAbstractPlottable *plottable) const;
                                                          -
                                                          117 
                                                          -
                                                          118  // specialized interface for QCPGraph:
                                                          -
                                                          119  QCPGraph *graph(int index) const;
                                                          -
                                                          120  QCPGraph *graph() const;
                                                          -
                                                          121  QCPGraph *addGraph(QCPAxis *keyAxis=0, QCPAxis *valueAxis=0);
                                                          -
                                                          122  bool removeGraph(QCPGraph *graph);
                                                          -
                                                          123  bool removeGraph(int index);
                                                          -
                                                          124  int clearGraphs();
                                                          -
                                                          125  int graphCount() const;
                                                          -
                                                          126  QList<QCPGraph*> selectedGraphs() const;
                                                          -
                                                          127 
                                                          -
                                                          128  // item interface:
                                                          -
                                                          129  QCPAbstractItem *item(int index) const;
                                                          -
                                                          130  QCPAbstractItem *item() const;
                                                          -
                                                          131  bool addItem(QCPAbstractItem* item);
                                                          -
                                                          132  bool removeItem(QCPAbstractItem *item);
                                                          -
                                                          133  bool removeItem(int index);
                                                          -
                                                          134  int clearItems();
                                                          -
                                                          135  int itemCount() const;
                                                          -
                                                          136  QList<QCPAbstractItem*> selectedItems() const;
                                                          -
                                                          137  QCPAbstractItem *itemAt(const QPointF &pos, bool onlySelectable=false) const;
                                                          -
                                                          138  bool hasItem(QCPAbstractItem *item) const;
                                                          -
                                                          139 
                                                          -
                                                          140  // layer interface:
                                                          -
                                                          141  QCPLayer *layer(const QString &name) const;
                                                          -
                                                          142  QCPLayer *layer(int index) const;
                                                          -
                                                          143  QCPLayer *currentLayer() const;
                                                          -
                                                          144  bool setCurrentLayer(const QString &name);
                                                          -
                                                          145  bool setCurrentLayer(QCPLayer *layer);
                                                          -
                                                          146  int layerCount() const;
                                                          -
                                                          147  bool addLayer(const QString &name, QCPLayer *otherLayer=0, LayerInsertMode insertMode=limAbove);
                                                          -
                                                          148  bool removeLayer(QCPLayer *layer);
                                                          -
                                                          149  bool moveLayer(QCPLayer *layer, QCPLayer *otherLayer, LayerInsertMode insertMode=limAbove);
                                                          -
                                                          150 
                                                          -
                                                          151  // axis rect/layout interface:
                                                          -
                                                          152  int axisRectCount() const;
                                                          -
                                                          153  QCPAxisRect* axisRect(int index=0) const;
                                                          -
                                                          154  QList<QCPAxisRect*> axisRects() const;
                                                          -
                                                          155  QCPLayoutElement* layoutElementAt(const QPointF &pos) const;
                                                          -
                                                          156  Q_SLOT void rescaleAxes(bool onlyVisiblePlottables=false);
                                                          -
                                                          157 
                                                          -
                                                          158  QList<QCPAxis*> selectedAxes() const;
                                                          -
                                                          159  QList<QCPLegend*> selectedLegends() const;
                                                          -
                                                          160  Q_SLOT void deselectAll();
                                                          -
                                                          161 
                                                          -
                                                          162  bool savePdf(const QString &fileName, bool noCosmeticPen=false, int width=0, int height=0);
                                                          -
                                                          163  bool savePng(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1);
                                                          -
                                                          164  bool saveJpg(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1);
                                                          -
                                                          165  bool saveBmp(const QString &fileName, int width=0, int height=0, double scale=1.0);
                                                          -
                                                          166  bool saveRastered(const QString &fileName, int width, int height, double scale, const char *format, int quality=-1);
                                                          -
                                                          167  QPixmap toPixmap(int width=0, int height=0, double scale=1.0);
                                                          -
                                                          168  void toPainter(QCPPainter *painter, int width=0, int height=0);
                                                          -
                                                          169  Q_SLOT void replot();
                                                          -
                                                          170 
                                                          -
                                                          171  QCPAxis *xAxis, *yAxis, *xAxis2, *yAxis2;
                                                          -
                                                          172  QCPLegend *legend;
                                                          -
                                                          173 
                                                          -
                                                          174 signals:
                                                          -
                                                          175  void mouseDoubleClick(QMouseEvent *event);
                                                          -
                                                          176  void mousePress(QMouseEvent *event);
                                                          -
                                                          177  void mouseMove(QMouseEvent *event);
                                                          -
                                                          178  void mouseRelease(QMouseEvent *event);
                                                          -
                                                          179  void mouseWheel(QWheelEvent *event);
                                                          +
                                                          67 
                                                          +
                                                          72  enum RefreshPriority { rpImmediate
                                                          +
                                                          73  ,rpQueued
                                                          +
                                                          74  ,rpHint
                                                          +
                                                          75  };
                                                          +
                                                          76 
                                                          +
                                                          77  explicit QCustomPlot(QWidget *parent = 0);
                                                          +
                                                          78  virtual ~QCustomPlot();
                                                          +
                                                          79 
                                                          +
                                                          80  // getters:
                                                          +
                                                          81  QRect viewport() const { return mViewport; }
                                                          +
                                                          82  QPixmap background() const { return mBackgroundPixmap; }
                                                          +
                                                          83  bool backgroundScaled() const { return mBackgroundScaled; }
                                                          +
                                                          84  Qt::AspectRatioMode backgroundScaledMode() const { return mBackgroundScaledMode; }
                                                          +
                                                          85  QCPLayoutGrid *plotLayout() const { return mPlotLayout; }
                                                          +
                                                          86  QCP::AntialiasedElements antialiasedElements() const { return mAntialiasedElements; }
                                                          +
                                                          87  QCP::AntialiasedElements notAntialiasedElements() const { return mNotAntialiasedElements; }
                                                          +
                                                          88  bool autoAddPlottableToLegend() const { return mAutoAddPlottableToLegend; }
                                                          +
                                                          89  const QCP::Interactions interactions() const { return mInteractions; }
                                                          +
                                                          90  int selectionTolerance() const { return mSelectionTolerance; }
                                                          +
                                                          91  bool noAntialiasingOnDrag() const { return mNoAntialiasingOnDrag; }
                                                          +
                                                          92  QCP::PlottingHints plottingHints() const { return mPlottingHints; }
                                                          +
                                                          93  Qt::KeyboardModifier multiSelectModifier() const { return mMultiSelectModifier; }
                                                          +
                                                          94 
                                                          +
                                                          95  // setters:
                                                          +
                                                          96  void setViewport(const QRect &rect);
                                                          +
                                                          97  void setBackground(const QPixmap &pm);
                                                          +
                                                          98  void setBackground(const QPixmap &pm, bool scaled, Qt::AspectRatioMode mode=Qt::KeepAspectRatioByExpanding);
                                                          +
                                                          99  void setBackground(const QBrush &brush);
                                                          +
                                                          100  void setBackgroundScaled(bool scaled);
                                                          +
                                                          101  void setBackgroundScaledMode(Qt::AspectRatioMode mode);
                                                          +
                                                          102  void setAntialiasedElements(const QCP::AntialiasedElements &antialiasedElements);
                                                          +
                                                          103  void setAntialiasedElement(QCP::AntialiasedElement antialiasedElement, bool enabled=true);
                                                          +
                                                          104  void setNotAntialiasedElements(const QCP::AntialiasedElements &notAntialiasedElements);
                                                          +
                                                          105  void setNotAntialiasedElement(QCP::AntialiasedElement notAntialiasedElement, bool enabled=true);
                                                          +
                                                          106  void setAutoAddPlottableToLegend(bool on);
                                                          +
                                                          107  void setInteractions(const QCP::Interactions &interactions);
                                                          +
                                                          108  void setInteraction(const QCP::Interaction &interaction, bool enabled=true);
                                                          +
                                                          109  void setSelectionTolerance(int pixels);
                                                          +
                                                          110  void setNoAntialiasingOnDrag(bool enabled);
                                                          +
                                                          111  void setPlottingHints(const QCP::PlottingHints &hints);
                                                          +
                                                          112  void setPlottingHint(QCP::PlottingHint hint, bool enabled=true);
                                                          +
                                                          113  void setMultiSelectModifier(Qt::KeyboardModifier modifier);
                                                          +
                                                          114 
                                                          +
                                                          115  // non-property methods:
                                                          +
                                                          116  // plottable interface:
                                                          +
                                                          117  QCPAbstractPlottable *plottable(int index);
                                                          +
                                                          118  QCPAbstractPlottable *plottable();
                                                          +
                                                          119  bool addPlottable(QCPAbstractPlottable *plottable);
                                                          +
                                                          120  bool removePlottable(QCPAbstractPlottable *plottable);
                                                          +
                                                          121  bool removePlottable(int index);
                                                          +
                                                          122  int clearPlottables();
                                                          +
                                                          123  int plottableCount() const;
                                                          +
                                                          124  QList<QCPAbstractPlottable*> selectedPlottables() const;
                                                          +
                                                          125  QCPAbstractPlottable *plottableAt(const QPointF &pos, bool onlySelectable=false) const;
                                                          +
                                                          126  bool hasPlottable(QCPAbstractPlottable *plottable) const;
                                                          +
                                                          127 
                                                          +
                                                          128  // specialized interface for QCPGraph:
                                                          +
                                                          129  QCPGraph *graph(int index) const;
                                                          +
                                                          130  QCPGraph *graph() const;
                                                          +
                                                          131  QCPGraph *addGraph(QCPAxis *keyAxis=0, QCPAxis *valueAxis=0);
                                                          +
                                                          132  bool removeGraph(QCPGraph *graph);
                                                          +
                                                          133  bool removeGraph(int index);
                                                          +
                                                          134  int clearGraphs();
                                                          +
                                                          135  int graphCount() const;
                                                          +
                                                          136  QList<QCPGraph*> selectedGraphs() const;
                                                          +
                                                          137 
                                                          +
                                                          138  // item interface:
                                                          +
                                                          139  QCPAbstractItem *item(int index) const;
                                                          +
                                                          140  QCPAbstractItem *item() const;
                                                          +
                                                          141  bool addItem(QCPAbstractItem* item);
                                                          +
                                                          142  bool removeItem(QCPAbstractItem *item);
                                                          +
                                                          143  bool removeItem(int index);
                                                          +
                                                          144  int clearItems();
                                                          +
                                                          145  int itemCount() const;
                                                          +
                                                          146  QList<QCPAbstractItem*> selectedItems() const;
                                                          +
                                                          147  QCPAbstractItem *itemAt(const QPointF &pos, bool onlySelectable=false) const;
                                                          +
                                                          148  bool hasItem(QCPAbstractItem *item) const;
                                                          +
                                                          149 
                                                          +
                                                          150  // layer interface:
                                                          +
                                                          151  QCPLayer *layer(const QString &name) const;
                                                          +
                                                          152  QCPLayer *layer(int index) const;
                                                          +
                                                          153  QCPLayer *currentLayer() const;
                                                          +
                                                          154  bool setCurrentLayer(const QString &name);
                                                          +
                                                          155  bool setCurrentLayer(QCPLayer *layer);
                                                          +
                                                          156  int layerCount() const;
                                                          +
                                                          157  bool addLayer(const QString &name, QCPLayer *otherLayer=0, LayerInsertMode insertMode=limAbove);
                                                          +
                                                          158  bool removeLayer(QCPLayer *layer);
                                                          +
                                                          159  bool moveLayer(QCPLayer *layer, QCPLayer *otherLayer, LayerInsertMode insertMode=limAbove);
                                                          +
                                                          160 
                                                          +
                                                          161  // axis rect/layout interface:
                                                          +
                                                          162  int axisRectCount() const;
                                                          +
                                                          163  QCPAxisRect* axisRect(int index=0) const;
                                                          +
                                                          164  QList<QCPAxisRect*> axisRects() const;
                                                          +
                                                          165  QCPLayoutElement* layoutElementAt(const QPointF &pos) const;
                                                          +
                                                          166  Q_SLOT void rescaleAxes(bool onlyVisiblePlottables=false);
                                                          +
                                                          167 
                                                          +
                                                          168  QList<QCPAxis*> selectedAxes() const;
                                                          +
                                                          169  QList<QCPLegend*> selectedLegends() const;
                                                          +
                                                          170  Q_SLOT void deselectAll();
                                                          +
                                                          171 
                                                          +
                                                          172  bool savePdf(const QString &fileName, bool noCosmeticPen=false, int width=0, int height=0, const QString &pdfCreator="", const QString &pdfTitle="");
                                                          +
                                                          173  bool savePng(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1);
                                                          +
                                                          174  bool saveJpg(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1);
                                                          +
                                                          175  bool saveBmp(const QString &fileName, int width=0, int height=0, double scale=1.0);
                                                          +
                                                          176  bool saveRastered(const QString &fileName, int width, int height, double scale, const char *format, int quality=-1);
                                                          +
                                                          177  QPixmap toPixmap(int width=0, int height=0, double scale=1.0);
                                                          +
                                                          178  void toPainter(QCPPainter *painter, int width=0, int height=0);
                                                          +
                                                          179  Q_SLOT void replot(QCustomPlot::RefreshPriority refreshPriority=QCustomPlot::rpHint);
                                                          180 
                                                          -
                                                          181  void plottableClick(QCPAbstractPlottable *plottable, QMouseEvent *event);
                                                          -
                                                          182  void plottableDoubleClick(QCPAbstractPlottable *plottable, QMouseEvent *event);
                                                          -
                                                          183  void itemClick(QCPAbstractItem *item, QMouseEvent *event);
                                                          -
                                                          184  void itemDoubleClick(QCPAbstractItem *item, QMouseEvent *event);
                                                          -
                                                          185  void axisClick(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event);
                                                          -
                                                          186  void axisDoubleClick(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event);
                                                          -
                                                          187  void legendClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event);
                                                          -
                                                          188  void legendDoubleClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event);
                                                          -
                                                          189  void titleClick(QMouseEvent *event, QCPPlotTitle *title);
                                                          -
                                                          190  void titleDoubleClick(QMouseEvent *event, QCPPlotTitle *title);
                                                          -
                                                          191 
                                                          -
                                                          192  void selectionChangedByUser();
                                                          -
                                                          193  void beforeReplot();
                                                          -
                                                          194  void afterReplot();
                                                          -
                                                          195 
                                                          -
                                                          196 protected:
                                                          -
                                                          197  // property members:
                                                          -
                                                          198  QRect mViewport;
                                                          -
                                                          199  QCPLayoutGrid *mPlotLayout;
                                                          -
                                                          200  bool mAutoAddPlottableToLegend;
                                                          -
                                                          201  QList<QCPAbstractPlottable*> mPlottables;
                                                          -
                                                          202  QList<QCPGraph*> mGraphs; // extra list of plottables also in mPlottables that are of type QCPGraph
                                                          -
                                                          203  QList<QCPAbstractItem*> mItems;
                                                          -
                                                          204  QList<QCPLayer*> mLayers;
                                                          -
                                                          205  QCP::AntialiasedElements mAntialiasedElements, mNotAntialiasedElements;
                                                          -
                                                          206  QCP::Interactions mInteractions;
                                                          -
                                                          207  int mSelectionTolerance;
                                                          -
                                                          208  bool mNoAntialiasingOnDrag;
                                                          -
                                                          209  QBrush mBackgroundBrush;
                                                          -
                                                          210  QPixmap mBackgroundPixmap;
                                                          -
                                                          211  QPixmap mScaledBackgroundPixmap;
                                                          -
                                                          212  bool mBackgroundScaled;
                                                          -
                                                          213  Qt::AspectRatioMode mBackgroundScaledMode;
                                                          -
                                                          214  QCPLayer *mCurrentLayer;
                                                          -
                                                          215  QCP::PlottingHints mPlottingHints;
                                                          -
                                                          216  Qt::KeyboardModifier mMultiSelectModifier;
                                                          -
                                                          217 
                                                          -
                                                          218  // non-property members:
                                                          -
                                                          219  QPixmap mPaintBuffer;
                                                          -
                                                          220  QPoint mMousePressPos;
                                                          -
                                                          221  QCPLayoutElement *mMouseEventElement;
                                                          -
                                                          222  bool mReplotting;
                                                          -
                                                          223 
                                                          -
                                                          224  // reimplemented virtual methods:
                                                          -
                                                          225  virtual QSize minimumSizeHint() const;
                                                          -
                                                          226  virtual QSize sizeHint() const;
                                                          -
                                                          227  virtual void paintEvent(QPaintEvent *event);
                                                          -
                                                          228  virtual void resizeEvent(QResizeEvent *event);
                                                          -
                                                          229  virtual void mouseDoubleClickEvent(QMouseEvent *event);
                                                          -
                                                          230  virtual void mousePressEvent(QMouseEvent *event);
                                                          -
                                                          231  virtual void mouseMoveEvent(QMouseEvent *event);
                                                          -
                                                          232  virtual void mouseReleaseEvent(QMouseEvent *event);
                                                          -
                                                          233  virtual void wheelEvent(QWheelEvent *event);
                                                          -
                                                          234 
                                                          -
                                                          235  // introduced virtual methods:
                                                          -
                                                          236  virtual void draw(QCPPainter *painter);
                                                          -
                                                          237  virtual void axisRemoved(QCPAxis *axis);
                                                          -
                                                          238  virtual void legendRemoved(QCPLegend *legend);
                                                          -
                                                          239 
                                                          -
                                                          240  // non-virtual methods:
                                                          -
                                                          241  void updateLayerIndices() const;
                                                          -
                                                          242  QCPLayerable *layerableAt(const QPointF &pos, bool onlySelectable, QVariant *selectionDetails=0) const;
                                                          -
                                                          243  void drawBackground(QCPPainter *painter);
                                                          +
                                                          181  QCPAxis *xAxis, *yAxis, *xAxis2, *yAxis2;
                                                          + +
                                                          183 
                                                          +
                                                          184 signals:
                                                          +
                                                          185  void mouseDoubleClick(QMouseEvent *event);
                                                          +
                                                          186  void mousePress(QMouseEvent *event);
                                                          +
                                                          187  void mouseMove(QMouseEvent *event);
                                                          +
                                                          188  void mouseRelease(QMouseEvent *event);
                                                          +
                                                          189  void mouseWheel(QWheelEvent *event);
                                                          +
                                                          190 
                                                          +
                                                          191  void plottableClick(QCPAbstractPlottable *plottable, QMouseEvent *event);
                                                          +
                                                          192  void plottableDoubleClick(QCPAbstractPlottable *plottable, QMouseEvent *event);
                                                          +
                                                          193  void itemClick(QCPAbstractItem *item, QMouseEvent *event);
                                                          +
                                                          194  void itemDoubleClick(QCPAbstractItem *item, QMouseEvent *event);
                                                          +
                                                          195  void axisClick(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event);
                                                          +
                                                          196  void axisDoubleClick(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event);
                                                          +
                                                          197  void legendClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event);
                                                          +
                                                          198  void legendDoubleClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event);
                                                          +
                                                          199  void titleClick(QMouseEvent *event, QCPPlotTitle *title);
                                                          +
                                                          200  void titleDoubleClick(QMouseEvent *event, QCPPlotTitle *title);
                                                          +
                                                          201 
                                                          +
                                                          202  void selectionChangedByUser();
                                                          +
                                                          203  void beforeReplot();
                                                          +
                                                          204  void afterReplot();
                                                          +
                                                          205 
                                                          +
                                                          206 protected:
                                                          +
                                                          207  // property members:
                                                          +
                                                          208  QRect mViewport;
                                                          +
                                                          209  QCPLayoutGrid *mPlotLayout;
                                                          +
                                                          210  bool mAutoAddPlottableToLegend;
                                                          +
                                                          211  QList<QCPAbstractPlottable*> mPlottables;
                                                          +
                                                          212  QList<QCPGraph*> mGraphs; // extra list of plottables also in mPlottables that are of type QCPGraph
                                                          +
                                                          213  QList<QCPAbstractItem*> mItems;
                                                          +
                                                          214  QList<QCPLayer*> mLayers;
                                                          +
                                                          215  QCP::AntialiasedElements mAntialiasedElements, mNotAntialiasedElements;
                                                          +
                                                          216  QCP::Interactions mInteractions;
                                                          +
                                                          217  int mSelectionTolerance;
                                                          +
                                                          218  bool mNoAntialiasingOnDrag;
                                                          +
                                                          219  QBrush mBackgroundBrush;
                                                          +
                                                          220  QPixmap mBackgroundPixmap;
                                                          +
                                                          221  QPixmap mScaledBackgroundPixmap;
                                                          +
                                                          222  bool mBackgroundScaled;
                                                          +
                                                          223  Qt::AspectRatioMode mBackgroundScaledMode;
                                                          +
                                                          224  QCPLayer *mCurrentLayer;
                                                          +
                                                          225  QCP::PlottingHints mPlottingHints;
                                                          +
                                                          226  Qt::KeyboardModifier mMultiSelectModifier;
                                                          +
                                                          227 
                                                          +
                                                          228  // non-property members:
                                                          +
                                                          229  QPixmap mPaintBuffer;
                                                          +
                                                          230  QPoint mMousePressPos;
                                                          +
                                                          231  QPointer<QCPLayoutElement> mMouseEventElement;
                                                          +
                                                          232  bool mReplotting;
                                                          +
                                                          233 
                                                          +
                                                          234  // reimplemented virtual methods:
                                                          +
                                                          235  virtual QSize minimumSizeHint() const;
                                                          +
                                                          236  virtual QSize sizeHint() const;
                                                          +
                                                          237  virtual void paintEvent(QPaintEvent *event);
                                                          +
                                                          238  virtual void resizeEvent(QResizeEvent *event);
                                                          +
                                                          239  virtual void mouseDoubleClickEvent(QMouseEvent *event);
                                                          +
                                                          240  virtual void mousePressEvent(QMouseEvent *event);
                                                          +
                                                          241  virtual void mouseMoveEvent(QMouseEvent *event);
                                                          +
                                                          242  virtual void mouseReleaseEvent(QMouseEvent *event);
                                                          +
                                                          243  virtual void wheelEvent(QWheelEvent *event);
                                                          244 
                                                          -
                                                          245  friend class QCPLegend;
                                                          -
                                                          246  friend class QCPAxis;
                                                          -
                                                          247  friend class QCPLayer;
                                                          -
                                                          248  friend class QCPAxisRect;
                                                          -
                                                          249 };
                                                          -
                                                          250 
                                                          -
                                                          251 #endif // QCP_CORE_H
                                                          +
                                                          245  // introduced virtual methods:
                                                          +
                                                          246  virtual void draw(QCPPainter *painter);
                                                          +
                                                          247  virtual void axisRemoved(QCPAxis *axis);
                                                          +
                                                          248  virtual void legendRemoved(QCPLegend *legend);
                                                          +
                                                          249 
                                                          +
                                                          250  // non-virtual methods:
                                                          +
                                                          251  void updateLayerIndices() const;
                                                          +
                                                          252  QCPLayerable *layerableAt(const QPointF &pos, bool onlySelectable, QVariant *selectionDetails=0) const;
                                                          +
                                                          253  void drawBackground(QCPPainter *painter);
                                                          +
                                                          254 
                                                          +
                                                          255  friend class QCPLegend;
                                                          +
                                                          256  friend class QCPAxis;
                                                          +
                                                          257  friend class QCPLayer;
                                                          +
                                                          258  friend class QCPAxisRect;
                                                          +
                                                          259 };
                                                          +
                                                          260 
                                                          +
                                                          261 #endif // QCP_CORE_H
                                                          diff -Nru qcustomplot-1.1.0/documentation/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html qcustomplot-1.2.0/documentation/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html --- qcustomplot-1.1.0/documentation/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html 2014-03-14 21:11:26.000000000 +0000 @@ -34,6 +34,8 @@ Files file  axis.cpp file  axis.h [code] +file  colorgradient.cpp +file  colorgradient.h [code] file  core.cpp file  core.h [code] file  global.h [code] diff -Nru qcustomplot-1.1.0/documentation/html/dir_78a97038723513eb3e3a9e944a7f482f.html qcustomplot-1.2.0/documentation/html/dir_78a97038723513eb3e3a9e944a7f482f.html --- qcustomplot-1.1.0/documentation/html/dir_78a97038723513eb3e3a9e944a7f482f.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/dir_78a97038723513eb3e3a9e944a7f482f.html 2014-03-14 21:11:26.000000000 +0000 @@ -28,6 +28,8 @@ Files file  layoutelement-axisrect.cpp file  layoutelement-axisrect.h [code] +file  layoutelement-colorscale.cpp +file  layoutelement-colorscale.h [code] file  layoutelement-legend.cpp file  layoutelement-legend.h [code] file  layoutelement-plottitle.cpp diff -Nru qcustomplot-1.1.0/documentation/html/dir_d1ab82e73f77cddd99808c625b504457.html qcustomplot-1.2.0/documentation/html/dir_d1ab82e73f77cddd99808c625b504457.html --- qcustomplot-1.1.0/documentation/html/dir_d1ab82e73f77cddd99808c625b504457.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/dir_d1ab82e73f77cddd99808c625b504457.html 2014-03-14 21:11:26.000000000 +0000 @@ -28,6 +28,8 @@ Files file  plottable-bars.cpp file  plottable-bars.h [code] +file  plottable-colormap.cpp +file  plottable-colormap.h [code] file  plottable-curve.cpp file  plottable-curve.h [code] file  plottable-graph.cpp diff -Nru qcustomplot-1.1.0/documentation/html/files.html qcustomplot-1.2.0/documentation/html/files.html --- qcustomplot-1.1.0/documentation/html/files.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/files.html 2014-03-14 21:11:26.000000000 +0000 @@ -34,25 +34,28 @@  |\*item-tracer.h  o-layoutelements  |o*layoutelement-axisrect.h - |o*layoutelement-legend.h - |\*layoutelement-plottitle.h - o-plottables - |o*plottable-bars.h - |o*plottable-curve.h - |o*plottable-graph.h - |\*plottable-statisticalbox.h + |o*layoutelement-colorscale.h + |o*layoutelement-legend.h + |\*layoutelement-plottitle.h + o-plottables + |o*plottable-bars.h + |o*plottable-colormap.h + |o*plottable-curve.h + |o*plottable-graph.h + |\*plottable-statisticalbox.h  o*axis.h - o*core.cpp - o*core.h - o*global.h - o*item.h - o*layer.h - o*layout.h - o*lineending.h - o*painter.h - o*plottable.h - o*qcp.h - \*range.h + o*colorgradient.h + o*core.cpp + o*core.h + o*global.h + o*item.h + o*layer.h + o*layout.h + o*lineending.h + o*painter.h + o*plottable.h + o*qcp.h + \*range.h diff -Nru qcustomplot-1.1.0/documentation/html/functions_0x63.html qcustomplot-1.2.0/documentation/html/functions_0x63.html --- qcustomplot-1.1.0/documentation/html/functions_0x63.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/functions_0x63.html 2014-03-14 21:11:26.000000000 +0000 @@ -28,6 +28,9 @@
                                                        • calculateMargin() : QCPAxis
                                                        • +
                                                        • cellToCoord() +: QCPColorMapData +
                                                        • center() : QCPRange , QCPAxisRect @@ -35,16 +38,27 @@
                                                        • children() : QCPLayer
                                                        • +
                                                        • ciHSV +: QCPColorGradient +
                                                        • +
                                                        • ciRGB +: QCPColorGradient +
                                                        • clear() : QCPMarginGroup , QCPLayout +, QCPColorMapData +
                                                        • +
                                                        • clearColorStops() +: QCPColorGradient
                                                        • clearData() -: QCPAbstractPlottable -, QCPBars +: QCPBars +, QCPColorMap , QCPCurve , QCPGraph , QCPStatisticalBox +, QCPAbstractPlottable
                                                        • clearGraphs() : QCustomPlot @@ -57,10 +71,22 @@ : QCustomPlot
                                                        • clipRect() -: QCPLayerable -, QCPAbstractPlottable -, QCPAbstractLegendItem +: QCPAbstractPlottable , QCPAbstractItem +, QCPLayerable +, QCPAbstractLegendItem +
                                                        • +
                                                        • color() +: QCPColorGradient +
                                                        • +
                                                        • ColorInterpolation +: QCPColorGradient +
                                                        • +
                                                        • colorize() +: QCPColorGradient +
                                                        • +
                                                        • colorMaps() +: QCPColorScale
                                                        • columnCount() : QCPLayoutGrid @@ -77,9 +103,15 @@
                                                        • coordsToPixels() : QCPAbstractPlottable
                                                        • +
                                                        • coordToCell() +: QCPColorMapData +
                                                        • coordToPixel() : QCPAxis
                                                        • +
                                                        • countDataInBounds() +: QCPGraph +
                                                        • createAnchor() : QCPAbstractItem
                                                        • diff -Nru qcustomplot-1.1.0/documentation/html/functions_0x64.html qcustomplot-1.2.0/documentation/html/functions_0x64.html --- qcustomplot-1.1.0/documentation/html/functions_0x64.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/functions_0x64.html 2014-03-14 21:11:26.000000000 +0000 @@ -18,53 +18,66 @@
                                                          Here is a list of all documented struct and union fields with links to the struct/union documentation for each field:

                                                          - d -

                                                          +

                                                          - c -

                                                          + +

                                                          - e -

                                                          +

                                                          - g -

                                                          + +

                                                          - i -

                                                          +

                                                          - r -

                                                          + +

                                                          - s -

                                                          + + +

                                                          - u -

                                                          diff -Nru qcustomplot-1.1.0/documentation/html/functions_func_0x63.html qcustomplot-1.2.0/documentation/html/functions_func_0x63.html --- qcustomplot-1.1.0/documentation/html/functions_func_0x63.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/functions_func_0x63.html 2014-03-14 21:11:26.000000000 +0000 @@ -28,6 +28,9 @@
                                                        • calculateMargin() : QCPAxis
                                                        • +
                                                        • cellToCoord() +: QCPColorMapData +
                                                        • center() : QCPRange , QCPAxisRect @@ -38,13 +41,18 @@
                                                        • clear() : QCPMarginGroup , QCPLayout +, QCPColorMapData +
                                                        • +
                                                        • clearColorStops() +: QCPColorGradient
                                                        • clearData() -: QCPAbstractPlottable -, QCPBars -, QCPCurve +: QCPCurve , QCPGraph , QCPStatisticalBox +, QCPAbstractPlottable +, QCPBars +, QCPColorMap
                                                        • clearGraphs() : QCustomPlot @@ -57,10 +65,19 @@ : QCustomPlot
                                                        • clipRect() -: QCPLayerable +: QCPAbstractItem +, QCPLayerable , QCPAbstractPlottable , QCPAbstractLegendItem -, QCPAbstractItem +
                                                        • +
                                                        • color() +: QCPColorGradient +
                                                        • +
                                                        • colorize() +: QCPColorGradient +
                                                        • +
                                                        • colorMaps() +: QCPColorScale
                                                        • columnCount() : QCPLayoutGrid @@ -77,9 +94,15 @@
                                                        • coordsToPixels() : QCPAbstractPlottable
                                                        • +
                                                        • coordToCell() +: QCPColorMapData +
                                                        • coordToPixel() : QCPAxis
                                                        • +
                                                        • countDataInBounds() +: QCPGraph +
                                                        • createAnchor() : QCPAbstractItem
                                                        • diff -Nru qcustomplot-1.1.0/documentation/html/functions_func_0x64.html qcustomplot-1.2.0/documentation/html/functions_func_0x64.html --- qcustomplot-1.1.0/documentation/html/functions_func_0x64.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/functions_func_0x64.html 2014-03-14 21:11:26.000000000 +0000 @@ -18,53 +18,66 @@  

                                                          - d -

                                                            +
                                                          • data() +: QCPColorMap +, QCPGraph +
                                                          • +
                                                          • dataRangeChanged() +: QCPColorScale +, QCPColorMap +
                                                          • +
                                                          • dataScaleTypeChanged() +: QCPColorMap +, QCPColorScale +
                                                          • deselectAll() : QCustomPlot
                                                          • deselectEvent() : QCPAxis +, QCPAbstractItem , QCPLayerable -, QCPPlotTitle , QCPAbstractPlottable -, QCPAbstractItem , QCPAbstractLegendItem , QCPLegend +, QCPPlotTitle
                                                          • distSqrToLine() -: QCPAbstractItem -, QCPAbstractPlottable +: QCPAbstractPlottable +, QCPAbstractItem
                                                          • distToStraightLine() : QCPItemStraightLine
                                                          • draw() -: QCPLayerable +: QCPItemBracket +, QCPItemCurve +, QCPItemEllipse +, QCPItemLine +, QCPGrid +, QCPItemPixmap +, QCPItemRect +, QCPPlotTitle +, QCPAxis +, QCPPlottableLegendItem +, QCPAbstractLegendItem +, QCPItemStraightLine , QCPItemText +, QCustomPlot , QCPItemTracer -, QCPLayoutElement , QCPAxisRect -, QCPAbstractLegendItem -, QCPLineEnding -, QCPPlottableLegendItem +, QCPAbstractItem +, QCPLayerable , QCPLegend +, QCPLayoutElement +, QCPLineEnding +, QCPStatisticalBox , QCPLineEnding -, QCPPlotTitle , QCPAbstractPlottable , QCPBars +, QCPColorMap , QCPCurve , QCPGraph -, QCPGrid -, QCPStatisticalBox -, QCPItemBracket -, QCPAxis -, QCPItemCurve -, QCPItemStraightLine -, QCPItemRect -, QCPItemPixmap -, QCPItemEllipse -, QCustomPlot -, QCPItemLine -, QCPAbstractItem
                                                          • drawBackground() : QCustomPlot @@ -83,10 +96,11 @@ : QCPGraph
                                                          • drawLegendIcon() -: QCPBars -, QCPAbstractPlottable +: QCPCurve +, QCPBars +, QCPColorMap , QCPStatisticalBox -, QCPCurve +, QCPAbstractPlottable , QCPGraph
                                                          • drawLine() @@ -105,8 +119,8 @@ : QCPStatisticalBox
                                                          • drawScatterPlot() -: QCPCurve -, QCPGraph +: QCPGraph +, QCPCurve
                                                          • drawShape() : QCPScatterStyle @@ -114,9 +128,6 @@
                                                          • drawSubGridLines() : QCPGrid
                                                          • -
                                                          • drawTickLabel() -: QCPAxis -
                                                          • drawWhiskers() : QCPStatisticalBox
                                                          • diff -Nru qcustomplot-1.1.0/documentation/html/functions_func_0x66.html qcustomplot-1.2.0/documentation/html/functions_func_0x66.html --- qcustomplot-1.1.0/documentation/html/functions_func_0x66.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/functions_func_0x66.html 2014-03-14 21:11:26.000000000 +0000 @@ -18,6 +18,9 @@  

                                                            - f -

                                                              +
                                                            • fill() +: QCPColorMapData +
                                                            • findIndexAboveX() : QCPGraph
                                                            • diff -Nru qcustomplot-1.1.0/documentation/html/functions_func_0x67.html qcustomplot-1.2.0/documentation/html/functions_func_0x67.html --- qcustomplot-1.1.0/documentation/html/functions_func_0x67.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/functions_func_0x67.html 2014-03-14 21:11:26.000000000 +0000 @@ -52,14 +52,15 @@ : QCPPlottableLegendItem
                                                            • getImpulsePlotData() -: QCPGraph +: QCPGraph
                                                            • getKeyRange() -: QCPGraph -, QCPStatisticalBox -, QCPAbstractPlottable -, QCPBars -, QCPCurve +: QCPCurve +, QCPGraph +, QCPStatisticalBox +, QCPAbstractPlottable +, QCPBars +, QCPColorMap
                                                            • getLabelColor() : QCPAxis @@ -68,14 +69,11 @@ : QCPAxis
                                                            • getLinePlotData() -: QCPGraph +: QCPGraph
                                                            • getMaximumRowColSizes() : QCPLayoutGrid
                                                            • -
                                                            • getMaxTickLabelSize() -: QCPAxis -
                                                            • getMinimumRowColSizes() : QCPLayoutGrid
                                                            • @@ -83,7 +81,10 @@ : QCPAxis
                                                            • getPlotData() -: QCPGraph +: QCPGraph +
                                                            • +
                                                            • getPreparedData() +: QCPGraph
                                                            • getRectClippedLine() : QCPItemLine @@ -92,19 +93,19 @@ : QCPItemStraightLine
                                                            • getScatterPlotData() -: QCPGraph +: QCPGraph
                                                            • getSectionSizes() : QCPLayout
                                                            • getStepCenterPlotData() -: QCPGraph +: QCPGraph
                                                            • getStepLeftPlotData() -: QCPGraph +: QCPGraph
                                                            • getStepRightPlotData() -: QCPGraph +: QCPGraph
                                                            • getSubTickPen() : QCPAxis @@ -118,12 +119,6 @@
                                                            • getTickLabelColor() : QCPAxis
                                                            • -
                                                            • getTickLabelData() -: QCPAxis -
                                                            • -
                                                            • getTickLabelDrawOffset() -: QCPAxis -
                                                            • getTickLabelFont() : QCPAxis
                                                            • @@ -131,14 +126,20 @@ : QCPAxis
                                                            • getValueRange() -: QCPGraph -, QCPAbstractPlottable -, QCPStatisticalBox -, QCPBars -, QCPCurve +: QCPBars +, QCPColorMap +, QCPGraph +, QCPAbstractPlottable +, QCPCurve +, QCPGraph +, QCPStatisticalBox
                                                            • getVisibleDataBounds() -: QCPGraph +: QCPGraph +
                                                            • +
                                                            • gradientChanged() +: QCPColorMap +, QCPColorScale
                                                            • graph() : QCustomPlot @@ -147,8 +148,8 @@ : QCustomPlot
                                                            • graphs() -: QCPAxisRect -, QCPAxis +: QCPAxis +, QCPAxisRect
                                                            • grid() : QCPAxis diff -Nru qcustomplot-1.1.0/documentation/html/functions_func_0x69.html qcustomplot-1.2.0/documentation/html/functions_func_0x69.html --- qcustomplot-1.1.0/documentation/html/functions_func_0x69.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/functions_func_0x69.html 2014-03-14 21:11:26.000000000 +0000 @@ -42,8 +42,12 @@
                                                            • insetRect() : QCPLayoutInset
                                                            • +
                                                            • inverted() +: QCPColorGradient +
                                                            • isEmpty() : QCPMarginGroup +, QCPColorMapData
                                                            • isNone() : QCPScatterStyle @@ -52,8 +56,9 @@ : QCPScatterStyle
                                                            • item() -: QCustomPlot +: QCustomPlot , QCPLegend +, QCustomPlot
                                                            • itemAt() : QCustomPlot @@ -69,8 +74,8 @@ : QCustomPlot
                                                            • items() -: QCPAxisRect -, QCPAxis +: QCPAxis +, QCPAxisRect
                                                            • itemWithPlottable() : QCPLegend diff -Nru qcustomplot-1.1.0/documentation/html/functions_func_0x6c.html qcustomplot-1.2.0/documentation/html/functions_func_0x6c.html --- qcustomplot-1.1.0/documentation/html/functions_func_0x6c.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/functions_func_0x6c.html 2014-03-14 21:11:26.000000000 +0000 @@ -24,6 +24,9 @@
                                                            • layerableAt() : QCustomPlot
                                                            • +
                                                            • layerChanged() +: QCPLayerable +
                                                            • layerCount() : QCustomPlot
                                                            • @@ -45,6 +48,9 @@
                                                            • legendRemoved() : QCustomPlot
                                                            • +
                                                            • loadPreset() +: QCPColorGradient +
                                                            • lowerFillBasePoint() : QCPGraph
                                                            • diff -Nru qcustomplot-1.1.0/documentation/html/functions_func_0x6d.html qcustomplot-1.2.0/documentation/html/functions_func_0x6d.html --- qcustomplot-1.1.0/documentation/html/functions_func_0x6d.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/functions_func_0x6d.html 2014-03-14 21:11:26.000000000 +0000 @@ -76,25 +76,28 @@ : QCustomPlot
                                                            • mouseMoveEvent() -: QCPLayoutElement -, QCustomPlot +: QCustomPlot , QCPAxisRect +, QCPColorScale +, QCPLayoutElement
                                                            • mousePress() : QCustomPlot
                                                            • mousePressEvent() -: QCustomPlot +: QCPAxisRect +, QCPColorScale , QCPLayoutElement -, QCPAxisRect +, QCustomPlot
                                                            • mouseRelease() : QCustomPlot
                                                            • mouseReleaseEvent() -: QCustomPlot +: QCPAxisRect , QCPLayoutElement -, QCPAxisRect +, QCustomPlot +, QCPColorScale
                                                            • mouseWheel() : QCustomPlot diff -Nru qcustomplot-1.1.0/documentation/html/functions_func_0x6f.html qcustomplot-1.2.0/documentation/html/functions_func_0x6f.html --- qcustomplot-1.1.0/documentation/html/functions_func_0x6f.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/functions_func_0x6f.html 2014-03-14 21:11:26.000000000 +0000 @@ -18,8 +18,26 @@  

                                                              - o -

                                                                +
                                                              • operator*=() +: QCPRange +
                                                              • +
                                                              • operator+=() +: QCPRange +
                                                              • +
                                                              • operator-=() +: QCPRange +
                                                              • +
                                                              • operator/=() +: QCPRange +
                                                              • +
                                                              • operator=() +: QCPColorMapData +
                                                              • +
                                                              • opposite() +: QCPAxis +
                                                              • orientation() -: QCPAxis +: QCPAxis
                                                              • outsideCoordsToPixels() : QCPCurve diff -Nru qcustomplot-1.1.0/documentation/html/functions_func_0x70.html qcustomplot-1.2.0/documentation/html/functions_func_0x70.html --- qcustomplot-1.1.0/documentation/html/functions_func_0x70.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/functions_func_0x70.html 2014-03-14 21:11:26.000000000 +0000 @@ -39,9 +39,6 @@
                                                              • pixelToCoord() : QCPAxis
                                                              • -
                                                              • placeTickLabel() -: QCPAxis -
                                                              • plotLayout() : QCustomPlot
                                                              • @@ -61,12 +58,12 @@ : QCustomPlot
                                                              • plottables() -: QCPAxisRect -, QCPAxis +: QCPAxis +, QCPAxisRect
                                                              • pointDistance() -: QCPGraph -, QCPCurve +: QCPCurve +, QCPGraph
                                                              • position() : QCPAbstractItem diff -Nru qcustomplot-1.1.0/documentation/html/functions_func_0x71.html qcustomplot-1.2.0/documentation/html/functions_func_0x71.html --- qcustomplot-1.1.0/documentation/html/functions_func_0x71.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/functions_func_0x71.html 2014-03-14 21:11:26.000000000 +0000 @@ -39,11 +39,23 @@
                                                              • QCPBars() : QCPBars
                                                              • +
                                                              • QCPColorGradient() +: QCPColorGradient +
                                                              • +
                                                              • QCPColorMap() +: QCPColorMap +
                                                              • +
                                                              • QCPColorMapData() +: QCPColorMapData +
                                                              • +
                                                              • QCPColorScale() +: QCPColorScale +
                                                              • QCPCurve() : QCPCurve
                                                              • QCPCurveData() -: QCPCurveData +: QCPCurveData
                                                              • QCPData() : QCPData @@ -109,13 +121,13 @@ : QCPLegend
                                                              • QCPLineEnding() -: QCPLineEnding +: QCPLineEnding
                                                              • QCPMarginGroup() : QCPMarginGroup
                                                              • QCPPainter() -: QCPPainter +: QCPPainter
                                                              • QCPPlottableLegendItem() : QCPPlottableLegendItem diff -Nru qcustomplot-1.1.0/documentation/html/functions_func_0x72.html qcustomplot-1.2.0/documentation/html/functions_func_0x72.html --- qcustomplot-1.1.0/documentation/html/functions_func_0x72.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/functions_func_0x72.html 2014-03-14 21:11:26.000000000 +0000 @@ -36,6 +36,9 @@
                                                              • realVisibility() : QCPLayerable
                                                              • +
                                                              • recalculateDataBounds() +: QCPColorMapData +
                                                              • rect() : QCPLayoutElement
                                                              • @@ -55,9 +58,9 @@ : QCPAxisRect
                                                              • removeChild() -: QCPMarginGroup +: QCPLayer +, QCPMarginGroup , QCPItemAnchor -, QCPLayer
                                                              • removeData() : QCPBars @@ -85,7 +88,8 @@
                                                              • removeItem() : QCustomPlot -, QCPLegend +, QCPLegend +, QCustomPlot
                                                              • removeLayer() : QCustomPlot @@ -94,23 +98,27 @@ : QCustomPlot
                                                              • replot() -: QCustomPlot +: QCustomPlot
                                                              • rescale() : QCPAxis
                                                              • rescaleAxes() : QCPAbstractPlottable -, QCustomPlot , QCPGraph +, QCustomPlot +
                                                              • +
                                                              • rescaleDataRange() +: QCPColorScale +, QCPColorMap
                                                              • rescaleKeyAxis() : QCPGraph , QCPAbstractPlottable
                                                              • rescaleValueAxis() -: QCPAbstractPlottable -, QCPGraph +: QCPGraph +, QCPAbstractPlottable
                                                              • resizeEvent() : QCustomPlot diff -Nru qcustomplot-1.1.0/documentation/html/functions_func_0x73.html qcustomplot-1.2.0/documentation/html/functions_func_0x73.html --- qcustomplot-1.1.0/documentation/html/functions_func_0x73.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/functions_func_0x73.html 2014-03-14 21:11:26.000000000 +0000 @@ -34,7 +34,7 @@ : QCustomPlot
                                                              • savePdf() -: QCustomPlot +: QCustomPlot
                                                              • savePng() : QCustomPlot @@ -45,6 +45,13 @@
                                                              • scaleRange() : QCPAxis
                                                              • +
                                                              • scaleTypeChanged() +: QCPAxis +
                                                              • +
                                                              • selectableChanged() +: QCPAxis +, QCPAbstractPlottable +
                                                              • selectedAxes() : QCustomPlot
                                                              • @@ -52,8 +59,8 @@ : QCustomPlot
                                                              • selectedItems() -: QCustomPlot -, QCPLegend +: QCPLegend +, QCustomPlot
                                                              • selectedLegends() : QCustomPlot @@ -79,12 +86,12 @@ , QCPLegend
                                                              • selectionChanged() -: QCPAbstractLegendItem -, QCPLegend -, QCPPlotTitle -, QCPAxis +: QCPAxis , QCPAbstractItem , QCPAbstractPlottable +, QCPAbstractLegendItem +, QCPLegend +, QCPPlotTitle
                                                              • selectionChangedByUser() : QCustomPlot @@ -97,6 +104,7 @@ , QCPLayoutInset , QCPAbstractPlottable , QCPBars +, QCPColorMap , QCPCurve , QCPGraph , QCPStatisticalBox @@ -113,6 +121,9 @@ , QCPLegend , QCPPlotTitle
                                                              • +
                                                              • setAdaptiveSampling() +: QCPGraph +
                                                              • setAntialiased() : QCPLayerable
                                                              • @@ -179,6 +190,9 @@ : QCustomPlot , QCPAxisRect +
                                                              • setBarWidth() +: QCPColorScale +
                                                              • setBasePen() : QCPAxis
                                                              • @@ -194,6 +208,9 @@ , QCPItemTracer , QCPLegend +
                                                              • setCell() +: QCPColorMapData +
                                                              • setChannelFillGraph() : QCPGraph
                                                              • @@ -206,6 +223,18 @@
                                                              • setColor() : QCPItemText
                                                              • +
                                                              • setColorInterpolation() +: QCPColorGradient +
                                                              • +
                                                              • setColorScale() +: QCPColorMap +
                                                              • +
                                                              • setColorStopAt() +: QCPColorGradient +
                                                              • +
                                                              • setColorStops() +: QCPColorGradient +
                                                              • setColumnSpacing() : QCPLayoutGrid
                                                              • @@ -226,6 +255,8 @@
                                                              • setData() : QCPBars +, QCPColorMapData +, QCPColorMap , QCPCurve , QCPGraph , QCPStatisticalBox @@ -236,6 +267,14 @@
                                                              • setDataKeyError() : QCPGraph
                                                              • +
                                                              • setDataRange() +: QCPColorMap +, QCPColorScale +
                                                              • +
                                                              • setDataScaleType() +: QCPColorMap +, QCPColorScale +
                                                              • setDataValueError() : QCPGraph
                                                              • @@ -258,10 +297,14 @@ : QCPGraph
                                                              • setFont() -: QCPAbstractLegendItem +: QCPItemText +, QCPAbstractLegendItem , QCPLegend , QCPPlotTitle -, QCPItemText +
                                                              • +
                                                              • setGradient() +: QCPColorMap +, QCPColorScale
                                                              • setGraph() : QCPItemTracer @@ -297,6 +340,9 @@
                                                              • setInteractions() : QCustomPlot
                                                              • +
                                                              • setInterpolate() +: QCPColorMap +
                                                              • setInterpolating() : QCPItemTracer
                                                              • @@ -309,8 +355,15 @@
                                                              • setKeyAxis() : QCPAbstractPlottable
                                                              • +
                                                              • setKeyRange() +: QCPColorMapData +
                                                              • +
                                                              • setKeySize() +: QCPColorMapData +
                                                              • setLabel() : QCPAxis +, QCPColorScale
                                                              • setLabelColor() : QCPAxis @@ -328,6 +381,9 @@ : QCPLineEnding , QCPItemBracket
                                                              • +
                                                              • setLevelCount() +: QCPColorGradient +
                                                              • setLineStyle() : QCPCurve , QCPGraph @@ -416,13 +472,13 @@
                                                              • setPen() : QCPItemRect +, QCPItemCurve , QCPPainter , QCPGrid , QCPScatterStyle , QCPPainter , QCPAbstractPlottable , QCPItemBracket -, QCPItemCurve , QCPItemEllipse , QCPItemLine , QCPItemPixmap @@ -430,6 +486,9 @@ , QCPItemText , QCPItemTracer
                                                              • +
                                                              • setPeriodic() +: QCPColorGradient +
                                                              • setPixelPoint() : QCPItemPosition
                                                              • @@ -447,10 +506,12 @@ : QCPItemText
                                                              • setRange() -: QCPAxis +: QCPAxis +, QCPColorMapData
                                                              • setRangeDrag() -: QCPAxisRect +: QCPColorScale +, QCPAxisRect
                                                              • setRangeDragAxes() : QCPAxisRect @@ -466,6 +527,7 @@
                                                              • setRangeZoom() : QCPAxisRect +, QCPColorScale
                                                              • setRangeZoomAxes() : QCPAxisRect @@ -495,27 +557,27 @@ : QCPAxis
                                                              • setScaleType() -: QCPAxis +: QCPAxis
                                                              • setScatterStyle() -: QCPGraph -, QCPCurve +: QCPCurve +, QCPGraph
                                                              • setSelectable() -: QCPAbstractItem -, QCPPlotTitle +: QCPPlotTitle , QCPAbstractPlottable +, QCPAbstractItem , QCPAbstractLegendItem
                                                              • setSelectableParts() -: QCPAxis -, QCPLegend +: QCPLegend +, QCPAxis
                                                              • setSelected() -: QCPAbstractItem -, QCPAbstractPlottable -, QCPAbstractLegendItem +: QCPAbstractPlottable , QCPPlotTitle +, QCPAbstractLegendItem +, QCPAbstractItem
                                                              • setSelectedBasePen() : QCPAxis @@ -524,21 +586,21 @@ : QCPLegend
                                                              • setSelectedBrush() -: QCPItemRect +: QCPItemEllipse +, QCPItemRect , QCPItemText +, QCPLegend , QCPItemTracer , QCPAbstractPlottable -, QCPItemEllipse -, QCPLegend
                                                              • setSelectedColor() : QCPItemText
                                                              • setSelectedFont() -: QCPPlotTitle -, QCPAbstractLegendItem +: QCPLegend +, QCPPlotTitle , QCPItemText -, QCPLegend +, QCPAbstractLegendItem
                                                              • setSelectedIconBorderPen() : QCPLegend @@ -555,22 +617,22 @@
                                                              • setSelectedPen() : QCPItemBracket +, QCPItemCurve +, QCPItemEllipse , QCPItemPixmap -, QCPItemStraightLine , QCPItemTracer -, QCPItemText -, QCPItemLine , QCPItemRect +, QCPItemStraightLine +, QCPItemText , QCPAbstractPlottable -, QCPItemCurve -, QCPItemEllipse +, QCPItemLine
                                                              • setSelectedSubTickPen() : QCPAxis
                                                              • setSelectedTextColor() -: QCPPlotTitle -, QCPAbstractLegendItem +: QCPAbstractLegendItem +, QCPPlotTitle , QCPLegend
                                                              • setSelectedTickLabelColor() @@ -591,11 +653,12 @@
                                                              • setSize() : QCPItemTracer , QCPScatterStyle +, QCPColorMapData
                                                              • setStyle() -: QCPLineEnding +: QCPItemTracer , QCPItemBracket -, QCPItemTracer +, QCPLineEnding
                                                              • setSubGridPen() : QCPGrid @@ -623,16 +686,16 @@ , QCPItemCurve
                                                              • setText() -: QCPPlotTitle -, QCPItemText +: QCPItemText +, QCPPlotTitle
                                                              • setTextAlignment() : QCPItemText
                                                              • setTextColor() -: QCPLegend +: QCPPlotTitle +, QCPLegend , QCPAbstractLegendItem -, QCPPlotTitle
                                                              • setTickLabelColor() : QCPAxis @@ -676,8 +739,12 @@
                                                              • setTickVectorLabels() : QCPAxis
                                                              • +
                                                              • setTightBoundary() +: QCPColorMap +
                                                              • setType() : QCPItemPosition +, QCPColorScale
                                                              • setupFullAxesBox() : QCPAxisRect @@ -694,11 +761,18 @@
                                                              • setValueAxis() : QCPAbstractPlottable
                                                              • +
                                                              • setValueRange() +: QCPColorMapData +
                                                              • +
                                                              • setValueSize() +: QCPColorMapData +
                                                              • setViewport() : QCustomPlot
                                                              • setVisible() : QCPLayerable +, QCPLayer
                                                              • setWhiskerBarPen() : QCPStatisticalBox @@ -710,21 +784,21 @@ : QCPStatisticalBox
                                                              • setWidth() -: QCPStatisticalBox +: QCPLineEnding , QCPBars -, QCPLineEnding +, QCPStatisticalBox
                                                              • setZeroLinePen() : QCPGrid
                                                              • simplify() -: QCPLayoutInset -, QCPLayout +: QCPLayout +, QCPLayoutInset , QCPLayoutGrid
                                                              • size() -: QCPAxisRect -, QCPRange +: QCPRange +, QCPAxisRect
                                                              • sizeConstraintsChanged() : QCPLayout diff -Nru qcustomplot-1.1.0/documentation/html/functions_func_0x75.html qcustomplot-1.2.0/documentation/html/functions_func_0x75.html --- qcustomplot-1.1.0/documentation/html/functions_func_0x75.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/functions_func_0x75.html 2014-03-14 21:11:26.000000000 +0000 @@ -19,20 +19,30 @@

                                                                - u -

                                                                • update() -: QCPLayoutElement -, QCPLayout -, QCPAxisRect +: QCPLayoutElement +, QCPLayout +, QCPColorScale +, QCPAxisRect
                                                                • updateAxesOffset() : QCPAxisRect
                                                                • +
                                                                • updateColorBuffer() +: QCPColorGradient +
                                                                • updateLayerIndices() : QCustomPlot
                                                                • updateLayout() -: QCPLayoutGrid +: QCPLayout +, QCPLayoutGrid , QCPLayoutInset -, QCPLayout +
                                                                • +
                                                                • updateLegendIcon() +: QCPColorMap +
                                                                • +
                                                                • updateMapImage() +: QCPColorMap
                                                                • updatePosition() : QCPItemTracer diff -Nru qcustomplot-1.1.0/documentation/html/functions_func_0x77.html qcustomplot-1.2.0/documentation/html/functions_func_0x77.html --- qcustomplot-1.1.0/documentation/html/functions_func_0x77.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/functions_func_0x77.html 2014-03-14 21:11:26.000000000 +0000 @@ -21,6 +21,7 @@
                                                                • wheelEvent() : QCustomPlot , QCPLayoutElement +, QCPColorScale , QCPAxisRect
                                                                • width() diff -Nru qcustomplot-1.1.0/documentation/html/functions_func.html qcustomplot-1.2.0/documentation/html/functions_func.html --- qcustomplot-1.1.0/documentation/html/functions_func.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/functions_func.html 2014-03-14 21:11:26.000000000 +0000 @@ -88,16 +88,17 @@ : QCPLayerable
                                                                • applyDefaultAntialiasingHint() -: QCPLayerable -, QCPAxisRect -, QCPAbstractPlottable +: QCPAbstractPlottable , QCPGrid +, QCPAxis , QCPAbstractItem +, QCPAxisRect , QCPLayoutElement -, QCPAbstractLegendItem +, QCPColorScale , QCPLegend -, QCPAxis +, QCPAbstractLegendItem , QCPPlotTitle +, QCPLayerable
                                                                • applyErrorBarsAntialiasingHint() : QCPAbstractPlottable @@ -112,10 +113,11 @@ : QCPScatterStyle
                                                                • axes() -: QCPAxisRect +: QCPAxisRect
                                                                • axis() : QCPAxisRect +, QCPColorScale
                                                                • axisClick() : QCustomPlot diff -Nru qcustomplot-1.1.0/documentation/html/functions.html qcustomplot-1.2.0/documentation/html/functions.html --- qcustomplot-1.1.0/documentation/html/functions.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/functions.html 2014-03-14 21:11:26.000000000 +0000 @@ -88,15 +88,16 @@ : QCPLayerable
                                                                • applyDefaultAntialiasingHint() -: QCPAbstractLegendItem -, QCPGrid +: QCPGrid , QCPAxis , QCPAbstractItem , QCPLayoutElement , QCPAbstractPlottable , QCPAxisRect +, QCPAbstractLegendItem , QCPLegend , QCPPlotTitle +, QCPColorScale , QCPLayerable
                                                                • applyErrorBarsAntialiasingHint() @@ -124,10 +125,11 @@ : QCPAxis
                                                                • axes() -: QCPAxisRect +: QCPAxisRect
                                                                • axis() -: QCPAxisRect +: QCPColorScale +, QCPAxisRect
                                                                • axisClick() : QCustomPlot diff -Nru qcustomplot-1.1.0/documentation/html/functions_rela.html qcustomplot-1.2.0/documentation/html/functions_rela.html --- qcustomplot-1.1.0/documentation/html/functions_rela.html 1970-01-01 00:00:00.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/functions_rela.html 2014-03-14 21:11:26.000000000 +0000 @@ -0,0 +1,35 @@ + + + + +Data Fields - Related Functions + + + + + + +
                                                                  +
                                                                  + + + diff -Nru qcustomplot-1.1.0/documentation/html/functions_vars.html qcustomplot-1.2.0/documentation/html/functions_vars.html --- qcustomplot-1.1.0/documentation/html/functions_vars.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/functions_vars.html 2014-03-14 21:11:26.000000000 +0000 @@ -16,12 +16,27 @@
                                                                   
                                                                  diff -Nru qcustomplot-1.1.0/documentation/html/global_8h_source.html qcustomplot-1.2.0/documentation/html/global_8h_source.html --- qcustomplot-1.1.0/documentation/html/global_8h_source.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/global_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -26,7 +26,7 @@ Go to the documentation of this file.
                                                                  1 /***************************************************************************
                                                                  2 ** **
                                                                  3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                                  -
                                                                  4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
                                                                  +
                                                                  4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                                  5 ** **
                                                                  6 ** This program is free software: you can redistribute it and/or modify **
                                                                  7 ** it under the terms of the GNU General Public License as published by **
                                                                  @@ -44,8 +44,8 @@
                                                                  19 ****************************************************************************
                                                                  20 ** Author: Emanuel Eichhammer **
                                                                  21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                                  -
                                                                  22 ** Date: 04.11.13 **
                                                                  -
                                                                  23 ** Version: 1.1.0 **
                                                                  +
                                                                  22 ** Date: 14.03.14 **
                                                                  +
                                                                  23 ** Version: 1.2.0 **
                                                                  24 ****************************************************************************/
                                                                  26 #ifndef QCP_GLOBAL_H
                                                                  27 #define QCP_GLOBAL_H
                                                                  @@ -73,116 +73,117 @@
                                                                  49 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
                                                                  50 # include <qnumeric.h>
                                                                  51 # include <QPrinter>
                                                                  -
                                                                  52 #else
                                                                  -
                                                                  53 # include <QtNumeric>
                                                                  -
                                                                  54 # include <QtPrintSupport>
                                                                  -
                                                                  55 #endif
                                                                  -
                                                                  56 // amalgamation: include end
                                                                  -
                                                                  57 
                                                                  -
                                                                  58 // decl definitions for shared library compilation/usage:
                                                                  -
                                                                  59 #if defined(QCUSTOMPLOT_COMPILE_LIBRARY)
                                                                  -
                                                                  60 # define QCP_LIB_DECL Q_DECL_EXPORT
                                                                  -
                                                                  61 #elif defined(QCUSTOMPLOT_USE_LIBRARY)
                                                                  -
                                                                  62 # define QCP_LIB_DECL Q_DECL_IMPORT
                                                                  -
                                                                  63 #else
                                                                  -
                                                                  64 # define QCP_LIB_DECL
                                                                  -
                                                                  65 #endif
                                                                  -
                                                                  66 
                                                                  -
                                                                  70 namespace QCP
                                                                  -
                                                                  71 {
                                                                  -
                                                                  77 enum MarginSide { msLeft = 0x01
                                                                  -
                                                                  78  ,msRight = 0x02
                                                                  -
                                                                  79  ,msTop = 0x04
                                                                  -
                                                                  80  ,msBottom = 0x08
                                                                  -
                                                                  81  ,msAll = 0xFF
                                                                  -
                                                                  82  ,msNone = 0x00
                                                                  -
                                                                  83  };
                                                                  -
                                                                  84 Q_DECLARE_FLAGS(MarginSides, MarginSide)
                                                                  -
                                                                  85 
                                                                  +
                                                                  52 # include <QPrintEngine>
                                                                  +
                                                                  53 #else
                                                                  +
                                                                  54 # include <QtNumeric>
                                                                  +
                                                                  55 # include <QtPrintSupport>
                                                                  +
                                                                  56 #endif
                                                                  +
                                                                  57 // amalgamation: include end
                                                                  +
                                                                  58 
                                                                  +
                                                                  59 // decl definitions for shared library compilation/usage:
                                                                  +
                                                                  60 #if defined(QCUSTOMPLOT_COMPILE_LIBRARY)
                                                                  +
                                                                  61 # define QCP_LIB_DECL Q_DECL_EXPORT
                                                                  +
                                                                  62 #elif defined(QCUSTOMPLOT_USE_LIBRARY)
                                                                  +
                                                                  63 # define QCP_LIB_DECL Q_DECL_IMPORT
                                                                  +
                                                                  64 #else
                                                                  +
                                                                  65 # define QCP_LIB_DECL
                                                                  +
                                                                  66 #endif
                                                                  +
                                                                  67 
                                                                  +
                                                                  71 namespace QCP
                                                                  +
                                                                  72 {
                                                                  +
                                                                  78 enum MarginSide { msLeft = 0x01
                                                                  +
                                                                  79  ,msRight = 0x02
                                                                  +
                                                                  80  ,msTop = 0x04
                                                                  +
                                                                  81  ,msBottom = 0x08
                                                                  +
                                                                  82  ,msAll = 0xFF
                                                                  +
                                                                  83  ,msNone = 0x00
                                                                  +
                                                                  84  };
                                                                  +
                                                                  85 Q_DECLARE_FLAGS(MarginSides, MarginSide)
                                                                  86 
                                                                  -
                                                                  95 enum AntialiasedElement { aeAxes = 0x0001
                                                                  -
                                                                  96  ,aeGrid = 0x0002
                                                                  -
                                                                  97  ,aeSubGrid = 0x0004
                                                                  -
                                                                  98  ,aeLegend = 0x0008
                                                                  -
                                                                  99  ,aeLegendItems = 0x0010
                                                                  -
                                                                  100  ,aePlottables = 0x0020
                                                                  -
                                                                  101  ,aeItems = 0x0040
                                                                  -
                                                                  102  ,aeScatters = 0x0080
                                                                  -
                                                                  103  ,aeErrorBars = 0x0100
                                                                  -
                                                                  104  ,aeFills = 0x0200
                                                                  -
                                                                  105  ,aeZeroLine = 0x0400
                                                                  -
                                                                  106  ,aeAll = 0xFFFF
                                                                  -
                                                                  107  ,aeNone = 0x0000
                                                                  -
                                                                  108  };
                                                                  -
                                                                  109 Q_DECLARE_FLAGS(AntialiasedElements, AntialiasedElement)
                                                                  -
                                                                  110 
                                                                  +
                                                                  87 
                                                                  +
                                                                  96 enum AntialiasedElement { aeAxes = 0x0001
                                                                  +
                                                                  97  ,aeGrid = 0x0002
                                                                  +
                                                                  98  ,aeSubGrid = 0x0004
                                                                  +
                                                                  99  ,aeLegend = 0x0008
                                                                  +
                                                                  100  ,aeLegendItems = 0x0010
                                                                  +
                                                                  101  ,aePlottables = 0x0020
                                                                  +
                                                                  102  ,aeItems = 0x0040
                                                                  +
                                                                  103  ,aeScatters = 0x0080
                                                                  +
                                                                  104  ,aeErrorBars = 0x0100
                                                                  +
                                                                  105  ,aeFills = 0x0200
                                                                  +
                                                                  106  ,aeZeroLine = 0x0400
                                                                  +
                                                                  107  ,aeAll = 0xFFFF
                                                                  +
                                                                  108  ,aeNone = 0x0000
                                                                  +
                                                                  109  };
                                                                  +
                                                                  110 Q_DECLARE_FLAGS(AntialiasedElements, AntialiasedElement)
                                                                  111 
                                                                  -
                                                                  116 enum PlottingHint { phNone = 0x000
                                                                  -
                                                                  117  ,phFastPolylines = 0x001
                                                                  -
                                                                  118 
                                                                  -
                                                                  119  ,phForceRepaint = 0x002
                                                                  -
                                                                  120 
                                                                  -
                                                                  121  ,phCacheLabels = 0x004
                                                                  -
                                                                  122  };
                                                                  -
                                                                  123 Q_DECLARE_FLAGS(PlottingHints, PlottingHint)
                                                                  -
                                                                  124 
                                                                  +
                                                                  112 
                                                                  +
                                                                  117 enum PlottingHint { phNone = 0x000
                                                                  +
                                                                  118  ,phFastPolylines = 0x001
                                                                  +
                                                                  119 
                                                                  +
                                                                  120  ,phForceRepaint = 0x002
                                                                  +
                                                                  121 
                                                                  +
                                                                  122  ,phCacheLabels = 0x004
                                                                  +
                                                                  123  };
                                                                  +
                                                                  124 Q_DECLARE_FLAGS(PlottingHints, PlottingHint)
                                                                  125 
                                                                  -
                                                                  132 enum Interaction { iRangeDrag = 0x001
                                                                  -
                                                                  133  ,iRangeZoom = 0x002
                                                                  -
                                                                  134  ,iMultiSelect = 0x004
                                                                  - -
                                                                  136  ,iSelectAxes = 0x010
                                                                  -
                                                                  137  ,iSelectLegend = 0x020
                                                                  -
                                                                  138  ,iSelectItems = 0x040
                                                                  -
                                                                  139  ,iSelectOther = 0x080
                                                                  -
                                                                  140  };
                                                                  -
                                                                  141 Q_DECLARE_FLAGS(Interactions, Interaction)
                                                                  -
                                                                  142 
                                                                  +
                                                                  126 
                                                                  +
                                                                  133 enum Interaction { iRangeDrag = 0x001
                                                                  +
                                                                  134  ,iRangeZoom = 0x002
                                                                  +
                                                                  135  ,iMultiSelect = 0x004
                                                                  + +
                                                                  137  ,iSelectAxes = 0x010
                                                                  +
                                                                  138  ,iSelectLegend = 0x020
                                                                  +
                                                                  139  ,iSelectItems = 0x040
                                                                  +
                                                                  140  ,iSelectOther = 0x080
                                                                  +
                                                                  141  };
                                                                  +
                                                                  142 Q_DECLARE_FLAGS(Interactions, Interaction)
                                                                  143 
                                                                  -
                                                                  149 inline bool isInvalidData(double value)
                                                                  -
                                                                  150 {
                                                                  -
                                                                  151  return qIsNaN(value) || qIsInf(value);
                                                                  -
                                                                  152 }
                                                                  -
                                                                  153 
                                                                  -
                                                                  159 inline bool isInvalidData(double value1, double value2)
                                                                  -
                                                                  160 {
                                                                  -
                                                                  161  return isInvalidData(value1) || isInvalidData(value2);
                                                                  -
                                                                  162 }
                                                                  -
                                                                  163 
                                                                  -
                                                                  170 inline void setMarginValue(QMargins &margins, QCP::MarginSide side, int value)
                                                                  -
                                                                  171 {
                                                                  -
                                                                  172  switch (side)
                                                                  -
                                                                  173  {
                                                                  -
                                                                  174  case QCP::msLeft: margins.setLeft(value); break;
                                                                  -
                                                                  175  case QCP::msRight: margins.setRight(value); break;
                                                                  -
                                                                  176  case QCP::msTop: margins.setTop(value); break;
                                                                  -
                                                                  177  case QCP::msBottom: margins.setBottom(value); break;
                                                                  -
                                                                  178  case QCP::msAll: margins = QMargins(value, value, value, value); break;
                                                                  -
                                                                  179  default: break;
                                                                  -
                                                                  180  }
                                                                  -
                                                                  181 }
                                                                  -
                                                                  182 
                                                                  -
                                                                  190 inline int getMarginValue(const QMargins &margins, QCP::MarginSide side)
                                                                  -
                                                                  191 {
                                                                  -
                                                                  192  switch (side)
                                                                  -
                                                                  193  {
                                                                  -
                                                                  194  case QCP::msLeft: return margins.left();
                                                                  -
                                                                  195  case QCP::msRight: return margins.right();
                                                                  -
                                                                  196  case QCP::msTop: return margins.top();
                                                                  -
                                                                  197  case QCP::msBottom: return margins.bottom();
                                                                  -
                                                                  198  default: break;
                                                                  -
                                                                  199  }
                                                                  -
                                                                  200  return 0;
                                                                  -
                                                                  201 }
                                                                  -
                                                                  202 
                                                                  -
                                                                  203 } // end of namespace QCP
                                                                  -
                                                                  204 
                                                                  -
                                                                  205 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::AntialiasedElements)
                                                                  -
                                                                  206 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::PlottingHints)
                                                                  -
                                                                  207 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::MarginSides)
                                                                  -
                                                                  208 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::Interactions)
                                                                  -
                                                                  209 
                                                                  -
                                                                  210 #endif // QCP_GLOBAL_H
                                                                  +
                                                                  144 
                                                                  +
                                                                  150 inline bool isInvalidData(double value)
                                                                  +
                                                                  151 {
                                                                  +
                                                                  152  return qIsNaN(value) || qIsInf(value);
                                                                  +
                                                                  153 }
                                                                  +
                                                                  154 
                                                                  +
                                                                  160 inline bool isInvalidData(double value1, double value2)
                                                                  +
                                                                  161 {
                                                                  +
                                                                  162  return isInvalidData(value1) || isInvalidData(value2);
                                                                  +
                                                                  163 }
                                                                  +
                                                                  164 
                                                                  +
                                                                  171 inline void setMarginValue(QMargins &margins, QCP::MarginSide side, int value)
                                                                  +
                                                                  172 {
                                                                  +
                                                                  173  switch (side)
                                                                  +
                                                                  174  {
                                                                  +
                                                                  175  case QCP::msLeft: margins.setLeft(value); break;
                                                                  +
                                                                  176  case QCP::msRight: margins.setRight(value); break;
                                                                  +
                                                                  177  case QCP::msTop: margins.setTop(value); break;
                                                                  +
                                                                  178  case QCP::msBottom: margins.setBottom(value); break;
                                                                  +
                                                                  179  case QCP::msAll: margins = QMargins(value, value, value, value); break;
                                                                  +
                                                                  180  default: break;
                                                                  +
                                                                  181  }
                                                                  +
                                                                  182 }
                                                                  +
                                                                  183 
                                                                  +
                                                                  191 inline int getMarginValue(const QMargins &margins, QCP::MarginSide side)
                                                                  +
                                                                  192 {
                                                                  +
                                                                  193  switch (side)
                                                                  +
                                                                  194  {
                                                                  +
                                                                  195  case QCP::msLeft: return margins.left();
                                                                  +
                                                                  196  case QCP::msRight: return margins.right();
                                                                  +
                                                                  197  case QCP::msTop: return margins.top();
                                                                  +
                                                                  198  case QCP::msBottom: return margins.bottom();
                                                                  +
                                                                  199  default: break;
                                                                  +
                                                                  200  }
                                                                  +
                                                                  201  return 0;
                                                                  +
                                                                  202 }
                                                                  +
                                                                  203 
                                                                  +
                                                                  204 } // end of namespace QCP
                                                                  +
                                                                  205 
                                                                  +
                                                                  206 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::AntialiasedElements)
                                                                  +
                                                                  207 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::PlottingHints)
                                                                  +
                                                                  208 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::MarginSides)
                                                                  +
                                                                  209 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::Interactions)
                                                                  +
                                                                  210 
                                                                  +
                                                                  211 #endif // QCP_GLOBAL_H
                                                                  diff -Nru qcustomplot-1.1.0/documentation/html/hierarchy.html qcustomplot-1.2.0/documentation/html/hierarchy.html --- qcustomplot-1.1.0/documentation/html/hierarchy.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/hierarchy.html 2014-03-14 21:11:26.000000000 +0000 @@ -24,44 +24,48 @@ This inheritance list is sorted roughly, but not completely, alphabetically:
                                                                  [detail level 12345]
                                                                  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
                                                                  oCQCPBarDataHolds the data of one single data point (one bar) for QCPBars
                                                                  oCQCPCurveDataHolds the data of one single data point for QCPCurve
                                                                  oCQCPDataHolds the data of one single data point for QCPGraph
                                                                  oCQCPItemAnchorAn anchor of an item to which positions can be attached to
                                                                  |\CQCPItemPositionManages the position of an item
                                                                  oCQCPLayerA layer that may contain objects, to control the rendering order
                                                                  oCQCPLayerableBase class for all drawable objects
                                                                  |oCQCPAbstractItemThe abstract base class for all items in a plot
                                                                  ||oCQCPItemBracketA bracket for referencing/highlighting certain parts in the plot
                                                                  ||oCQCPItemCurveA curved line from one point to another
                                                                  ||oCQCPItemEllipseAn ellipse
                                                                  ||oCQCPItemLineA line from one point to another
                                                                  ||oCQCPItemPixmapAn arbitrary pixmap
                                                                  ||oCQCPItemRectA rectangle
                                                                  ||oCQCPItemStraightLineA straight line that spans infinitely in both directions
                                                                  ||oCQCPItemTextA text label
                                                                  ||\CQCPItemTracerItem that sticks to QCPGraph data points
                                                                  |oCQCPAbstractPlottableThe abstract base class for all data representing objects in a plot
                                                                  ||oCQCPBarsA plottable representing a bar chart in a plot
                                                                  ||oCQCPCurveA plottable representing a parametric curve in a plot
                                                                  ||oCQCPGraphA plottable representing a graph in a plot
                                                                  ||\CQCPStatisticalBoxA plottable representing a single statistical box in a plot
                                                                  |oCQCPAxisManages a single axis inside a QCustomPlot
                                                                  |oCQCPGridResponsible for drawing the grid of a QCPAxis
                                                                  |\CQCPLayoutElementThe abstract base class for all objects that form the layout system
                                                                  | oCQCPAbstractLegendItemThe abstract base class for all entries in a QCPLegend
                                                                  | |\CQCPPlottableLegendItemA legend item representing a plottable with an icon and the plottable name
                                                                  | oCQCPAxisRectHolds multiple axes and arranges them in a rectangular shape
                                                                  | oCQCPLayoutThe abstract base class for layouts
                                                                  | |oCQCPLayoutGridA layout that arranges child elements in a grid
                                                                  | ||\CQCPLegendManages a legend inside a QCustomPlot
                                                                  | |\CQCPLayoutInsetA layout that places child elements aligned to the border or arbitrarily positioned
                                                                  | \CQCPPlotTitleA layout element displaying a plot title text
                                                                  oCQCPLineEndingHandles the different ending decorations for line-like items
                                                                  oCQCPMarginGroupA margin group allows synchronization of margin sides if working with multiple layout elements
                                                                  oCQCPPainterQPainter subclass used internally
                                                                  oCQCPRangeRepresents the range an axis is encompassing
                                                                  oCQCPScatterStyleRepresents the visual appearance of scatter points
                                                                  \CQCustomPlotThe central class of the library. This is the QWidget which displays the plot and interacts with the user
                                                                  oCQCPColorGradientDefines a color gradient for use with e.g. QCPColorMap
                                                                  oCQCPColorMapDataHolds the two-dimensional data of a QCPColorMap plottable
                                                                  oCQCPCurveDataHolds the data of one single data point for QCPCurve
                                                                  oCQCPDataHolds the data of one single data point for QCPGraph
                                                                  oCQCPItemAnchorAn anchor of an item to which positions can be attached to
                                                                  |\CQCPItemPositionManages the position of an item
                                                                  oCQCPLayerA layer that may contain objects, to control the rendering order
                                                                  oCQCPLayerableBase class for all drawable objects
                                                                  |oCQCPAbstractItemThe abstract base class for all items in a plot
                                                                  ||oCQCPItemBracketA bracket for referencing/highlighting certain parts in the plot
                                                                  ||oCQCPItemCurveA curved line from one point to another
                                                                  ||oCQCPItemEllipseAn ellipse
                                                                  ||oCQCPItemLineA line from one point to another
                                                                  ||oCQCPItemPixmapAn arbitrary pixmap
                                                                  ||oCQCPItemRectA rectangle
                                                                  ||oCQCPItemStraightLineA straight line that spans infinitely in both directions
                                                                  ||oCQCPItemTextA text label
                                                                  ||\CQCPItemTracerItem that sticks to QCPGraph data points
                                                                  |oCQCPAbstractPlottableThe abstract base class for all data representing objects in a plot
                                                                  ||oCQCPBarsA plottable representing a bar chart in a plot
                                                                  ||oCQCPColorMapA plottable representing a two-dimensional color map in a plot
                                                                  ||oCQCPCurveA plottable representing a parametric curve in a plot
                                                                  ||oCQCPGraphA plottable representing a graph in a plot
                                                                  ||\CQCPStatisticalBoxA plottable representing a single statistical box in a plot
                                                                  |oCQCPAxisManages a single axis inside a QCustomPlot
                                                                  |oCQCPGridResponsible for drawing the grid of a QCPAxis
                                                                  |\CQCPLayoutElementThe abstract base class for all objects that form the layout system
                                                                  | oCQCPAbstractLegendItemThe abstract base class for all entries in a QCPLegend
                                                                  | |\CQCPPlottableLegendItemA legend item representing a plottable with an icon and the plottable name
                                                                  | oCQCPAxisRectHolds multiple axes and arranges them in a rectangular shape
                                                                  | oCQCPColorScaleA color scale for use with color coding data such as QCPColorMap
                                                                  | oCQCPLayoutThe abstract base class for layouts
                                                                  | |oCQCPLayoutGridA layout that arranges child elements in a grid
                                                                  | ||\CQCPLegendManages a legend inside a QCustomPlot
                                                                  | |\CQCPLayoutInsetA layout that places child elements aligned to the border or arbitrarily positioned
                                                                  | \CQCPPlotTitleA layout element displaying a plot title text
                                                                  oCQCPLineEndingHandles the different ending decorations for line-like items
                                                                  oCQCPMarginGroupA margin group allows synchronization of margin sides if working with multiple layout elements
                                                                  oCQCPPainterQPainter subclass used internally
                                                                  oCQCPRangeRepresents the range an axis is encompassing
                                                                  oCQCPScatterStyleRepresents the visual appearance of scatter points
                                                                  \CQCustomPlotThe central class of the library. This is the QWidget which displays the plot and interacts with the user
                                                                  diff -Nru qcustomplot-1.1.0/documentation/html/index.html qcustomplot-1.2.0/documentation/html/index.html --- qcustomplot-1.1.0/documentation/html/index.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/index.html 2014-03-14 21:11:26.000000000 +0000 @@ -2,7 +2,7 @@ -QCustomPlot 1.1.0 Documentation +QCustomPlot 1.2.0 Documentation @@ -16,7 +16,7 @@
                                                                  -
                                                                  QCustomPlot 1.1.0 Documentation
                                                                  +
                                                                  QCustomPlot 1.2.0 Documentation
                                                                  @@ -25,7 +25,7 @@

                                                                  Below is a brief overview of and guide to the classes and their relations. If you are new to QCustomPlot and just want to start using it, it's recommended to look at the tutorials and examples at

                                                                  http://www.qcustomplot.com/

                                                                  This documentation is especially helpful as a reference, when you're familiar with the basic concept of how to use QCustomPlot and you wish to learn more about specific functionality. See the class overview for diagrams explaining the relationships between the most important classes of the QCustomPlot library.

                                                                  -

                                                                  The central widget which displays the plottables and axes on its surface is QCustomPlot. Every QCustomPlot contains four axes by default. They can be accessed via the members xAxis, yAxis, xAxis2 and yAxis2, and are of type QCPAxis. QCustomPlot supports an arbitrary number of axes and axis rects, see the documentation of QCPAxisRect for details.

                                                                  +

                                                                  The central widget which displays the plottables and axes on its surface is QCustomPlot. Every QCustomPlot contains four axes by default. They can be accessed via the members xAxis, yAxis, xAxis2 and yAxis2, and are of type QCPAxis. QCustomPlot supports an arbitrary number of axes and axis rects, see the documentation of QCPAxisRect for details.

                                                                  Plottables

                                                                  Plottables are classes that display any kind of data inside the QCustomPlot. They all derive from QCPAbstractPlottable. For example, the QCPGraph class is a plottable that displays a graph inside the plot with different line styles, scatter styles, filling etc.

                                                                  @@ -38,20 +38,20 @@
                                                                  customPlot->addPlottable(newCurve);

                                                                  and then modify the properties of the newly created plottable via the newCurve pointer.

                                                                  Plottables (including graphs) can be retrieved via QCustomPlot::plottable. Since the return type of that function is the abstract base class of all plottables, QCPAbstractPlottable, you will probably want to qobject_cast the returned pointer to the respective plottable subclass. (As usual, if the cast returns zero, the plottable wasn't of that specific subclass.)

                                                                  -

                                                                  All further interfacing with plottables (e.g how to set data) is specific to the plottable type. See the documentations of the subclasses: QCPGraph, QCPCurve, QCPBars, QCPStatisticalBox.

                                                                  +

                                                                  All further interfacing with plottables (e.g how to set data) is specific to the plottable type. See the documentations of the subclasses: QCPGraph, QCPCurve, QCPBars, QCPStatisticalBox, QCPColorMap.

                                                                  Controlling the Axes

                                                                  As mentioned, QCustomPlot has four axes by default: xAxis (bottom), yAxis (left), xAxis2 (top), yAxis2 (right).

                                                                  -

                                                                  Their range is handled by the simple QCPRange class. You can set the range with the QCPAxis::setRange function. By default, the axes represent a linear scale. To set a logarithmic scale, set QCPAxis::setScaleType to QCPAxis::stLogarithmic. The logarithm base can be set freely with QCPAxis::setScaleLogBase.

                                                                  +

                                                                  Their range is handled by the simple QCPRange class. You can set the range with the QCPAxis::setRange function. By default, the axes represent a linear scale. To set a logarithmic scale, set QCPAxis::setScaleType to QCPAxis::stLogarithmic. The logarithm base can be set freely with QCPAxis::setScaleLogBase.

                                                                  By default, an axis automatically creates and labels ticks in a sensible manner. See the following functions for tick manipulation:
                                                                  QCPAxis::setTicks, QCPAxis::setAutoTicks, QCPAxis::setAutoTickCount, QCPAxis::setAutoTickStep, QCPAxis::setTickLabels, QCPAxis::setTickLabelType, QCPAxis::setTickLabelRotation, QCPAxis::setTickStep, QCPAxis::setTickLength,...

                                                                  Each axis can be given an axis label (e.g. "Voltage (mV)") with QCPAxis::setLabel.

                                                                  The distance of an axis backbone to the respective viewport border is called its margin. Normally, the margins are calculated automatically. To change this, set QCPAxisRect::setAutoMargins to exclude the respective margin sides, set the margins manually with QCPAxisRect::setMargins. The main axis rect can be reached with QCustomPlot::axisRect().

                                                                  Plot Legend

                                                                  -

                                                                  Every QCustomPlot owns one QCPLegend (as legend) by default. A legend is a small layout element inside the plot which lists the plottables with an icon of the plottable line/symbol and a description. The Description is retrieved from the plottable name (QCPAbstractPlottable::setName). Plottables can be added and removed from the legend via QCPAbstractPlottable::addToLegend and QCPAbstractPlottable::removeFromLegend. By default, adding a plottable to QCustomPlot automatically adds it to the legend, too. This behaviour can be modified with the QCustomPlot::setAutoAddPlottableToLegend property.

                                                                  +

                                                                  Every QCustomPlot has one QCPLegend (as QCustomPlot::legend) by default. A legend is a small layout element inside the plot which lists the plottables with an icon of the plottable line/symbol and a name (QCPAbstractPlottable::setName). Plottables can be added and removed from the main legend via QCPAbstractPlottable::addToLegend and QCPAbstractPlottable::removeFromLegend. By default, adding a plottable to QCustomPlot automatically adds it to the legend, too. This behaviour can be modified with the QCustomPlot::setAutoAddPlottableToLegend property.

                                                                  The QCPLegend provides an interface to access, add and remove legend items directly, too. See QCPLegend::item, QCPLegend::itemWithPlottable, QCPLegend::addItem, QCPLegend::removeItem for example.

                                                                  -

                                                                  Multiple legends are supported via the layout system (as a QCPLegend simply is a normal layout element).

                                                                  +

                                                                  Multiple legends are supported via the layout system (as a QCPLegend simply is a normal layout element).

                                                                  User Interactions

                                                                  QCustomPlot supports dragging axis ranges with the mouse (QCPAxisRect::setRangeDrag), zooming axis ranges with the mouse wheel (QCPAxisRect::setRangeZoom) and a complete selection mechanism.

                                                                  Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/InheritanceOverview.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/InheritanceOverview.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/inherit_graph_10.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/inherit_graph_10.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/inherit_graph_11.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/inherit_graph_11.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/inherit_graph_12.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/inherit_graph_12.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/inherit_graph_13.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/inherit_graph_13.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/inherit_graph_1.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/inherit_graph_1.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/inherit_graph_2.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/inherit_graph_2.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/inherit_graph_3.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/inherit_graph_3.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/inherit_graph_4.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/inherit_graph_4.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/inherit_graph_5.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/inherit_graph_5.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/inherit_graph_6.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/inherit_graph_6.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/inherit_graph_7.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/inherit_graph_7.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/inherit_graph_8.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/inherit_graph_8.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/inherit_graph_9.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/inherit_graph_9.png differ diff -Nru qcustomplot-1.1.0/documentation/html/inherits.html qcustomplot-1.2.0/documentation/html/inherits.html --- qcustomplot-1.1.0/documentation/html/inherits.html 2013-11-04 22:19:42.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/inherits.html 2014-03-14 21:11:27.000000000 +0000 @@ -26,47 +26,55 @@ - + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + diff -Nru qcustomplot-1.1.0/documentation/html/item_8h_source.html qcustomplot-1.2.0/documentation/html/item_8h_source.html --- qcustomplot-1.1.0/documentation/html/item_8h_source.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/item_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -26,7 +26,7 @@
                                                                  1 /***************************************************************************
                                                                  2 ** **
                                                                  3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                                  -
                                                                  4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
                                                                  +
                                                                  4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                                  5 ** **
                                                                  6 ** This program is free software: you can redistribute it and/or modify **
                                                                  7 ** it under the terms of the GNU General Public License as published by **
                                                                  @@ -44,8 +44,8 @@
                                                                  19 ****************************************************************************
                                                                  20 ** Author: Emanuel Eichhammer **
                                                                  21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                                  -
                                                                  22 ** Date: 04.11.13 **
                                                                  -
                                                                  23 ** Version: 1.1.0 **
                                                                  +
                                                                  22 ** Date: 14.03.14 **
                                                                  +
                                                                  23 ** Version: 1.2.0 **
                                                                  24 ****************************************************************************/
                                                                  25 
                                                                  26 #ifndef QCP_ITEM_H
                                                                  @@ -101,120 +101,125 @@
                                                                  76 public:
                                                                  83  enum PositionType { ptAbsolute
                                                                  84  ,ptViewportRatio
                                                                  -
                                                                  85  ,ptAxisRectRatio
                                                                  -
                                                                  86  ,ptPlotCoords
                                                                  -
                                                                  87  };
                                                                  -
                                                                  88 
                                                                  -
                                                                  89  QCPItemPosition(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString name);
                                                                  -
                                                                  90  virtual ~QCPItemPosition();
                                                                  -
                                                                  91 
                                                                  -
                                                                  92  // getters:
                                                                  -
                                                                  93  PositionType type() const { return mPositionType; }
                                                                  -
                                                                  94  QCPItemAnchor *parentAnchor() const { return mParentAnchor; }
                                                                  -
                                                                  95  double key() const { return mKey; }
                                                                  -
                                                                  96  double value() const { return mValue; }
                                                                  -
                                                                  97  QPointF coords() const { return QPointF(mKey, mValue); }
                                                                  -
                                                                  98  QCPAxis *keyAxis() const { return mKeyAxis.data(); }
                                                                  -
                                                                  99  QCPAxis *valueAxis() const { return mValueAxis.data(); }
                                                                  -
                                                                  100  QCPAxisRect *axisRect() const;
                                                                  -
                                                                  101  virtual QPointF pixelPoint() const;
                                                                  -
                                                                  102 
                                                                  -
                                                                  103  // setters:
                                                                  -
                                                                  104  void setType(PositionType type);
                                                                  -
                                                                  105  bool setParentAnchor(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false);
                                                                  -
                                                                  106  void setCoords(double key, double value);
                                                                  -
                                                                  107  void setCoords(const QPointF &coords);
                                                                  -
                                                                  108  void setAxes(QCPAxis* keyAxis, QCPAxis* valueAxis);
                                                                  -
                                                                  109  void setAxisRect(QCPAxisRect *axisRect);
                                                                  -
                                                                  110  void setPixelPoint(const QPointF &pixelPoint);
                                                                  -
                                                                  111 
                                                                  -
                                                                  112 protected:
                                                                  -
                                                                  113  // property members:
                                                                  -
                                                                  114  PositionType mPositionType;
                                                                  -
                                                                  115  QPointer<QCPAxis> mKeyAxis, mValueAxis;
                                                                  -
                                                                  116  QPointer<QCPAxisRect> mAxisRect;
                                                                  -
                                                                  117  double mKey, mValue;
                                                                  -
                                                                  118  QCPItemAnchor *mParentAnchor;
                                                                  -
                                                                  119 
                                                                  -
                                                                  120  // reimplemented virtual methods:
                                                                  -
                                                                  121  virtual QCPItemPosition *toQCPItemPosition() { return this; }
                                                                  -
                                                                  122 
                                                                  -
                                                                  123 private:
                                                                  -
                                                                  124  Q_DISABLE_COPY(QCPItemPosition)
                                                                  -
                                                                  125 
                                                                  -
                                                                  126 };
                                                                  -
                                                                  127 
                                                                  -
                                                                  128 
                                                                  -
                                                                  129 class QCP_LIB_DECL QCPAbstractItem : public QCPLayerable
                                                                  -
                                                                  130 {
                                                                  -
                                                                  131  Q_OBJECT
                                                                  -
                                                                  133  Q_PROPERTY(bool clipToAxisRect READ clipToAxisRect WRITE setClipToAxisRect)
                                                                  -
                                                                  134  Q_PROPERTY(QCPAxisRect* clipAxisRect READ clipAxisRect WRITE setClipAxisRect)
                                                                  -
                                                                  135  Q_PROPERTY(bool selectable READ selectable WRITE setSelectable)
                                                                  -
                                                                  136  Q_PROPERTY(bool selected READ selected WRITE setSelected)
                                                                  -
                                                                  138 public:
                                                                  -
                                                                  139  QCPAbstractItem(QCustomPlot *parentPlot);
                                                                  -
                                                                  140  virtual ~QCPAbstractItem();
                                                                  -
                                                                  141 
                                                                  -
                                                                  142  // getters:
                                                                  -
                                                                  143  bool clipToAxisRect() const { return mClipToAxisRect; }
                                                                  -
                                                                  144  QCPAxisRect *clipAxisRect() const;
                                                                  -
                                                                  145  bool selectable() const { return mSelectable; }
                                                                  -
                                                                  146  bool selected() const { return mSelected; }
                                                                  -
                                                                  147 
                                                                  -
                                                                  148  // setters:
                                                                  -
                                                                  149  void setClipToAxisRect(bool clip);
                                                                  -
                                                                  150  void setClipAxisRect(QCPAxisRect *rect);
                                                                  -
                                                                  151  void setSelectable(bool selectable);
                                                                  -
                                                                  152  void setSelected(bool selected);
                                                                  -
                                                                  153 
                                                                  -
                                                                  154  // reimplemented virtual methods:
                                                                  -
                                                                  155  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const = 0;
                                                                  -
                                                                  156 
                                                                  -
                                                                  157  // non-virtual methods:
                                                                  -
                                                                  158  QList<QCPItemPosition*> positions() const { return mPositions; }
                                                                  -
                                                                  159  QList<QCPItemAnchor*> anchors() const { return mAnchors; }
                                                                  -
                                                                  160  QCPItemPosition *position(const QString &name) const;
                                                                  -
                                                                  161  QCPItemAnchor *anchor(const QString &name) const;
                                                                  -
                                                                  162  bool hasAnchor(const QString &name) const;
                                                                  -
                                                                  163 
                                                                  -
                                                                  164 signals:
                                                                  -
                                                                  165  void selectionChanged(bool selected);
                                                                  -
                                                                  166 
                                                                  -
                                                                  167 protected:
                                                                  -
                                                                  168  // property members:
                                                                  -
                                                                  169  bool mClipToAxisRect;
                                                                  -
                                                                  170  QPointer<QCPAxisRect> mClipAxisRect;
                                                                  -
                                                                  171  QList<QCPItemPosition*> mPositions;
                                                                  -
                                                                  172  QList<QCPItemAnchor*> mAnchors;
                                                                  -
                                                                  173  bool mSelectable, mSelected;
                                                                  -
                                                                  174 
                                                                  -
                                                                  175  // reimplemented virtual methods:
                                                                  -
                                                                  176  virtual QCP::Interaction selectionCategory() const;
                                                                  -
                                                                  177  virtual QRect clipRect() const;
                                                                  -
                                                                  178  virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
                                                                  -
                                                                  179  virtual void draw(QCPPainter *painter) = 0;
                                                                  -
                                                                  180  // events:
                                                                  -
                                                                  181  virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
                                                                  -
                                                                  182  virtual void deselectEvent(bool *selectionStateChanged);
                                                                  -
                                                                  183 
                                                                  -
                                                                  184  // introduced virtual methods:
                                                                  -
                                                                  185  virtual QPointF anchorPixelPoint(int anchorId) const;
                                                                  -
                                                                  186 
                                                                  -
                                                                  187  // non-virtual methods:
                                                                  -
                                                                  188  double distSqrToLine(const QPointF &start, const QPointF &end, const QPointF &point) const;
                                                                  -
                                                                  189  double rectSelectTest(const QRectF &rect, const QPointF &pos, bool filledRect) const;
                                                                  -
                                                                  190  QCPItemPosition *createPosition(const QString &name);
                                                                  -
                                                                  191  QCPItemAnchor *createAnchor(const QString &name, int anchorId);
                                                                  -
                                                                  192 
                                                                  -
                                                                  193 private:
                                                                  -
                                                                  194  Q_DISABLE_COPY(QCPAbstractItem)
                                                                  -
                                                                  195 
                                                                  -
                                                                  196  friend class QCustomPlot;
                                                                  -
                                                                  197  friend class QCPItemAnchor;
                                                                  -
                                                                  198 };
                                                                  -
                                                                  199 
                                                                  -
                                                                  200 #endif // QCP_ITEM_H
                                                                  +
                                                                  85 
                                                                  +
                                                                  86 
                                                                  +
                                                                  87  ,ptAxisRectRatio
                                                                  +
                                                                  88 
                                                                  +
                                                                  89 
                                                                  +
                                                                  90  ,ptPlotCoords
                                                                  +
                                                                  91  };
                                                                  +
                                                                  92 
                                                                  +
                                                                  93  QCPItemPosition(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString name);
                                                                  +
                                                                  94  virtual ~QCPItemPosition();
                                                                  +
                                                                  95 
                                                                  +
                                                                  96  // getters:
                                                                  +
                                                                  97  PositionType type() const { return mPositionType; }
                                                                  +
                                                                  98  QCPItemAnchor *parentAnchor() const { return mParentAnchor; }
                                                                  +
                                                                  99  double key() const { return mKey; }
                                                                  +
                                                                  100  double value() const { return mValue; }
                                                                  +
                                                                  101  QPointF coords() const { return QPointF(mKey, mValue); }
                                                                  +
                                                                  102  QCPAxis *keyAxis() const { return mKeyAxis.data(); }
                                                                  +
                                                                  103  QCPAxis *valueAxis() const { return mValueAxis.data(); }
                                                                  +
                                                                  104  QCPAxisRect *axisRect() const;
                                                                  +
                                                                  105  virtual QPointF pixelPoint() const;
                                                                  +
                                                                  106 
                                                                  +
                                                                  107  // setters:
                                                                  +
                                                                  108  void setType(PositionType type);
                                                                  +
                                                                  109  bool setParentAnchor(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false);
                                                                  +
                                                                  110  void setCoords(double key, double value);
                                                                  +
                                                                  111  void setCoords(const QPointF &coords);
                                                                  +
                                                                  112  void setAxes(QCPAxis* keyAxis, QCPAxis* valueAxis);
                                                                  +
                                                                  113  void setAxisRect(QCPAxisRect *axisRect);
                                                                  +
                                                                  114  void setPixelPoint(const QPointF &pixelPoint);
                                                                  +
                                                                  115 
                                                                  +
                                                                  116 protected:
                                                                  +
                                                                  117  // property members:
                                                                  +
                                                                  118  PositionType mPositionType;
                                                                  +
                                                                  119  QPointer<QCPAxis> mKeyAxis, mValueAxis;
                                                                  +
                                                                  120  QPointer<QCPAxisRect> mAxisRect;
                                                                  +
                                                                  121  double mKey, mValue;
                                                                  +
                                                                  122  QCPItemAnchor *mParentAnchor;
                                                                  +
                                                                  123 
                                                                  +
                                                                  124  // reimplemented virtual methods:
                                                                  +
                                                                  125  virtual QCPItemPosition *toQCPItemPosition() { return this; }
                                                                  +
                                                                  126 
                                                                  +
                                                                  127 private:
                                                                  +
                                                                  128  Q_DISABLE_COPY(QCPItemPosition)
                                                                  +
                                                                  129 
                                                                  +
                                                                  130 };
                                                                  +
                                                                  131 
                                                                  +
                                                                  132 
                                                                  +
                                                                  133 class QCP_LIB_DECL QCPAbstractItem : public QCPLayerable
                                                                  +
                                                                  134 {
                                                                  +
                                                                  135  Q_OBJECT
                                                                  +
                                                                  137  Q_PROPERTY(bool clipToAxisRect READ clipToAxisRect WRITE setClipToAxisRect)
                                                                  +
                                                                  138  Q_PROPERTY(QCPAxisRect* clipAxisRect READ clipAxisRect WRITE setClipAxisRect)
                                                                  +
                                                                  139  Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectableChanged)
                                                                  +
                                                                  140  Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectionChanged)
                                                                  +
                                                                  142 public:
                                                                  +
                                                                  143  QCPAbstractItem(QCustomPlot *parentPlot);
                                                                  +
                                                                  144  virtual ~QCPAbstractItem();
                                                                  +
                                                                  145 
                                                                  +
                                                                  146  // getters:
                                                                  +
                                                                  147  bool clipToAxisRect() const { return mClipToAxisRect; }
                                                                  +
                                                                  148  QCPAxisRect *clipAxisRect() const;
                                                                  +
                                                                  149  bool selectable() const { return mSelectable; }
                                                                  +
                                                                  150  bool selected() const { return mSelected; }
                                                                  +
                                                                  151 
                                                                  +
                                                                  152  // setters:
                                                                  +
                                                                  153  void setClipToAxisRect(bool clip);
                                                                  +
                                                                  154  void setClipAxisRect(QCPAxisRect *rect);
                                                                  +
                                                                  155  Q_SLOT void setSelectable(bool selectable);
                                                                  +
                                                                  156  Q_SLOT void setSelected(bool selected);
                                                                  +
                                                                  157 
                                                                  +
                                                                  158  // reimplemented virtual methods:
                                                                  +
                                                                  159  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const = 0;
                                                                  +
                                                                  160 
                                                                  +
                                                                  161  // non-virtual methods:
                                                                  +
                                                                  162  QList<QCPItemPosition*> positions() const { return mPositions; }
                                                                  +
                                                                  163  QList<QCPItemAnchor*> anchors() const { return mAnchors; }
                                                                  +
                                                                  164  QCPItemPosition *position(const QString &name) const;
                                                                  +
                                                                  165  QCPItemAnchor *anchor(const QString &name) const;
                                                                  +
                                                                  166  bool hasAnchor(const QString &name) const;
                                                                  +
                                                                  167 
                                                                  +
                                                                  168 signals:
                                                                  +
                                                                  169  void selectionChanged(bool selected);
                                                                  +
                                                                  170  void selectableChanged(bool selectable);
                                                                  +
                                                                  171 
                                                                  +
                                                                  172 protected:
                                                                  +
                                                                  173  // property members:
                                                                  +
                                                                  174  bool mClipToAxisRect;
                                                                  +
                                                                  175  QPointer<QCPAxisRect> mClipAxisRect;
                                                                  +
                                                                  176  QList<QCPItemPosition*> mPositions;
                                                                  +
                                                                  177  QList<QCPItemAnchor*> mAnchors;
                                                                  +
                                                                  178  bool mSelectable, mSelected;
                                                                  +
                                                                  179 
                                                                  +
                                                                  180  // reimplemented virtual methods:
                                                                  +
                                                                  181  virtual QCP::Interaction selectionCategory() const;
                                                                  +
                                                                  182  virtual QRect clipRect() const;
                                                                  +
                                                                  183  virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
                                                                  +
                                                                  184  virtual void draw(QCPPainter *painter) = 0;
                                                                  +
                                                                  185  // events:
                                                                  +
                                                                  186  virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
                                                                  +
                                                                  187  virtual void deselectEvent(bool *selectionStateChanged);
                                                                  +
                                                                  188 
                                                                  +
                                                                  189  // introduced virtual methods:
                                                                  +
                                                                  190  virtual QPointF anchorPixelPoint(int anchorId) const;
                                                                  +
                                                                  191 
                                                                  +
                                                                  192  // non-virtual methods:
                                                                  +
                                                                  193  double distSqrToLine(const QPointF &start, const QPointF &end, const QPointF &point) const;
                                                                  +
                                                                  194  double rectSelectTest(const QRectF &rect, const QPointF &pos, bool filledRect) const;
                                                                  +
                                                                  195  QCPItemPosition *createPosition(const QString &name);
                                                                  +
                                                                  196  QCPItemAnchor *createAnchor(const QString &name, int anchorId);
                                                                  +
                                                                  197 
                                                                  +
                                                                  198 private:
                                                                  +
                                                                  199  Q_DISABLE_COPY(QCPAbstractItem)
                                                                  +
                                                                  200 
                                                                  +
                                                                  201  friend class QCustomPlot;
                                                                  +
                                                                  202  friend class QCPItemAnchor;
                                                                  +
                                                                  203 };
                                                                  +
                                                                  204 
                                                                  +
                                                                  205 #endif // QCP_ITEM_H
                                                                  diff -Nru qcustomplot-1.1.0/documentation/html/item-bracket_8h_source.html qcustomplot-1.2.0/documentation/html/item-bracket_8h_source.html --- qcustomplot-1.1.0/documentation/html/item-bracket_8h_source.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/item-bracket_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -26,7 +26,7 @@
                                                                  1 /***************************************************************************
                                                                  2 ** **
                                                                  3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                                  -
                                                                  4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
                                                                  +
                                                                  4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                                  5 ** **
                                                                  6 ** This program is free software: you can redistribute it and/or modify **
                                                                  7 ** it under the terms of the GNU General Public License as published by **
                                                                  @@ -44,8 +44,8 @@
                                                                  19 ****************************************************************************
                                                                  20 ** Author: Emanuel Eichhammer **
                                                                  21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                                  -
                                                                  22 ** Date: 04.11.13 **
                                                                  -
                                                                  23 ** Version: 1.1.0 **
                                                                  +
                                                                  22 ** Date: 14.03.14 **
                                                                  +
                                                                  23 ** Version: 1.2.0 **
                                                                  24 ****************************************************************************/
                                                                  25 
                                                                  26 #ifndef QCP_ITEM_BRACKET_H
                                                                  diff -Nru qcustomplot-1.1.0/documentation/html/item-curve_8h_source.html qcustomplot-1.2.0/documentation/html/item-curve_8h_source.html --- qcustomplot-1.1.0/documentation/html/item-curve_8h_source.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/item-curve_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -26,7 +26,7 @@
                                                                  1 /***************************************************************************
                                                                  2 ** **
                                                                  3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                                  -
                                                                  4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
                                                                  +
                                                                  4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                                  5 ** **
                                                                  6 ** This program is free software: you can redistribute it and/or modify **
                                                                  7 ** it under the terms of the GNU General Public License as published by **
                                                                  @@ -44,8 +44,8 @@
                                                                  19 ****************************************************************************
                                                                  20 ** Author: Emanuel Eichhammer **
                                                                  21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                                  -
                                                                  22 ** Date: 04.11.13 **
                                                                  -
                                                                  23 ** Version: 1.1.0 **
                                                                  +
                                                                  22 ** Date: 14.03.14 **
                                                                  +
                                                                  23 ** Version: 1.2.0 **
                                                                  24 ****************************************************************************/
                                                                  25 
                                                                  26 #ifndef QCP_ITEM_CURVE_H
                                                                  diff -Nru qcustomplot-1.1.0/documentation/html/item-ellipse_8h_source.html qcustomplot-1.2.0/documentation/html/item-ellipse_8h_source.html --- qcustomplot-1.1.0/documentation/html/item-ellipse_8h_source.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/item-ellipse_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -26,7 +26,7 @@
                                                                  1 /***************************************************************************
                                                                  2 ** **
                                                                  3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                                  -
                                                                  4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
                                                                  +
                                                                  4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                                  5 ** **
                                                                  6 ** This program is free software: you can redistribute it and/or modify **
                                                                  7 ** it under the terms of the GNU General Public License as published by **
                                                                  @@ -44,8 +44,8 @@
                                                                  19 ****************************************************************************
                                                                  20 ** Author: Emanuel Eichhammer **
                                                                  21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                                  -
                                                                  22 ** Date: 04.11.13 **
                                                                  -
                                                                  23 ** Version: 1.1.0 **
                                                                  +
                                                                  22 ** Date: 14.03.14 **
                                                                  +
                                                                  23 ** Version: 1.2.0 **
                                                                  24 ****************************************************************************/
                                                                  25 
                                                                  26 #ifndef QCP_ITEM_ELLIPSE_H
                                                                  diff -Nru qcustomplot-1.1.0/documentation/html/item-line_8h_source.html qcustomplot-1.2.0/documentation/html/item-line_8h_source.html --- qcustomplot-1.1.0/documentation/html/item-line_8h_source.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/item-line_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -26,7 +26,7 @@
                                                                  1 /***************************************************************************
                                                                  2 ** **
                                                                  3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                                  -
                                                                  4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
                                                                  +
                                                                  4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                                  5 ** **
                                                                  6 ** This program is free software: you can redistribute it and/or modify **
                                                                  7 ** it under the terms of the GNU General Public License as published by **
                                                                  @@ -44,8 +44,8 @@
                                                                  19 ****************************************************************************
                                                                  20 ** Author: Emanuel Eichhammer **
                                                                  21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                                  -
                                                                  22 ** Date: 04.11.13 **
                                                                  -
                                                                  23 ** Version: 1.1.0 **
                                                                  +
                                                                  22 ** Date: 14.03.14 **
                                                                  +
                                                                  23 ** Version: 1.2.0 **
                                                                  24 ****************************************************************************/
                                                                  25 
                                                                  26 #ifndef QCP_ITEM_LINE_H
                                                                  diff -Nru qcustomplot-1.1.0/documentation/html/item-pixmap_8h_source.html qcustomplot-1.2.0/documentation/html/item-pixmap_8h_source.html --- qcustomplot-1.1.0/documentation/html/item-pixmap_8h_source.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/item-pixmap_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -26,7 +26,7 @@
                                                                  1 /***************************************************************************
                                                                  2 ** **
                                                                  3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                                  -
                                                                  4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
                                                                  +
                                                                  4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                                  5 ** **
                                                                  6 ** This program is free software: you can redistribute it and/or modify **
                                                                  7 ** it under the terms of the GNU General Public License as published by **
                                                                  @@ -44,8 +44,8 @@
                                                                  19 ****************************************************************************
                                                                  20 ** Author: Emanuel Eichhammer **
                                                                  21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                                  -
                                                                  22 ** Date: 04.11.13 **
                                                                  -
                                                                  23 ** Version: 1.1.0 **
                                                                  +
                                                                  22 ** Date: 14.03.14 **
                                                                  +
                                                                  23 ** Version: 1.2.0 **
                                                                  24 ****************************************************************************/
                                                                  25 
                                                                  26 #ifndef QCP_ITEM_PIXMAP_H
                                                                  diff -Nru qcustomplot-1.1.0/documentation/html/item-rect_8h_source.html qcustomplot-1.2.0/documentation/html/item-rect_8h_source.html --- qcustomplot-1.1.0/documentation/html/item-rect_8h_source.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/item-rect_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -26,7 +26,7 @@
                                                                  1 /***************************************************************************
                                                                  2 ** **
                                                                  3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                                  -
                                                                  4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
                                                                  +
                                                                  4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                                  5 ** **
                                                                  6 ** This program is free software: you can redistribute it and/or modify **
                                                                  7 ** it under the terms of the GNU General Public License as published by **
                                                                  @@ -44,8 +44,8 @@
                                                                  19 ****************************************************************************
                                                                  20 ** Author: Emanuel Eichhammer **
                                                                  21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                                  -
                                                                  22 ** Date: 04.11.13 **
                                                                  -
                                                                  23 ** Version: 1.1.0 **
                                                                  +
                                                                  22 ** Date: 14.03.14 **
                                                                  +
                                                                  23 ** Version: 1.2.0 **
                                                                  24 ****************************************************************************/
                                                                  25 
                                                                  26 #ifndef QCP_ITEM_RECT_H
                                                                  diff -Nru qcustomplot-1.1.0/documentation/html/item-straightline_8h_source.html qcustomplot-1.2.0/documentation/html/item-straightline_8h_source.html --- qcustomplot-1.1.0/documentation/html/item-straightline_8h_source.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/item-straightline_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -26,7 +26,7 @@
                                                                  1 /***************************************************************************
                                                                  2 ** **
                                                                  3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                                  -
                                                                  4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
                                                                  +
                                                                  4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                                  5 ** **
                                                                  6 ** This program is free software: you can redistribute it and/or modify **
                                                                  7 ** it under the terms of the GNU General Public License as published by **
                                                                  @@ -44,8 +44,8 @@
                                                                  19 ****************************************************************************
                                                                  20 ** Author: Emanuel Eichhammer **
                                                                  21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                                  -
                                                                  22 ** Date: 04.11.13 **
                                                                  -
                                                                  23 ** Version: 1.1.0 **
                                                                  +
                                                                  22 ** Date: 14.03.14 **
                                                                  +
                                                                  23 ** Version: 1.2.0 **
                                                                  24 ****************************************************************************/
                                                                  25 
                                                                  26 #ifndef QCP_ITEM_STRAIGHTLINE_H
                                                                  diff -Nru qcustomplot-1.1.0/documentation/html/item-text_8h_source.html qcustomplot-1.2.0/documentation/html/item-text_8h_source.html --- qcustomplot-1.1.0/documentation/html/item-text_8h_source.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/item-text_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -26,7 +26,7 @@
                                                                  1 /***************************************************************************
                                                                  2 ** **
                                                                  3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                                  -
                                                                  4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
                                                                  +
                                                                  4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                                  5 ** **
                                                                  6 ** This program is free software: you can redistribute it and/or modify **
                                                                  7 ** it under the terms of the GNU General Public License as published by **
                                                                  @@ -44,8 +44,8 @@
                                                                  19 ****************************************************************************
                                                                  20 ** Author: Emanuel Eichhammer **
                                                                  21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                                  -
                                                                  22 ** Date: 04.11.13 **
                                                                  -
                                                                  23 ** Version: 1.1.0 **
                                                                  +
                                                                  22 ** Date: 14.03.14 **
                                                                  +
                                                                  23 ** Version: 1.2.0 **
                                                                  24 ****************************************************************************/
                                                                  25 
                                                                  26 #ifndef QCP_ITEM_TEXT_H
                                                                  diff -Nru qcustomplot-1.1.0/documentation/html/item-tracer_8h_source.html qcustomplot-1.2.0/documentation/html/item-tracer_8h_source.html --- qcustomplot-1.1.0/documentation/html/item-tracer_8h_source.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/item-tracer_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -26,7 +26,7 @@
                                                                  1 /***************************************************************************
                                                                  2 ** **
                                                                  3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                                  -
                                                                  4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
                                                                  +
                                                                  4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                                  5 ** **
                                                                  6 ** This program is free software: you can redistribute it and/or modify **
                                                                  7 ** it under the terms of the GNU General Public License as published by **
                                                                  @@ -44,8 +44,8 @@
                                                                  19 ****************************************************************************
                                                                  20 ** Author: Emanuel Eichhammer **
                                                                  21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                                  -
                                                                  22 ** Date: 04.11.13 **
                                                                  -
                                                                  23 ** Version: 1.1.0 **
                                                                  +
                                                                  22 ** Date: 14.03.14 **
                                                                  +
                                                                  23 ** Version: 1.2.0 **
                                                                  24 ****************************************************************************/
                                                                  25 
                                                                  26 #ifndef QCP_ITEM_TRACER_H
                                                                  diff -Nru qcustomplot-1.1.0/documentation/html/layer_8h_source.html qcustomplot-1.2.0/documentation/html/layer_8h_source.html --- qcustomplot-1.1.0/documentation/html/layer_8h_source.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/layer_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -26,7 +26,7 @@
                                                                  1 /***************************************************************************
                                                                  2 ** **
                                                                  3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                                  -
                                                                  4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
                                                                  +
                                                                  4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                                  5 ** **
                                                                  6 ** This program is free software: you can redistribute it and/or modify **
                                                                  7 ** it under the terms of the GNU General Public License as published by **
                                                                  @@ -44,8 +44,8 @@
                                                                  19 ****************************************************************************
                                                                  20 ** Author: Emanuel Eichhammer **
                                                                  21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                                  -
                                                                  22 ** Date: 04.11.13 **
                                                                  -
                                                                  23 ** Version: 1.1.0 **
                                                                  +
                                                                  22 ** Date: 14.03.14 **
                                                                  +
                                                                  23 ** Version: 1.2.0 **
                                                                  24 ****************************************************************************/
                                                                  25 
                                                                  26 #ifndef QCP_LAYER_H
                                                                  @@ -66,97 +66,106 @@
                                                                  42  Q_PROPERTY(QString name READ name)
                                                                  43  Q_PROPERTY(int index READ index)
                                                                  44  Q_PROPERTY(QList<QCPLayerable*> children READ children)
                                                                  -
                                                                  46 public:
                                                                  -
                                                                  47  QCPLayer(QCustomPlot* parentPlot, const QString &layerName);
                                                                  -
                                                                  48  ~QCPLayer();
                                                                  -
                                                                  49 
                                                                  -
                                                                  50  // getters:
                                                                  -
                                                                  51  QCustomPlot *parentPlot() const { return mParentPlot; }
                                                                  -
                                                                  52  QString name() const { return mName; }
                                                                  -
                                                                  53  int index() const { return mIndex; }
                                                                  -
                                                                  54  QList<QCPLayerable*> children() const { return mChildren; }
                                                                  -
                                                                  55 
                                                                  -
                                                                  56 protected:
                                                                  -
                                                                  57  // property members:
                                                                  -
                                                                  58  QCustomPlot *mParentPlot;
                                                                  -
                                                                  59  QString mName;
                                                                  -
                                                                  60  int mIndex;
                                                                  -
                                                                  61  QList<QCPLayerable*> mChildren;
                                                                  -
                                                                  62 
                                                                  -
                                                                  63  // non-virtual methods:
                                                                  -
                                                                  64  void addChild(QCPLayerable *layerable, bool prepend);
                                                                  -
                                                                  65  void removeChild(QCPLayerable *layerable);
                                                                  -
                                                                  66 
                                                                  -
                                                                  67 private:
                                                                  -
                                                                  68  Q_DISABLE_COPY(QCPLayer)
                                                                  -
                                                                  69 
                                                                  -
                                                                  70  friend class QCustomPlot;
                                                                  -
                                                                  71  friend class QCPLayerable;
                                                                  -
                                                                  72 };
                                                                  -
                                                                  73 
                                                                  -
                                                                  74 class QCP_LIB_DECL QCPLayerable : public QObject
                                                                  -
                                                                  75 {
                                                                  -
                                                                  76  Q_OBJECT
                                                                  -
                                                                  78  Q_PROPERTY(bool visible READ visible WRITE setVisible)
                                                                  -
                                                                  79  Q_PROPERTY(QCustomPlot* parentPlot READ parentPlot)
                                                                  -
                                                                  80  Q_PROPERTY(QCPLayerable* parentLayerable READ parentLayerable)
                                                                  -
                                                                  81  Q_PROPERTY(QCPLayer* layer READ layer WRITE setLayer)
                                                                  -
                                                                  82  Q_PROPERTY(bool antialiased READ antialiased WRITE setAntialiased)
                                                                  -
                                                                  84 public:
                                                                  -
                                                                  85  QCPLayerable(QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0);
                                                                  -
                                                                  86  ~QCPLayerable();
                                                                  -
                                                                  87 
                                                                  -
                                                                  88  // getters:
                                                                  -
                                                                  89  bool visible() const { return mVisible; }
                                                                  -
                                                                  90  QCustomPlot *parentPlot() const { return mParentPlot; }
                                                                  -
                                                                  91  QCPLayerable *parentLayerable() const { return mParentLayerable.data(); }
                                                                  -
                                                                  92  QCPLayer *layer() const { return mLayer; }
                                                                  -
                                                                  93  bool antialiased() const { return mAntialiased; }
                                                                  -
                                                                  94 
                                                                  -
                                                                  95  // setters:
                                                                  -
                                                                  96  void setVisible(bool on);
                                                                  -
                                                                  97  bool setLayer(QCPLayer *layer);
                                                                  -
                                                                  98  bool setLayer(const QString &layerName);
                                                                  -
                                                                  99  void setAntialiased(bool enabled);
                                                                  +
                                                                  45  Q_PROPERTY(bool visible READ visible WRITE setVisible)
                                                                  +
                                                                  47 public:
                                                                  +
                                                                  48  QCPLayer(QCustomPlot* parentPlot, const QString &layerName);
                                                                  +
                                                                  49  ~QCPLayer();
                                                                  +
                                                                  50 
                                                                  +
                                                                  51  // getters:
                                                                  +
                                                                  52  QCustomPlot *parentPlot() const { return mParentPlot; }
                                                                  +
                                                                  53  QString name() const { return mName; }
                                                                  +
                                                                  54  int index() const { return mIndex; }
                                                                  +
                                                                  55  QList<QCPLayerable*> children() const { return mChildren; }
                                                                  +
                                                                  56  bool visible() const { return mVisible; }
                                                                  +
                                                                  57 
                                                                  +
                                                                  58  // setters:
                                                                  +
                                                                  59  void setVisible(bool visible);
                                                                  +
                                                                  60 
                                                                  +
                                                                  61 protected:
                                                                  +
                                                                  62  // property members:
                                                                  +
                                                                  63  QCustomPlot *mParentPlot;
                                                                  +
                                                                  64  QString mName;
                                                                  +
                                                                  65  int mIndex;
                                                                  +
                                                                  66  QList<QCPLayerable*> mChildren;
                                                                  +
                                                                  67  bool mVisible;
                                                                  +
                                                                  68 
                                                                  +
                                                                  69  // non-virtual methods:
                                                                  +
                                                                  70  void addChild(QCPLayerable *layerable, bool prepend);
                                                                  +
                                                                  71  void removeChild(QCPLayerable *layerable);
                                                                  +
                                                                  72 
                                                                  +
                                                                  73 private:
                                                                  +
                                                                  74  Q_DISABLE_COPY(QCPLayer)
                                                                  +
                                                                  75 
                                                                  +
                                                                  76  friend class QCustomPlot;
                                                                  +
                                                                  77  friend class QCPLayerable;
                                                                  +
                                                                  78 };
                                                                  +
                                                                  79 
                                                                  +
                                                                  80 class QCP_LIB_DECL QCPLayerable : public QObject
                                                                  +
                                                                  81 {
                                                                  +
                                                                  82  Q_OBJECT
                                                                  +
                                                                  84  Q_PROPERTY(bool visible READ visible WRITE setVisible)
                                                                  +
                                                                  85  Q_PROPERTY(QCustomPlot* parentPlot READ parentPlot)
                                                                  +
                                                                  86  Q_PROPERTY(QCPLayerable* parentLayerable READ parentLayerable)
                                                                  +
                                                                  87  Q_PROPERTY(QCPLayer* layer READ layer WRITE setLayer NOTIFY layerChanged)
                                                                  +
                                                                  88  Q_PROPERTY(bool antialiased READ antialiased WRITE setAntialiased)
                                                                  +
                                                                  90 public:
                                                                  +
                                                                  91  QCPLayerable(QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0);
                                                                  +
                                                                  92  ~QCPLayerable();
                                                                  +
                                                                  93 
                                                                  +
                                                                  94  // getters:
                                                                  +
                                                                  95  bool visible() const { return mVisible; }
                                                                  +
                                                                  96  QCustomPlot *parentPlot() const { return mParentPlot; }
                                                                  +
                                                                  97  QCPLayerable *parentLayerable() const { return mParentLayerable.data(); }
                                                                  +
                                                                  98  QCPLayer *layer() const { return mLayer; }
                                                                  +
                                                                  99  bool antialiased() const { return mAntialiased; }
                                                                  100 
                                                                  -
                                                                  101  // introduced virtual methods:
                                                                  -
                                                                  102  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
                                                                  -
                                                                  103 
                                                                  -
                                                                  104  // non-property methods:
                                                                  -
                                                                  105  bool realVisibility() const;
                                                                  +
                                                                  101  // setters:
                                                                  +
                                                                  102  void setVisible(bool on);
                                                                  +
                                                                  103  Q_SLOT bool setLayer(QCPLayer *layer);
                                                                  +
                                                                  104  bool setLayer(const QString &layerName);
                                                                  +
                                                                  105  void setAntialiased(bool enabled);
                                                                  106 
                                                                  -
                                                                  107 protected:
                                                                  -
                                                                  108  // property members:
                                                                  -
                                                                  109  bool mVisible;
                                                                  -
                                                                  110  QCustomPlot *mParentPlot;
                                                                  -
                                                                  111  QPointer<QCPLayerable> mParentLayerable;
                                                                  -
                                                                  112  QCPLayer *mLayer;
                                                                  -
                                                                  113  bool mAntialiased;
                                                                  -
                                                                  114 
                                                                  -
                                                                  115  // introduced virtual methods:
                                                                  -
                                                                  116  virtual void parentPlotInitialized(QCustomPlot *parentPlot);
                                                                  -
                                                                  117  virtual QCP::Interaction selectionCategory() const;
                                                                  -
                                                                  118  virtual QRect clipRect() const;
                                                                  -
                                                                  119  virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const = 0;
                                                                  -
                                                                  120  virtual void draw(QCPPainter *painter) = 0;
                                                                  -
                                                                  121  // events:
                                                                  -
                                                                  122  virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
                                                                  -
                                                                  123  virtual void deselectEvent(bool *selectionStateChanged);
                                                                  -
                                                                  124 
                                                                  -
                                                                  125  // non-property methods:
                                                                  -
                                                                  126  void initializeParentPlot(QCustomPlot *parentPlot);
                                                                  -
                                                                  127  void setParentLayerable(QCPLayerable* parentLayerable);
                                                                  -
                                                                  128  bool moveToLayer(QCPLayer *layer, bool prepend);
                                                                  -
                                                                  129  void applyAntialiasingHint(QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const;
                                                                  -
                                                                  130 
                                                                  -
                                                                  131 private:
                                                                  -
                                                                  132  Q_DISABLE_COPY(QCPLayerable)
                                                                  +
                                                                  107  // introduced virtual methods:
                                                                  +
                                                                  108  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
                                                                  +
                                                                  109 
                                                                  +
                                                                  110  // non-property methods:
                                                                  +
                                                                  111  bool realVisibility() const;
                                                                  +
                                                                  112 
                                                                  +
                                                                  113 signals:
                                                                  +
                                                                  114  void layerChanged(QCPLayer *newLayer);
                                                                  +
                                                                  115 
                                                                  +
                                                                  116 protected:
                                                                  +
                                                                  117  // property members:
                                                                  +
                                                                  118  bool mVisible;
                                                                  +
                                                                  119  QCustomPlot *mParentPlot;
                                                                  +
                                                                  120  QPointer<QCPLayerable> mParentLayerable;
                                                                  +
                                                                  121  QCPLayer *mLayer;
                                                                  +
                                                                  122  bool mAntialiased;
                                                                  +
                                                                  123 
                                                                  +
                                                                  124  // introduced virtual methods:
                                                                  +
                                                                  125  virtual void parentPlotInitialized(QCustomPlot *parentPlot);
                                                                  +
                                                                  126  virtual QCP::Interaction selectionCategory() const;
                                                                  +
                                                                  127  virtual QRect clipRect() const;
                                                                  +
                                                                  128  virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const = 0;
                                                                  +
                                                                  129  virtual void draw(QCPPainter *painter) = 0;
                                                                  +
                                                                  130  // events:
                                                                  +
                                                                  131  virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
                                                                  +
                                                                  132  virtual void deselectEvent(bool *selectionStateChanged);
                                                                  133 
                                                                  -
                                                                  134  friend class QCustomPlot;
                                                                  -
                                                                  135  friend class QCPAxisRect;
                                                                  -
                                                                  136 };
                                                                  -
                                                                  137 
                                                                  -
                                                                  138 #endif // QCP_LAYER_H
                                                                  +
                                                                  134  // non-property methods:
                                                                  +
                                                                  135  void initializeParentPlot(QCustomPlot *parentPlot);
                                                                  +
                                                                  136  void setParentLayerable(QCPLayerable* parentLayerable);
                                                                  +
                                                                  137  bool moveToLayer(QCPLayer *layer, bool prepend);
                                                                  +
                                                                  138  void applyAntialiasingHint(QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const;
                                                                  +
                                                                  139 
                                                                  +
                                                                  140 private:
                                                                  +
                                                                  141  Q_DISABLE_COPY(QCPLayerable)
                                                                  +
                                                                  142 
                                                                  +
                                                                  143  friend class QCustomPlot;
                                                                  +
                                                                  144  friend class QCPAxisRect;
                                                                  +
                                                                  145 };
                                                                  +
                                                                  146 
                                                                  +
                                                                  147 #endif // QCP_LAYER_H
                                                                  diff -Nru qcustomplot-1.1.0/documentation/html/layout_8h_source.html qcustomplot-1.2.0/documentation/html/layout_8h_source.html --- qcustomplot-1.1.0/documentation/html/layout_8h_source.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/layout_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -26,7 +26,7 @@
                                                                  1 /***************************************************************************
                                                                  2 ** **
                                                                  3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                                  -
                                                                  4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
                                                                  +
                                                                  4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                                  5 ** **
                                                                  6 ** This program is free software: you can redistribute it and/or modify **
                                                                  7 ** it under the terms of the GNU General Public License as published by **
                                                                  @@ -44,8 +44,8 @@
                                                                  19 ****************************************************************************
                                                                  20 ** Author: Emanuel Eichhammer **
                                                                  21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                                  -
                                                                  22 ** Date: 04.11.13 **
                                                                  -
                                                                  23 ** Version: 1.1.0 **
                                                                  +
                                                                  22 ** Date: 14.03.14 **
                                                                  +
                                                                  23 ** Version: 1.2.0 **
                                                                  24 ****************************************************************************/
                                                                  25 
                                                                  26 #ifndef QCP_LAYOUT_H
                                                                  @@ -98,221 +98,227 @@
                                                                  74  Q_PROPERTY(QSize minimumSize READ minimumSize WRITE setMinimumSize)
                                                                  75  Q_PROPERTY(QSize maximumSize READ maximumSize WRITE setMaximumSize)
                                                                  77 public:
                                                                  -
                                                                  78  explicit QCPLayoutElement(QCustomPlot *parentPlot=0);
                                                                  -
                                                                  79  virtual ~QCPLayoutElement();
                                                                  -
                                                                  80 
                                                                  -
                                                                  81  // getters:
                                                                  -
                                                                  82  QCPLayout *layout() const { return mParentLayout; }
                                                                  -
                                                                  83  QRect rect() const { return mRect; }
                                                                  -
                                                                  84  QRect outerRect() const { return mOuterRect; }
                                                                  -
                                                                  85  QMargins margins() const { return mMargins; }
                                                                  -
                                                                  86  QMargins minimumMargins() const { return mMinimumMargins; }
                                                                  -
                                                                  87  QCP::MarginSides autoMargins() const { return mAutoMargins; }
                                                                  -
                                                                  88  QSize minimumSize() const { return mMinimumSize; }
                                                                  -
                                                                  89  QSize maximumSize() const { return mMaximumSize; }
                                                                  -
                                                                  90  QCPMarginGroup *marginGroup(QCP::MarginSide side) const { return mMarginGroups.value(side, (QCPMarginGroup*)0); }
                                                                  -
                                                                  91  QHash<QCP::MarginSide, QCPMarginGroup*> marginGroups() const { return mMarginGroups; }
                                                                  -
                                                                  92 
                                                                  -
                                                                  93  // setters:
                                                                  -
                                                                  94  void setOuterRect(const QRect &rect);
                                                                  -
                                                                  95  void setMargins(const QMargins &margins);
                                                                  -
                                                                  96  void setMinimumMargins(const QMargins &margins);
                                                                  -
                                                                  97  void setAutoMargins(QCP::MarginSides sides);
                                                                  -
                                                                  98  void setMinimumSize(const QSize &size);
                                                                  -
                                                                  99  void setMinimumSize(int width, int height);
                                                                  -
                                                                  100  void setMaximumSize(const QSize &size);
                                                                  -
                                                                  101  void setMaximumSize(int width, int height);
                                                                  -
                                                                  102  void setMarginGroup(QCP::MarginSides sides, QCPMarginGroup *group);
                                                                  -
                                                                  103 
                                                                  -
                                                                  104  // introduced virtual methods:
                                                                  -
                                                                  105  virtual void update();
                                                                  -
                                                                  106  virtual QSize minimumSizeHint() const;
                                                                  -
                                                                  107  virtual QSize maximumSizeHint() const;
                                                                  -
                                                                  108  virtual QList<QCPLayoutElement*> elements(bool recursive) const;
                                                                  -
                                                                  109 
                                                                  -
                                                                  110  // reimplemented virtual methods:
                                                                  -
                                                                  111  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
                                                                  -
                                                                  112 
                                                                  -
                                                                  113 protected:
                                                                  -
                                                                  114  // property members:
                                                                  -
                                                                  115  QCPLayout *mParentLayout;
                                                                  -
                                                                  116  QSize mMinimumSize, mMaximumSize;
                                                                  -
                                                                  117  QRect mRect, mOuterRect;
                                                                  -
                                                                  118  QMargins mMargins, mMinimumMargins;
                                                                  -
                                                                  119  QCP::MarginSides mAutoMargins;
                                                                  -
                                                                  120  QHash<QCP::MarginSide, QCPMarginGroup*> mMarginGroups;
                                                                  -
                                                                  121 
                                                                  -
                                                                  122  // introduced virtual methods:
                                                                  -
                                                                  123  virtual int calculateAutoMargin(QCP::MarginSide side);
                                                                  -
                                                                  124  // events:
                                                                  -
                                                                  125  virtual void mousePressEvent(QMouseEvent *event) {Q_UNUSED(event)}
                                                                  -
                                                                  126  virtual void mouseMoveEvent(QMouseEvent *event) {Q_UNUSED(event)}
                                                                  -
                                                                  127  virtual void mouseReleaseEvent(QMouseEvent *event) {Q_UNUSED(event)}
                                                                  -
                                                                  128  virtual void mouseDoubleClickEvent(QMouseEvent *event) {Q_UNUSED(event)}
                                                                  -
                                                                  129  virtual void wheelEvent(QWheelEvent *event) {Q_UNUSED(event)}
                                                                  -
                                                                  130 
                                                                  -
                                                                  131  // reimplemented virtual methods:
                                                                  -
                                                                  132  virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const { Q_UNUSED(painter) }
                                                                  -
                                                                  133  virtual void draw(QCPPainter *painter) { Q_UNUSED(painter) }
                                                                  -
                                                                  134  virtual void parentPlotInitialized(QCustomPlot *parentPlot);
                                                                  -
                                                                  135 
                                                                  -
                                                                  136 private:
                                                                  -
                                                                  137  Q_DISABLE_COPY(QCPLayoutElement)
                                                                  -
                                                                  138 
                                                                  -
                                                                  139  friend class QCustomPlot;
                                                                  -
                                                                  140  friend class QCPLayout;
                                                                  -
                                                                  141  friend class QCPMarginGroup;
                                                                  -
                                                                  142 };
                                                                  -
                                                                  143 
                                                                  -
                                                                  144 
                                                                  -
                                                                  145 class QCP_LIB_DECL QCPLayout : public QCPLayoutElement
                                                                  -
                                                                  146 {
                                                                  -
                                                                  147  Q_OBJECT
                                                                  -
                                                                  148 public:
                                                                  -
                                                                  149  explicit QCPLayout();
                                                                  -
                                                                  150 
                                                                  -
                                                                  151  // reimplemented virtual methods:
                                                                  -
                                                                  152  virtual void update();
                                                                  -
                                                                  153  virtual QList<QCPLayoutElement*> elements(bool recursive) const;
                                                                  -
                                                                  154 
                                                                  -
                                                                  155  // introduced virtual methods:
                                                                  -
                                                                  156  virtual int elementCount() const = 0;
                                                                  -
                                                                  157  virtual QCPLayoutElement* elementAt(int index) const = 0;
                                                                  -
                                                                  158  virtual QCPLayoutElement* takeAt(int index) = 0;
                                                                  -
                                                                  159  virtual bool take(QCPLayoutElement* element) = 0;
                                                                  -
                                                                  160  virtual void simplify();
                                                                  -
                                                                  161 
                                                                  -
                                                                  162  // non-virtual methods:
                                                                  -
                                                                  163  bool removeAt(int index);
                                                                  -
                                                                  164  bool remove(QCPLayoutElement* element);
                                                                  -
                                                                  165  void clear();
                                                                  -
                                                                  166 
                                                                  -
                                                                  167 protected:
                                                                  -
                                                                  168  // introduced virtual methods:
                                                                  -
                                                                  169  virtual void updateLayout();
                                                                  -
                                                                  170 
                                                                  -
                                                                  171  // non-virtual methods:
                                                                  -
                                                                  172  void sizeConstraintsChanged() const;
                                                                  -
                                                                  173  void adoptElement(QCPLayoutElement *el);
                                                                  -
                                                                  174  void releaseElement(QCPLayoutElement *el);
                                                                  -
                                                                  175  QVector<int> getSectionSizes(QVector<int> maxSizes, QVector<int> minSizes, QVector<double> stretchFactors, int totalSize) const;
                                                                  +
                                                                  82  enum UpdatePhase { upPreparation
                                                                  +
                                                                  83  ,upMargins
                                                                  +
                                                                  84  ,upLayout
                                                                  +
                                                                  85  };
                                                                  +
                                                                  86  Q_ENUMS(UpdatePhase)
                                                                  +
                                                                  87 
                                                                  +
                                                                  88  explicit QCPLayoutElement(QCustomPlot *parentPlot=0);
                                                                  +
                                                                  89  virtual ~QCPLayoutElement();
                                                                  +
                                                                  90 
                                                                  +
                                                                  91  // getters:
                                                                  +
                                                                  92  QCPLayout *layout() const { return mParentLayout; }
                                                                  +
                                                                  93  QRect rect() const { return mRect; }
                                                                  +
                                                                  94  QRect outerRect() const { return mOuterRect; }
                                                                  +
                                                                  95  QMargins margins() const { return mMargins; }
                                                                  +
                                                                  96  QMargins minimumMargins() const { return mMinimumMargins; }
                                                                  +
                                                                  97  QCP::MarginSides autoMargins() const { return mAutoMargins; }
                                                                  +
                                                                  98  QSize minimumSize() const { return mMinimumSize; }
                                                                  +
                                                                  99  QSize maximumSize() const { return mMaximumSize; }
                                                                  +
                                                                  100  QCPMarginGroup *marginGroup(QCP::MarginSide side) const { return mMarginGroups.value(side, (QCPMarginGroup*)0); }
                                                                  +
                                                                  101  QHash<QCP::MarginSide, QCPMarginGroup*> marginGroups() const { return mMarginGroups; }
                                                                  +
                                                                  102 
                                                                  +
                                                                  103  // setters:
                                                                  +
                                                                  104  void setOuterRect(const QRect &rect);
                                                                  +
                                                                  105  void setMargins(const QMargins &margins);
                                                                  +
                                                                  106  void setMinimumMargins(const QMargins &margins);
                                                                  +
                                                                  107  void setAutoMargins(QCP::MarginSides sides);
                                                                  +
                                                                  108  void setMinimumSize(const QSize &size);
                                                                  +
                                                                  109  void setMinimumSize(int width, int height);
                                                                  +
                                                                  110  void setMaximumSize(const QSize &size);
                                                                  +
                                                                  111  void setMaximumSize(int width, int height);
                                                                  +
                                                                  112  void setMarginGroup(QCP::MarginSides sides, QCPMarginGroup *group);
                                                                  +
                                                                  113 
                                                                  +
                                                                  114  // introduced virtual methods:
                                                                  +
                                                                  115  virtual void update(UpdatePhase phase);
                                                                  +
                                                                  116  virtual QSize minimumSizeHint() const;
                                                                  +
                                                                  117  virtual QSize maximumSizeHint() const;
                                                                  +
                                                                  118  virtual QList<QCPLayoutElement*> elements(bool recursive) const;
                                                                  +
                                                                  119 
                                                                  +
                                                                  120  // reimplemented virtual methods:
                                                                  +
                                                                  121  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
                                                                  +
                                                                  122 
                                                                  +
                                                                  123 protected:
                                                                  +
                                                                  124  // property members:
                                                                  +
                                                                  125  QCPLayout *mParentLayout;
                                                                  +
                                                                  126  QSize mMinimumSize, mMaximumSize;
                                                                  +
                                                                  127  QRect mRect, mOuterRect;
                                                                  +
                                                                  128  QMargins mMargins, mMinimumMargins;
                                                                  +
                                                                  129  QCP::MarginSides mAutoMargins;
                                                                  +
                                                                  130  QHash<QCP::MarginSide, QCPMarginGroup*> mMarginGroups;
                                                                  +
                                                                  131 
                                                                  +
                                                                  132  // introduced virtual methods:
                                                                  +
                                                                  133  virtual int calculateAutoMargin(QCP::MarginSide side);
                                                                  +
                                                                  134  // events:
                                                                  +
                                                                  135  virtual void mousePressEvent(QMouseEvent *event) {Q_UNUSED(event)}
                                                                  +
                                                                  136  virtual void mouseMoveEvent(QMouseEvent *event) {Q_UNUSED(event)}
                                                                  +
                                                                  137  virtual void mouseReleaseEvent(QMouseEvent *event) {Q_UNUSED(event)}
                                                                  +
                                                                  138  virtual void mouseDoubleClickEvent(QMouseEvent *event) {Q_UNUSED(event)}
                                                                  +
                                                                  139  virtual void wheelEvent(QWheelEvent *event) {Q_UNUSED(event)}
                                                                  +
                                                                  140 
                                                                  +
                                                                  141  // reimplemented virtual methods:
                                                                  +
                                                                  142  virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const { Q_UNUSED(painter) }
                                                                  +
                                                                  143  virtual void draw(QCPPainter *painter) { Q_UNUSED(painter) }
                                                                  +
                                                                  144  virtual void parentPlotInitialized(QCustomPlot *parentPlot);
                                                                  +
                                                                  145 
                                                                  +
                                                                  146 private:
                                                                  +
                                                                  147  Q_DISABLE_COPY(QCPLayoutElement)
                                                                  +
                                                                  148 
                                                                  +
                                                                  149  friend class QCustomPlot;
                                                                  +
                                                                  150  friend class QCPLayout;
                                                                  +
                                                                  151  friend class QCPMarginGroup;
                                                                  +
                                                                  152 };
                                                                  +
                                                                  153 
                                                                  +
                                                                  154 
                                                                  +
                                                                  155 class QCP_LIB_DECL QCPLayout : public QCPLayoutElement
                                                                  +
                                                                  156 {
                                                                  +
                                                                  157  Q_OBJECT
                                                                  +
                                                                  158 public:
                                                                  +
                                                                  159  explicit QCPLayout();
                                                                  +
                                                                  160 
                                                                  +
                                                                  161  // reimplemented virtual methods:
                                                                  +
                                                                  162  virtual void update(UpdatePhase phase);
                                                                  +
                                                                  163  virtual QList<QCPLayoutElement*> elements(bool recursive) const;
                                                                  +
                                                                  164 
                                                                  +
                                                                  165  // introduced virtual methods:
                                                                  +
                                                                  166  virtual int elementCount() const = 0;
                                                                  +
                                                                  167  virtual QCPLayoutElement* elementAt(int index) const = 0;
                                                                  +
                                                                  168  virtual QCPLayoutElement* takeAt(int index) = 0;
                                                                  +
                                                                  169  virtual bool take(QCPLayoutElement* element) = 0;
                                                                  +
                                                                  170  virtual void simplify();
                                                                  +
                                                                  171 
                                                                  +
                                                                  172  // non-virtual methods:
                                                                  +
                                                                  173  bool removeAt(int index);
                                                                  +
                                                                  174  bool remove(QCPLayoutElement* element);
                                                                  +
                                                                  175  void clear();
                                                                  176 
                                                                  -
                                                                  177 private:
                                                                  -
                                                                  178  Q_DISABLE_COPY(QCPLayout)
                                                                  -
                                                                  179  friend class QCPLayoutElement;
                                                                  -
                                                                  180 };
                                                                  -
                                                                  181 
                                                                  -
                                                                  182 
                                                                  -
                                                                  183 class QCP_LIB_DECL QCPLayoutGrid : public QCPLayout
                                                                  -
                                                                  184 {
                                                                  -
                                                                  185  Q_OBJECT
                                                                  -
                                                                  187  Q_PROPERTY(int rowCount READ rowCount)
                                                                  -
                                                                  188  Q_PROPERTY(int columnCount READ columnCount)
                                                                  -
                                                                  189  Q_PROPERTY(QList<double> columnStretchFactors READ columnStretchFactors WRITE setColumnStretchFactors)
                                                                  -
                                                                  190  Q_PROPERTY(QList<double> rowStretchFactors READ rowStretchFactors WRITE setRowStretchFactors)
                                                                  -
                                                                  191  Q_PROPERTY(int columnSpacing READ columnSpacing WRITE setColumnSpacing)
                                                                  -
                                                                  192  Q_PROPERTY(int rowSpacing READ rowSpacing WRITE setRowSpacing)
                                                                  -
                                                                  194 public:
                                                                  -
                                                                  195  explicit QCPLayoutGrid();
                                                                  -
                                                                  196  virtual ~QCPLayoutGrid();
                                                                  -
                                                                  197 
                                                                  -
                                                                  198  // getters:
                                                                  -
                                                                  199  int rowCount() const;
                                                                  -
                                                                  200  int columnCount() const;
                                                                  -
                                                                  201  QList<double> columnStretchFactors() const { return mColumnStretchFactors; }
                                                                  -
                                                                  202  QList<double> rowStretchFactors() const { return mRowStretchFactors; }
                                                                  -
                                                                  203  int columnSpacing() const { return mColumnSpacing; }
                                                                  -
                                                                  204  int rowSpacing() const { return mRowSpacing; }
                                                                  -
                                                                  205 
                                                                  -
                                                                  206  // setters:
                                                                  -
                                                                  207  void setColumnStretchFactor(int column, double factor);
                                                                  -
                                                                  208  void setColumnStretchFactors(const QList<double> &factors);
                                                                  -
                                                                  209  void setRowStretchFactor(int row, double factor);
                                                                  -
                                                                  210  void setRowStretchFactors(const QList<double> &factors);
                                                                  -
                                                                  211  void setColumnSpacing(int pixels);
                                                                  -
                                                                  212  void setRowSpacing(int pixels);
                                                                  -
                                                                  213 
                                                                  -
                                                                  214  // reimplemented virtual methods:
                                                                  -
                                                                  215  virtual void updateLayout();
                                                                  -
                                                                  216  virtual int elementCount() const;
                                                                  -
                                                                  217  virtual QCPLayoutElement* elementAt(int index) const;
                                                                  -
                                                                  218  virtual QCPLayoutElement* takeAt(int index);
                                                                  -
                                                                  219  virtual bool take(QCPLayoutElement* element);
                                                                  -
                                                                  220  virtual QList<QCPLayoutElement*> elements(bool recursive) const;
                                                                  -
                                                                  221  virtual void simplify();
                                                                  -
                                                                  222  virtual QSize minimumSizeHint() const;
                                                                  -
                                                                  223  virtual QSize maximumSizeHint() const;
                                                                  -
                                                                  224 
                                                                  -
                                                                  225  // non-virtual methods:
                                                                  -
                                                                  226  QCPLayoutElement *element(int row, int column) const;
                                                                  -
                                                                  227  bool addElement(int row, int column, QCPLayoutElement *element);
                                                                  -
                                                                  228  bool hasElement(int row, int column);
                                                                  -
                                                                  229  void expandTo(int newRowCount, int newColumnCount);
                                                                  -
                                                                  230  void insertRow(int newIndex);
                                                                  -
                                                                  231  void insertColumn(int newIndex);
                                                                  -
                                                                  232 
                                                                  -
                                                                  233 protected:
                                                                  -
                                                                  234  // property members:
                                                                  -
                                                                  235  QList<QList<QCPLayoutElement*> > mElements;
                                                                  -
                                                                  236  QList<double> mColumnStretchFactors;
                                                                  -
                                                                  237  QList<double> mRowStretchFactors;
                                                                  -
                                                                  238  int mColumnSpacing, mRowSpacing;
                                                                  -
                                                                  239 
                                                                  -
                                                                  240  // non-virtual methods:
                                                                  -
                                                                  241  void getMinimumRowColSizes(QVector<int> *minColWidths, QVector<int> *minRowHeights) const;
                                                                  -
                                                                  242  void getMaximumRowColSizes(QVector<int> *maxColWidths, QVector<int> *maxRowHeights) const;
                                                                  -
                                                                  243 
                                                                  -
                                                                  244 private:
                                                                  -
                                                                  245  Q_DISABLE_COPY(QCPLayoutGrid)
                                                                  -
                                                                  246 };
                                                                  -
                                                                  247 
                                                                  -
                                                                  248 
                                                                  -
                                                                  249 class QCP_LIB_DECL QCPLayoutInset : public QCPLayout
                                                                  -
                                                                  250 {
                                                                  -
                                                                  251  Q_OBJECT
                                                                  -
                                                                  252 public:
                                                                  -
                                                                  256  enum InsetPlacement {ipFree
                                                                  -
                                                                  257  ,ipBorderAligned
                                                                  -
                                                                  258  };
                                                                  -
                                                                  259 
                                                                  -
                                                                  260  explicit QCPLayoutInset();
                                                                  -
                                                                  261  virtual ~QCPLayoutInset();
                                                                  -
                                                                  262 
                                                                  -
                                                                  263  // getters:
                                                                  -
                                                                  264  InsetPlacement insetPlacement(int index) const;
                                                                  -
                                                                  265  Qt::Alignment insetAlignment(int index) const;
                                                                  -
                                                                  266  QRectF insetRect(int index) const;
                                                                  -
                                                                  267 
                                                                  -
                                                                  268  // setters:
                                                                  -
                                                                  269  void setInsetPlacement(int index, InsetPlacement placement);
                                                                  -
                                                                  270  void setInsetAlignment(int index, Qt::Alignment alignment);
                                                                  -
                                                                  271  void setInsetRect(int index, const QRectF &rect);
                                                                  +
                                                                  177 protected:
                                                                  +
                                                                  178  // introduced virtual methods:
                                                                  +
                                                                  179  virtual void updateLayout();
                                                                  +
                                                                  180 
                                                                  +
                                                                  181  // non-virtual methods:
                                                                  +
                                                                  182  void sizeConstraintsChanged() const;
                                                                  +
                                                                  183  void adoptElement(QCPLayoutElement *el);
                                                                  +
                                                                  184  void releaseElement(QCPLayoutElement *el);
                                                                  +
                                                                  185  QVector<int> getSectionSizes(QVector<int> maxSizes, QVector<int> minSizes, QVector<double> stretchFactors, int totalSize) const;
                                                                  +
                                                                  186 
                                                                  +
                                                                  187 private:
                                                                  +
                                                                  188  Q_DISABLE_COPY(QCPLayout)
                                                                  +
                                                                  189  friend class QCPLayoutElement;
                                                                  +
                                                                  190 };
                                                                  +
                                                                  191 
                                                                  +
                                                                  192 
                                                                  +
                                                                  193 class QCP_LIB_DECL QCPLayoutGrid : public QCPLayout
                                                                  +
                                                                  194 {
                                                                  +
                                                                  195  Q_OBJECT
                                                                  +
                                                                  197  Q_PROPERTY(int rowCount READ rowCount)
                                                                  +
                                                                  198  Q_PROPERTY(int columnCount READ columnCount)
                                                                  +
                                                                  199  Q_PROPERTY(QList<double> columnStretchFactors READ columnStretchFactors WRITE setColumnStretchFactors)
                                                                  +
                                                                  200  Q_PROPERTY(QList<double> rowStretchFactors READ rowStretchFactors WRITE setRowStretchFactors)
                                                                  +
                                                                  201  Q_PROPERTY(int columnSpacing READ columnSpacing WRITE setColumnSpacing)
                                                                  +
                                                                  202  Q_PROPERTY(int rowSpacing READ rowSpacing WRITE setRowSpacing)
                                                                  +
                                                                  204 public:
                                                                  +
                                                                  205  explicit QCPLayoutGrid();
                                                                  +
                                                                  206  virtual ~QCPLayoutGrid();
                                                                  +
                                                                  207 
                                                                  +
                                                                  208  // getters:
                                                                  +
                                                                  209  int rowCount() const;
                                                                  +
                                                                  210  int columnCount() const;
                                                                  +
                                                                  211  QList<double> columnStretchFactors() const { return mColumnStretchFactors; }
                                                                  +
                                                                  212  QList<double> rowStretchFactors() const { return mRowStretchFactors; }
                                                                  +
                                                                  213  int columnSpacing() const { return mColumnSpacing; }
                                                                  +
                                                                  214  int rowSpacing() const { return mRowSpacing; }
                                                                  +
                                                                  215 
                                                                  +
                                                                  216  // setters:
                                                                  +
                                                                  217  void setColumnStretchFactor(int column, double factor);
                                                                  +
                                                                  218  void setColumnStretchFactors(const QList<double> &factors);
                                                                  +
                                                                  219  void setRowStretchFactor(int row, double factor);
                                                                  +
                                                                  220  void setRowStretchFactors(const QList<double> &factors);
                                                                  +
                                                                  221  void setColumnSpacing(int pixels);
                                                                  +
                                                                  222  void setRowSpacing(int pixels);
                                                                  +
                                                                  223 
                                                                  +
                                                                  224  // reimplemented virtual methods:
                                                                  +
                                                                  225  virtual void updateLayout();
                                                                  +
                                                                  226  virtual int elementCount() const;
                                                                  +
                                                                  227  virtual QCPLayoutElement* elementAt(int index) const;
                                                                  +
                                                                  228  virtual QCPLayoutElement* takeAt(int index);
                                                                  +
                                                                  229  virtual bool take(QCPLayoutElement* element);
                                                                  +
                                                                  230  virtual QList<QCPLayoutElement*> elements(bool recursive) const;
                                                                  +
                                                                  231  virtual void simplify();
                                                                  +
                                                                  232  virtual QSize minimumSizeHint() const;
                                                                  +
                                                                  233  virtual QSize maximumSizeHint() const;
                                                                  +
                                                                  234 
                                                                  +
                                                                  235  // non-virtual methods:
                                                                  +
                                                                  236  QCPLayoutElement *element(int row, int column) const;
                                                                  +
                                                                  237  bool addElement(int row, int column, QCPLayoutElement *element);
                                                                  +
                                                                  238  bool hasElement(int row, int column);
                                                                  +
                                                                  239  void expandTo(int newRowCount, int newColumnCount);
                                                                  +
                                                                  240  void insertRow(int newIndex);
                                                                  +
                                                                  241  void insertColumn(int newIndex);
                                                                  +
                                                                  242 
                                                                  +
                                                                  243 protected:
                                                                  +
                                                                  244  // property members:
                                                                  +
                                                                  245  QList<QList<QCPLayoutElement*> > mElements;
                                                                  +
                                                                  246  QList<double> mColumnStretchFactors;
                                                                  +
                                                                  247  QList<double> mRowStretchFactors;
                                                                  +
                                                                  248  int mColumnSpacing, mRowSpacing;
                                                                  +
                                                                  249 
                                                                  +
                                                                  250  // non-virtual methods:
                                                                  +
                                                                  251  void getMinimumRowColSizes(QVector<int> *minColWidths, QVector<int> *minRowHeights) const;
                                                                  +
                                                                  252  void getMaximumRowColSizes(QVector<int> *maxColWidths, QVector<int> *maxRowHeights) const;
                                                                  +
                                                                  253 
                                                                  +
                                                                  254 private:
                                                                  +
                                                                  255  Q_DISABLE_COPY(QCPLayoutGrid)
                                                                  +
                                                                  256 };
                                                                  +
                                                                  257 
                                                                  +
                                                                  258 
                                                                  +
                                                                  259 class QCP_LIB_DECL QCPLayoutInset : public QCPLayout
                                                                  +
                                                                  260 {
                                                                  +
                                                                  261  Q_OBJECT
                                                                  +
                                                                  262 public:
                                                                  +
                                                                  266  enum InsetPlacement { ipFree
                                                                  +
                                                                  267  ,ipBorderAligned
                                                                  +
                                                                  268  };
                                                                  +
                                                                  269 
                                                                  +
                                                                  270  explicit QCPLayoutInset();
                                                                  +
                                                                  271  virtual ~QCPLayoutInset();
                                                                  272 
                                                                  -
                                                                  273  // reimplemented virtual methods:
                                                                  -
                                                                  274  virtual void updateLayout();
                                                                  -
                                                                  275  virtual int elementCount() const;
                                                                  -
                                                                  276  virtual QCPLayoutElement* elementAt(int index) const;
                                                                  -
                                                                  277  virtual QCPLayoutElement* takeAt(int index);
                                                                  -
                                                                  278  virtual bool take(QCPLayoutElement* element);
                                                                  -
                                                                  279  virtual void simplify() {}
                                                                  -
                                                                  280  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
                                                                  -
                                                                  281 
                                                                  -
                                                                  282  // non-virtual methods:
                                                                  -
                                                                  283  void addElement(QCPLayoutElement *element, Qt::Alignment alignment);
                                                                  -
                                                                  284  void addElement(QCPLayoutElement *element, const QRectF &rect);
                                                                  -
                                                                  285 
                                                                  -
                                                                  286 protected:
                                                                  -
                                                                  287  // property members:
                                                                  -
                                                                  288  QList<QCPLayoutElement*> mElements;
                                                                  -
                                                                  289  QList<InsetPlacement> mInsetPlacement;
                                                                  -
                                                                  290  QList<Qt::Alignment> mInsetAlignment;
                                                                  -
                                                                  291  QList<QRectF> mInsetRect;
                                                                  -
                                                                  292 
                                                                  -
                                                                  293 private:
                                                                  -
                                                                  294  Q_DISABLE_COPY(QCPLayoutInset)
                                                                  -
                                                                  295 };
                                                                  -
                                                                  296 
                                                                  -
                                                                  297 #endif // QCP_LAYOUT_H
                                                                  +
                                                                  273  // getters:
                                                                  +
                                                                  274  InsetPlacement insetPlacement(int index) const;
                                                                  +
                                                                  275  Qt::Alignment insetAlignment(int index) const;
                                                                  +
                                                                  276  QRectF insetRect(int index) const;
                                                                  +
                                                                  277 
                                                                  +
                                                                  278  // setters:
                                                                  +
                                                                  279  void setInsetPlacement(int index, InsetPlacement placement);
                                                                  +
                                                                  280  void setInsetAlignment(int index, Qt::Alignment alignment);
                                                                  +
                                                                  281  void setInsetRect(int index, const QRectF &rect);
                                                                  +
                                                                  282 
                                                                  +
                                                                  283  // reimplemented virtual methods:
                                                                  +
                                                                  284  virtual void updateLayout();
                                                                  +
                                                                  285  virtual int elementCount() const;
                                                                  +
                                                                  286  virtual QCPLayoutElement* elementAt(int index) const;
                                                                  +
                                                                  287  virtual QCPLayoutElement* takeAt(int index);
                                                                  +
                                                                  288  virtual bool take(QCPLayoutElement* element);
                                                                  +
                                                                  289  virtual void simplify() {}
                                                                  +
                                                                  290  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
                                                                  +
                                                                  291 
                                                                  +
                                                                  292  // non-virtual methods:
                                                                  +
                                                                  293  void addElement(QCPLayoutElement *element, Qt::Alignment alignment);
                                                                  +
                                                                  294  void addElement(QCPLayoutElement *element, const QRectF &rect);
                                                                  +
                                                                  295 
                                                                  +
                                                                  296 protected:
                                                                  +
                                                                  297  // property members:
                                                                  +
                                                                  298  QList<QCPLayoutElement*> mElements;
                                                                  +
                                                                  299  QList<InsetPlacement> mInsetPlacement;
                                                                  +
                                                                  300  QList<Qt::Alignment> mInsetAlignment;
                                                                  +
                                                                  301  QList<QRectF> mInsetRect;
                                                                  +
                                                                  302 
                                                                  +
                                                                  303 private:
                                                                  +
                                                                  304  Q_DISABLE_COPY(QCPLayoutInset)
                                                                  +
                                                                  305 };
                                                                  +
                                                                  306 
                                                                  +
                                                                  307 #endif // QCP_LAYOUT_H
                                                                  diff -Nru qcustomplot-1.1.0/documentation/html/layoutelement-axisrect_8h_source.html qcustomplot-1.2.0/documentation/html/layoutelement-axisrect_8h_source.html --- qcustomplot-1.1.0/documentation/html/layoutelement-axisrect_8h_source.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/layoutelement-axisrect_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -26,7 +26,7 @@
                                                                  1 /***************************************************************************
                                                                  2 ** **
                                                                  3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                                  -
                                                                  4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
                                                                  +
                                                                  4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                                  5 ** **
                                                                  6 ** This program is free software: you can redistribute it and/or modify **
                                                                  7 ** it under the terms of the GNU General Public License as published by **
                                                                  @@ -44,8 +44,8 @@
                                                                  19 ****************************************************************************
                                                                  20 ** Author: Emanuel Eichhammer **
                                                                  21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                                  -
                                                                  22 ** Date: 04.11.13 **
                                                                  -
                                                                  23 ** Version: 1.1.0 **
                                                                  +
                                                                  22 ** Date: 14.03.14 **
                                                                  +
                                                                  23 ** Version: 1.2.0 **
                                                                  24 ****************************************************************************/
                                                                  25 
                                                                  26 #ifndef QCP_LAYOUTELEMENT_AXISRECT_H
                                                                  @@ -60,7 +60,7 @@
                                                                  35 class QCPAxis;
                                                                  37 class QCPGraph;
                                                                  -
                                                                  38 class QCPAbstractItem;
                                                                  +
                                                                  38 class QCPAbstractItem;
                                                                  39 
                                                                  40 class QCP_LIB_DECL QCPAxisRect : public QCPLayoutElement
                                                                  41 {
                                                                  @@ -127,7 +127,7 @@
                                                                  104  QPoint center() const { return mRect.center(); }
                                                                  105 
                                                                  106  // reimplemented virtual methods:
                                                                  -
                                                                  107  virtual void update();
                                                                  +
                                                                  107  virtual void update(UpdatePhase phase);
                                                                  108  virtual QList<QCPLayoutElement*> elements(bool recursive) const;
                                                                  109 
                                                                  110 protected:
                                                                  diff -Nru qcustomplot-1.1.0/documentation/html/layoutelement-colorscale_8h_source.html qcustomplot-1.2.0/documentation/html/layoutelement-colorscale_8h_source.html --- qcustomplot-1.1.0/documentation/html/layoutelement-colorscale_8h_source.html 1970-01-01 00:00:00.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/layoutelement-colorscale_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -0,0 +1,169 @@ + + + + +src/layoutelements/layoutelement-colorscale.h Source File + + + + + + +
                                                                  +
                                                                  +
                                                                  +
                                                                  layoutelement-colorscale.h
                                                                  +
                                                                  +
                                                                  +
                                                                  1 /***************************************************************************
                                                                  +
                                                                  2 ** **
                                                                  +
                                                                  3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                                  +
                                                                  4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                                  +
                                                                  5 ** **
                                                                  +
                                                                  6 ** This program is free software: you can redistribute it and/or modify **
                                                                  +
                                                                  7 ** it under the terms of the GNU General Public License as published by **
                                                                  +
                                                                  8 ** the Free Software Foundation, either version 3 of the License, or **
                                                                  +
                                                                  9 ** (at your option) any later version. **
                                                                  +
                                                                  10 ** **
                                                                  +
                                                                  11 ** This program is distributed in the hope that it will be useful, **
                                                                  +
                                                                  12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of **
                                                                  +
                                                                  13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
                                                                  +
                                                                  14 ** GNU General Public License for more details. **
                                                                  +
                                                                  15 ** **
                                                                  +
                                                                  16 ** You should have received a copy of the GNU General Public License **
                                                                  +
                                                                  17 ** along with this program. If not, see http://www.gnu.org/licenses/. **
                                                                  +
                                                                  18 ** **
                                                                  +
                                                                  19 ****************************************************************************
                                                                  +
                                                                  20 ** Author: Emanuel Eichhammer **
                                                                  +
                                                                  21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                                  +
                                                                  22 ** Date: 14.03.14 **
                                                                  +
                                                                  23 ** Version: 1.2.0 **
                                                                  +
                                                                  24 ****************************************************************************/
                                                                  +
                                                                  25 
                                                                  +
                                                                  26 #ifndef QCP_LAYOUTELEMENT_COLORSCALE_H
                                                                  +
                                                                  27 #define QCP_LAYOUTELEMENT_COLORSCALE_H
                                                                  +
                                                                  28 
                                                                  +
                                                                  29 #include "../global.h"
                                                                  +
                                                                  30 #include "../axis.h"
                                                                  +
                                                                  31 #include "../layout.h"
                                                                  +
                                                                  32 #include "../colorgradient.h"
                                                                  +
                                                                  33 #include "../layoutelements/layoutelement-axisrect.h"
                                                                  +
                                                                  34 
                                                                  +
                                                                  35 class QCPPainter;
                                                                  +
                                                                  36 class QCustomPlot;
                                                                  +
                                                                  37 class QCPColorMap;
                                                                  +
                                                                  38 class QCPColorScale;
                                                                  +
                                                                  39 
                                                                  +
                                                                  40 
                                                                  +
                                                                  41 class QCPColorScaleAxisRectPrivate : public QCPAxisRect
                                                                  +
                                                                  42 {
                                                                  +
                                                                  43  Q_OBJECT
                                                                  +
                                                                  44 public:
                                                                  +
                                                                  45  explicit QCPColorScaleAxisRectPrivate(QCPColorScale *parentColorScale);
                                                                  +
                                                                  46 protected:
                                                                  +
                                                                  47  QCPColorScale *mParentColorScale;
                                                                  +
                                                                  48  QImage mGradientImage;
                                                                  +
                                                                  49  bool mGradientImageInvalidated;
                                                                  +
                                                                  50  // re-using some methods of QCPAxisRect to make them available to friend class QCPColorScale
                                                                  + + + + + +
                                                                  56  using QCPAxisRect::update;
                                                                  +
                                                                  57  virtual void draw(QCPPainter *painter);
                                                                  +
                                                                  58  void updateGradientImage();
                                                                  +
                                                                  59  Q_SLOT void axisSelectionChanged(QCPAxis::SelectableParts selectedParts);
                                                                  +
                                                                  60  Q_SLOT void axisSelectableChanged(QCPAxis::SelectableParts selectableParts);
                                                                  +
                                                                  61  friend class QCPColorScale;
                                                                  +
                                                                  62 };
                                                                  +
                                                                  63 
                                                                  +
                                                                  64 
                                                                  +
                                                                  65 class QCP_LIB_DECL QCPColorScale : public QCPLayoutElement
                                                                  +
                                                                  66 {
                                                                  +
                                                                  67  Q_OBJECT
                                                                  +
                                                                  69  Q_PROPERTY(QCPAxis::AxisType type READ type WRITE setType)
                                                                  +
                                                                  70  Q_PROPERTY(QCPRange dataRange READ dataRange WRITE setDataRange NOTIFY dataRangeChanged)
                                                                  +
                                                                  71  Q_PROPERTY(QCPAxis::ScaleType dataScaleType READ dataScaleType WRITE setDataScaleType NOTIFY dataScaleTypeChanged)
                                                                  +
                                                                  72  Q_PROPERTY(QCPColorGradient gradient READ gradient WRITE setGradient NOTIFY gradientChanged)
                                                                  +
                                                                  73  Q_PROPERTY(QString label READ label WRITE setLabel)
                                                                  +
                                                                  74  Q_PROPERTY(int barWidth READ barWidth WRITE setBarWidth)
                                                                  +
                                                                  75  Q_PROPERTY(bool rangeDrag READ rangeDrag WRITE setRangeDrag)
                                                                  +
                                                                  76  Q_PROPERTY(bool rangeZoom READ rangeZoom WRITE setRangeZoom)
                                                                  +
                                                                  78 public:
                                                                  +
                                                                  79  explicit QCPColorScale(QCustomPlot *parentPlot);
                                                                  +
                                                                  80  virtual ~QCPColorScale();
                                                                  +
                                                                  81 
                                                                  +
                                                                  82  // getters:
                                                                  +
                                                                  83  QCPAxis *axis() const { return mColorAxis.data(); }
                                                                  +
                                                                  84  QCPAxis::AxisType type() const { return mType; }
                                                                  +
                                                                  85  QCPRange dataRange() const { return mDataRange; }
                                                                  +
                                                                  86  QCPAxis::ScaleType dataScaleType() const { return mDataScaleType; }
                                                                  +
                                                                  87  QCPColorGradient gradient() const { return mGradient; }
                                                                  +
                                                                  88  QString label() const;
                                                                  +
                                                                  89  int barWidth () const { return mBarWidth; }
                                                                  +
                                                                  90  bool rangeDrag() const;
                                                                  +
                                                                  91  bool rangeZoom() const;
                                                                  +
                                                                  92 
                                                                  +
                                                                  93  // setters:
                                                                  +
                                                                  94  void setType(QCPAxis::AxisType type);
                                                                  +
                                                                  95  Q_SLOT void setDataRange(const QCPRange &dataRange);
                                                                  +
                                                                  96  Q_SLOT void setDataScaleType(QCPAxis::ScaleType scaleType);
                                                                  +
                                                                  97  Q_SLOT void setGradient(const QCPColorGradient &gradient);
                                                                  +
                                                                  98  void setLabel(const QString &str);
                                                                  +
                                                                  99  void setBarWidth(int width);
                                                                  +
                                                                  100  void setRangeDrag(bool enabled);
                                                                  +
                                                                  101  void setRangeZoom(bool enabled);
                                                                  +
                                                                  102 
                                                                  +
                                                                  103  // non-property methods:
                                                                  +
                                                                  104  QList<QCPColorMap*> colorMaps() const;
                                                                  +
                                                                  105  void rescaleDataRange(bool onlyVisibleMaps);
                                                                  +
                                                                  106 
                                                                  +
                                                                  107  // reimplemented virtual methods:
                                                                  +
                                                                  108  virtual void update(UpdatePhase phase);
                                                                  +
                                                                  109 
                                                                  +
                                                                  110 signals:
                                                                  +
                                                                  111  void dataRangeChanged(QCPRange newRange);
                                                                  +
                                                                  112  void dataScaleTypeChanged(QCPAxis::ScaleType scaleType);
                                                                  +
                                                                  113  void gradientChanged(QCPColorGradient newGradient);
                                                                  +
                                                                  114 
                                                                  +
                                                                  115 protected:
                                                                  +
                                                                  116  // property members:
                                                                  +
                                                                  117  QCPAxis::AxisType mType;
                                                                  +
                                                                  118  QCPRange mDataRange;
                                                                  +
                                                                  119  QCPAxis::ScaleType mDataScaleType;
                                                                  +
                                                                  120  QCPColorGradient mGradient;
                                                                  +
                                                                  121  int mBarWidth;
                                                                  +
                                                                  122 
                                                                  +
                                                                  123  // non-property members:
                                                                  +
                                                                  124  QPointer<QCPColorScaleAxisRectPrivate> mAxisRect;
                                                                  +
                                                                  125  QPointer<QCPAxis> mColorAxis;
                                                                  +
                                                                  126 
                                                                  +
                                                                  127  // reimplemented virtual methods:
                                                                  +
                                                                  128  virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
                                                                  +
                                                                  129  // events:
                                                                  +
                                                                  130  virtual void mousePressEvent(QMouseEvent *event);
                                                                  +
                                                                  131  virtual void mouseMoveEvent(QMouseEvent *event);
                                                                  +
                                                                  132  virtual void mouseReleaseEvent(QMouseEvent *event);
                                                                  +
                                                                  133  virtual void wheelEvent(QWheelEvent *event);
                                                                  +
                                                                  134 
                                                                  +
                                                                  135 private:
                                                                  +
                                                                  136  Q_DISABLE_COPY(QCPColorScale)
                                                                  +
                                                                  137 
                                                                  +
                                                                  138  friend class QCPColorScaleAxisRectPrivate;
                                                                  +
                                                                  139 };
                                                                  +
                                                                  140 
                                                                  +
                                                                  141 
                                                                  +
                                                                  142 #endif // QCP_LAYOUTELEMENT_COLORSCALE_H
                                                                  +
                                                                  + + + diff -Nru qcustomplot-1.1.0/documentation/html/layoutelement-legend_8h_source.html qcustomplot-1.2.0/documentation/html/layoutelement-legend_8h_source.html --- qcustomplot-1.1.0/documentation/html/layoutelement-legend_8h_source.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/layoutelement-legend_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -26,7 +26,7 @@
                                                                  1 /***************************************************************************
                                                                  2 ** **
                                                                  3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                                  -
                                                                  4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
                                                                  +
                                                                  4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                                  5 ** **
                                                                  6 ** This program is free software: you can redistribute it and/or modify **
                                                                  7 ** it under the terms of the GNU General Public License as published by **
                                                                  @@ -44,8 +44,8 @@
                                                                  19 ****************************************************************************
                                                                  20 ** Author: Emanuel Eichhammer **
                                                                  21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                                  -
                                                                  22 ** Date: 04.11.13 **
                                                                  -
                                                                  23 ** Version: 1.1.0 **
                                                                  +
                                                                  22 ** Date: 14.03.14 **
                                                                  +
                                                                  23 ** Version: 1.2.0 **
                                                                  24 ****************************************************************************/
                                                                  25 
                                                                  26 #ifndef QCP_LAYOUTELEMENT_LEGEND_H
                                                                  @@ -68,8 +68,8 @@
                                                                  44  Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor)
                                                                  45  Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont)
                                                                  46  Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor)
                                                                  -
                                                                  47  Q_PROPERTY(bool selectable READ selectable WRITE setSelectable)
                                                                  -
                                                                  48  Q_PROPERTY(bool selected READ selected WRITE setSelected)
                                                                  +
                                                                  47  Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectionChanged)
                                                                  +
                                                                  48  Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectableChanged)
                                                                  50 public:
                                                                  51  explicit QCPAbstractLegendItem(QCPLegend *parent);
                                                                  52 
                                                                  @@ -87,180 +87,182 @@
                                                                  64  void setTextColor(const QColor &color);
                                                                  65  void setSelectedFont(const QFont &font);
                                                                  66  void setSelectedTextColor(const QColor &color);
                                                                  -
                                                                  67  void setSelectable(bool selectable);
                                                                  -
                                                                  68  void setSelected(bool selected);
                                                                  +
                                                                  67  Q_SLOT void setSelectable(bool selectable);
                                                                  +
                                                                  68  Q_SLOT void setSelected(bool selected);
                                                                  69 
                                                                  70  // reimplemented virtual methods:
                                                                  71  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
                                                                  72 
                                                                  73 signals:
                                                                  74  void selectionChanged(bool selected);
                                                                  -
                                                                  75 
                                                                  -
                                                                  76 protected:
                                                                  -
                                                                  77  // property members:
                                                                  -
                                                                  78  QCPLegend *mParentLegend;
                                                                  -
                                                                  79  QFont mFont;
                                                                  -
                                                                  80  QColor mTextColor;
                                                                  -
                                                                  81  QFont mSelectedFont;
                                                                  -
                                                                  82  QColor mSelectedTextColor;
                                                                  -
                                                                  83  bool mSelectable, mSelected;
                                                                  -
                                                                  84 
                                                                  -
                                                                  85  // reimplemented virtual methods:
                                                                  -
                                                                  86  virtual QCP::Interaction selectionCategory() const;
                                                                  -
                                                                  87  virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
                                                                  -
                                                                  88  virtual QRect clipRect() const;
                                                                  -
                                                                  89  virtual void draw(QCPPainter *painter) = 0;
                                                                  -
                                                                  90  // events:
                                                                  -
                                                                  91  virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
                                                                  -
                                                                  92  virtual void deselectEvent(bool *selectionStateChanged);
                                                                  -
                                                                  93 
                                                                  -
                                                                  94 private:
                                                                  -
                                                                  95  Q_DISABLE_COPY(QCPAbstractLegendItem)
                                                                  -
                                                                  96 
                                                                  -
                                                                  97  friend class QCPLegend;
                                                                  -
                                                                  98 };
                                                                  -
                                                                  99 
                                                                  +
                                                                  75  void selectableChanged(bool selectable);
                                                                  +
                                                                  76 
                                                                  +
                                                                  77 protected:
                                                                  +
                                                                  78  // property members:
                                                                  +
                                                                  79  QCPLegend *mParentLegend;
                                                                  +
                                                                  80  QFont mFont;
                                                                  +
                                                                  81  QColor mTextColor;
                                                                  +
                                                                  82  QFont mSelectedFont;
                                                                  +
                                                                  83  QColor mSelectedTextColor;
                                                                  +
                                                                  84  bool mSelectable, mSelected;
                                                                  +
                                                                  85 
                                                                  +
                                                                  86  // reimplemented virtual methods:
                                                                  +
                                                                  87  virtual QCP::Interaction selectionCategory() const;
                                                                  +
                                                                  88  virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
                                                                  +
                                                                  89  virtual QRect clipRect() const;
                                                                  +
                                                                  90  virtual void draw(QCPPainter *painter) = 0;
                                                                  +
                                                                  91  // events:
                                                                  +
                                                                  92  virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
                                                                  +
                                                                  93  virtual void deselectEvent(bool *selectionStateChanged);
                                                                  +
                                                                  94 
                                                                  +
                                                                  95 private:
                                                                  +
                                                                  96  Q_DISABLE_COPY(QCPAbstractLegendItem)
                                                                  +
                                                                  97 
                                                                  +
                                                                  98  friend class QCPLegend;
                                                                  +
                                                                  99 };
                                                                  100 
                                                                  - -
                                                                  102 {
                                                                  -
                                                                  103  Q_OBJECT
                                                                  -
                                                                  104 public:
                                                                  - -
                                                                  106 
                                                                  -
                                                                  107  // getters:
                                                                  -
                                                                  108  QCPAbstractPlottable *plottable() { return mPlottable; }
                                                                  -
                                                                  109 
                                                                  -
                                                                  110 protected:
                                                                  -
                                                                  111  // property members:
                                                                  -
                                                                  112  QCPAbstractPlottable *mPlottable;
                                                                  -
                                                                  113 
                                                                  -
                                                                  114  // reimplemented virtual methods:
                                                                  -
                                                                  115  virtual void draw(QCPPainter *painter);
                                                                  -
                                                                  116  virtual QSize minimumSizeHint() const;
                                                                  -
                                                                  117 
                                                                  -
                                                                  118  // non-virtual methods:
                                                                  -
                                                                  119  QPen getIconBorderPen() const;
                                                                  -
                                                                  120  QColor getTextColor() const;
                                                                  -
                                                                  121  QFont getFont() const;
                                                                  -
                                                                  122 };
                                                                  -
                                                                  123 
                                                                  +
                                                                  101 
                                                                  + +
                                                                  103 {
                                                                  +
                                                                  104  Q_OBJECT
                                                                  +
                                                                  105 public:
                                                                  + +
                                                                  107 
                                                                  +
                                                                  108  // getters:
                                                                  +
                                                                  109  QCPAbstractPlottable *plottable() { return mPlottable; }
                                                                  +
                                                                  110 
                                                                  +
                                                                  111 protected:
                                                                  +
                                                                  112  // property members:
                                                                  +
                                                                  113  QCPAbstractPlottable *mPlottable;
                                                                  +
                                                                  114 
                                                                  +
                                                                  115  // reimplemented virtual methods:
                                                                  +
                                                                  116  virtual void draw(QCPPainter *painter);
                                                                  +
                                                                  117  virtual QSize minimumSizeHint() const;
                                                                  +
                                                                  118 
                                                                  +
                                                                  119  // non-virtual methods:
                                                                  +
                                                                  120  QPen getIconBorderPen() const;
                                                                  +
                                                                  121  QColor getTextColor() const;
                                                                  +
                                                                  122  QFont getFont() const;
                                                                  +
                                                                  123 };
                                                                  124 
                                                                  -
                                                                  125 class QCP_LIB_DECL QCPLegend : public QCPLayoutGrid
                                                                  -
                                                                  126 {
                                                                  -
                                                                  127  Q_OBJECT
                                                                  -
                                                                  129  Q_PROPERTY(QPen borderPen READ borderPen WRITE setBorderPen)
                                                                  -
                                                                  130  Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
                                                                  -
                                                                  131  Q_PROPERTY(QFont font READ font WRITE setFont)
                                                                  -
                                                                  132  Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor)
                                                                  -
                                                                  133  Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
                                                                  -
                                                                  134  Q_PROPERTY(int iconTextPadding READ iconTextPadding WRITE setIconTextPadding)
                                                                  -
                                                                  135  Q_PROPERTY(QPen iconBorderPen READ iconBorderPen WRITE setIconBorderPen)
                                                                  -
                                                                  136  Q_PROPERTY(SelectableParts selectableParts READ selectableParts WRITE setSelectableParts)
                                                                  -
                                                                  137  Q_PROPERTY(SelectableParts selectedParts READ selectedParts WRITE setSelectedParts)
                                                                  -
                                                                  138  Q_PROPERTY(QPen selectedBorderPen READ selectedBorderPen WRITE setSelectedBorderPen)
                                                                  -
                                                                  139  Q_PROPERTY(QPen selectedIconBorderPen READ selectedIconBorderPen WRITE setSelectedIconBorderPen)
                                                                  -
                                                                  140  Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
                                                                  -
                                                                  141  Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont)
                                                                  -
                                                                  142  Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor)
                                                                  -
                                                                  144 public:
                                                                  -
                                                                  150  enum SelectablePart { spNone = 0x000
                                                                  -
                                                                  151  ,spLegendBox = 0x001
                                                                  -
                                                                  152  ,spItems = 0x002
                                                                  -
                                                                  153  };
                                                                  -
                                                                  154  Q_FLAGS(SelectablePart SelectableParts)
                                                                  -
                                                                  155  Q_DECLARE_FLAGS(SelectableParts, SelectablePart)
                                                                  -
                                                                  156 
                                                                  -
                                                                  157  explicit QCPLegend();
                                                                  -
                                                                  158  virtual ~QCPLegend();
                                                                  -
                                                                  159 
                                                                  -
                                                                  160  // getters:
                                                                  -
                                                                  161  QPen borderPen() const { return mBorderPen; }
                                                                  -
                                                                  162  QBrush brush() const { return mBrush; }
                                                                  -
                                                                  163  QFont font() const { return mFont; }
                                                                  -
                                                                  164  QColor textColor() const { return mTextColor; }
                                                                  -
                                                                  165  QSize iconSize() const { return mIconSize; }
                                                                  -
                                                                  166  int iconTextPadding() const { return mIconTextPadding; }
                                                                  -
                                                                  167  QPen iconBorderPen() const { return mIconBorderPen; }
                                                                  -
                                                                  168  SelectableParts selectableParts() const { return mSelectableParts; }
                                                                  -
                                                                  169  SelectableParts selectedParts() const;
                                                                  -
                                                                  170  QPen selectedBorderPen() const { return mSelectedBorderPen; }
                                                                  -
                                                                  171  QPen selectedIconBorderPen() const { return mSelectedIconBorderPen; }
                                                                  -
                                                                  172  QBrush selectedBrush() const { return mSelectedBrush; }
                                                                  -
                                                                  173  QFont selectedFont() const { return mSelectedFont; }
                                                                  -
                                                                  174  QColor selectedTextColor() const { return mSelectedTextColor; }
                                                                  -
                                                                  175 
                                                                  -
                                                                  176  // setters:
                                                                  -
                                                                  177  void setBorderPen(const QPen &pen);
                                                                  -
                                                                  178  void setBrush(const QBrush &brush);
                                                                  -
                                                                  179  void setFont(const QFont &font);
                                                                  -
                                                                  180  void setTextColor(const QColor &color);
                                                                  -
                                                                  181  void setIconSize(const QSize &size);
                                                                  -
                                                                  182  void setIconSize(int width, int height);
                                                                  -
                                                                  183  void setIconTextPadding(int padding);
                                                                  -
                                                                  184  void setIconBorderPen(const QPen &pen);
                                                                  -
                                                                  185  void setSelectableParts(const SelectableParts &selectableParts);
                                                                  -
                                                                  186  void setSelectedParts(const SelectableParts &selectedParts);
                                                                  -
                                                                  187  void setSelectedBorderPen(const QPen &pen);
                                                                  -
                                                                  188  void setSelectedIconBorderPen(const QPen &pen);
                                                                  -
                                                                  189  void setSelectedBrush(const QBrush &brush);
                                                                  -
                                                                  190  void setSelectedFont(const QFont &font);
                                                                  -
                                                                  191  void setSelectedTextColor(const QColor &color);
                                                                  -
                                                                  192 
                                                                  -
                                                                  193  // reimplemented virtual methods:
                                                                  -
                                                                  194  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
                                                                  -
                                                                  195 
                                                                  -
                                                                  196  // non-virtual methods:
                                                                  -
                                                                  197  QCPAbstractLegendItem *item(int index) const;
                                                                  -
                                                                  198  QCPPlottableLegendItem *itemWithPlottable(const QCPAbstractPlottable *plottable) const;
                                                                  -
                                                                  199  int itemCount() const;
                                                                  -
                                                                  200  bool hasItem(QCPAbstractLegendItem *item) const;
                                                                  -
                                                                  201  bool hasItemWithPlottable(const QCPAbstractPlottable *plottable) const;
                                                                  -
                                                                  202  bool addItem(QCPAbstractLegendItem *item);
                                                                  -
                                                                  203  bool removeItem(int index);
                                                                  -
                                                                  204  bool removeItem(QCPAbstractLegendItem *item);
                                                                  -
                                                                  205  void clearItems();
                                                                  -
                                                                  206  QList<QCPAbstractLegendItem*> selectedItems() const;
                                                                  -
                                                                  207 
                                                                  -
                                                                  208 signals:
                                                                  -
                                                                  209  void selectionChanged(QCPLegend::SelectableParts selection);
                                                                  -
                                                                  210 
                                                                  -
                                                                  211 protected:
                                                                  -
                                                                  212  // property members:
                                                                  -
                                                                  213  QPen mBorderPen, mIconBorderPen;
                                                                  -
                                                                  214  QBrush mBrush;
                                                                  -
                                                                  215  QFont mFont;
                                                                  -
                                                                  216  QColor mTextColor;
                                                                  -
                                                                  217  QSize mIconSize;
                                                                  -
                                                                  218  int mIconTextPadding;
                                                                  -
                                                                  219  SelectableParts mSelectedParts, mSelectableParts;
                                                                  -
                                                                  220  QPen mSelectedBorderPen, mSelectedIconBorderPen;
                                                                  -
                                                                  221  QBrush mSelectedBrush;
                                                                  -
                                                                  222  QFont mSelectedFont;
                                                                  -
                                                                  223  QColor mSelectedTextColor;
                                                                  -
                                                                  224 
                                                                  -
                                                                  225  // reimplemented virtual methods:
                                                                  -
                                                                  226  virtual void parentPlotInitialized(QCustomPlot *parentPlot);
                                                                  -
                                                                  227  virtual QCP::Interaction selectionCategory() const;
                                                                  -
                                                                  228  virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
                                                                  -
                                                                  229  virtual void draw(QCPPainter *painter);
                                                                  -
                                                                  230  // events:
                                                                  -
                                                                  231  virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
                                                                  -
                                                                  232  virtual void deselectEvent(bool *selectionStateChanged);
                                                                  -
                                                                  233 
                                                                  -
                                                                  234  // non-virtual methods:
                                                                  -
                                                                  235  QPen getBorderPen() const;
                                                                  -
                                                                  236  QBrush getBrush() const;
                                                                  -
                                                                  237 
                                                                  -
                                                                  238 private:
                                                                  -
                                                                  239  Q_DISABLE_COPY(QCPLegend)
                                                                  -
                                                                  240 
                                                                  -
                                                                  241  friend class QCustomPlot;
                                                                  -
                                                                  242  friend class QCPAbstractLegendItem;
                                                                  -
                                                                  243 };
                                                                  -
                                                                  244 Q_DECLARE_OPERATORS_FOR_FLAGS(QCPLegend::SelectableParts)
                                                                  -
                                                                  245 Q_DECLARE_METATYPE(QCPLegend::SelectablePart)
                                                                  -
                                                                  246 
                                                                  -
                                                                  247 #endif // QCP_LAYOUTELEMENT_LEGEND_H
                                                                  +
                                                                  125 
                                                                  +
                                                                  126 class QCP_LIB_DECL QCPLegend : public QCPLayoutGrid
                                                                  +
                                                                  127 {
                                                                  +
                                                                  128  Q_OBJECT
                                                                  +
                                                                  130  Q_PROPERTY(QPen borderPen READ borderPen WRITE setBorderPen)
                                                                  +
                                                                  131  Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
                                                                  +
                                                                  132  Q_PROPERTY(QFont font READ font WRITE setFont)
                                                                  +
                                                                  133  Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor)
                                                                  +
                                                                  134  Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
                                                                  +
                                                                  135  Q_PROPERTY(int iconTextPadding READ iconTextPadding WRITE setIconTextPadding)
                                                                  +
                                                                  136  Q_PROPERTY(QPen iconBorderPen READ iconBorderPen WRITE setIconBorderPen)
                                                                  +
                                                                  137  Q_PROPERTY(SelectableParts selectableParts READ selectableParts WRITE setSelectableParts NOTIFY selectionChanged)
                                                                  +
                                                                  138  Q_PROPERTY(SelectableParts selectedParts READ selectedParts WRITE setSelectedParts NOTIFY selectableChanged)
                                                                  +
                                                                  139  Q_PROPERTY(QPen selectedBorderPen READ selectedBorderPen WRITE setSelectedBorderPen)
                                                                  +
                                                                  140  Q_PROPERTY(QPen selectedIconBorderPen READ selectedIconBorderPen WRITE setSelectedIconBorderPen)
                                                                  +
                                                                  141  Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
                                                                  +
                                                                  142  Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont)
                                                                  +
                                                                  143  Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor)
                                                                  +
                                                                  145 public:
                                                                  +
                                                                  151  enum SelectablePart { spNone = 0x000
                                                                  +
                                                                  152  ,spLegendBox = 0x001
                                                                  +
                                                                  153  ,spItems = 0x002
                                                                  +
                                                                  154  };
                                                                  +
                                                                  155  Q_FLAGS(SelectablePart SelectableParts)
                                                                  +
                                                                  156  Q_DECLARE_FLAGS(SelectableParts, SelectablePart)
                                                                  +
                                                                  157 
                                                                  +
                                                                  158  explicit QCPLegend();
                                                                  +
                                                                  159  virtual ~QCPLegend();
                                                                  +
                                                                  160 
                                                                  +
                                                                  161  // getters:
                                                                  +
                                                                  162  QPen borderPen() const { return mBorderPen; }
                                                                  +
                                                                  163  QBrush brush() const { return mBrush; }
                                                                  +
                                                                  164  QFont font() const { return mFont; }
                                                                  +
                                                                  165  QColor textColor() const { return mTextColor; }
                                                                  +
                                                                  166  QSize iconSize() const { return mIconSize; }
                                                                  +
                                                                  167  int iconTextPadding() const { return mIconTextPadding; }
                                                                  +
                                                                  168  QPen iconBorderPen() const { return mIconBorderPen; }
                                                                  +
                                                                  169  SelectableParts selectableParts() const { return mSelectableParts; }
                                                                  +
                                                                  170  SelectableParts selectedParts() const;
                                                                  +
                                                                  171  QPen selectedBorderPen() const { return mSelectedBorderPen; }
                                                                  +
                                                                  172  QPen selectedIconBorderPen() const { return mSelectedIconBorderPen; }
                                                                  +
                                                                  173  QBrush selectedBrush() const { return mSelectedBrush; }
                                                                  +
                                                                  174  QFont selectedFont() const { return mSelectedFont; }
                                                                  +
                                                                  175  QColor selectedTextColor() const { return mSelectedTextColor; }
                                                                  +
                                                                  176 
                                                                  +
                                                                  177  // setters:
                                                                  +
                                                                  178  void setBorderPen(const QPen &pen);
                                                                  +
                                                                  179  void setBrush(const QBrush &brush);
                                                                  +
                                                                  180  void setFont(const QFont &font);
                                                                  +
                                                                  181  void setTextColor(const QColor &color);
                                                                  +
                                                                  182  void setIconSize(const QSize &size);
                                                                  +
                                                                  183  void setIconSize(int width, int height);
                                                                  +
                                                                  184  void setIconTextPadding(int padding);
                                                                  +
                                                                  185  void setIconBorderPen(const QPen &pen);
                                                                  +
                                                                  186  Q_SLOT void setSelectableParts(const SelectableParts &selectableParts);
                                                                  +
                                                                  187  Q_SLOT void setSelectedParts(const SelectableParts &selectedParts);
                                                                  +
                                                                  188  void setSelectedBorderPen(const QPen &pen);
                                                                  +
                                                                  189  void setSelectedIconBorderPen(const QPen &pen);
                                                                  +
                                                                  190  void setSelectedBrush(const QBrush &brush);
                                                                  +
                                                                  191  void setSelectedFont(const QFont &font);
                                                                  +
                                                                  192  void setSelectedTextColor(const QColor &color);
                                                                  +
                                                                  193 
                                                                  +
                                                                  194  // reimplemented virtual methods:
                                                                  +
                                                                  195  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
                                                                  +
                                                                  196 
                                                                  +
                                                                  197  // non-virtual methods:
                                                                  +
                                                                  198  QCPAbstractLegendItem *item(int index) const;
                                                                  +
                                                                  199  QCPPlottableLegendItem *itemWithPlottable(const QCPAbstractPlottable *plottable) const;
                                                                  +
                                                                  200  int itemCount() const;
                                                                  +
                                                                  201  bool hasItem(QCPAbstractLegendItem *item) const;
                                                                  +
                                                                  202  bool hasItemWithPlottable(const QCPAbstractPlottable *plottable) const;
                                                                  +
                                                                  203  bool addItem(QCPAbstractLegendItem *item);
                                                                  +
                                                                  204  bool removeItem(int index);
                                                                  +
                                                                  205  bool removeItem(QCPAbstractLegendItem *item);
                                                                  +
                                                                  206  void clearItems();
                                                                  +
                                                                  207  QList<QCPAbstractLegendItem*> selectedItems() const;
                                                                  +
                                                                  208 
                                                                  +
                                                                  209 signals:
                                                                  +
                                                                  210  void selectionChanged(QCPLegend::SelectableParts parts);
                                                                  +
                                                                  211  void selectableChanged(QCPLegend::SelectableParts parts);
                                                                  +
                                                                  212 
                                                                  +
                                                                  213 protected:
                                                                  +
                                                                  214  // property members:
                                                                  +
                                                                  215  QPen mBorderPen, mIconBorderPen;
                                                                  +
                                                                  216  QBrush mBrush;
                                                                  +
                                                                  217  QFont mFont;
                                                                  +
                                                                  218  QColor mTextColor;
                                                                  +
                                                                  219  QSize mIconSize;
                                                                  +
                                                                  220  int mIconTextPadding;
                                                                  +
                                                                  221  SelectableParts mSelectedParts, mSelectableParts;
                                                                  +
                                                                  222  QPen mSelectedBorderPen, mSelectedIconBorderPen;
                                                                  +
                                                                  223  QBrush mSelectedBrush;
                                                                  +
                                                                  224  QFont mSelectedFont;
                                                                  +
                                                                  225  QColor mSelectedTextColor;
                                                                  +
                                                                  226 
                                                                  +
                                                                  227  // reimplemented virtual methods:
                                                                  +
                                                                  228  virtual void parentPlotInitialized(QCustomPlot *parentPlot);
                                                                  +
                                                                  229  virtual QCP::Interaction selectionCategory() const;
                                                                  +
                                                                  230  virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
                                                                  +
                                                                  231  virtual void draw(QCPPainter *painter);
                                                                  +
                                                                  232  // events:
                                                                  +
                                                                  233  virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
                                                                  +
                                                                  234  virtual void deselectEvent(bool *selectionStateChanged);
                                                                  +
                                                                  235 
                                                                  +
                                                                  236  // non-virtual methods:
                                                                  +
                                                                  237  QPen getBorderPen() const;
                                                                  +
                                                                  238  QBrush getBrush() const;
                                                                  +
                                                                  239 
                                                                  +
                                                                  240 private:
                                                                  +
                                                                  241  Q_DISABLE_COPY(QCPLegend)
                                                                  +
                                                                  242 
                                                                  +
                                                                  243  friend class QCustomPlot;
                                                                  +
                                                                  244  friend class QCPAbstractLegendItem;
                                                                  +
                                                                  245 };
                                                                  +
                                                                  246 Q_DECLARE_OPERATORS_FOR_FLAGS(QCPLegend::SelectableParts)
                                                                  +
                                                                  247 Q_DECLARE_METATYPE(QCPLegend::SelectablePart)
                                                                  +
                                                                  248 
                                                                  +
                                                                  249 #endif // QCP_LAYOUTELEMENT_LEGEND_H
                                                                  diff -Nru qcustomplot-1.1.0/documentation/html/layoutelement-plottitle_8h_source.html qcustomplot-1.2.0/documentation/html/layoutelement-plottitle_8h_source.html --- qcustomplot-1.1.0/documentation/html/layoutelement-plottitle_8h_source.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/layoutelement-plottitle_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -26,7 +26,7 @@
                                                                  1 /***************************************************************************
                                                                  2 ** **
                                                                  3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                                  -
                                                                  4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
                                                                  +
                                                                  4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                                  5 ** **
                                                                  6 ** This program is free software: you can redistribute it and/or modify **
                                                                  7 ** it under the terms of the GNU General Public License as published by **
                                                                  @@ -44,8 +44,8 @@
                                                                  19 ****************************************************************************
                                                                  20 ** Author: Emanuel Eichhammer **
                                                                  21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                                  -
                                                                  22 ** Date: 04.11.13 **
                                                                  -
                                                                  23 ** Version: 1.1.0 **
                                                                  +
                                                                  22 ** Date: 14.03.14 **
                                                                  +
                                                                  23 ** Version: 1.2.0 **
                                                                  24 ****************************************************************************/
                                                                  25 
                                                                  26 #ifndef QCP_LAYOUTELEMENT_PLOTTITLE_H
                                                                  @@ -66,8 +66,8 @@
                                                                  42  Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor)
                                                                  43  Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont)
                                                                  44  Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor)
                                                                  -
                                                                  45  Q_PROPERTY(bool selectable READ selectable WRITE setSelectable)
                                                                  -
                                                                  46  Q_PROPERTY(bool selected READ selected WRITE setSelected)
                                                                  +
                                                                  45  Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectableChanged)
                                                                  +
                                                                  46  Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectionChanged)
                                                                  48 public:
                                                                  49  explicit QCPPlotTitle(QCustomPlot *parentPlot);
                                                                  50  explicit QCPPlotTitle(QCustomPlot *parentPlot, const QString &text);
                                                                  @@ -87,45 +87,46 @@
                                                                  64  void setTextColor(const QColor &color);
                                                                  65  void setSelectedFont(const QFont &font);
                                                                  66  void setSelectedTextColor(const QColor &color);
                                                                  -
                                                                  67  void setSelectable(bool selectable);
                                                                  -
                                                                  68  void setSelected(bool selected);
                                                                  +
                                                                  67  Q_SLOT void setSelectable(bool selectable);
                                                                  +
                                                                  68  Q_SLOT void setSelected(bool selected);
                                                                  69 
                                                                  70  // reimplemented virtual methods:
                                                                  71  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
                                                                  72 
                                                                  73 signals:
                                                                  74  void selectionChanged(bool selected);
                                                                  -
                                                                  75 
                                                                  -
                                                                  76 protected:
                                                                  -
                                                                  77  // property members:
                                                                  -
                                                                  78  QString mText;
                                                                  -
                                                                  79  QFont mFont;
                                                                  -
                                                                  80  QColor mTextColor;
                                                                  -
                                                                  81  QFont mSelectedFont;
                                                                  -
                                                                  82  QColor mSelectedTextColor;
                                                                  -
                                                                  83  QRect mTextBoundingRect;
                                                                  -
                                                                  84  bool mSelectable, mSelected;
                                                                  -
                                                                  85 
                                                                  -
                                                                  86  // reimplemented virtual methods:
                                                                  -
                                                                  87  virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
                                                                  -
                                                                  88  virtual void draw(QCPPainter *painter);
                                                                  -
                                                                  89  virtual QSize minimumSizeHint() const;
                                                                  -
                                                                  90  virtual QSize maximumSizeHint() const;
                                                                  -
                                                                  91  // events:
                                                                  -
                                                                  92  virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
                                                                  -
                                                                  93  virtual void deselectEvent(bool *selectionStateChanged);
                                                                  -
                                                                  94 
                                                                  -
                                                                  95  // non-virtual methods:
                                                                  -
                                                                  96  QFont mainFont() const;
                                                                  -
                                                                  97  QColor mainTextColor() const;
                                                                  -
                                                                  98 
                                                                  -
                                                                  99 private:
                                                                  -
                                                                  100  Q_DISABLE_COPY(QCPPlotTitle)
                                                                  -
                                                                  101 };
                                                                  -
                                                                  102 
                                                                  +
                                                                  75  void selectableChanged(bool selectable);
                                                                  +
                                                                  76 
                                                                  +
                                                                  77 protected:
                                                                  +
                                                                  78  // property members:
                                                                  +
                                                                  79  QString mText;
                                                                  +
                                                                  80  QFont mFont;
                                                                  +
                                                                  81  QColor mTextColor;
                                                                  +
                                                                  82  QFont mSelectedFont;
                                                                  +
                                                                  83  QColor mSelectedTextColor;
                                                                  +
                                                                  84  QRect mTextBoundingRect;
                                                                  +
                                                                  85  bool mSelectable, mSelected;
                                                                  +
                                                                  86 
                                                                  +
                                                                  87  // reimplemented virtual methods:
                                                                  +
                                                                  88  virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
                                                                  +
                                                                  89  virtual void draw(QCPPainter *painter);
                                                                  +
                                                                  90  virtual QSize minimumSizeHint() const;
                                                                  +
                                                                  91  virtual QSize maximumSizeHint() const;
                                                                  +
                                                                  92  // events:
                                                                  +
                                                                  93  virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
                                                                  +
                                                                  94  virtual void deselectEvent(bool *selectionStateChanged);
                                                                  +
                                                                  95 
                                                                  +
                                                                  96  // non-virtual methods:
                                                                  +
                                                                  97  QFont mainFont() const;
                                                                  +
                                                                  98  QColor mainTextColor() const;
                                                                  +
                                                                  99 
                                                                  +
                                                                  100 private:
                                                                  +
                                                                  101  Q_DISABLE_COPY(QCPPlotTitle)
                                                                  +
                                                                  102 };
                                                                  103 
                                                                  104 
                                                                  -
                                                                  105 #endif // QCP_LAYOUTELEMENT_PLOTTITLE_H
                                                                  +
                                                                  105 
                                                                  +
                                                                  106 #endif // QCP_LAYOUTELEMENT_PLOTTITLE_H
                                                                  Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/layoutsystem-multipleaxisrects.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/layoutsystem-multipleaxisrects.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/LayoutsystemSketch0.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/LayoutsystemSketch0.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/LayoutsystemSketch1.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/LayoutsystemSketch1.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/LayoutsystemSketch.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/LayoutsystemSketch.png differ diff -Nru qcustomplot-1.1.0/documentation/html/lineending_8h_source.html qcustomplot-1.2.0/documentation/html/lineending_8h_source.html --- qcustomplot-1.1.0/documentation/html/lineending_8h_source.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/lineending_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -26,7 +26,7 @@
                                                                  1 /***************************************************************************
                                                                  2 ** **
                                                                  3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                                  -
                                                                  4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
                                                                  +
                                                                  4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                                  5 ** **
                                                                  6 ** This program is free software: you can redistribute it and/or modify **
                                                                  7 ** it under the terms of the GNU General Public License as published by **
                                                                  @@ -44,8 +44,8 @@
                                                                  19 ****************************************************************************
                                                                  20 ** Author: Emanuel Eichhammer **
                                                                  21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                                  -
                                                                  22 ** Date: 04.11.13 **
                                                                  -
                                                                  23 ** Version: 1.1.0 **
                                                                  +
                                                                  22 ** Date: 14.03.14 **
                                                                  +
                                                                  23 ** Version: 1.2.0 **
                                                                  24 ****************************************************************************/
                                                                  25 
                                                                  26 #ifndef QCP_LINEENDING_H
                                                                  diff -Nru qcustomplot-1.1.0/documentation/html/namespaceQCP.html qcustomplot-1.2.0/documentation/html/namespaceQCP.html --- qcustomplot-1.1.0/documentation/html/namespaceQCP.html 2013-11-04 22:19:41.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/namespaceQCP.html 2014-03-14 21:11:26.000000000 +0000 @@ -153,7 +153,7 @@

                                                                  0x001 Graph/Curve lines are drawn with a faster method. This reduces the quality especially of the line segment joins. (Only relevant for solid line pens.)

                                                                  phForceRepaint  -

                                                                  0x002 causes an immediate repaint() instead of a soft update() when QCustomPlot::replot() is called. This is set by default on Windows-Systems to prevent the plot from freezing on fast consecutive replots (e.g. user drags ranges with mouse).

                                                                  +

                                                                  0x002 causes an immediate repaint() instead of a soft update() when QCustomPlot::replot() is called with parameter QCustomPlot::rpHint. This is set by default to prevent the plot from freezing on fast consecutive replots (e.g. user drags ranges with mouse).

                                                                  phCacheLabels 

                                                                  0x004 axis (tick) labels will be cached as pixmaps, increasing replot performance.

                                                                  diff -Nru qcustomplot-1.1.0/documentation/html/painter_8h_source.html qcustomplot-1.2.0/documentation/html/painter_8h_source.html --- qcustomplot-1.1.0/documentation/html/painter_8h_source.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/painter_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -26,7 +26,7 @@
                                                                  1 /***************************************************************************
                                                                  2 ** **
                                                                  3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                                  -
                                                                  4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
                                                                  +
                                                                  4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                                  5 ** **
                                                                  6 ** This program is free software: you can redistribute it and/or modify **
                                                                  7 ** it under the terms of the GNU General Public License as published by **
                                                                  @@ -44,8 +44,8 @@
                                                                  19 ****************************************************************************
                                                                  20 ** Author: Emanuel Eichhammer **
                                                                  21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                                  -
                                                                  22 ** Date: 04.11.13 **
                                                                  -
                                                                  23 ** Version: 1.1.0 **
                                                                  +
                                                                  22 ** Date: 14.03.14 **
                                                                  +
                                                                  23 ** Version: 1.2.0 **
                                                                  24 ****************************************************************************/
                                                                  25 
                                                                  26 #ifndef QCP_PAINTER_H
                                                                  @@ -130,10 +130,10 @@
                                                                  112 {
                                                                  113  Q_GADGET
                                                                  114 public:
                                                                  -
                                                                  119  enum PainterMode {pmDefault = 0x00
                                                                  -
                                                                  120  ,pmVectorized = 0x01
                                                                  -
                                                                  121  ,pmNoCaching = 0x02
                                                                  -
                                                                  122  ,pmNonCosmetic = 0x04
                                                                  +
                                                                  119  enum PainterMode { pmDefault = 0x00
                                                                  +
                                                                  120  ,pmVectorized = 0x01
                                                                  +
                                                                  121  ,pmNoCaching = 0x02
                                                                  +
                                                                  122  ,pmNonCosmetic = 0x04
                                                                  123  };
                                                                  124  Q_FLAGS(PainterMode PainterModes)
                                                                  125  Q_DECLARE_FLAGS(PainterModes, PainterMode)
                                                                  diff -Nru qcustomplot-1.1.0/documentation/html/plottable_8h_source.html qcustomplot-1.2.0/documentation/html/plottable_8h_source.html --- qcustomplot-1.1.0/documentation/html/plottable_8h_source.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/plottable_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -26,7 +26,7 @@
                                                                  1 /***************************************************************************
                                                                  2 ** **
                                                                  3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                                  -
                                                                  4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
                                                                  +
                                                                  4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                                  5 ** **
                                                                  6 ** This program is free software: you can redistribute it and/or modify **
                                                                  7 ** it under the terms of the GNU General Public License as published by **
                                                                  @@ -44,8 +44,8 @@
                                                                  19 ****************************************************************************
                                                                  20 ** Author: Emanuel Eichhammer **
                                                                  21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                                  -
                                                                  22 ** Date: 04.11.13 **
                                                                  -
                                                                  23 ** Version: 1.1.0 **
                                                                  +
                                                                  22 ** Date: 14.03.14 **
                                                                  +
                                                                  23 ** Version: 1.2.0 **
                                                                  24 ****************************************************************************/
                                                                  25 
                                                                  26 #ifndef QCP_PLOTTABLE_H
                                                                  @@ -71,8 +71,8 @@
                                                                  47  Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
                                                                  48  Q_PROPERTY(QCPAxis* keyAxis READ keyAxis WRITE setKeyAxis)
                                                                  49  Q_PROPERTY(QCPAxis* valueAxis READ valueAxis WRITE setValueAxis)
                                                                  -
                                                                  50  Q_PROPERTY(bool selectable READ selectable WRITE setSelectable)
                                                                  -
                                                                  51  Q_PROPERTY(bool selected READ selected WRITE setSelected)
                                                                  +
                                                                  50  Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectableChanged)
                                                                  +
                                                                  51  Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectionChanged)
                                                                  53 public:
                                                                  54  QCPAbstractPlottable(QCPAxis *keyAxis, QCPAxis *valueAxis);
                                                                  55 
                                                                  @@ -117,56 +117,57 @@
                                                                  94 
                                                                  95 signals:
                                                                  96  void selectionChanged(bool selected);
                                                                  -
                                                                  97 
                                                                  -
                                                                  98 protected:
                                                                  -
                                                                  102  enum SignDomain { sdNegative
                                                                  -
                                                                  103  ,sdBoth
                                                                  -
                                                                  104  ,sdPositive
                                                                  -
                                                                  105  };
                                                                  -
                                                                  106 
                                                                  -
                                                                  107  // property members:
                                                                  -
                                                                  108  QString mName;
                                                                  -
                                                                  109  bool mAntialiasedFill, mAntialiasedScatters, mAntialiasedErrorBars;
                                                                  -
                                                                  110  QPen mPen, mSelectedPen;
                                                                  -
                                                                  111  QBrush mBrush, mSelectedBrush;
                                                                  -
                                                                  112  QPointer<QCPAxis> mKeyAxis, mValueAxis;
                                                                  -
                                                                  113  bool mSelectable, mSelected;
                                                                  -
                                                                  114 
                                                                  -
                                                                  115  // reimplemented virtual methods:
                                                                  -
                                                                  116  virtual QRect clipRect() const;
                                                                  -
                                                                  117  virtual void draw(QCPPainter *painter) = 0;
                                                                  -
                                                                  118  virtual QCP::Interaction selectionCategory() const;
                                                                  -
                                                                  119  void applyDefaultAntialiasingHint(QCPPainter *painter) const;
                                                                  -
                                                                  120  // events:
                                                                  -
                                                                  121  virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
                                                                  -
                                                                  122  virtual void deselectEvent(bool *selectionStateChanged);
                                                                  -
                                                                  123 
                                                                  -
                                                                  124  // introduced virtual methods:
                                                                  -
                                                                  125  virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const = 0;
                                                                  -
                                                                  126  virtual QCPRange getKeyRange(bool &validRange, SignDomain inSignDomain=sdBoth) const = 0;
                                                                  -
                                                                  127  virtual QCPRange getValueRange(bool &validRange, SignDomain inSignDomain=sdBoth) const = 0;
                                                                  -
                                                                  128 
                                                                  -
                                                                  129  // non-virtual methods:
                                                                  -
                                                                  130  void coordsToPixels(double key, double value, double &x, double &y) const;
                                                                  -
                                                                  131  const QPointF coordsToPixels(double key, double value) const;
                                                                  -
                                                                  132  void pixelsToCoords(double x, double y, double &key, double &value) const;
                                                                  -
                                                                  133  void pixelsToCoords(const QPointF &pixelPos, double &key, double &value) const;
                                                                  -
                                                                  134  QPen mainPen() const;
                                                                  -
                                                                  135  QBrush mainBrush() const;
                                                                  -
                                                                  136  void applyFillAntialiasingHint(QCPPainter *painter) const;
                                                                  -
                                                                  137  void applyScattersAntialiasingHint(QCPPainter *painter) const;
                                                                  -
                                                                  138  void applyErrorBarsAntialiasingHint(QCPPainter *painter) const;
                                                                  -
                                                                  139  double distSqrToLine(const QPointF &start, const QPointF &end, const QPointF &point) const;
                                                                  -
                                                                  140 
                                                                  -
                                                                  141 private:
                                                                  -
                                                                  142  Q_DISABLE_COPY(QCPAbstractPlottable)
                                                                  -
                                                                  143 
                                                                  -
                                                                  144  friend class QCustomPlot;
                                                                  -
                                                                  145  friend class QCPAxis;
                                                                  -
                                                                  146  friend class QCPPlottableLegendItem;
                                                                  -
                                                                  147 };
                                                                  -
                                                                  148 
                                                                  -
                                                                  149 #endif // QCP_PLOTTABLE_H
                                                                  +
                                                                  97  void selectableChanged(bool selectable);
                                                                  +
                                                                  98 
                                                                  +
                                                                  99 protected:
                                                                  +
                                                                  103  enum SignDomain { sdNegative
                                                                  +
                                                                  104  ,sdBoth
                                                                  +
                                                                  105  ,sdPositive
                                                                  +
                                                                  106  };
                                                                  +
                                                                  107 
                                                                  +
                                                                  108  // property members:
                                                                  +
                                                                  109  QString mName;
                                                                  +
                                                                  110  bool mAntialiasedFill, mAntialiasedScatters, mAntialiasedErrorBars;
                                                                  +
                                                                  111  QPen mPen, mSelectedPen;
                                                                  +
                                                                  112  QBrush mBrush, mSelectedBrush;
                                                                  +
                                                                  113  QPointer<QCPAxis> mKeyAxis, mValueAxis;
                                                                  +
                                                                  114  bool mSelectable, mSelected;
                                                                  +
                                                                  115 
                                                                  +
                                                                  116  // reimplemented virtual methods:
                                                                  +
                                                                  117  virtual QRect clipRect() const;
                                                                  +
                                                                  118  virtual void draw(QCPPainter *painter) = 0;
                                                                  +
                                                                  119  virtual QCP::Interaction selectionCategory() const;
                                                                  +
                                                                  120  void applyDefaultAntialiasingHint(QCPPainter *painter) const;
                                                                  +
                                                                  121  // events:
                                                                  +
                                                                  122  virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
                                                                  +
                                                                  123  virtual void deselectEvent(bool *selectionStateChanged);
                                                                  +
                                                                  124 
                                                                  +
                                                                  125  // introduced virtual methods:
                                                                  +
                                                                  126  virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const = 0;
                                                                  +
                                                                  127  virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const = 0;
                                                                  +
                                                                  128  virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const = 0;
                                                                  +
                                                                  129 
                                                                  +
                                                                  130  // non-virtual methods:
                                                                  +
                                                                  131  void coordsToPixels(double key, double value, double &x, double &y) const;
                                                                  +
                                                                  132  const QPointF coordsToPixels(double key, double value) const;
                                                                  +
                                                                  133  void pixelsToCoords(double x, double y, double &key, double &value) const;
                                                                  +
                                                                  134  void pixelsToCoords(const QPointF &pixelPos, double &key, double &value) const;
                                                                  +
                                                                  135  QPen mainPen() const;
                                                                  +
                                                                  136  QBrush mainBrush() const;
                                                                  +
                                                                  137  void applyFillAntialiasingHint(QCPPainter *painter) const;
                                                                  +
                                                                  138  void applyScattersAntialiasingHint(QCPPainter *painter) const;
                                                                  +
                                                                  139  void applyErrorBarsAntialiasingHint(QCPPainter *painter) const;
                                                                  +
                                                                  140  double distSqrToLine(const QPointF &start, const QPointF &end, const QPointF &point) const;
                                                                  +
                                                                  141 
                                                                  +
                                                                  142 private:
                                                                  +
                                                                  143  Q_DISABLE_COPY(QCPAbstractPlottable)
                                                                  +
                                                                  144 
                                                                  +
                                                                  145  friend class QCustomPlot;
                                                                  +
                                                                  146  friend class QCPAxis;
                                                                  +
                                                                  147  friend class QCPPlottableLegendItem;
                                                                  +
                                                                  148 };
                                                                  +
                                                                  149 
                                                                  +
                                                                  150 #endif // QCP_PLOTTABLE_H
                                                                  diff -Nru qcustomplot-1.1.0/documentation/html/plottable-bars_8h_source.html qcustomplot-1.2.0/documentation/html/plottable-bars_8h_source.html --- qcustomplot-1.1.0/documentation/html/plottable-bars_8h_source.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/plottable-bars_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -26,7 +26,7 @@ Go to the documentation of this file.
                                                                  1 /***************************************************************************
                                                                  2 ** **
                                                                  3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                                  -
                                                                  4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
                                                                  +
                                                                  4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                                  5 ** **
                                                                  6 ** This program is free software: you can redistribute it and/or modify **
                                                                  7 ** it under the terms of the GNU General Public License as published by **
                                                                  @@ -44,8 +44,8 @@
                                                                  19 ****************************************************************************
                                                                  20 ** Author: Emanuel Eichhammer **
                                                                  21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                                  -
                                                                  22 ** Date: 04.11.13 **
                                                                  -
                                                                  23 ** Version: 1.1.0 **
                                                                  +
                                                                  22 ** Date: 14.03.14 **
                                                                  +
                                                                  23 ** Version: 1.2.0 **
                                                                  24 ****************************************************************************/
                                                                  26 #ifndef QCP_PLOTTABLE_BARS_H
                                                                  27 #define QCP_PLOTTABLE_BARS_H
                                                                  @@ -117,8 +117,8 @@
                                                                  102  // reimplemented virtual methods:
                                                                  103  virtual void draw(QCPPainter *painter);
                                                                  104  virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const;
                                                                  -
                                                                  105  virtual QCPRange getKeyRange(bool &validRange, SignDomain inSignDomain=sdBoth) const;
                                                                  -
                                                                  106  virtual QCPRange getValueRange(bool &validRange, SignDomain inSignDomain=sdBoth) const;
                                                                  +
                                                                  105  virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
                                                                  +
                                                                  106  virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
                                                                  107 
                                                                  108  // non-virtual methods:
                                                                  109  QPolygonF getBarPolygon(double key, double value) const;
                                                                  diff -Nru qcustomplot-1.1.0/documentation/html/plottable-colormap_8h_source.html qcustomplot-1.2.0/documentation/html/plottable-colormap_8h_source.html --- qcustomplot-1.1.0/documentation/html/plottable-colormap_8h_source.html 1970-01-01 00:00:00.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/plottable-colormap_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -0,0 +1,189 @@ + + + + +src/plottables/plottable-colormap.h Source File + + + + + + +
                                                                  +
                                                                  +
                                                                  +
                                                                  plottable-colormap.h
                                                                  +
                                                                  +
                                                                  +
                                                                  1 /***************************************************************************
                                                                  +
                                                                  2 ** **
                                                                  +
                                                                  3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                                  +
                                                                  4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                                  +
                                                                  5 ** **
                                                                  +
                                                                  6 ** This program is free software: you can redistribute it and/or modify **
                                                                  +
                                                                  7 ** it under the terms of the GNU General Public License as published by **
                                                                  +
                                                                  8 ** the Free Software Foundation, either version 3 of the License, or **
                                                                  +
                                                                  9 ** (at your option) any later version. **
                                                                  +
                                                                  10 ** **
                                                                  +
                                                                  11 ** This program is distributed in the hope that it will be useful, **
                                                                  +
                                                                  12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of **
                                                                  +
                                                                  13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
                                                                  +
                                                                  14 ** GNU General Public License for more details. **
                                                                  +
                                                                  15 ** **
                                                                  +
                                                                  16 ** You should have received a copy of the GNU General Public License **
                                                                  +
                                                                  17 ** along with this program. If not, see http://www.gnu.org/licenses/. **
                                                                  +
                                                                  18 ** **
                                                                  +
                                                                  19 ****************************************************************************
                                                                  +
                                                                  20 ** Author: Emanuel Eichhammer **
                                                                  +
                                                                  21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                                  +
                                                                  22 ** Date: 14.03.14 **
                                                                  +
                                                                  23 ** Version: 1.2.0 **
                                                                  +
                                                                  24 ****************************************************************************/
                                                                  +
                                                                  25 
                                                                  +
                                                                  26 #ifndef QCP_PLOTTABLE_COLORMAP_H
                                                                  +
                                                                  27 #define QCP_PLOTTABLE_COLORMAP_H
                                                                  +
                                                                  28 
                                                                  +
                                                                  29 #include "../global.h"
                                                                  +
                                                                  30 #include "../range.h"
                                                                  +
                                                                  31 #include "../plottable.h"
                                                                  +
                                                                  32 #include "../colorgradient.h"
                                                                  +
                                                                  33 #include "../layoutelements/layoutelement-colorscale.h"
                                                                  +
                                                                  34 
                                                                  +
                                                                  35 class QCPPainter;
                                                                  +
                                                                  36 class QCPAxis;
                                                                  +
                                                                  37 class QCPColorMap;
                                                                  +
                                                                  38 
                                                                  +
                                                                  39 class QCP_LIB_DECL QCPColorMapData
                                                                  +
                                                                  40 {
                                                                  +
                                                                  41 public:
                                                                  +
                                                                  42  QCPColorMapData(int keySize, int valueSize, const QCPRange &keyRange, const QCPRange &valueRange);
                                                                  +
                                                                  43  ~QCPColorMapData();
                                                                  +
                                                                  44  QCPColorMapData(const QCPColorMapData &other);
                                                                  +
                                                                  45  QCPColorMapData &operator=(const QCPColorMapData &other);
                                                                  +
                                                                  46 
                                                                  +
                                                                  47  // getters:
                                                                  +
                                                                  48  int keySize() const { return mKeySize; }
                                                                  +
                                                                  49  int valueSize() const { return mValueSize; }
                                                                  +
                                                                  50  QCPRange keyRange() const { return mKeyRange; }
                                                                  +
                                                                  51  QCPRange valueRange() const { return mValueRange; }
                                                                  +
                                                                  52  QCPRange dataBounds() const { return mDataBounds; }
                                                                  +
                                                                  53  double data(double key, double value);
                                                                  +
                                                                  54  double cell(int keyIndex, int valueIndex);
                                                                  +
                                                                  55 
                                                                  +
                                                                  56  // setters:
                                                                  +
                                                                  57  void setSize(int keySize, int valueSize);
                                                                  +
                                                                  58  void setKeySize(int keySize);
                                                                  +
                                                                  59  void setValueSize(int valueSize);
                                                                  +
                                                                  60  void setRange(const QCPRange &keyRange, const QCPRange &valueRange);
                                                                  +
                                                                  61  void setKeyRange(const QCPRange &keyRange);
                                                                  +
                                                                  62  void setValueRange(const QCPRange &valueRange);
                                                                  +
                                                                  63  void setData(double key, double value, double z);
                                                                  +
                                                                  64  void setCell(int keyIndex, int valueIndex, double z);
                                                                  +
                                                                  65 
                                                                  +
                                                                  66  // non-property methods:
                                                                  +
                                                                  67  void recalculateDataBounds();
                                                                  +
                                                                  68  void clear();
                                                                  +
                                                                  69  void fill(double z);
                                                                  +
                                                                  70  bool isEmpty() const { return mIsEmpty; }
                                                                  +
                                                                  71  void coordToCell(double key, double value, int *keyIndex, int *valueIndex) const;
                                                                  +
                                                                  72  void cellToCoord(int keyIndex, int valueIndex, double *key, double *value) const;
                                                                  +
                                                                  73 
                                                                  +
                                                                  74 protected:
                                                                  +
                                                                  75  // property members:
                                                                  +
                                                                  76  int mKeySize, mValueSize;
                                                                  +
                                                                  77  QCPRange mKeyRange, mValueRange;
                                                                  +
                                                                  78  bool mIsEmpty;
                                                                  +
                                                                  79  // non-property members:
                                                                  +
                                                                  80  double *mData;
                                                                  +
                                                                  81  QCPRange mDataBounds;
                                                                  +
                                                                  82  bool mDataModified;
                                                                  +
                                                                  83 
                                                                  +
                                                                  84  friend class QCPColorMap;
                                                                  +
                                                                  85 };
                                                                  +
                                                                  86 
                                                                  +
                                                                  87 
                                                                  +
                                                                  88 class QCP_LIB_DECL QCPColorMap : public QCPAbstractPlottable
                                                                  +
                                                                  89 {
                                                                  +
                                                                  90  Q_OBJECT
                                                                  +
                                                                  92  Q_PROPERTY(QCPRange dataRange READ dataRange WRITE setDataRange NOTIFY dataRangeChanged)
                                                                  +
                                                                  93  Q_PROPERTY(QCPAxis::ScaleType dataScaleType READ dataScaleType WRITE setDataScaleType NOTIFY dataScaleTypeChanged)
                                                                  +
                                                                  94  Q_PROPERTY(QCPColorGradient gradient READ gradient WRITE setGradient NOTIFY gradientChanged)
                                                                  +
                                                                  95  Q_PROPERTY(bool interpolate READ interpolate WRITE setInterpolate)
                                                                  +
                                                                  96  Q_PROPERTY(bool tightBoundary READ tightBoundary WRITE setTightBoundary)
                                                                  +
                                                                  97  Q_PROPERTY(QCPColorScale* colorScale READ colorScale WRITE setColorScale)
                                                                  +
                                                                  99 public:
                                                                  +
                                                                  100  explicit QCPColorMap(QCPAxis *keyAxis, QCPAxis *valueAxis);
                                                                  +
                                                                  101  virtual ~QCPColorMap();
                                                                  +
                                                                  102 
                                                                  +
                                                                  103  // getters:
                                                                  +
                                                                  104  QCPColorMapData *data() const { return mMapData; }
                                                                  +
                                                                  105  QCPRange dataRange() const { return mDataRange; }
                                                                  +
                                                                  106  QCPAxis::ScaleType dataScaleType() const { return mDataScaleType; }
                                                                  +
                                                                  107  bool interpolate() const { return mInterpolate; }
                                                                  +
                                                                  108  bool tightBoundary() const { return mTightBoundary; }
                                                                  +
                                                                  109  QCPColorGradient gradient() const { return mGradient; }
                                                                  +
                                                                  110  QCPColorScale *colorScale() const { return mColorScale.data(); }
                                                                  +
                                                                  111 
                                                                  +
                                                                  112  // setters:
                                                                  +
                                                                  113  void setData(QCPColorMapData *data, bool copy=false);
                                                                  +
                                                                  114  Q_SLOT void setDataRange(const QCPRange &dataRange);
                                                                  +
                                                                  115  Q_SLOT void setDataScaleType(QCPAxis::ScaleType scaleType);
                                                                  +
                                                                  116  Q_SLOT void setGradient(const QCPColorGradient &gradient);
                                                                  +
                                                                  117  void setInterpolate(bool enabled);
                                                                  +
                                                                  118  void setTightBoundary(bool enabled);
                                                                  +
                                                                  119  void setColorScale(QCPColorScale *colorScale);
                                                                  +
                                                                  120 
                                                                  +
                                                                  121  // non-property methods:
                                                                  +
                                                                  122  void rescaleDataRange(bool recalculateDataBounds=false);
                                                                  +
                                                                  123  Q_SLOT void updateLegendIcon(Qt::TransformationMode transformMode=Qt::SmoothTransformation, const QSize &thumbSize=QSize(32, 18));
                                                                  +
                                                                  124 
                                                                  +
                                                                  125  // reimplemented virtual methods:
                                                                  +
                                                                  126  virtual void clearData();
                                                                  +
                                                                  127  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
                                                                  +
                                                                  128 
                                                                  +
                                                                  129 signals:
                                                                  +
                                                                  130  void dataRangeChanged(QCPRange newRange);
                                                                  +
                                                                  131  void dataScaleTypeChanged(QCPAxis::ScaleType scaleType);
                                                                  +
                                                                  132  void gradientChanged(QCPColorGradient newGradient);
                                                                  +
                                                                  133 
                                                                  +
                                                                  134 protected:
                                                                  +
                                                                  135  // property members:
                                                                  +
                                                                  136  QCPRange mDataRange;
                                                                  +
                                                                  137  QCPAxis::ScaleType mDataScaleType;
                                                                  +
                                                                  138  QCPColorMapData *mMapData;
                                                                  +
                                                                  139  QCPColorGradient mGradient;
                                                                  +
                                                                  140  bool mInterpolate;
                                                                  +
                                                                  141  bool mTightBoundary;
                                                                  +
                                                                  142  QPointer<QCPColorScale> mColorScale;
                                                                  +
                                                                  143  // non-property members:
                                                                  +
                                                                  144  QImage mMapImage;
                                                                  +
                                                                  145  QPixmap mLegendIcon;
                                                                  +
                                                                  146  bool mMapImageInvalidated;
                                                                  +
                                                                  147 
                                                                  +
                                                                  148  // introduced virtual methods:
                                                                  +
                                                                  149  virtual void updateMapImage();
                                                                  +
                                                                  150 
                                                                  +
                                                                  151  // reimplemented virtual methods:
                                                                  +
                                                                  152  virtual void draw(QCPPainter *painter);
                                                                  +
                                                                  153  virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const;
                                                                  +
                                                                  154  virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
                                                                  +
                                                                  155  virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
                                                                  +
                                                                  156 
                                                                  +
                                                                  157  friend class QCustomPlot;
                                                                  +
                                                                  158  friend class QCPLegend;
                                                                  +
                                                                  159 };
                                                                  +
                                                                  160 
                                                                  +
                                                                  161 #endif // QCP_PLOTTABLE_COLORMAP_H
                                                                  +
                                                                  162 
                                                                  +
                                                                  + + + diff -Nru qcustomplot-1.1.0/documentation/html/plottable-curve_8h_source.html qcustomplot-1.2.0/documentation/html/plottable-curve_8h_source.html --- qcustomplot-1.1.0/documentation/html/plottable-curve_8h_source.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/plottable-curve_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -26,7 +26,7 @@ Go to the documentation of this file.
                                                                  1 /***************************************************************************
                                                                  2 ** **
                                                                  3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                                  -
                                                                  4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
                                                                  +
                                                                  4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                                  5 ** **
                                                                  6 ** This program is free software: you can redistribute it and/or modify **
                                                                  7 ** it under the terms of the GNU General Public License as published by **
                                                                  @@ -44,8 +44,8 @@
                                                                  19 ****************************************************************************
                                                                  20 ** Author: Emanuel Eichhammer **
                                                                  21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                                  -
                                                                  22 ** Date: 04.11.13 **
                                                                  -
                                                                  23 ** Version: 1.1.0 **
                                                                  +
                                                                  22 ** Date: 14.03.14 **
                                                                  +
                                                                  23 ** Version: 1.2.0 **
                                                                  24 ****************************************************************************/
                                                                  26 #ifndef QCP_PLOTTABLE_CURVE_H
                                                                  27 #define QCP_PLOTTABLE_CURVE_H
                                                                  @@ -78,8 +78,8 @@
                                                                  63  Q_PROPERTY(QCPScatterStyle scatterStyle READ scatterStyle WRITE setScatterStyle)
                                                                  64  Q_PROPERTY(LineStyle lineStyle READ lineStyle WRITE setLineStyle)
                                                                  66 public:
                                                                  -
                                                                  72  enum LineStyle { lsNone,
                                                                  -
                                                                  73  lsLine
                                                                  +
                                                                  72  enum LineStyle { lsNone
                                                                  +
                                                                  73  ,lsLine
                                                                  74  };
                                                                  75  explicit QCPCurve(QCPAxis *keyAxis, QCPAxis *valueAxis);
                                                                  76  virtual ~QCPCurve();
                                                                  @@ -120,8 +120,8 @@
                                                                  111  // reimplemented virtual methods:
                                                                  112  virtual void draw(QCPPainter *painter);
                                                                  113  virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const;
                                                                  -
                                                                  114  virtual QCPRange getKeyRange(bool &validRange, SignDomain inSignDomain=sdBoth) const;
                                                                  -
                                                                  115  virtual QCPRange getValueRange(bool &validRange, SignDomain inSignDomain=sdBoth) const;
                                                                  +
                                                                  114  virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
                                                                  +
                                                                  115  virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
                                                                  116 
                                                                  117  // introduced virtual methods:
                                                                  118  virtual void drawScatterPlot(QCPPainter *painter, const QVector<QPointF> *pointData) const;
                                                                  diff -Nru qcustomplot-1.1.0/documentation/html/plottable-graph_8h_source.html qcustomplot-1.2.0/documentation/html/plottable-graph_8h_source.html --- qcustomplot-1.1.0/documentation/html/plottable-graph_8h_source.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/plottable-graph_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -26,7 +26,7 @@ Go to the documentation of this file.
                                                                  1 /***************************************************************************
                                                                  2 ** **
                                                                  3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                                  -
                                                                  4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
                                                                  +
                                                                  4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                                  5 ** **
                                                                  6 ** This program is free software: you can redistribute it and/or modify **
                                                                  7 ** it under the terms of the GNU General Public License as published by **
                                                                  @@ -44,8 +44,8 @@
                                                                  19 ****************************************************************************
                                                                  20 ** Author: Emanuel Eichhammer **
                                                                  21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                                  -
                                                                  22 ** Date: 04.11.13 **
                                                                  -
                                                                  23 ** Version: 1.1.0 **
                                                                  +
                                                                  22 ** Date: 14.03.14 **
                                                                  +
                                                                  23 ** Version: 1.2.0 **
                                                                  24 ****************************************************************************/
                                                                  26 #ifndef QCP_PLOTTABLE_GRAPH_H
                                                                  27 #define QCP_PLOTTABLE_GRAPH_H
                                                                  @@ -84,124 +84,130 @@
                                                                  68  Q_PROPERTY(double errorBarSize READ errorBarSize WRITE setErrorBarSize)
                                                                  69  Q_PROPERTY(bool errorBarSkipSymbol READ errorBarSkipSymbol WRITE setErrorBarSkipSymbol)
                                                                  70  Q_PROPERTY(QCPGraph* channelFillGraph READ channelFillGraph WRITE setChannelFillGraph)
                                                                  -
                                                                  72 public:
                                                                  -
                                                                  78  enum LineStyle { lsNone
                                                                  -
                                                                  79 
                                                                  -
                                                                  80  ,lsLine
                                                                  -
                                                                  81  ,lsStepLeft
                                                                  -
                                                                  82  ,lsStepRight
                                                                  -
                                                                  83  ,lsStepCenter
                                                                  -
                                                                  84  ,lsImpulse
                                                                  -
                                                                  85  };
                                                                  -
                                                                  86  Q_ENUMS(LineStyle)
                                                                  -
                                                                  90  enum ErrorType { etNone
                                                                  -
                                                                  91  ,etKey
                                                                  -
                                                                  92  ,etValue
                                                                  -
                                                                  93  ,etBoth
                                                                  -
                                                                  94  };
                                                                  -
                                                                  95  Q_ENUMS(ErrorType)
                                                                  -
                                                                  96 
                                                                  -
                                                                  97  explicit QCPGraph(QCPAxis *keyAxis, QCPAxis *valueAxis);
                                                                  -
                                                                  98  virtual ~QCPGraph();
                                                                  -
                                                                  99 
                                                                  -
                                                                  100  // getters:
                                                                  -
                                                                  101  const QCPDataMap *data() const { return mData; }
                                                                  -
                                                                  102  LineStyle lineStyle() const { return mLineStyle; }
                                                                  -
                                                                  103  QCPScatterStyle scatterStyle() const { return mScatterStyle; }
                                                                  -
                                                                  104  ErrorType errorType() const { return mErrorType; }
                                                                  -
                                                                  105  QPen errorPen() const { return mErrorPen; }
                                                                  -
                                                                  106  double errorBarSize() const { return mErrorBarSize; }
                                                                  -
                                                                  107  bool errorBarSkipSymbol() const { return mErrorBarSkipSymbol; }
                                                                  -
                                                                  108  QCPGraph *channelFillGraph() const { return mChannelFillGraph.data(); }
                                                                  -
                                                                  109 
                                                                  -
                                                                  110  // setters:
                                                                  -
                                                                  111  void setData(QCPDataMap *data, bool copy=false);
                                                                  -
                                                                  112  void setData(const QVector<double> &key, const QVector<double> &value);
                                                                  -
                                                                  113  void setDataKeyError(const QVector<double> &key, const QVector<double> &value, const QVector<double> &keyError);
                                                                  -
                                                                  114  void setDataKeyError(const QVector<double> &key, const QVector<double> &value, const QVector<double> &keyErrorMinus, const QVector<double> &keyErrorPlus);
                                                                  -
                                                                  115  void setDataValueError(const QVector<double> &key, const QVector<double> &value, const QVector<double> &valueError);
                                                                  -
                                                                  116  void setDataValueError(const QVector<double> &key, const QVector<double> &value, const QVector<double> &valueErrorMinus, const QVector<double> &valueErrorPlus);
                                                                  -
                                                                  117  void setDataBothError(const QVector<double> &key, const QVector<double> &value, const QVector<double> &keyError, const QVector<double> &valueError);
                                                                  -
                                                                  118  void setDataBothError(const QVector<double> &key, const QVector<double> &value, const QVector<double> &keyErrorMinus, const QVector<double> &keyErrorPlus, const QVector<double> &valueErrorMinus, const QVector<double> &valueErrorPlus);
                                                                  -
                                                                  119  void setLineStyle(LineStyle ls);
                                                                  -
                                                                  120  void setScatterStyle(const QCPScatterStyle &style);
                                                                  -
                                                                  121  void setErrorType(ErrorType errorType);
                                                                  -
                                                                  122  void setErrorPen(const QPen &pen);
                                                                  -
                                                                  123  void setErrorBarSize(double size);
                                                                  -
                                                                  124  void setErrorBarSkipSymbol(bool enabled);
                                                                  -
                                                                  125  void setChannelFillGraph(QCPGraph *targetGraph);
                                                                  -
                                                                  126 
                                                                  -
                                                                  127  // non-property methods:
                                                                  -
                                                                  128  void addData(const QCPDataMap &dataMap);
                                                                  -
                                                                  129  void addData(const QCPData &data);
                                                                  -
                                                                  130  void addData(double key, double value);
                                                                  -
                                                                  131  void addData(const QVector<double> &keys, const QVector<double> &values);
                                                                  -
                                                                  132  void removeDataBefore(double key);
                                                                  -
                                                                  133  void removeDataAfter(double key);
                                                                  -
                                                                  134  void removeData(double fromKey, double toKey);
                                                                  -
                                                                  135  void removeData(double key);
                                                                  -
                                                                  136 
                                                                  -
                                                                  137  // reimplemented virtual methods:
                                                                  -
                                                                  138  virtual void clearData();
                                                                  -
                                                                  139  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
                                                                  - - - -
                                                                  143  void rescaleAxes(bool onlyEnlarge, bool includeErrorBars) const; // overloads base class interface
                                                                  -
                                                                  144  void rescaleKeyAxis(bool onlyEnlarge, bool includeErrorBars) const; // overloads base class interface
                                                                  -
                                                                  145  void rescaleValueAxis(bool onlyEnlarge, bool includeErrorBars) const; // overloads base class interface
                                                                  -
                                                                  146 
                                                                  -
                                                                  147 protected:
                                                                  -
                                                                  148  // property members:
                                                                  -
                                                                  149  QCPDataMap *mData;
                                                                  -
                                                                  150  QPen mErrorPen;
                                                                  -
                                                                  151  LineStyle mLineStyle;
                                                                  -
                                                                  152  QCPScatterStyle mScatterStyle;
                                                                  -
                                                                  153  ErrorType mErrorType;
                                                                  -
                                                                  154  double mErrorBarSize;
                                                                  -
                                                                  155  bool mErrorBarSkipSymbol;
                                                                  -
                                                                  156  QPointer<QCPGraph> mChannelFillGraph;
                                                                  -
                                                                  157 
                                                                  -
                                                                  158  // reimplemented virtual methods:
                                                                  -
                                                                  159  virtual void draw(QCPPainter *painter);
                                                                  -
                                                                  160  virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const;
                                                                  -
                                                                  161  virtual QCPRange getKeyRange(bool &validRange, SignDomain inSignDomain=sdBoth) const;
                                                                  -
                                                                  162  virtual QCPRange getValueRange(bool &validRange, SignDomain inSignDomain=sdBoth) const;
                                                                  -
                                                                  163  virtual QCPRange getKeyRange(bool &validRange, SignDomain inSignDomain, bool includeErrors) const; // overloads base class interface
                                                                  -
                                                                  164  virtual QCPRange getValueRange(bool &validRange, SignDomain inSignDomain, bool includeErrors) const; // overloads base class interface
                                                                  -
                                                                  165 
                                                                  -
                                                                  166  // introduced virtual methods:
                                                                  -
                                                                  167  virtual void drawFill(QCPPainter *painter, QVector<QPointF> *lineData) const;
                                                                  -
                                                                  168  virtual void drawScatterPlot(QCPPainter *painter, QVector<QCPData> *pointData) const;
                                                                  -
                                                                  169  virtual void drawLinePlot(QCPPainter *painter, QVector<QPointF> *lineData) const;
                                                                  -
                                                                  170  virtual void drawImpulsePlot(QCPPainter *painter, QVector<QPointF> *lineData) const;
                                                                  -
                                                                  171 
                                                                  -
                                                                  172  // non-virtual methods:
                                                                  -
                                                                  173  void getPlotData(QVector<QPointF> *lineData, QVector<QCPData> *pointData) const;
                                                                  -
                                                                  174  void getScatterPlotData(QVector<QCPData> *pointData) const;
                                                                  -
                                                                  175  void getLinePlotData(QVector<QPointF> *lineData, QVector<QCPData> *pointData) const;
                                                                  -
                                                                  176  void getStepLeftPlotData(QVector<QPointF> *lineData, QVector<QCPData> *pointData) const;
                                                                  -
                                                                  177  void getStepRightPlotData(QVector<QPointF> *lineData, QVector<QCPData> *pointData) const;
                                                                  -
                                                                  178  void getStepCenterPlotData(QVector<QPointF> *lineData, QVector<QCPData> *pointData) const;
                                                                  -
                                                                  179  void getImpulsePlotData(QVector<QPointF> *lineData, QVector<QCPData> *pointData) const;
                                                                  -
                                                                  180  void drawError(QCPPainter *painter, double x, double y, const QCPData &data) const;
                                                                  -
                                                                  181  void getVisibleDataBounds(QCPDataMap::const_iterator &lower, QCPDataMap::const_iterator &upper, int &count) const;
                                                                  -
                                                                  182  void addFillBasePoints(QVector<QPointF> *lineData) const;
                                                                  -
                                                                  183  void removeFillBasePoints(QVector<QPointF> *lineData) const;
                                                                  -
                                                                  184  QPointF lowerFillBasePoint(double lowerKey) const;
                                                                  -
                                                                  185  QPointF upperFillBasePoint(double upperKey) const;
                                                                  -
                                                                  186  const QPolygonF getChannelFillPolygon(const QVector<QPointF> *lineData) const;
                                                                  -
                                                                  187  int findIndexBelowX(const QVector<QPointF> *data, double x) const;
                                                                  -
                                                                  188  int findIndexAboveX(const QVector<QPointF> *data, double x) const;
                                                                  -
                                                                  189  int findIndexBelowY(const QVector<QPointF> *data, double y) const;
                                                                  -
                                                                  190  int findIndexAboveY(const QVector<QPointF> *data, double y) const;
                                                                  -
                                                                  191  double pointDistance(const QPointF &pixelPoint) const;
                                                                  -
                                                                  192 
                                                                  -
                                                                  193  friend class QCustomPlot;
                                                                  -
                                                                  194  friend class QCPLegend;
                                                                  -
                                                                  195 };
                                                                  -
                                                                  196 
                                                                  -
                                                                  197 #endif // QCP_PLOTTABLE_GRAPH_H
                                                                  +
                                                                  71  Q_PROPERTY(bool adaptiveSampling READ adaptiveSampling WRITE setAdaptiveSampling)
                                                                  +
                                                                  73 public:
                                                                  +
                                                                  79  enum LineStyle { lsNone
                                                                  +
                                                                  80 
                                                                  +
                                                                  81  ,lsLine
                                                                  +
                                                                  82  ,lsStepLeft
                                                                  +
                                                                  83  ,lsStepRight
                                                                  +
                                                                  84  ,lsStepCenter
                                                                  +
                                                                  85  ,lsImpulse
                                                                  +
                                                                  86  };
                                                                  +
                                                                  87  Q_ENUMS(LineStyle)
                                                                  +
                                                                  91  enum ErrorType { etNone
                                                                  +
                                                                  92  ,etKey
                                                                  +
                                                                  93  ,etValue
                                                                  +
                                                                  94  ,etBoth
                                                                  +
                                                                  95  };
                                                                  +
                                                                  96  Q_ENUMS(ErrorType)
                                                                  +
                                                                  97 
                                                                  +
                                                                  98  explicit QCPGraph(QCPAxis *keyAxis, QCPAxis *valueAxis);
                                                                  +
                                                                  99  virtual ~QCPGraph();
                                                                  +
                                                                  100 
                                                                  +
                                                                  101  // getters:
                                                                  +
                                                                  102  QCPDataMap *data() const { return mData; }
                                                                  +
                                                                  103  LineStyle lineStyle() const { return mLineStyle; }
                                                                  +
                                                                  104  QCPScatterStyle scatterStyle() const { return mScatterStyle; }
                                                                  +
                                                                  105  ErrorType errorType() const { return mErrorType; }
                                                                  +
                                                                  106  QPen errorPen() const { return mErrorPen; }
                                                                  +
                                                                  107  double errorBarSize() const { return mErrorBarSize; }
                                                                  +
                                                                  108  bool errorBarSkipSymbol() const { return mErrorBarSkipSymbol; }
                                                                  +
                                                                  109  QCPGraph *channelFillGraph() const { return mChannelFillGraph.data(); }
                                                                  +
                                                                  110  bool adaptiveSampling() const { return mAdaptiveSampling; }
                                                                  +
                                                                  111 
                                                                  +
                                                                  112  // setters:
                                                                  +
                                                                  113  void setData(QCPDataMap *data, bool copy=false);
                                                                  +
                                                                  114  void setData(const QVector<double> &key, const QVector<double> &value);
                                                                  +
                                                                  115  void setDataKeyError(const QVector<double> &key, const QVector<double> &value, const QVector<double> &keyError);
                                                                  +
                                                                  116  void setDataKeyError(const QVector<double> &key, const QVector<double> &value, const QVector<double> &keyErrorMinus, const QVector<double> &keyErrorPlus);
                                                                  +
                                                                  117  void setDataValueError(const QVector<double> &key, const QVector<double> &value, const QVector<double> &valueError);
                                                                  +
                                                                  118  void setDataValueError(const QVector<double> &key, const QVector<double> &value, const QVector<double> &valueErrorMinus, const QVector<double> &valueErrorPlus);
                                                                  +
                                                                  119  void setDataBothError(const QVector<double> &key, const QVector<double> &value, const QVector<double> &keyError, const QVector<double> &valueError);
                                                                  +
                                                                  120  void setDataBothError(const QVector<double> &key, const QVector<double> &value, const QVector<double> &keyErrorMinus, const QVector<double> &keyErrorPlus, const QVector<double> &valueErrorMinus, const QVector<double> &valueErrorPlus);
                                                                  +
                                                                  121  void setLineStyle(LineStyle ls);
                                                                  +
                                                                  122  void setScatterStyle(const QCPScatterStyle &style);
                                                                  +
                                                                  123  void setErrorType(ErrorType errorType);
                                                                  +
                                                                  124  void setErrorPen(const QPen &pen);
                                                                  +
                                                                  125  void setErrorBarSize(double size);
                                                                  +
                                                                  126  void setErrorBarSkipSymbol(bool enabled);
                                                                  +
                                                                  127  void setChannelFillGraph(QCPGraph *targetGraph);
                                                                  +
                                                                  128  void setAdaptiveSampling(bool enabled);
                                                                  +
                                                                  129 
                                                                  +
                                                                  130  // non-property methods:
                                                                  +
                                                                  131  void addData(const QCPDataMap &dataMap);
                                                                  +
                                                                  132  void addData(const QCPData &data);
                                                                  +
                                                                  133  void addData(double key, double value);
                                                                  +
                                                                  134  void addData(const QVector<double> &keys, const QVector<double> &values);
                                                                  +
                                                                  135  void removeDataBefore(double key);
                                                                  +
                                                                  136  void removeDataAfter(double key);
                                                                  +
                                                                  137  void removeData(double fromKey, double toKey);
                                                                  +
                                                                  138  void removeData(double key);
                                                                  +
                                                                  139 
                                                                  +
                                                                  140  // reimplemented virtual methods:
                                                                  +
                                                                  141  virtual void clearData();
                                                                  +
                                                                  142  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
                                                                  + + + +
                                                                  146  void rescaleAxes(bool onlyEnlarge, bool includeErrorBars) const; // overloads base class interface
                                                                  +
                                                                  147  void rescaleKeyAxis(bool onlyEnlarge, bool includeErrorBars) const; // overloads base class interface
                                                                  +
                                                                  148  void rescaleValueAxis(bool onlyEnlarge, bool includeErrorBars) const; // overloads base class interface
                                                                  +
                                                                  149 
                                                                  +
                                                                  150 protected:
                                                                  +
                                                                  151  // property members:
                                                                  +
                                                                  152  QCPDataMap *mData;
                                                                  +
                                                                  153  QPen mErrorPen;
                                                                  +
                                                                  154  LineStyle mLineStyle;
                                                                  +
                                                                  155  QCPScatterStyle mScatterStyle;
                                                                  +
                                                                  156  ErrorType mErrorType;
                                                                  +
                                                                  157  double mErrorBarSize;
                                                                  +
                                                                  158  bool mErrorBarSkipSymbol;
                                                                  +
                                                                  159  QPointer<QCPGraph> mChannelFillGraph;
                                                                  +
                                                                  160  bool mAdaptiveSampling;
                                                                  +
                                                                  161 
                                                                  +
                                                                  162  // reimplemented virtual methods:
                                                                  +
                                                                  163  virtual void draw(QCPPainter *painter);
                                                                  +
                                                                  164  virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const;
                                                                  +
                                                                  165  virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
                                                                  +
                                                                  166  virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
                                                                  +
                                                                  167  virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain, bool includeErrors) const; // overloads base class interface
                                                                  +
                                                                  168  virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain, bool includeErrors) const; // overloads base class interface
                                                                  +
                                                                  169 
                                                                  +
                                                                  170  // introduced virtual methods:
                                                                  +
                                                                  171  virtual void drawFill(QCPPainter *painter, QVector<QPointF> *lineData) const;
                                                                  +
                                                                  172  virtual void drawScatterPlot(QCPPainter *painter, QVector<QCPData> *scatterData) const;
                                                                  +
                                                                  173  virtual void drawLinePlot(QCPPainter *painter, QVector<QPointF> *lineData) const;
                                                                  +
                                                                  174  virtual void drawImpulsePlot(QCPPainter *painter, QVector<QPointF> *lineData) const;
                                                                  +
                                                                  175 
                                                                  +
                                                                  176  // non-virtual methods:
                                                                  +
                                                                  177  void getPreparedData(QVector<QCPData> *lineData, QVector<QCPData> *scatterData) const;
                                                                  +
                                                                  178  void getPlotData(QVector<QPointF> *lineData, QVector<QCPData> *scatterData) const;
                                                                  +
                                                                  179  void getScatterPlotData(QVector<QCPData> *scatterData) const;
                                                                  +
                                                                  180  void getLinePlotData(QVector<QPointF> *linePixelData, QVector<QCPData> *scatterData) const;
                                                                  +
                                                                  181  void getStepLeftPlotData(QVector<QPointF> *linePixelData, QVector<QCPData> *scatterData) const;
                                                                  +
                                                                  182  void getStepRightPlotData(QVector<QPointF> *linePixelData, QVector<QCPData> *scatterData) const;
                                                                  +
                                                                  183  void getStepCenterPlotData(QVector<QPointF> *linePixelData, QVector<QCPData> *scatterData) const;
                                                                  +
                                                                  184  void getImpulsePlotData(QVector<QPointF> *linePixelData, QVector<QCPData> *scatterData) const;
                                                                  +
                                                                  185  void drawError(QCPPainter *painter, double x, double y, const QCPData &data) const;
                                                                  +
                                                                  186  void getVisibleDataBounds(QCPDataMap::const_iterator &lower, QCPDataMap::const_iterator &upper) const;
                                                                  +
                                                                  187  int countDataInBounds(const QCPDataMap::const_iterator &lower, const QCPDataMap::const_iterator &upper, int maxCount) const;
                                                                  +
                                                                  188  void addFillBasePoints(QVector<QPointF> *lineData) const;
                                                                  +
                                                                  189  void removeFillBasePoints(QVector<QPointF> *lineData) const;
                                                                  +
                                                                  190  QPointF lowerFillBasePoint(double lowerKey) const;
                                                                  +
                                                                  191  QPointF upperFillBasePoint(double upperKey) const;
                                                                  +
                                                                  192  const QPolygonF getChannelFillPolygon(const QVector<QPointF> *lineData) const;
                                                                  +
                                                                  193  int findIndexBelowX(const QVector<QPointF> *data, double x) const;
                                                                  +
                                                                  194  int findIndexAboveX(const QVector<QPointF> *data, double x) const;
                                                                  +
                                                                  195  int findIndexBelowY(const QVector<QPointF> *data, double y) const;
                                                                  +
                                                                  196  int findIndexAboveY(const QVector<QPointF> *data, double y) const;
                                                                  +
                                                                  197  double pointDistance(const QPointF &pixelPoint) const;
                                                                  +
                                                                  198 
                                                                  +
                                                                  199  friend class QCustomPlot;
                                                                  +
                                                                  200  friend class QCPLegend;
                                                                  +
                                                                  201 };
                                                                  +
                                                                  202 
                                                                  +
                                                                  203 #endif // QCP_PLOTTABLE_GRAPH_H
                                                                  diff -Nru qcustomplot-1.1.0/documentation/html/plottable-statisticalbox_8h_source.html qcustomplot-1.2.0/documentation/html/plottable-statisticalbox_8h_source.html --- qcustomplot-1.1.0/documentation/html/plottable-statisticalbox_8h_source.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/plottable-statisticalbox_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -26,7 +26,7 @@ Go to the documentation of this file.
                                                                  1 /***************************************************************************
                                                                  2 ** **
                                                                  3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                                  -
                                                                  4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
                                                                  +
                                                                  4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                                  5 ** **
                                                                  6 ** This program is free software: you can redistribute it and/or modify **
                                                                  7 ** it under the terms of the GNU General Public License as published by **
                                                                  @@ -44,8 +44,8 @@
                                                                  19 ****************************************************************************
                                                                  20 ** Author: Emanuel Eichhammer **
                                                                  21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                                  -
                                                                  22 ** Date: 04.11.13 **
                                                                  -
                                                                  23 ** Version: 1.1.0 **
                                                                  +
                                                                  22 ** Date: 14.03.14 **
                                                                  +
                                                                  23 ** Version: 1.2.0 **
                                                                  24 ****************************************************************************/
                                                                  26 #ifndef QCP_PLOTTABLE_STATISTICALBOX_H
                                                                  27 #define QCP_PLOTTABLE_STATISTICALBOX_H
                                                                  @@ -124,8 +124,8 @@
                                                                  102  // reimplemented virtual methods:
                                                                  103  virtual void draw(QCPPainter *painter);
                                                                  104  virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const;
                                                                  -
                                                                  105  virtual QCPRange getKeyRange(bool &validRange, SignDomain inSignDomain=sdBoth) const;
                                                                  -
                                                                  106  virtual QCPRange getValueRange(bool &validRange, SignDomain inSignDomain=sdBoth) const;
                                                                  +
                                                                  105  virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
                                                                  +
                                                                  106  virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
                                                                  107 
                                                                  108  // introduced virtual methods:
                                                                  109  virtual void drawQuartileBox(QCPPainter *painter, QRectF *quartileBox=0) const;
                                                                  diff -Nru qcustomplot-1.1.0/documentation/html/qcp_8h_source.html qcustomplot-1.2.0/documentation/html/qcp_8h_source.html --- qcustomplot-1.1.0/documentation/html/qcp_8h_source.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/qcp_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -26,7 +26,7 @@
                                                                  1 /***************************************************************************
                                                                  2 ** **
                                                                  3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                                  -
                                                                  4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
                                                                  +
                                                                  4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                                  5 ** **
                                                                  6 ** This program is free software: you can redistribute it and/or modify **
                                                                  7 ** it under the terms of the GNU General Public License as published by **
                                                                  @@ -44,8 +44,8 @@
                                                                  19 ****************************************************************************
                                                                  20 ** Author: Emanuel Eichhammer **
                                                                  21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                                  -
                                                                  22 ** Date: 04.11.13 **
                                                                  -
                                                                  23 ** Version: 1.1.0 **
                                                                  +
                                                                  22 ** Date: 14.03.14 **
                                                                  +
                                                                  23 ** Version: 1.2.0 **
                                                                  24 ****************************************************************************/
                                                                  25 
                                                                  26 #ifndef QCP_H
                                                                  @@ -61,24 +61,27 @@
                                                                  36 #include "item.h"
                                                                  37 #include "lineending.h"
                                                                  38 #include "core.h"
                                                                  - - - - -
                                                                  43 #include "items/item-straightline.h"
                                                                  -
                                                                  44 #include "items/item-line.h"
                                                                  -
                                                                  45 #include "items/item-curve.h"
                                                                  -
                                                                  46 #include "items/item-rect.h"
                                                                  -
                                                                  47 #include "items/item-text.h"
                                                                  -
                                                                  48 #include "items/item-ellipse.h"
                                                                  -
                                                                  49 #include "items/item-pixmap.h"
                                                                  -
                                                                  50 #include "items/item-tracer.h"
                                                                  -
                                                                  51 #include "items/item-bracket.h"
                                                                  -
                                                                  52 #include "layoutelements/layoutelement-axisrect.h"
                                                                  -
                                                                  53 #include "layoutelements/layoutelement-legend.h"
                                                                  -
                                                                  54 #include "layoutelements/layoutelement-plottitle.h"
                                                                  -
                                                                  55 
                                                                  -
                                                                  56 #endif // QCP_H
                                                                  +
                                                                  39 #include "colorgradient.h"
                                                                  + + + + +
                                                                  44 #include "plottables/plottable-colormap.h"
                                                                  +
                                                                  45 #include "items/item-straightline.h"
                                                                  +
                                                                  46 #include "items/item-line.h"
                                                                  +
                                                                  47 #include "items/item-curve.h"
                                                                  +
                                                                  48 #include "items/item-rect.h"
                                                                  +
                                                                  49 #include "items/item-text.h"
                                                                  +
                                                                  50 #include "items/item-ellipse.h"
                                                                  +
                                                                  51 #include "items/item-pixmap.h"
                                                                  +
                                                                  52 #include "items/item-tracer.h"
                                                                  +
                                                                  53 #include "items/item-bracket.h"
                                                                  +
                                                                  54 #include "layoutelements/layoutelement-axisrect.h"
                                                                  +
                                                                  55 #include "layoutelements/layoutelement-legend.h"
                                                                  +
                                                                  56 #include "layoutelements/layoutelement-plottitle.h"
                                                                  +
                                                                  57 #include "layoutelements/layoutelement-colorscale.h"
                                                                  +
                                                                  58 
                                                                  +
                                                                  59 #endif // QCP_H
                                                                  Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/QCPBars.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/QCPBars.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/QCPColorGradient-levelcount.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/QCPColorGradient-levelcount.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/QCPColorGradient-periodic.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/QCPColorGradient-periodic.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/QCPColorGradient.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/QCPColorGradient.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/QCPColorMap-interpolate.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/QCPColorMap-interpolate.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/QCPColorMap.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/QCPColorMap.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/QCPColorMap-tightboundary.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/QCPColorMap-tightboundary.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/QCPColorScale.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/QCPColorScale.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/QCPCurve.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/QCPCurve.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/QCPGraph.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/QCPGraph.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/QCPItemBracket-length.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/QCPItemBracket-length.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/QCPItemCurve.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/QCPItemCurve.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/QCPItemEllipse.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/QCPItemEllipse.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/QCPItemLine.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/QCPItemLine.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/QCPItemPixmap.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/QCPItemPixmap.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/QCPItemRect.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/QCPItemRect.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/QCPItemText.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/QCPItemText.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/QCPItemTracer.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/QCPItemTracer.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/QCPLineEnding.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/QCPLineEnding.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/QCPStatisticalBox.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/QCPStatisticalBox.png differ diff -Nru qcustomplot-1.1.0/documentation/html/qt.css qcustomplot-1.2.0/documentation/html/qt.css --- qcustomplot-1.1.0/documentation/html/qt.css 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/qt.css 2014-03-14 21:11:25.000000000 +0000 @@ -41,9 +41,14 @@ border-radius: 7px 7px 7px 7px; font-size: 12px; max-width: 1400px; - padding: 0 10px 0 0; + padding: 1em 1em 1em 1em; margin-bottom: 15px; } +table.memberdecls h2 { + font-size: 140%; + margin: 0 0 0.3em; + padding: 0 0 0 0; +} table.memberdecls td { padding: 2px 0; } @@ -82,11 +87,11 @@ margin-right: 2em; } h1 { - font-size: 120%; + font-size: 130%; margin: 1.6em 0; } h2 { - font-size: 110%; + font-size: 120%; margin: 1em 0; } h3 { @@ -150,6 +155,14 @@ display: block; padding: 0.2em; } +tr.inherit_header > td{ + font-size: 110%; + font-weight: 700; + padding: 2em 0 0.3em 0; +} +tr.inherit_header > td > img{ + display: none; +} td.memItemLeft, td.memItemRight, td.memTemplItemLeft, td.memTemplItemRight, td.memTemplParams { border: medium none; margin: 4px; @@ -405,6 +418,9 @@ padding: 4px 6px; word-wrap: break-word; } +div.fragment div.line { + white-space: pre; +} div.ah { background-color: #000000; color: #FFFFFF; diff -Nru qcustomplot-1.1.0/documentation/html/range_8h_source.html qcustomplot-1.2.0/documentation/html/range_8h_source.html --- qcustomplot-1.1.0/documentation/html/range_8h_source.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/range_8h_source.html 2014-03-14 21:11:25.000000000 +0000 @@ -26,7 +26,7 @@
                                                                  1 /***************************************************************************
                                                                  2 ** **
                                                                  3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
                                                                  -
                                                                  4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
                                                                  +
                                                                  4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
                                                                  5 ** **
                                                                  6 ** This program is free software: you can redistribute it and/or modify **
                                                                  7 ** it under the terms of the GNU General Public License as published by **
                                                                  @@ -44,8 +44,8 @@
                                                                  19 ****************************************************************************
                                                                  20 ** Author: Emanuel Eichhammer **
                                                                  21 ** Website/Contact: http://www.qcustomplot.com/ **
                                                                  -
                                                                  22 ** Date: 04.11.13 **
                                                                  -
                                                                  23 ** Version: 1.1.0 **
                                                                  +
                                                                  22 ** Date: 14.03.14 **
                                                                  +
                                                                  23 ** Version: 1.2.0 **
                                                                  24 ****************************************************************************/
                                                                  25 
                                                                  26 #ifndef QCP_RANGE_H
                                                                  @@ -61,23 +61,84 @@
                                                                  36  QCPRange();
                                                                  37  QCPRange(double lower, double upper);
                                                                  38 
                                                                  -
                                                                  39  double size() const;
                                                                  -
                                                                  40  double center() const;
                                                                  -
                                                                  41  void normalize();
                                                                  -
                                                                  42  void expand(const QCPRange &otherRange);
                                                                  -
                                                                  43  QCPRange expanded(const QCPRange &otherRange) const;
                                                                  -
                                                                  44  QCPRange sanitizedForLogScale() const;
                                                                  -
                                                                  45  QCPRange sanitizedForLinScale() const;
                                                                  -
                                                                  46  bool contains(double value) const;
                                                                  -
                                                                  47 
                                                                  -
                                                                  48  static bool validRange(double lower, double upper);
                                                                  -
                                                                  49  static bool validRange(const QCPRange &range);
                                                                  -
                                                                  50  static const double minRange; //1e-280;
                                                                  -
                                                                  51  static const double maxRange; //1e280;
                                                                  -
                                                                  52 };
                                                                  -
                                                                  53 Q_DECLARE_TYPEINFO(QCPRange, Q_MOVABLE_TYPE);
                                                                  -
                                                                  54 
                                                                  -
                                                                  55 #endif // QCP_RANGE_H
                                                                  +
                                                                  39  bool operator==(const QCPRange& other) { return lower == other.lower && upper == other.upper; }
                                                                  +
                                                                  40  bool operator!=(const QCPRange& other) { return !(*this == other); }
                                                                  +
                                                                  41 
                                                                  +
                                                                  42  QCPRange &operator+=(const double& value) { lower+=value; upper+=value; return *this; }
                                                                  +
                                                                  43  QCPRange &operator-=(const double& value) { lower-=value; upper-=value; return *this; }
                                                                  +
                                                                  44  QCPRange &operator*=(const double& value) { lower*=value; upper*=value; return *this; }
                                                                  +
                                                                  45  QCPRange &operator/=(const double& value) { lower/=value; upper/=value; return *this; }
                                                                  +
                                                                  46  friend inline const QCPRange operator+(const QCPRange&, double);
                                                                  +
                                                                  47  friend inline const QCPRange operator+(double, const QCPRange&);
                                                                  +
                                                                  48  friend inline const QCPRange operator-(const QCPRange& range, double value);
                                                                  +
                                                                  49  friend inline const QCPRange operator*(const QCPRange& range, double value);
                                                                  +
                                                                  50  friend inline const QCPRange operator*(double value, const QCPRange& range);
                                                                  +
                                                                  51  friend inline const QCPRange operator/(const QCPRange& range, double value);
                                                                  +
                                                                  52 
                                                                  +
                                                                  53  double size() const;
                                                                  +
                                                                  54  double center() const;
                                                                  +
                                                                  55  void normalize();
                                                                  +
                                                                  56  void expand(const QCPRange &otherRange);
                                                                  +
                                                                  57  QCPRange expanded(const QCPRange &otherRange) const;
                                                                  +
                                                                  58  QCPRange sanitizedForLogScale() const;
                                                                  +
                                                                  59  QCPRange sanitizedForLinScale() const;
                                                                  +
                                                                  60  bool contains(double value) const;
                                                                  +
                                                                  61 
                                                                  +
                                                                  62  static bool validRange(double lower, double upper);
                                                                  +
                                                                  63  static bool validRange(const QCPRange &range);
                                                                  +
                                                                  64  static const double minRange; //1e-280;
                                                                  +
                                                                  65  static const double maxRange; //1e280;
                                                                  +
                                                                  66 
                                                                  +
                                                                  67 };
                                                                  +
                                                                  68 Q_DECLARE_TYPEINFO(QCPRange, Q_MOVABLE_TYPE);
                                                                  +
                                                                  69 
                                                                  +
                                                                  70 /* documentation of inline functions */
                                                                  +
                                                                  71 
                                                                  +
                                                                  92 /* end documentation of inline functions */
                                                                  +
                                                                  93 
                                                                  +
                                                                  97 inline const QCPRange operator+(const QCPRange& range, double value)
                                                                  +
                                                                  98 {
                                                                  +
                                                                  99  QCPRange result(range);
                                                                  +
                                                                  100  result += value;
                                                                  +
                                                                  101  return result;
                                                                  +
                                                                  102 }
                                                                  +
                                                                  103 
                                                                  +
                                                                  107 inline const QCPRange operator+(double value, const QCPRange& range)
                                                                  +
                                                                  108 {
                                                                  +
                                                                  109  QCPRange result(range);
                                                                  +
                                                                  110  result += value;
                                                                  +
                                                                  111  return result;
                                                                  +
                                                                  112 }
                                                                  +
                                                                  113 
                                                                  +
                                                                  117 inline const QCPRange operator-(const QCPRange& range, double value)
                                                                  +
                                                                  118 {
                                                                  +
                                                                  119  QCPRange result(range);
                                                                  +
                                                                  120  result -= value;
                                                                  +
                                                                  121  return result;
                                                                  +
                                                                  122 }
                                                                  +
                                                                  123 
                                                                  +
                                                                  127 inline const QCPRange operator*(const QCPRange& range, double value)
                                                                  +
                                                                  128 {
                                                                  +
                                                                  129  QCPRange result(range);
                                                                  +
                                                                  130  result *= value;
                                                                  +
                                                                  131  return result;
                                                                  +
                                                                  132 }
                                                                  +
                                                                  133 
                                                                  +
                                                                  137 inline const QCPRange operator*(double value, const QCPRange& range)
                                                                  +
                                                                  138 {
                                                                  +
                                                                  139  QCPRange result(range);
                                                                  +
                                                                  140  result *= value;
                                                                  +
                                                                  141  return result;
                                                                  +
                                                                  142 }
                                                                  +
                                                                  143 
                                                                  +
                                                                  147 inline const QCPRange operator/(const QCPRange& range, double value)
                                                                  +
                                                                  148 {
                                                                  +
                                                                  149  QCPRange result(range);
                                                                  +
                                                                  150  result /= value;
                                                                  +
                                                                  151  return result;
                                                                  +
                                                                  152 }
                                                                  +
                                                                  153 
                                                                  +
                                                                  154 #endif // QCP_RANGE_H
                                                                  Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/RelationOverview.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/RelationOverview.png differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/html/ssDisc.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/html/ssDisc.png differ diff -Nru qcustomplot-1.1.0/documentation/html/thelayoutsystem.html qcustomplot-1.2.0/documentation/html/thelayoutsystem.html --- qcustomplot-1.1.0/documentation/html/thelayoutsystem.html 2013-11-04 22:19:40.000000000 +0000 +++ qcustomplot-1.2.0/documentation/html/thelayoutsystem.html 2014-03-14 21:11:25.000000000 +0000 @@ -35,13 +35,11 @@ Layouts

                                                                  As mentioned, a QCPLayoutElement may have an arbitrary number of child layout elements and in princple can have the only purpose to manage/arrange those child elements. This is what the subclass QCPLayout specializes on. It is a QCPLayoutElement itself but has no visual representation. It defines an interface to add, remove and manage child layout elements. QCPLayout isn't a usable layout though, it's an abstract base class that concrete layouts derive from, like QCPLayoutGrid which arranges its child elements in a grid and QCPLayoutInset which allows placing child elements freely inside its rect.

                                                                  Since a QCPLayout is a layout element itself, it may be placed inside other layouts. This way, complex hierarchies may be created, offering very flexible arrangements.

                                                                  -
                                                                  -LayoutsystemSketch0.png +
                                                                  +LayoutsystemSketch.png
                                                                  -
                                                                  -LayoutsystemSketch1.png -
                                                                  -
                                                                  Sketch of the default QCPLayoutGrid accessible via QCustomPlot::plotLayout. The left image shows the outer and inner rect of the grid layout itself while the right image shows how two child layout elements are placed inside the grid layout next to each other in cells (0, 0) and (0, 1).

                                                                  +

                                                                  Above is a sketch of the default QCPLayoutGrid accessible via QCustomPlot::plotLayout. It shows how two child layout elements are placed inside the grid layout next to each other in cells (0, 0) and (0, 1).

                                                                  +

                                                                  The top level plot layout

                                                                  Every QCustomPlot has one top level layout of type QCPLayoutGrid. It is accessible via QCustomPlot::plotLayout and contains (directly or indirectly via other sub-layouts) all layout elements in the QCustomPlot. By default, this top level grid layout contains a single cell which holds the main axis rect.

                                                                  @@ -53,22 +51,35 @@
                                                                  title->setFont(QFont("sans", 12, QFont::Bold));
                                                                  // then we add it to the main plot layout:
                                                                  customPlot->plotLayout()->insertRow(0); // insert an empty row above the axis rect
                                                                  -
                                                                  customPlot->plotLayout()->addElement(0, 0, title); // insert the title in the empty cell we just created
                                                                  +
                                                                  customPlot->plotLayout()->addElement(0, 0, title); // place the title in the empty cell we've just created

                                                                  layoutsystem-addingplottitle.png

                                                                  Arranging multiple axis rects actually is the central purpose of the layout system.

                                                                  customPlot->plotLayout()->clear(); // let's start from scratch and remove the default axis rect
                                                                  // add the first axis rect in second row (row index 1):
                                                                  -
                                                                  customPlot->plotLayout()->addElement(1, 0, new QCPAxisRect(customPlot));
                                                                  +
                                                                  QCPAxisRect *topAxisRect = new QCPAxisRect(customPlot);
                                                                  +
                                                                  customPlot->plotLayout()->addElement(1, 0, topAxisRect);
                                                                  // create a sub layout that we'll place in first row:
                                                                  QCPLayoutGrid *subLayout = new QCPLayoutGrid;
                                                                  customPlot->plotLayout()->addElement(0, 0, subLayout);
                                                                  -
                                                                  // add two axis rects in the sub layout next to eachother:
                                                                  -
                                                                  subLayout->addElement(0, 0, new QCPAxisRect(customPlot));
                                                                  -
                                                                  subLayout->addElement(0, 1, new QCPAxisRect(customPlot));
                                                                  +
                                                                  // add two axis rects in the sub layout next to each other:
                                                                  +
                                                                  QCPAxisRect *leftAxisRect = new QCPAxisRect(customPlot);
                                                                  +
                                                                  QCPAxisRect *rightAxisRect = new QCPAxisRect(customPlot);
                                                                  +
                                                                  subLayout->addElement(0, 0, leftAxisRect);
                                                                  +
                                                                  subLayout->addElement(0, 1, rightAxisRect);
                                                                  subLayout->setColumnStretchFactor(0, 3); // left axis rect shall have 60% of width
                                                                  subLayout->setColumnStretchFactor(1, 2); // right one only 40% (3:2 = 60:40)
                                                                  +
                                                                  // since we've created the axis rects and axes from scratch, we need to place them on
                                                                  +
                                                                  // according layers, if we don't want the grid to be drawn above the axes etc.
                                                                  +
                                                                  // place the axis on "axes" layer and grids on the "grid" layer, which is below "axes":
                                                                  +
                                                                  QList<QCPAxis*> allAxes;
                                                                  +
                                                                  allAxes << topAxisRect->axes() << leftAxisRect->axes() << rightAxisRect->axes();
                                                                  +
                                                                  foreach (QCPAxis *axis, allAxes)
                                                                  +
                                                                  {
                                                                  +
                                                                  axis->setLayer("axes");
                                                                  +
                                                                  axis->grid()->setLayer("grid");
                                                                  +
                                                                  }
                                                                  layoutsystem-multipleaxisrects.png
                                                                  Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/documentation/qcustomplot.qch and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/documentation/qcustomplot.qch differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/examples/plots/balboa.jpg and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/examples/plots/balboa.jpg differ Binary files /tmp/eBMHu6Oqzn/qcustomplot-1.1.0/examples/plots/dali.png and /tmp/jwxEVTe5mK/qcustomplot-1.2.0/examples/plots/dali.png differ diff -Nru qcustomplot-1.1.0/examples/plots/main.cpp qcustomplot-1.2.0/examples/plots/main.cpp --- qcustomplot-1.1.0/examples/plots/main.cpp 2013-11-04 21:34:30.000000000 +0000 +++ qcustomplot-1.2.0/examples/plots/main.cpp 2014-03-14 21:07:49.000000000 +0000 @@ -1,7 +1,7 @@ /*************************************************************************** ** ** ** QCustomPlot, an easy to use, modern plotting widget for Qt ** -** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer ** +** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer ** ** ** ** 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 ** @@ -19,8 +19,8 @@ **************************************************************************** ** Author: Emanuel Eichhammer ** ** Website/Contact: http://www.qcustomplot.com/ ** -** Date: 04.11.13 ** -** Version: 1.1.0 ** +** Date: 14.03.14 ** +** Version: 1.2.0 ** ****************************************************************************/ #include diff -Nru qcustomplot-1.1.0/examples/plots/mainwindow.cpp qcustomplot-1.2.0/examples/plots/mainwindow.cpp --- qcustomplot-1.1.0/examples/plots/mainwindow.cpp 2013-11-04 21:34:33.000000000 +0000 +++ qcustomplot-1.2.0/examples/plots/mainwindow.cpp 2014-03-14 21:07:49.000000000 +0000 @@ -1,7 +1,7 @@ /*************************************************************************** ** ** ** QCustomPlot, an easy to use, modern plotting widget for Qt ** -** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer ** +** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer ** ** ** ** 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 ** @@ -19,8 +19,8 @@ **************************************************************************** ** Author: Emanuel Eichhammer ** ** Website/Contact: http://www.qcustomplot.com/ ** -** Date: 04.11.13 ** -** Version: 1.1.0 ** +** Date: 14.03.14 ** +** Version: 1.2.0 ** ****************************************************************************/ /************************************************************************************************************ @@ -74,10 +74,11 @@ // 15: setupItemDemo(ui->customPlot); // 16: setupStyledDemo(ui->customPlot); // 17: setupAdvancedAxesDemo(ui->customPlot); + // 18: setupColorMapDemo(ui->customPlot); // for making screenshots of the current demo or all demos (for website screenshots): //QTimer::singleShot(1500, this, SLOT(allScreenShots())); - //QTimer::singleShot(1000, this, SLOT(screenShot())); + //QTimer::singleShot(4000, this, SLOT(screenShot())); } void MainWindow::setupDemo(int demoIndex) @@ -102,6 +103,7 @@ case 15: setupItemDemo(ui->customPlot); break; case 16: setupStyledDemo(ui->customPlot); break; case 17: setupAdvancedAxesDemo(ui->customPlot); break; + case 18: setupColorMapDemo(ui->customPlot); break; } setWindowTitle("QCustomPlot: "+demoName); statusBar()->clearMessage(); @@ -468,7 +470,7 @@ redDotPen.setColor(QColor(170, 100, 100, 180)); redDotPen.setWidthF(2); customPlot->graph(0)->setPen(redDotPen); - customPlot->graph(0)->setBrush(QBrush(QPixmap("./dali.png"))); // fill with texture of specified png-image + customPlot->graph(0)->setBrush(QBrush(QPixmap("./balboa.jpg"))); // fill with texture of specified image customPlot->addGraph(); customPlot->graph(1)->setPen(QPen(Qt::red)); @@ -484,7 +486,7 @@ // just playing with numbers, not much to learn here x[i] = 3*i/250.0; y0[i] = 1+exp(-x[i]*x[i]*0.8)*(x[i]*x[i]+x[i]); - y1[i] = 1-exp(-x[i]*x[i]*0.4)*(x[i]*x[i])*0.1; + y1[i] = 1-exp(-x[i]*x[i]*0.4)*(x[i]*x[i])*0.1; } // pass data points to graphs: @@ -521,7 +523,7 @@ // will contain left maxwell-like function customPlot->addGraph(customPlot->yAxis, customPlot->xAxis); customPlot->graph(0)->setPen(QPen(QColor(255, 100, 0))); - customPlot->graph(0)->setBrush(QBrush(QPixmap("./dali.png"))); // fill with texture of specified png-image + customPlot->graph(0)->setBrush(QBrush(QPixmap("./balboa.jpg"))); // fill with texture of specified image customPlot->graph(0)->setLineStyle(QCPGraph::lsLine); customPlot->graph(0)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 5)); customPlot->graph(0)->setName("Left maxwell function"); @@ -530,7 +532,7 @@ // will contain bottom maxwell-like function customPlot->addGraph(); customPlot->graph(1)->setPen(QPen(Qt::red)); - customPlot->graph(1)->setBrush(QBrush(QPixmap("./dali.png"))); // same fill as we used for graph 0 + customPlot->graph(1)->setBrush(QBrush(QPixmap("./balboa.jpg"))); // same fill as we used for graph 0 customPlot->graph(1)->setLineStyle(QCPGraph::lsStepCenter); customPlot->graph(1)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, Qt::red, Qt::white, 7)); customPlot->graph(1)->setErrorType(QCPGraph::etValue); @@ -734,7 +736,7 @@ customPlot->graph(2)->setLineStyle(QCPGraph::lsNone); customPlot->graph(2)->setScatterStyle(QCPScatterStyle::ssDisc); customPlot->addGraph(); // red dot - customPlot->graph(3)->setPen(QPen(Qt::red)); + customPlot->graph(3)->setPen(QPen(Qt::red)); customPlot->graph(3)->setLineStyle(QCPGraph::lsNone); customPlot->graph(3)->setScatterStyle(QCPScatterStyle::ssDisc); @@ -832,7 +834,7 @@ // prepare x axis with country labels: QVector ticks; - QVector labels; + QVector labels; ticks << 1 << 2 << 3 << 4 << 5 << 6 << 7; labels << "USA" << "Japan" << "Germany" << "France" << "UK" << "Italy" << "Canada"; customPlot->xAxis->setAutoTicks(false); @@ -1202,7 +1204,7 @@ wideAxisRect->axis(QCPAxis::atRight, 0)->setTickLabels(true); wideAxisRect->addAxis(QCPAxis::atLeft)->setTickLabelColor(QColor("#6050F8")); // add an extra axis on the left and color its numbers QCPLayoutGrid *subLayout = new QCPLayoutGrid; - customPlot->plotLayout()->addElement(0, 0, wideAxisRect); // insert axis rect in first row + customPlot->plotLayout()->addElement(0, 0, wideAxisRect); // insert axis rect in first row customPlot->plotLayout()->addElement(1, 0, subLayout); // sub layout in second row (grid layout will grow accordingly) //customPlot->plotLayout()->setRowStretchFactor(1, 2); // prepare axis rects that will be placed in the sublayout: @@ -1295,6 +1297,60 @@ wideAxisRect->axis(QCPAxis::atLeft, 1)->setRangeLower(0); } +void MainWindow::setupColorMapDemo(QCustomPlot *customPlot) +{ + demoName = "Color Map Demo"; + + // configure axis rect: + customPlot->setInteractions(QCP::iRangeDrag|QCP::iRangeZoom); // this will also allow rescaling the color scale by dragging/zooming + customPlot->axisRect()->setupFullAxesBox(true); + customPlot->xAxis->setLabel("x"); + customPlot->yAxis->setLabel("y"); + + // set up the QCPColorMap: + QCPColorMap *colorMap = new QCPColorMap(customPlot->xAxis, customPlot->yAxis); + customPlot->addPlottable(colorMap); + int nx = 200; + int ny = 200; + colorMap->data()->setSize(nx, ny); // we want the color map to have nx * ny data points + colorMap->data()->setRange(QCPRange(-4, 4), QCPRange(-4, 4)); // and span the coordinate range -4..4 in both key (x) and value (y) dimensions + // now we assign some data, by accessing the QCPColorMapData instance of the color map: + double x, y, z; + for (int xIndex=0; xIndexdata()->cellToCoord(xIndex, yIndex, &x, &y); + double r = 3*qSqrt(x*x+y*y)+1e-2; + z = 2*x*(qCos(r+2)/r-qSin(r+2)/r); // the B field strength of dipole radiation (modulo physical constants) + colorMap->data()->setCell(xIndex, yIndex, z); + } + } + + // add a color scale: + QCPColorScale *colorScale = new QCPColorScale(customPlot); + customPlot->plotLayout()->addElement(0, 1, colorScale); // add it to the right of the main axis rect + colorScale->setType(QCPAxis::atRight); // scale shall be vertical bar with tick/axis labels right (actually atRight is already the default) + colorMap->setColorScale(colorScale); // associate the color map with the color scale + colorScale->axis()->setLabel("Magnetic Field Strength"); + + // set the color gradient of the color map to one of the presets: + colorMap->setGradient(QCPColorGradient::gpPolar); + // we could have also created a QCPColorGradient instance and added own colors to + // the gradient, see the documentation of QCPColorGradient for what's possible. + + // rescale the data dimension (color) such that all data points lie in the span visualized by the color gradient: + colorMap->rescaleDataRange(); + + // make sure the axis rect and color scale synchronize their bottom and top margins (so they line up): + QCPMarginGroup *marginGroup = new QCPMarginGroup(customPlot); + customPlot->axisRect()->setMarginGroup(QCP::msBottom|QCP::msTop, marginGroup); + colorScale->setMarginGroup(QCP::msBottom|QCP::msTop, marginGroup); + + // rescale the key (x) and value (y) axes so the whole color map is visible: + customPlot->rescaleAxes(); +} + void MainWindow::realtimeDataSlot() { // calculate two new data points: @@ -1419,7 +1475,7 @@ fileName.replace(" ", ""); pm.save("./screenshots/"+fileName); - if (currentDemoIndex < 17) + if (currentDemoIndex < 18) { if (dataTimer.isActive()) dataTimer.stop(); @@ -1431,7 +1487,7 @@ // setup delay for demos that need time to develop proper look: int delay = 250; if (currentDemoIndex == 10) // Next is Realtime data demo - delay = 12000; + delay = 12000; else if (currentDemoIndex == 15) // Next is Item demo delay = 5000; QTimer::singleShot(delay, this, SLOT(allScreenShots())); diff -Nru qcustomplot-1.1.0/examples/plots/mainwindow.h qcustomplot-1.2.0/examples/plots/mainwindow.h --- qcustomplot-1.1.0/examples/plots/mainwindow.h 2013-11-04 21:34:30.000000000 +0000 +++ qcustomplot-1.2.0/examples/plots/mainwindow.h 2014-03-14 21:07:49.000000000 +0000 @@ -1,7 +1,7 @@ /*************************************************************************** ** ** ** QCustomPlot, an easy to use, modern plotting widget for Qt ** -** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer ** +** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer ** ** ** ** 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 ** @@ -19,8 +19,8 @@ **************************************************************************** ** Author: Emanuel Eichhammer ** ** Website/Contact: http://www.qcustomplot.com/ ** -** Date: 04.11.13 ** -** Version: 1.1.0 ** +** Date: 14.03.14 ** +** Version: 1.2.0 ** ****************************************************************************/ /************************************************************************************************************ @@ -77,6 +77,7 @@ void setupItemDemo(QCustomPlot *customPlot); void setupStyledDemo(QCustomPlot *customPlot); void setupAdvancedAxesDemo(QCustomPlot *customPlot); + void setupColorMapDemo(QCustomPlot *customPlot); void setupPlayground(QCustomPlot *customPlot); diff -Nru qcustomplot-1.1.0/examples/scrollbar-axis-range-control/mainwindow.cpp qcustomplot-1.2.0/examples/scrollbar-axis-range-control/mainwindow.cpp --- qcustomplot-1.1.0/examples/scrollbar-axis-range-control/mainwindow.cpp 2013-11-04 21:34:30.000000000 +0000 +++ qcustomplot-1.2.0/examples/scrollbar-axis-range-control/mainwindow.cpp 2014-03-14 21:07:49.000000000 +0000 @@ -1,7 +1,7 @@ /*************************************************************************** ** ** ** QCustomPlot, an easy to use, modern plotting widget for Qt ** -** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer ** +** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer ** ** ** ** 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 ** @@ -19,8 +19,8 @@ **************************************************************************** ** Author: Emanuel Eichhammer ** ** Website/Contact: http://www.qcustomplot.com/ ** -** Date: 04.11.13 ** -** Version: 1.1.0 ** +** Date: 14.03.14 ** +** Version: 1.2.0 ** ****************************************************************************/ #include "mainwindow.h" diff -Nru qcustomplot-1.1.0/examples/scrollbar-axis-range-control/mainwindow.h qcustomplot-1.2.0/examples/scrollbar-axis-range-control/mainwindow.h --- qcustomplot-1.1.0/examples/scrollbar-axis-range-control/mainwindow.h 2013-11-04 21:34:30.000000000 +0000 +++ qcustomplot-1.2.0/examples/scrollbar-axis-range-control/mainwindow.h 2014-03-14 21:07:49.000000000 +0000 @@ -1,7 +1,7 @@ /*************************************************************************** ** ** ** QCustomPlot, an easy to use, modern plotting widget for Qt ** -** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer ** +** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer ** ** ** ** 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 ** @@ -19,8 +19,8 @@ **************************************************************************** ** Author: Emanuel Eichhammer ** ** Website/Contact: http://www.qcustomplot.com/ ** -** Date: 04.11.13 ** -** Version: 1.1.0 ** +** Date: 14.03.14 ** +** Version: 1.2.0 ** ****************************************************************************/ #ifndef MAINWINDOW_H diff -Nru qcustomplot-1.1.0/examples/text-document-integration/mainwindow.cpp qcustomplot-1.2.0/examples/text-document-integration/mainwindow.cpp --- qcustomplot-1.1.0/examples/text-document-integration/mainwindow.cpp 2013-11-04 21:34:30.000000000 +0000 +++ qcustomplot-1.2.0/examples/text-document-integration/mainwindow.cpp 2014-03-14 21:07:49.000000000 +0000 @@ -1,7 +1,7 @@ /*************************************************************************** ** ** ** QCustomPlot, an easy to use, modern plotting widget for Qt ** -** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer ** +** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer ** ** ** ** 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 ** @@ -19,8 +19,8 @@ **************************************************************************** ** Author: Emanuel Eichhammer ** ** Website/Contact: http://www.qcustomplot.com/ ** -** Date: 04.11.13 ** -** Version: 1.1.0 ** +** Date: 14.03.14 ** +** Version: 1.2.0 ** ****************************************************************************/ #include "mainwindow.h" diff -Nru qcustomplot-1.1.0/examples/text-document-integration/mainwindow.h qcustomplot-1.2.0/examples/text-document-integration/mainwindow.h --- qcustomplot-1.1.0/examples/text-document-integration/mainwindow.h 2013-11-04 21:34:30.000000000 +0000 +++ qcustomplot-1.2.0/examples/text-document-integration/mainwindow.h 2014-03-14 21:07:49.000000000 +0000 @@ -1,7 +1,7 @@ /*************************************************************************** ** ** ** QCustomPlot, an easy to use, modern plotting widget for Qt ** -** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer ** +** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer ** ** ** ** 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 ** @@ -19,8 +19,8 @@ **************************************************************************** ** Author: Emanuel Eichhammer ** ** Website/Contact: http://www.qcustomplot.com/ ** -** Date: 04.11.13 ** -** Version: 1.1.0 ** +** Date: 14.03.14 ** +** Version: 1.2.0 ** ****************************************************************************/ #ifndef MAINWINDOW_H diff -Nru qcustomplot-1.1.0/examples/text-document-integration/qcpdocumentobject.cpp qcustomplot-1.2.0/examples/text-document-integration/qcpdocumentobject.cpp --- qcustomplot-1.1.0/examples/text-document-integration/qcpdocumentobject.cpp 2013-11-04 21:34:30.000000000 +0000 +++ qcustomplot-1.2.0/examples/text-document-integration/qcpdocumentobject.cpp 2014-03-14 21:07:49.000000000 +0000 @@ -1,7 +1,7 @@ /*************************************************************************** ** ** ** QCustomPlot, an easy to use, modern plotting widget for Qt ** -** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer ** +** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer ** ** ** ** 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 ** @@ -19,8 +19,8 @@ **************************************************************************** ** Author: Emanuel Eichhammer ** ** Website/Contact: http://www.qcustomplot.com/ ** -** Date: 04.11.13 ** -** Version: 1.1.0 ** +** Date: 14.03.14 ** +** Version: 1.2.0 ** ****************************************************************************/ #include "qcpdocumentobject.h" diff -Nru qcustomplot-1.1.0/examples/text-document-integration/qcpdocumentobject.h qcustomplot-1.2.0/examples/text-document-integration/qcpdocumentobject.h --- qcustomplot-1.1.0/examples/text-document-integration/qcpdocumentobject.h 2013-11-04 21:34:30.000000000 +0000 +++ qcustomplot-1.2.0/examples/text-document-integration/qcpdocumentobject.h 2014-03-14 21:07:49.000000000 +0000 @@ -1,7 +1,7 @@ /*************************************************************************** ** ** ** QCustomPlot, an easy to use, modern plotting widget for Qt ** -** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer ** +** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer ** ** ** ** 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 ** @@ -19,8 +19,8 @@ **************************************************************************** ** Author: Emanuel Eichhammer ** ** Website/Contact: http://www.qcustomplot.com/ ** -** Date: 04.11.13 ** -** Version: 1.1.0 ** +** Date: 14.03.14 ** +** Version: 1.2.0 ** ****************************************************************************/ #ifndef QCPDOCUMENTOBJECT_H diff -Nru qcustomplot-1.1.0/qcustomplot.cpp qcustomplot-1.2.0/qcustomplot.cpp --- qcustomplot-1.1.0/qcustomplot.cpp 2013-11-04 22:19:27.000000000 +0000 +++ qcustomplot-1.2.0/qcustomplot.cpp 2014-03-14 21:11:10.000000000 +0000 @@ -1,7 +1,7 @@ /*************************************************************************** ** ** ** QCustomPlot, an easy to use, modern plotting widget for Qt ** -** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer ** +** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer ** ** ** ** 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 ** @@ -19,8 +19,8 @@ **************************************************************************** ** Author: Emanuel Eichhammer ** ** Website/Contact: http://www.qcustomplot.com/ ** -** Date: 04.11.13 ** -** Version: 1.1.0 ** +** Date: 14.03.14 ** +** Version: 1.2.0 ** ****************************************************************************/ #include "qcustomplot.h" @@ -35,7 +35,7 @@ /*! \class QCPPainter \brief QPainter subclass used internally - This internal class is used to provide some extended functionality e.g. for tweaking position + This QPainter subclass is used to provide some extended functionality e.g. for tweaking position consistency between antialiased and non-antialiased painting. Further it provides workarounds for QPainter quirks. @@ -135,7 +135,7 @@ QPainter::drawLine(line.toLine()); } -/*! +/*! Sets whether painting uses antialiasing or not. Use this method instead of using setRenderHint with QPainter::Antialiasing directly, as it allows QCPPainter to regain pixel exactness between antialiased and non-antialiased painting (Since Qt < 5.0 uses slightly different coordinate systems for @@ -752,7 +752,8 @@ QObject(parentPlot), mParentPlot(parentPlot), mName(layerName), - mIndex(-1) // will be set to a proper value by the QCustomPlot layer creation function + mIndex(-1), // will be set to a proper value by the QCustomPlot layer creation function + mVisible(true) { // Note: no need to make sure layerName is unique, because layer // management is done with QCustomPlot functions. @@ -772,6 +773,19 @@ qDebug() << Q_FUNC_INFO << "The parent plot's mCurrentLayer will be a dangling pointer. Should have been set to a valid layer or 0 beforehand."; } +/*! + Sets whether this layer is visible or not. If \a visible is set to false, all layerables on this + layer will be invisible. + + This function doesn't change the visibility property of the layerables (\ref + QCPLayerable::setVisible), but the \ref QCPLayerable::realVisibility of each layerable takes the + visibility of the parent layer into account. +*/ +void QCPLayer::setVisible(bool visible) +{ + mVisible = visible; +} + /*! \internal Adds the \a layerable to the list of this layer. If \a prepend is set to true, the layerable will @@ -885,6 +899,17 @@ */ /* end documentation of pure virtual functions */ +/* start documentation of signals */ + +/*! \fn void QCPLayerable::layerChanged(QCPLayer *newLayer); + + This signal is emitted when the layer of this layerable changes, i.e. this layerable is moved to + a different layer. + + \see setLayer +*/ + +/* end documentation of signals */ /*! Creates a new QCPLayerable instance. @@ -985,9 +1010,9 @@ } /*! - Returns whether this layerable is visible, taking possible direct layerable parent visibility - into account. This is the method that is consulted to decide whether a layerable shall be drawn - or not. + Returns whether this layerable is visible, taking the visibility of the layerable parent and the + visibility of the layer this layerable is on into account. This is the method that is consulted + to decide whether a layerable shall be drawn or not. If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this @@ -999,7 +1024,7 @@ */ bool QCPLayerable::realVisibility() const { - return mVisible && (!mParentLayerable || mParentLayerable.data()->realVisibility()); + return mVisible && (!mLayer || mLayer->visible()) && (!mParentLayerable || mParentLayerable.data()->realVisibility()); } /*! @@ -1113,11 +1138,14 @@ return false; } + QCPLayer *oldLayer = mLayer; if (mLayer) mLayer->removeChild(this); mLayer = layer; if (mLayer) mLayer->addChild(this, prepend); + if (mLayer != oldLayer) + emit layerChanged(mLayer); return true; } @@ -1205,7 +1233,7 @@ Every selectEvent is preceded by a call to \ref selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). - The \a details data you output from \ref selectTest is feeded back via \a details here. You may + The \a details data you output from \ref selectTest is fed back via \a details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually \a details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need @@ -1258,7 +1286,7 @@ \see QCPAxis::setRange */ -/*! +/*! Minimum range size (\a upper - \a lower) the range changing functions will accept. Smaller intervals would cause errors due to the 11-bit exponent of double precision numbers, corresponding to a minimum magnitude of roughly 1e-308. @@ -1266,7 +1294,7 @@ */ const double QCPRange::minRange = 1e-280; -/*! +/*! Maximum values (negative and positive) the range will accept in range-changing functions. Larger absolute values would cause errors due to the 11-bit exponent of double precision numbers, corresponding to a maximum magnitude of roughly 1e308. @@ -1276,7 +1304,7 @@ */ const double QCPRange::maxRange = 1e250; -/*! +/*! Constructs a range with \a lower and \a upper set to zero. */ QCPRange::QCPRange() : @@ -1295,7 +1323,7 @@ normalize(); } -/*! +/*! Returns the size of the range, i.e. \a upper-\a lower */ double QCPRange::size() const @@ -1303,7 +1331,7 @@ return upper-lower; } -/*! +/*! Returns the center of the range, i.e. (\a upper+\a lower)*0.5 */ double QCPRange::center() const @@ -1311,7 +1339,7 @@ return (upper+lower)*0.5; } -/*! +/*! Makes sure \a lower is numerically smaller than \a upper. If this is not the case, the values are swapped. */ @@ -1321,7 +1349,7 @@ qSwap(lower, upper); } -/*! +/*! Expands this range such that \a otherRange is contained in the new range. It is assumed that both this range and \a otherRange are normalized (see \ref normalize). @@ -1338,7 +1366,7 @@ } -/*! +/*! Returns an expanded range that contains this and \a otherRange. It is assumed that both this range and \a otherRange are normalized (see \ref normalize). @@ -1351,7 +1379,7 @@ return result; } -/*! +/*! Returns a sanitized version of the range. Sanitized means for logarithmic scales, that the range won't span the positive and negative sign domain, i.e. contain zero. Further \a lower will always be numerically smaller (or equal) to \a upper. @@ -1408,7 +1436,7 @@ return sanitizedRange; } -/*! +/*! Returns a sanitized version of the range. Sanitized means for linear scales, that \a lower will always be numerically smaller (or equal) to \a upper. */ @@ -1419,7 +1447,7 @@ return sanitizedRange; } -/*! +/*! Returns true when \a value lies within or exactly on the borders of the range. */ bool QCPRange::contains(double value) const @@ -1427,7 +1455,7 @@ return value >= lower && value <= upper; } -/*! +/*! Checks, whether the specified range is within valid bounds, which are defined as QCPRange::maxRange and QCPRange::minRange. A valid range means: @@ -1450,7 +1478,7 @@ qAbs(lower-upper) < maxRange); } -/*! +/*! \overload Checks, whether the specified range is within valid bounds, which are defined as QCPRange::maxRange and QCPRange::minRange. @@ -1532,17 +1560,11 @@ Since a QCPLayout is a layout element itself, it may be placed inside other layouts. This way, complex hierarchies may be created, offering very flexible arrangements. -
                                                                  -
                                                                  \image html LayoutsystemSketch0.png ""
                                                                  -
                                                                  \image html LayoutsystemSketch1.png ""
                                                                  -
                                                                  -
                                                                  - Sketch of the default QCPLayoutGrid accessible via \ref QCustomPlot::plotLayout. The left image - shows the outer and inner rect of the grid layout itself while the right image shows how two - child layout elements are placed inside the grid layout next to each other in cells (0, 0) and - (0, 1). -
                                                                  -
                                                                  + \image html LayoutsystemSketch.png + + Above is a sketch of the default \ref QCPLayoutGrid accessible via \ref QCustomPlot::plotLayout. + It shows how two child layout elements are placed inside the grid layout next to each other in + cells (0, 0) and (0, 1). \subsection layoutsystem-plotlayout The top level plot layout @@ -1561,7 +1583,7 @@ title->setFont(QFont("sans", 12, QFont::Bold)); // then we add it to the main plot layout: customPlot->plotLayout()->insertRow(0); // insert an empty row above the axis rect - customPlot->plotLayout()->addElement(0, 0, title); // insert the title in the empty cell we just created + customPlot->plotLayout()->addElement(0, 0, title); // place the title in the empty cell we've just created \endcode \image html layoutsystem-addingplottitle.png @@ -1569,15 +1591,28 @@ \code customPlot->plotLayout()->clear(); // let's start from scratch and remove the default axis rect // add the first axis rect in second row (row index 1): - customPlot->plotLayout()->addElement(1, 0, new QCPAxisRect(customPlot)); + QCPAxisRect *topAxisRect = new QCPAxisRect(customPlot); + customPlot->plotLayout()->addElement(1, 0, topAxisRect); // create a sub layout that we'll place in first row: QCPLayoutGrid *subLayout = new QCPLayoutGrid; customPlot->plotLayout()->addElement(0, 0, subLayout); - // add two axis rects in the sub layout next to eachother: - subLayout->addElement(0, 0, new QCPAxisRect(customPlot)); - subLayout->addElement(0, 1, new QCPAxisRect(customPlot)); + // add two axis rects in the sub layout next to each other: + QCPAxisRect *leftAxisRect = new QCPAxisRect(customPlot); + QCPAxisRect *rightAxisRect = new QCPAxisRect(customPlot); + subLayout->addElement(0, 0, leftAxisRect); + subLayout->addElement(0, 1, rightAxisRect); subLayout->setColumnStretchFactor(0, 3); // left axis rect shall have 60% of width subLayout->setColumnStretchFactor(1, 2); // right one only 40% (3:2 = 60:40) + // since we've created the axis rects and axes from scratch, we need to place them on + // according layers, if we don't want the grid to be drawn above the axes etc. + // place the axis on "axes" layer and grids on the "grid" layer, which is below "axes": + QList allAxes; + allAxes << topAxisRect->axes() << leftAxisRect->axes() << rightAxisRect->axes(); + foreach (QCPAxis *axis, allAxes) + { + axis->setLayer("axes"); + axis->grid()->setLayer("grid"); + } \endcode \image html layoutsystem-multipleaxisrects.png @@ -1612,7 +1647,7 @@ \section QCPMarginGroup-example Example First create a margin group: - \code + \code QCPMarginGroup *group = new QCPMarginGroup(customPlot); \endcode Then set this group on the layout element sides: @@ -2007,37 +2042,40 @@ } /*! - Updates the layout element and sub-elements. This function is automatically called upon replot by - the parent layout element. + Updates the layout element and sub-elements. This function is automatically called before every + replot by the parent layout element. It is called multiple times, once for every \ref + UpdatePhase. The phases are run through in the order of the enum values. For details about what + happens at the different phases, see the documentation of \ref UpdatePhase. Layout elements that have child elements should call the \ref update method of their child - elements. + elements, and pass the current \a phase unchanged. - The default implementation executes the automatic margin mechanism, so subclasses should make - sure to call the base class implementation. + The default implementation executes the automatic margin mechanism in the \ref upMargins phase. + Subclasses should make sure to call the base class implementation. */ -void QCPLayoutElement::update() +void QCPLayoutElement::update(UpdatePhase phase) { - if (mAutoMargins != QCP::msNone) + if (phase == upMargins) { - // set the margins of this layout element according to automatic margin calculation, either directly or via a margin group: - QMargins newMargins = mMargins; - QVector marginSides = QVector() << QCP::msLeft << QCP::msRight << QCP::msTop << QCP::msBottom; - for (int i=0; i() << QCP::msLeft << QCP::msRight << QCP::msTop << QCP::msBottom) { - if (mMarginGroups.contains(side)) - QCP::setMarginValue(newMargins, side, mMarginGroups[side]->commonMargin(side)); // this side is part of a margin group, so get the margin value from that group - else - QCP::setMarginValue(newMargins, side, calculateAutoMargin(side)); // this side is not part of a group, so calculate the value directly - // apply minimum margin restrictions: - if (QCP::getMarginValue(newMargins, side) < QCP::getMarginValue(mMinimumMargins, side)) - QCP::setMarginValue(newMargins, side, QCP::getMarginValue(mMinimumMargins, side)); + if (mAutoMargins.testFlag(side)) // this side's margin shall be calculated automatically + { + if (mMarginGroups.contains(side)) + QCP::setMarginValue(newMargins, side, mMarginGroups[side]->commonMargin(side)); // this side is part of a margin group, so get the margin value from that group + else + QCP::setMarginValue(newMargins, side, calculateAutoMargin(side)); // this side is not part of a group, so calculate the value directly + // apply minimum margin restrictions: + if (QCP::getMarginValue(newMargins, side) < QCP::getMarginValue(mMinimumMargins, side)) + QCP::setMarginValue(newMargins, side, QCP::getMarginValue(mMinimumMargins, side)); + } } + setMargins(newMargins); } - setMargins(newMargins); } } @@ -2069,7 +2107,7 @@ Returns a list of all child elements in this layout element. If \a recursive is true, all sub-child elements are included in the list, too. - Note that there may be entries with value 0 in the returned list. (For example, QCPLayoutGrid may have + \warning There may be entries with value 0 in the returned list. (For example, QCPLayoutGrid may have empty cells which yield 0 at the respective index.) */ QList QCPLayoutElement::elements(bool recursive) const @@ -2109,22 +2147,21 @@ return -1; } -/*! \internal +/*! \internal propagates the parent plot initialization to all child elements, by calling \ref QCPLayerable::initializeParentPlot on them. */ void QCPLayoutElement::parentPlotInitialized(QCustomPlot *parentPlot) { - QList els = elements(false); - for (int i=0; iparentPlot()) - els.at(i)->initializeParentPlot(parentPlot); + if (!el->parentPlot()) + el->initializeParentPlot(parentPlot); } } -/*! \internal +/*! \internal Returns the margin size for this \a side. It is used if automatic margins is enabled for this \a side (see \ref setAutoMargins). If a minimum margin was set with \ref setMinimumMargins, the @@ -2212,7 +2249,7 @@ /* end documentation of pure virtual functions */ /*! - Creates an instance of QCPLayoutElement and sets default values. Note that since QCPLayoutElement + Creates an instance of QCPLayout and sets default values. Note that since QCPLayout is an abstract base class, it can't be instantiated directly. */ QCPLayout::QCPLayout() @@ -2227,25 +2264,27 @@ Finally, \ref update is called on all child elements. */ -void QCPLayout::update() +void QCPLayout::update(UpdatePhase phase) { - QCPLayoutElement::update(); // recalculates (auto-)margins + QCPLayoutElement::update(phase); // set child element rects according to layout: - updateLayout(); + if (phase == upLayout) + updateLayout(); // propagate update call to child elements: - for (int i=0; iupdate(); + el->update(phase); } } /* inherits documentation from base class */ QList QCPLayout::elements(bool recursive) const { - int c = elementCount(); + const int c = elementCount(); QList result; #if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) result.reserve(c); @@ -2657,7 +2696,7 @@ adoptElement(element); return true; } else - qDebug() << Q_FUNC_INFO << "There is already an element in the specified row/column:" << row << column; + qDebug() << Q_FUNC_INFO << "There is already an element in the specified row/column:" << row << column; } else qDebug() << Q_FUNC_INFO << "Can't add null element to row/column:" << row << column; return false; @@ -3367,11 +3406,11 @@ } /*! - The inset layout is sensitive to events only at areas where its child elements are sensitive. If - the selectTest method of any of the child elements returns a positive number for \a pos, this - method returns a value corresponding to 0.99 times the parent plot's selection tolerance. The - inset layout is not selectable itself by default. So if \a onlySelectable is true, -1.0 is - returned. + The inset layout is sensitive to events only at areas where its (visible) child elements are + sensitive. If the selectTest method of any of the child elements returns a positive number for \a + pos, this method returns a value corresponding to 0.99 times the parent plot's selection + tolerance. The inset layout is not selectable itself by default. So if \a onlySelectable is true, + -1.0 is returned. See \ref QCPLayerable::selectTest for a general explanation of this virtual method. */ @@ -3385,7 +3424,7 @@ { // inset layout shall only return positive selectTest, if actually an inset object is at pos // else it would block the entire underlying QCPAxisRect with its surface. - if (mElements.at(i)->selectTest(pos, onlySelectable) >= 0) + if (mElements.at(i)->realVisibility() && mElements.at(i)->selectTest(pos, onlySelectable) >= 0) return mParentPlot->selectionTolerance()*0.99; } return -1; @@ -3616,8 +3655,8 @@ if (lengthVec.isNull()) lengthVec = QVector2D(1, 0); QVector2D widthVec(-lengthVec.y(), lengthVec.x()); - lengthVec *= mLength*(mInverted ? -1 : 1); - widthVec *= mWidth*0.5*(mInverted ? -1 : 1); + lengthVec *= (float)(mLength*(mInverted ? -1 : 1)); + widthVec *= (float)(mWidth*0.5*(mInverted ? -1 : 1)); QPen penBackup = painter->pen(); QBrush brushBackup = painter->brush(); @@ -3644,7 +3683,7 @@ { QPointF points[4] = {pos.toPointF(), (pos-lengthVec+widthVec).toPointF(), - (pos-lengthVec*0.8).toPointF(), + (pos-lengthVec*0.8f).toPointF(), (pos-lengthVec-widthVec).toPointF() }; painter->setPen(miterPen); @@ -3717,13 +3756,13 @@ if (qFuzzyIsNull(painter->pen().widthF()) && !painter->modes().testFlag(QCPPainter::pmNonCosmetic)) { // if drawing with cosmetic pen (perfectly thin stroke, happens only in vector exports), draw bar exactly on tip of line - painter->drawLine((pos+widthVec+lengthVec*0.2*(mInverted?-1:1)).toPointF(), - (pos-widthVec-lengthVec*0.2*(mInverted?-1:1)).toPointF()); + painter->drawLine((pos+widthVec+lengthVec*0.2f*(mInverted?-1:1)).toPointF(), + (pos-widthVec-lengthVec*0.2f*(mInverted?-1:1)).toPointF()); } else { // if drawing with thick (non-cosmetic) pen, shift bar a little in line direction to prevent line from sticking through bar slightly - painter->drawLine((pos+widthVec+lengthVec*0.2*(mInverted?-1:1)+dir.normalized()*qMax(1.0, (double)painter->pen().widthF())*0.5).toPointF(), - (pos-widthVec-lengthVec*0.2*(mInverted?-1:1)+dir.normalized()*qMax(1.0, (double)painter->pen().widthF())*0.5).toPointF()); + painter->drawLine((pos+widthVec+lengthVec*0.2f*(mInverted?-1:1)+dir.normalized()*qMax(1.0f, (float)painter->pen().widthF())*0.5f).toPointF(), + (pos-widthVec-lengthVec*0.2f*(mInverted?-1:1)+dir.normalized()*qMax(1.0f, (float)painter->pen().widthF())*0.5f).toPointF()); } break; } @@ -3994,8 +4033,10 @@ /*! \fn Qt::Orientation QCPAxis::orientation() const - Returns the orientation of the axis. The axis orientation (horizontal or vertical) is deduced + Returns the orientation of this axis. The axis orientation (horizontal or vertical) is deduced from the axis type (left, top, right or bottom). + + \see orientation(AxisType type) */ /*! \fn QCPGrid *QCPAxis::grid() const @@ -4004,6 +4045,13 @@ grid is displayed. */ +/*! \fn static Qt::Orientation QCPAxis::orientation(AxisType type) + + Returns the orientation of the specified axis type + + \see orientation() +*/ + /* end of documentation of inline functions */ /* start of documentation of signals */ @@ -4036,12 +4084,22 @@ \a oldRange. */ +/*! \fn void QCPAxis::scaleTypeChanged(QCPAxis::ScaleType scaleType); + + This signal is emitted when the scale type changes, by calls to \ref setScaleType +*/ + /*! \fn void QCPAxis::selectionChanged(QCPAxis::SelectableParts selection) This signal is emitted when the selection state of this axis has changed, either by user interaction or by a direct call to \ref setSelectedParts. */ +/*! \fn void QCPAxis::selectableChanged(const QCPAxis::SelectableParts &parts); + + This signal is emitted when the selectability changes, by calls to \ref setSelectableParts +*/ + /* end of documentation of signals */ /*! @@ -4053,27 +4111,21 @@ // axis base: mAxisType(type), mAxisRect(parent), - mOffset(0), mPadding(5), - mOrientation((type == atBottom || type == atTop) ? Qt::Horizontal : Qt::Vertical), + mOrientation(orientation(type)), mSelectableParts(spAxis | spTickLabels | spAxisLabel), mSelectedParts(spNone), mBasePen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)), mSelectedBasePen(QPen(Qt::blue, 2)), - mLowerEnding(QCPLineEnding::esNone), - mUpperEnding(QCPLineEnding::esNone), // axis label: - mLabelPadding(0), mLabel(""), mLabelFont(mParentPlot->font()), mSelectedLabelFont(QFont(mLabelFont.family(), mLabelFont.pointSize(), QFont::Bold)), mLabelColor(Qt::black), mSelectedLabelColor(Qt::blue), // tick labels: - mTickLabelPadding(0), mTickLabels(true), mAutoTickLabels(true), - mTickLabelRotation(0), mTickLabelType(ltNumber), mTickLabelFont(mParentPlot->font()), mSelectedTickLabelFont(QFont(mTickLabelFont.family(), mTickLabelFont.pointSize(), QFont::Bold)), @@ -4084,7 +4136,6 @@ mNumberPrecision(6), mNumberFormatChar('g'), mNumberBeautifulPowers(true), - mNumberMultiplyCross(false), // ticks and subticks: mTicks(true), mTickStep(1), @@ -4093,10 +4144,6 @@ mAutoTicks(true), mAutoTickStep(true), mAutoSubTicks(true), - mTickLengthIn(5), - mTickLengthOut(0), - mSubTickLengthIn(2), - mSubTickLengthOut(0), mTickPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)), mSelectedTickPen(QPen(Qt::blue, 2)), mSubTickPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)), @@ -4109,11 +4156,9 @@ mScaleLogBaseLogInv(1.0/qLn(mScaleLogBase)), // internal members: mGrid(new QCPGrid(this)), - mLabelCache(16), // cache at most 16 (tick) labels + mAxisPainter(new QCPAxisPainterPrivate(parent->parentPlot())), mLowestVisibleTick(0), mHighestVisibleTick(-1), - mExponentialChar('e'), // will be updated with locale sensitive values in setupTickVector - mPositiveSignChar('+'), // will be updated with locale sensitive values in setupTickVector mCachedMarginValid(false), mCachedMargin(0) { @@ -4140,6 +4185,23 @@ } } +QCPAxis::~QCPAxis() +{ + delete mAxisPainter; +} + +/* No documentation as it is a property getter */ +int QCPAxis::tickLabelPadding() const +{ + return mAxisPainter->tickLabelPadding; +} + +/* No documentation as it is a property getter */ +double QCPAxis::tickLabelRotation() const +{ + return mAxisPainter->tickLabelRotation; +} + /* No documentation as it is a property getter */ QString QCPAxis::numberFormat() const { @@ -4148,12 +4210,60 @@ if (mNumberBeautifulPowers) { result.append("b"); - if (mNumberMultiplyCross) + if (mAxisPainter->numberMultiplyCross) result.append("c"); } return result; } +/* No documentation as it is a property getter */ +int QCPAxis::tickLengthIn() const +{ + return mAxisPainter->tickLengthIn; +} + +/* No documentation as it is a property getter */ +int QCPAxis::tickLengthOut() const +{ + return mAxisPainter->tickLengthOut; +} + +/* No documentation as it is a property getter */ +int QCPAxis::subTickLengthIn() const +{ + return mAxisPainter->subTickLengthIn; +} + +/* No documentation as it is a property getter */ +int QCPAxis::subTickLengthOut() const +{ + return mAxisPainter->subTickLengthOut; +} + +/* No documentation as it is a property getter */ +int QCPAxis::labelPadding() const +{ + return mAxisPainter->labelPadding; +} + +/* No documentation as it is a property getter */ +int QCPAxis::offset() const +{ + return mAxisPainter->offset; +} + +/* No documentation as it is a property getter */ +QCPLineEnding QCPAxis::lowerEnding() const +{ + return mAxisPainter->lowerEnding; +} + +/* No documentation as it is a property getter */ +QCPLineEnding QCPAxis::upperEnding() const +{ + return mAxisPainter->upperEnding; +} + /*! Sets whether the axis uses a linear scale or a logarithmic scale. If \a type is set to \ref stLogarithmic, the logarithm base can be set with \ref setScaleLogBase. In logarithmic axis @@ -4167,14 +4277,15 @@ part). To only display the decimal power, set the number precision to zero with \ref setNumberPrecision. */ -void QCPAxis::setScaleType(ScaleType type) +void QCPAxis::setScaleType(QCPAxis::ScaleType type) { if (mScaleType != type) { mScaleType = type; if (mScaleType == stLogarithmic) - mRange = mRange.sanitizedForLogScale(); + setRange(mRange.sanitizedForLogScale()); mCachedMarginValid = false; + emit scaleTypeChanged(mScaleType); } } @@ -4235,7 +4346,11 @@ */ void QCPAxis::setSelectableParts(const SelectableParts &selectable) { - mSelectableParts = selectable; + if (mSelectableParts != selectable) + { + mSelectableParts = selectable; + emit selectableChanged(mSelectableParts); + } } /*! @@ -4257,8 +4372,6 @@ { if (mSelectedParts != selected) { - if (mSelectedParts.testFlag(spTickLabels) != selected.testFlag(spTickLabels)) - mLabelCache.clear(); mSelectedParts = selected; emit selectionChanged(mSelectedParts); } @@ -4391,6 +4504,8 @@ If you need dynamically calculated tick vectors (and possibly tick label vectors), set the vectors in a slot connected to the \ref ticksRequest signal. + + \see setAutoTickLabels, setAutoSubTicks, setAutoTickCount, setAutoTickStep */ void QCPAxis::setAutoTicks(bool on) { @@ -4409,6 +4524,8 @@ tolerance of about two. Only values greater than zero are accepted as \a approximateCount. + + \see setAutoTickStep, setAutoTicks, setAutoSubTicks */ void QCPAxis::setAutoTickCount(int approximateCount) { @@ -4435,6 +4552,8 @@ If you need dynamically calculated tick vectors (and possibly tick label vectors), set the vectors in a slot connected to the \ref ticksRequest signal. + + \see setAutoTicks */ void QCPAxis::setAutoTickLabels(bool on) { @@ -4448,12 +4567,14 @@ /*! Sets whether the tick step, i.e. the interval between two (major) ticks, is calculated automatically. If \a on is set to true, the axis finds a tick step that is reasonable for human - readable plots. + readable plots. - The number of ticks the algorithm aims for within the visible range can be set with \ref + The number of ticks the algorithm aims for within the visible range can be specified with \ref setAutoTickCount. If \a on is set to false, you may set the tick step manually with \ref setTickStep. + + \see setAutoTicks, setAutoSubTicks, setAutoTickCount */ void QCPAxis::setAutoTickStep(bool on) { @@ -4470,6 +4591,8 @@ enabled, this is always the case. When \a on is set to false, you may set the sub tick count with \ref setSubTickCount manually. + + \see setAutoTickCount, setAutoTicks, setAutoTickStep */ void QCPAxis::setAutoSubTicks(bool on) { @@ -4513,9 +4636,9 @@ */ void QCPAxis::setTickLabelPadding(int padding) { - if (mTickLabelPadding != padding) + if (mAxisPainter->tickLabelPadding != padding) { - mTickLabelPadding = padding; + mAxisPainter->tickLabelPadding = padding; mCachedMarginValid = false; } } @@ -4561,7 +4684,6 @@ { mTickLabelFont = font; mCachedMarginValid = false; - mLabelCache.clear(); } } @@ -4576,7 +4698,6 @@ { mTickLabelColor = color; mCachedMarginValid = false; - mLabelCache.clear(); } } @@ -4591,11 +4712,10 @@ */ void QCPAxis::setTickLabelRotation(double degrees) { - if (!qFuzzyIsNull(degrees-mTickLabelRotation)) + if (!qFuzzyIsNull(degrees-mAxisPainter->tickLabelRotation)) { - mTickLabelRotation = qBound(-90.0, degrees, 90.0); + mAxisPainter->tickLabelRotation = qBound(-90.0, degrees, 90.0); mCachedMarginValid = false; - mLabelCache.clear(); } } @@ -4613,7 +4733,6 @@ { mDateTimeFormat = format; mCachedMarginValid = false; - mLabelCache.clear(); } } @@ -4675,7 +4794,6 @@ qDebug() << Q_FUNC_INFO << "Passed formatCode is empty"; return; } - mLabelCache.clear(); mCachedMarginValid = false; // interpret first char as number format char: @@ -4691,7 +4809,7 @@ if (formatCode.length() < 2) { mNumberBeautifulPowers = false; - mNumberMultiplyCross = false; + mAxisPainter->numberMultiplyCross = false; return; } @@ -4706,17 +4824,17 @@ } if (formatCode.length() < 3) { - mNumberMultiplyCross = false; + mAxisPainter->numberMultiplyCross = false; return; } // interpret third char as indicator for dot or cross multiplication symbol: if (formatCode.at(2) == 'c') { - mNumberMultiplyCross = true; + mAxisPainter->numberMultiplyCross = true; } else if (formatCode.at(2) == 'd') { - mNumberMultiplyCross = false; + mAxisPainter->numberMultiplyCross = false; } else { qDebug() << Q_FUNC_INFO << "Invalid number format code (third char neither 'c' nor 'd'):" << formatCode; @@ -4802,32 +4920,25 @@ zero, the tick labels and axis label will increase their distance to the axis accordingly, so they won't collide with the ticks. - \see setSubTickLength + \see setSubTickLength, setTickLengthIn, setTickLengthOut */ void QCPAxis::setTickLength(int inside, int outside) { - if (mTickLengthIn != inside) - { - mTickLengthIn = inside; - } - if (mTickLengthOut != outside) - { - mTickLengthOut = outside; - mCachedMarginValid = false; // only outside tick length can change margin - } + setTickLengthIn(inside); + setTickLengthOut(outside); } /*! Sets the length of the inward ticks in pixels. \a inside is the length the ticks will reach inside the plot. - \see setTickLengthOut, setSubTickLength + \see setTickLengthOut, setTickLength, setSubTickLength */ void QCPAxis::setTickLengthIn(int inside) { - if (mTickLengthIn != inside) + if (mAxisPainter->tickLengthIn != inside) { - mTickLengthIn = inside; + mAxisPainter->tickLengthIn = inside; } } @@ -4836,13 +4947,13 @@ outside the plot. If \a outside is greater than zero, the tick labels and axis label will increase their distance to the axis accordingly, so they won't collide with the ticks. - \see setTickLengthIn, setSubTickLength + \see setTickLengthIn, setTickLength, setSubTickLength */ void QCPAxis::setTickLengthOut(int outside) { - if (mTickLengthOut != outside) + if (mAxisPainter->tickLengthOut != outside) { - mTickLengthOut = outside; + mAxisPainter->tickLengthOut = outside; mCachedMarginValid = false; // only outside tick length can change margin } } @@ -4868,31 +4979,26 @@ the plot and \a outside is the length they will reach outside the plot. If \a outside is greater than zero, the tick labels and axis label will increase their distance to the axis accordingly, so they won't collide with the ticks. + + \see setTickLength, setSubTickLengthIn, setSubTickLengthOut */ void QCPAxis::setSubTickLength(int inside, int outside) { - if (mSubTickLengthIn != inside) - { - mSubTickLengthIn = inside; - } - if (mSubTickLengthOut != outside) - { - mSubTickLengthOut = outside; - mCachedMarginValid = false; // only outside tick length can change margin - } + setSubTickLengthIn(inside); + setSubTickLengthOut(outside); } /*! Sets the length of the inward subticks in pixels. \a inside is the length the subticks will reach inside the plot. - \see setSubTickLengthOut, setTickLength + \see setSubTickLengthOut, setSubTickLength, setTickLength */ void QCPAxis::setSubTickLengthIn(int inside) { - if (mSubTickLengthIn != inside) + if (mAxisPainter->subTickLengthIn != inside) { - mSubTickLengthIn = inside; + mAxisPainter->subTickLengthIn = inside; } } @@ -4901,13 +5007,13 @@ outside the plot. If \a outside is greater than zero, the tick labels will increase their distance to the axis accordingly, so they won't collide with the ticks. - \see setSubTickLengthIn, setTickLength + \see setSubTickLengthIn, setSubTickLength, setTickLength */ void QCPAxis::setSubTickLengthOut(int outside) { - if (mSubTickLengthOut != outside) + if (mAxisPainter->subTickLengthOut != outside) { - mSubTickLengthOut = outside; + mAxisPainter->subTickLengthOut = outside; mCachedMarginValid = false; // only outside tick length can change margin } } @@ -4986,9 +5092,9 @@ */ void QCPAxis::setLabelPadding(int padding) { - if (mLabelPadding != padding) + if (mAxisPainter->labelPadding != padding) { - mLabelPadding = padding; + mAxisPainter->labelPadding = padding; mCachedMarginValid = false; } } @@ -5015,12 +5121,14 @@ /*! Sets the offset the axis has to its axis rect side. - If an axis rect side has multiple axes, only the offset of the inner most axis has meaning. The offset of the other axes - is controlled automatically, to place the axes at appropriate positions to prevent them from overlapping. + If an axis rect side has multiple axes and automatic margin calculation is enabled for that side, + only the offset of the inner most axis has meaning (even if it is set to be invisible). The + offset of the other, outer axes is controlled automatically, to place them at appropriate + positions. */ void QCPAxis::setOffset(int offset) { - mOffset = offset; + mAxisPainter->offset = offset; } /*! @@ -5033,7 +5141,6 @@ if (font != mSelectedTickLabelFont) { mSelectedTickLabelFont = font; - mLabelCache.clear(); // don't set mCachedMarginValid to false here because margin calculation is always done with non-selected fonts } } @@ -5059,7 +5166,6 @@ if (color != mSelectedTickLabelColor) { mSelectedTickLabelColor = color; - mLabelCache.clear(); } } @@ -5115,7 +5221,7 @@ */ void QCPAxis::setLowerEnding(const QCPLineEnding &ending) { - mLowerEnding = ending; + mAxisPainter->lowerEnding = ending; } /*! @@ -5130,7 +5236,7 @@ */ void QCPAxis::setUpperEnding(const QCPLineEnding &ending) { - mUpperEnding = ending; + mAxisPainter->upperEnding = ending; } /*! @@ -5237,15 +5343,15 @@ if (!p.at(i)->realVisibility() && onlyVisiblePlottables) continue; QCPRange plottableRange; - bool validRange; + bool currentFoundRange; QCPAbstractPlottable::SignDomain signDomain = QCPAbstractPlottable::sdBoth; if (mScaleType == stLogarithmic) signDomain = (mRange.upper < 0 ? QCPAbstractPlottable::sdNegative : QCPAbstractPlottable::sdPositive); if (p.at(i)->keyAxis() == this) - plottableRange = p.at(i)->getKeyRange(validRange, signDomain); + plottableRange = p.at(i)->getKeyRange(currentFoundRange, signDomain); else - plottableRange = p.at(i)->getValueRange(validRange, signDomain); - if (validRange) + plottableRange = p.at(i)->getValueRange(currentFoundRange, signDomain); + if (currentFoundRange) { if (!haveRange) newRange = plottableRange; @@ -5255,7 +5361,22 @@ } } if (haveRange) + { + if (!QCPRange::validRange(newRange)) // likely due to range being zero (plottable has only constant data in this axis dimension), shift current range to at least center the plottable + { + double center = (newRange.lower+newRange.upper)*0.5; // upper and lower should be equal anyway, but just to make sure, incase validRange returned false for other reason + if (mScaleType == stLinear) + { + newRange.lower = center-mRange.size()/2.0; + newRange.upper = center+mRange.size()/2.0; + } else // mScaleType == stLogarithmic + { + newRange.lower = center/qSqrt(mRange.upper/mRange.lower); + newRange.upper = center*qSqrt(mRange.upper/mRange.lower); + } + } setRange(newRange); + } } /*! @@ -5332,7 +5453,7 @@ else return mAxisRect->bottom()-(mRange.upper-value)/mRange.size()*mAxisRect->height(); } else // mScaleType == stLogarithmic - { + { if (value >= 0 && mRange.upper < 0) // invalid value for logarithmic scale, just draw it outside visible range return !mRangeReversed ? mAxisRect->top()-200 : mAxisRect->bottom()+200; else if (value <= 0 && mRange.upper > 0) // invalid value for logarithmic scale, just draw it outside visible range @@ -5362,11 +5483,11 @@ if (!mVisible) return spNone; - if (mAxisSelectionBox.contains(pos.toPoint())) + if (mAxisPainter->axisSelectionBox().contains(pos.toPoint())) return spAxis; - else if (mTickLabelsSelectionBox.contains(pos.toPoint())) + else if (mAxisPainter->tickLabelsSelectionBox().contains(pos.toPoint())) return spTickLabels; - else if (mLabelSelectionBox.contains(pos.toPoint())) + else if (mAxisPainter->labelSelectionBox().contains(pos.toPoint())) return spAxisLabel; else return spNone; @@ -5467,6 +5588,21 @@ return atLeft; } +/*! + Returns the axis type that describes the opposite axis of an axis with the specified \a type. +*/ +QCPAxis::AxisType QCPAxis::opposite(QCPAxis::AxisType type) +{ + switch (type) + { + case atLeft: return atRight; break; + case atRight: return atLeft; break; + case atBottom: return atTop; break; + case atTop: return atBottom; break; + default: qDebug() << Q_FUNC_INFO << "invalid axis type"; return atLeft; break; + } +} + /*! \internal This function is called to prepare the tick vector, sub tick vector and tick label vector. If @@ -5527,8 +5663,6 @@ } // generate tick labels according to tick positions: - mExponentialChar = mParentPlot->locale().exponential(); // will be needed when drawing the numbers generated here, in getTickLabelData() - mPositiveSignChar = mParentPlot->locale().positiveSign(); // will be needed when drawing the numbers generated here, in getTickLabelData() if (mAutoTickLabels) { int vecsize = mTickVector.size(); @@ -5701,183 +5835,525 @@ return result; } +/* inherits documentation from base class */ +void QCPAxis::selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) +{ + Q_UNUSED(event) + SelectablePart part = details.value(); + if (mSelectableParts.testFlag(part)) + { + SelectableParts selBefore = mSelectedParts; + setSelectedParts(additive ? mSelectedParts^part : part); + if (selectionStateChanged) + *selectionStateChanged = mSelectedParts != selBefore; + } +} + +/* inherits documentation from base class */ +void QCPAxis::deselectEvent(bool *selectionStateChanged) +{ + SelectableParts selBefore = mSelectedParts; + setSelectedParts(mSelectedParts & ~mSelectableParts); + if (selectionStateChanged) + *selectionStateChanged = mSelectedParts != selBefore; +} + /*! \internal + + A convenience function to easily set the QPainter::Antialiased hint on the provided \a painter + before drawing axis lines. + + This is the antialiasing state the painter passed to the \ref draw method is in by default. - Draws the axis with the specified \a painter. + This function takes into account the local setting of the antialiasing flag as well as the + overrides set with \ref QCustomPlot::setAntialiasedElements and \ref + QCustomPlot::setNotAntialiasedElements. - The selection boxes (mAxisSelectionBox, mTickLabelsSelectionBox, mLabelSelectionBox) are set - here, too. + \see setAntialiased */ -void QCPAxis::draw(QCPPainter *painter) +void QCPAxis::applyDefaultAntialiasingHint(QCPPainter *painter) const { - if (!mParentPlot) return; - QPoint origin; - if (mAxisType == atLeft) - origin = mAxisRect->bottomLeft()+QPoint(-mOffset, 0); - else if (mAxisType == atRight) - origin = mAxisRect->bottomRight()+QPoint(+mOffset, 0); - else if (mAxisType == atTop) - origin = mAxisRect->topLeft()+QPoint(0, -mOffset); - else if (mAxisType == atBottom) - origin = mAxisRect->bottomLeft()+QPoint(0, +mOffset); - - double xCor = 0, yCor = 0; // paint system correction, for pixel exact matches (affects baselines and ticks of top/right axes) - switch (mAxisType) - { - case atTop: yCor = -1; break; - case atRight: xCor = 1; break; - default: break; - } + applyAntialiasingHint(painter, mAntialiased, QCP::aeAxes); +} + +/*! \internal - int margin = 0; - int lowTick = mLowestVisibleTick; - int highTick = mHighestVisibleTick; - double t; // helper variable, result of coordinate-to-pixel transforms + Draws the axis with the specified \a painter, using the internal QCPAxisPainterPrivate instance. - // draw baseline: - QLineF baseLine; - painter->setPen(getBasePen()); - if (orientation() == Qt::Horizontal) - baseLine.setPoints(origin+QPointF(xCor, yCor), origin+QPointF(mAxisRect->width()+xCor, yCor)); - else - baseLine.setPoints(origin+QPointF(xCor, yCor), origin+QPointF(xCor, -mAxisRect->height()+yCor)); - if (mRangeReversed) - baseLine = QLineF(baseLine.p2(), baseLine.p1()); // won't make a difference for line itself, but for line endings later - painter->drawLine(baseLine); +*/ +void QCPAxis::draw(QCPPainter *painter) +{ + const int lowTick = mLowestVisibleTick; + const int highTick = mHighestVisibleTick; + QVector subTickPositions; // the final coordToPixel transformed vector passed to QCPAxisPainter + QVector tickPositions; // the final coordToPixel transformed vector passed to QCPAxisPainter + QVector tickLabels; // the final vector passed to QCPAxisPainter + tickPositions.reserve(highTick-lowTick+1); + tickLabels.reserve(highTick-lowTick+1); + subTickPositions.reserve(mSubTickVector.size()); - // draw ticks: if (mTicks) { - painter->setPen(getTickPen()); - // direction of ticks ("inward" is right for left axis and left for right axis) - int tickDir = (mAxisType == atBottom || mAxisType == atRight) ? -1 : 1; - if (orientation() == Qt::Horizontal) + for (int i=lowTick; i<=highTick; ++i) { - for (int i=lowTick; i <= highTick; ++i) - { - t = coordToPixel(mTickVector.at(i)); // x - painter->drawLine(QLineF(t+xCor, origin.y()-mTickLengthOut*tickDir+yCor, t+xCor, origin.y()+mTickLengthIn*tickDir+yCor)); - } - } else - { - for (int i=lowTick; i <= highTick; ++i) - { - t = coordToPixel(mTickVector.at(i)); // y - painter->drawLine(QLineF(origin.x()-mTickLengthOut*tickDir+xCor, t+yCor, origin.x()+mTickLengthIn*tickDir+xCor, t+yCor)); - } + tickPositions.append(coordToPixel(mTickVector.at(i))); + if (mTickLabels) + tickLabels.append(mTickVectorLabels.at(i)); } - } + + if (mSubTickCount > 0) + { + const int subTickCount = mSubTickVector.size(); + for (int i=0; itype = mAxisType; + mAxisPainter->basePen = getBasePen(); + mAxisPainter->labelFont = getLabelFont(); + mAxisPainter->labelColor = getLabelColor(); + mAxisPainter->label = mLabel; + mAxisPainter->substituteExponent = mAutoTickLabels && mNumberBeautifulPowers; + mAxisPainter->tickPen = getTickPen(); + mAxisPainter->subTickPen = getSubTickPen(); + mAxisPainter->tickLabelFont = getTickLabelFont(); + mAxisPainter->tickLabelColor = getTickLabelColor(); + mAxisPainter->alignmentRect = mAxisRect->rect(); + mAxisPainter->viewportRect = mParentPlot->viewport(); + mAxisPainter->abbreviateDecimalPowers = mScaleType == stLogarithmic; + mAxisPainter->reversedEndings = mRangeReversed; + mAxisPainter->tickPositions = tickPositions; + mAxisPainter->tickLabels = tickLabels; + mAxisPainter->subTickPositions = subTickPositions; + mAxisPainter->draw(painter); +} + +/*! \internal - // draw subticks: - if (mTicks && mSubTickCount > 0) + Returns via \a lowIndex and \a highIndex, which ticks in the current tick vector are visible in + the current range. The return values are indices of the tick vector, not the positions of the + ticks themselves. + + The actual use of this function is when an external tick vector is provided, since it might + exceed far beyond the currently displayed range, and would cause unnecessary calculations e.g. of + subticks. + + If all ticks are outside the axis range, an inverted range is returned, i.e. highIndex will be + smaller than lowIndex. There is one case, where this function returns indices that are not really + visible in the current axis range: When the tick spacing is larger than the axis range size and + one tick is below the axis range and the next tick is already above the axis range. Because in + such cases it is usually desirable to know the tick pair, to draw proper subticks. +*/ +void QCPAxis::visibleTickBounds(int &lowIndex, int &highIndex) const +{ + bool lowFound = false; + bool highFound = false; + lowIndex = 0; + highIndex = -1; + + for (int i=0; i < mTickVector.size(); ++i) { - painter->setPen(getSubTickPen()); - // direction of ticks ("inward" is right for left axis and left for right axis) - int tickDir = (mAxisType == atBottom || mAxisType == atRight) ? -1 : 1; - if (orientation() == Qt::Horizontal) - { - for (int i=0; idrawLine(QLineF(t+xCor, origin.y()-mSubTickLengthOut*tickDir+yCor, t+xCor, origin.y()+mSubTickLengthIn*tickDir+yCor)); - } - } else + if (mTickVector.at(i) >= mRange.lower) { - for (int i=0; idrawLine(QLineF(origin.x()-mSubTickLengthOut*tickDir+xCor, t+yCor, origin.x()+mSubTickLengthIn*tickDir+xCor, t+yCor)); - } + lowFound = true; + lowIndex = i; + break; } } - margin += qMax(0, qMax(mTickLengthOut, mSubTickLengthOut)); - - // draw axis base endings: - bool antialiasingBackup = painter->antialiasing(); - painter->setAntialiasing(true); // always want endings to be antialiased, even if base and ticks themselves aren't - painter->setBrush(QBrush(basePen().color())); - QVector2D baseLineVector(baseLine.dx(), baseLine.dy()); - if (mLowerEnding.style() != QCPLineEnding::esNone) - mLowerEnding.draw(painter, QVector2D(baseLine.p1())-baseLineVector.normalized()*mLowerEnding.realLength()*(mLowerEnding.inverted()?-1:1), -baseLineVector); - if (mUpperEnding.style() != QCPLineEnding::esNone) - mUpperEnding.draw(painter, QVector2D(baseLine.p2())+baseLineVector.normalized()*mUpperEnding.realLength()*(mUpperEnding.inverted()?-1:1), baseLineVector); - painter->setAntialiasing(antialiasingBackup); - - // tick labels: - QSize tickLabelsSize(0, 0); // size of largest tick label, for offset calculation of axis label - if (mTickLabels) + for (int i=mTickVector.size()-1; i >= 0; --i) { - margin += mTickLabelPadding; - painter->setFont(getTickLabelFont()); - painter->setPen(QPen(getTickLabelColor())); - for (int i=lowTick; i <= highTick; ++i) + if (mTickVector.at(i) <= mRange.upper) { - t = coordToPixel(mTickVector.at(i)); - placeTickLabel(painter, t, margin, mTickVectorLabels.at(i), &tickLabelsSize); + highFound = true; + highIndex = i; + break; } } - if (orientation() == Qt::Horizontal) - margin += tickLabelsSize.height(); + + if (!lowFound && highFound) + lowIndex = highIndex+1; + else if (lowFound && !highFound) + highIndex = lowIndex-1; +} + +/*! \internal + + A log function with the base mScaleLogBase, used mostly for coordinate transforms in logarithmic + scales with arbitrary log base. Uses the buffered mScaleLogBaseLogInv for faster calculation. + This is set to 1.0/qLn(mScaleLogBase) in \ref setScaleLogBase. + + \see basePow, setScaleLogBase, setScaleType +*/ +double QCPAxis::baseLog(double value) const +{ + return qLn(value)*mScaleLogBaseLogInv; +} + +/*! \internal + + A power function with the base mScaleLogBase, used mostly for coordinate transforms in + logarithmic scales with arbitrary log base. + + \see baseLog, setScaleLogBase, setScaleType +*/ +double QCPAxis::basePow(double value) const +{ + return qPow(mScaleLogBase, value); +} + +/*! \internal + + Returns the pen that is used to draw the axis base line. Depending on the selection state, this + is either mSelectedBasePen or mBasePen. +*/ +QPen QCPAxis::getBasePen() const +{ + return mSelectedParts.testFlag(spAxis) ? mSelectedBasePen : mBasePen; +} + +/*! \internal + + Returns the pen that is used to draw the (major) ticks. Depending on the selection state, this + is either mSelectedTickPen or mTickPen. +*/ +QPen QCPAxis::getTickPen() const +{ + return mSelectedParts.testFlag(spAxis) ? mSelectedTickPen : mTickPen; +} + +/*! \internal + + Returns the pen that is used to draw the subticks. Depending on the selection state, this + is either mSelectedSubTickPen or mSubTickPen. +*/ +QPen QCPAxis::getSubTickPen() const +{ + return mSelectedParts.testFlag(spAxis) ? mSelectedSubTickPen : mSubTickPen; +} + +/*! \internal + + Returns the font that is used to draw the tick labels. Depending on the selection state, this + is either mSelectedTickLabelFont or mTickLabelFont. +*/ +QFont QCPAxis::getTickLabelFont() const +{ + return mSelectedParts.testFlag(spTickLabels) ? mSelectedTickLabelFont : mTickLabelFont; +} + +/*! \internal + + Returns the font that is used to draw the axis label. Depending on the selection state, this + is either mSelectedLabelFont or mLabelFont. +*/ +QFont QCPAxis::getLabelFont() const +{ + return mSelectedParts.testFlag(spAxisLabel) ? mSelectedLabelFont : mLabelFont; +} + +/*! \internal + + Returns the color that is used to draw the tick labels. Depending on the selection state, this + is either mSelectedTickLabelColor or mTickLabelColor. +*/ +QColor QCPAxis::getTickLabelColor() const +{ + return mSelectedParts.testFlag(spTickLabels) ? mSelectedTickLabelColor : mTickLabelColor; +} + +/*! \internal + + Returns the color that is used to draw the axis label. Depending on the selection state, this + is either mSelectedLabelColor or mLabelColor. +*/ +QColor QCPAxis::getLabelColor() const +{ + return mSelectedParts.testFlag(spAxisLabel) ? mSelectedLabelColor : mLabelColor; +} + +/*! \internal + + Returns the appropriate outward margin for this axis. It is needed if \ref + QCPAxisRect::setAutoMargins is set to true on the parent axis rect. An axis with axis type \ref + atLeft will return an appropriate left margin, \ref atBottom will return an appropriate bottom + margin and so forth. For the calculation, this function goes through similar steps as \ref draw, + so changing one function likely requires the modification of the other one as well. + + The margin consists of the outward tick length, tick label padding, tick label size, label + padding, label size, and padding. + + The margin is cached internally, so repeated calls while leaving the axis range, fonts, etc. + unchanged are very fast. +*/ +int QCPAxis::calculateMargin() +{ + if (!mVisible) // if not visible, directly return 0, don't cache 0 because we can't react to setVisible in QCPAxis + return 0; + + if (mCachedMarginValid) + return mCachedMargin; + + // run through similar steps as QCPAxis::draw, and caluclate margin needed to fit axis and its labels + int margin = 0; + + int lowTick, highTick; + visibleTickBounds(lowTick, highTick); + QVector tickPositions; // the final coordToPixel transformed vector passed to QCPAxisPainter + QVector tickLabels; // the final vector passed to QCPAxisPainter + tickPositions.reserve(highTick-lowTick+1); + tickLabels.reserve(highTick-lowTick+1); + if (mTicks) + { + for (int i=lowTick; i<=highTick; ++i) + { + tickPositions.append(coordToPixel(mTickVector.at(i))); + if (mTickLabels) + tickLabels.append(mTickVectorLabels.at(i)); + } + } + // transfer all properties of this axis to QCPAxisPainterPrivate which it needs to calculate the size. + // Note that some axis painter properties are already set by direct feed-through with QCPAxis setters + mAxisPainter->type = mAxisType; + mAxisPainter->labelFont = getLabelFont(); + mAxisPainter->label = mLabel; + mAxisPainter->tickLabelFont = mTickLabelFont; + mAxisPainter->alignmentRect = mAxisRect->rect(); + mAxisPainter->viewportRect = mParentPlot->viewport(); + mAxisPainter->tickPositions = tickPositions; + mAxisPainter->tickLabels = tickLabels; + margin += mAxisPainter->size(); + margin += mPadding; + + mCachedMargin = margin; + mCachedMarginValid = true; + return margin; +} + +/* inherits documentation from base class */ +QCP::Interaction QCPAxis::selectionCategory() const +{ + return QCP::iSelectAxes; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPAxisPainterPrivate +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPAxisPainterPrivate + + \internal + \brief (Private) + + This is a private class and not part of the public QCustomPlot interface. + + It is used by QCPAxis to do the low-level drawing of axis backbone, tick marks, tick labels and + axis label. It also buffers the labels to reduce replot times. The parameters are configured by + directly accessing the public member variables. +*/ + +/*! + Constructs a QCPAxisPainterPrivate instance. Make sure to not create a new instance on every + redraw, to utilize the caching mechanisms. +*/ +QCPAxisPainterPrivate::QCPAxisPainterPrivate(QCustomPlot *parentPlot) : + type(QCPAxis::atLeft), + basePen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)), + lowerEnding(QCPLineEnding::esNone), + upperEnding(QCPLineEnding::esNone), + labelPadding(0), + tickLabelPadding(0), + tickLabelRotation(0), + substituteExponent(true), + numberMultiplyCross(false), + tickLengthIn(5), + tickLengthOut(0), + subTickLengthIn(2), + subTickLengthOut(0), + tickPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)), + subTickPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)), + offset(0), + abbreviateDecimalPowers(false), + reversedEndings(false), + mParentPlot(parentPlot), + mLabelCache(16) // cache at most 16 (tick) labels +{ +} + +QCPAxisPainterPrivate::~QCPAxisPainterPrivate() +{ +} + +/*! \internal + + Draws the axis with the specified \a painter. + + The selection boxes (mAxisSelectionBox, mTickLabelsSelectionBox, mLabelSelectionBox) are set + here, too. +*/ +void QCPAxisPainterPrivate::draw(QCPPainter *painter) +{ + QByteArray newHash = generateLabelParameterHash(); + if (newHash != mLabelParameterHash) + { + mLabelCache.clear(); + mLabelParameterHash = newHash; + } + + QPoint origin; + switch (type) + { + case QCPAxis::atLeft: origin = alignmentRect.bottomLeft() +QPoint(-offset, 0); break; + case QCPAxis::atRight: origin = alignmentRect.bottomRight()+QPoint(+offset, 0); break; + case QCPAxis::atTop: origin = alignmentRect.topLeft() +QPoint(0, -offset); break; + case QCPAxis::atBottom: origin = alignmentRect.bottomLeft() +QPoint(0, +offset); break; + } + + double xCor = 0, yCor = 0; // paint system correction, for pixel exact matches (affects baselines and ticks of top/right axes) + switch (type) + { + case QCPAxis::atTop: yCor = -1; break; + case QCPAxis::atRight: xCor = 1; break; + default: break; + } + + int margin = 0; + // draw baseline: + QLineF baseLine; + painter->setPen(basePen); + if (QCPAxis::orientation(type) == Qt::Horizontal) + baseLine.setPoints(origin+QPointF(xCor, yCor), origin+QPointF(alignmentRect.width()+xCor, yCor)); else - margin += tickLabelsSize.width(); + baseLine.setPoints(origin+QPointF(xCor, yCor), origin+QPointF(xCor, -alignmentRect.height()+yCor)); + if (reversedEndings) + baseLine = QLineF(baseLine.p2(), baseLine.p1()); // won't make a difference for line itself, but for line endings later + painter->drawLine(baseLine); + + // draw ticks: + if (!tickPositions.isEmpty()) + { + painter->setPen(tickPen); + int tickDir = (type == QCPAxis::atBottom || type == QCPAxis::atRight) ? -1 : 1; // direction of ticks ("inward" is right for left axis and left for right axis) + if (QCPAxis::orientation(type) == Qt::Horizontal) + { + for (int i=0; idrawLine(QLineF(tickPositions.at(i)+xCor, origin.y()-tickLengthOut*tickDir+yCor, tickPositions.at(i)+xCor, origin.y()+tickLengthIn*tickDir+yCor)); + } else + { + for (int i=0; idrawLine(QLineF(origin.x()-tickLengthOut*tickDir+xCor, tickPositions.at(i)+yCor, origin.x()+tickLengthIn*tickDir+xCor, tickPositions.at(i)+yCor)); + } + } + + // draw subticks: + if (!subTickPositions.isEmpty()) + { + painter->setPen(subTickPen); + // direction of ticks ("inward" is right for left axis and left for right axis) + int tickDir = (type == QCPAxis::atBottom || type == QCPAxis::atRight) ? -1 : 1; + if (QCPAxis::orientation(type) == Qt::Horizontal) + { + for (int i=0; idrawLine(QLineF(subTickPositions.at(i)+xCor, origin.y()-subTickLengthOut*tickDir+yCor, subTickPositions.at(i)+xCor, origin.y()+subTickLengthIn*tickDir+yCor)); + } else + { + for (int i=0; idrawLine(QLineF(origin.x()-subTickLengthOut*tickDir+xCor, subTickPositions.at(i)+yCor, origin.x()+subTickLengthIn*tickDir+xCor, subTickPositions.at(i)+yCor)); + } + } + margin += qMax(0, qMax(tickLengthOut, subTickLengthOut)); + + // draw axis base endings: + bool antialiasingBackup = painter->antialiasing(); + painter->setAntialiasing(true); // always want endings to be antialiased, even if base and ticks themselves aren't + painter->setBrush(QBrush(basePen.color())); + QVector2D baseLineVector(baseLine.dx(), baseLine.dy()); + if (lowerEnding.style() != QCPLineEnding::esNone) + lowerEnding.draw(painter, QVector2D(baseLine.p1())-baseLineVector.normalized()*lowerEnding.realLength()*(lowerEnding.inverted()?-1:1), -baseLineVector); + if (upperEnding.style() != QCPLineEnding::esNone) + upperEnding.draw(painter, QVector2D(baseLine.p2())+baseLineVector.normalized()*upperEnding.realLength()*(upperEnding.inverted()?-1:1), baseLineVector); + painter->setAntialiasing(antialiasingBackup); + + // tick labels: + QSize tickLabelsSize(0, 0); // size of largest tick label, for offset calculation of axis label + if (!tickLabels.isEmpty()) + { + margin += tickLabelPadding; + painter->setFont(tickLabelFont); + painter->setPen(QPen(tickLabelColor)); + const int maxLabelIndex = qMin(tickPositions.size(), tickLabels.size()); + for (int i=0; isetFont(getLabelFont()); - painter->setPen(QPen(getLabelColor())); - labelBounds = painter->fontMetrics().boundingRect(0, 0, 0, 0, Qt::TextDontClip, mLabel); - if (mAxisType == atLeft) + margin += labelPadding; + painter->setFont(labelFont); + painter->setPen(QPen(labelColor)); + labelBounds = painter->fontMetrics().boundingRect(0, 0, 0, 0, Qt::TextDontClip, label); + if (type == QCPAxis::atLeft) { QTransform oldTransform = painter->transform(); painter->translate((origin.x()-margin-labelBounds.height()), origin.y()); painter->rotate(-90); - painter->drawText(0, 0, mAxisRect->height(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter, mLabel); + painter->drawText(0, 0, alignmentRect.height(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter, label); painter->setTransform(oldTransform); } - else if (mAxisType == atRight) + else if (type == QCPAxis::atRight) { QTransform oldTransform = painter->transform(); - painter->translate((origin.x()+margin+labelBounds.height()), origin.y()-mAxisRect->height()); + painter->translate((origin.x()+margin+labelBounds.height()), origin.y()-alignmentRect.height()); painter->rotate(90); - painter->drawText(0, 0, mAxisRect->height(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter, mLabel); + painter->drawText(0, 0, alignmentRect.height(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter, label); painter->setTransform(oldTransform); } - else if (mAxisType == atTop) - painter->drawText(origin.x(), origin.y()-margin-labelBounds.height(), mAxisRect->width(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter, mLabel); - else if (mAxisType == atBottom) - painter->drawText(origin.x(), origin.y()+margin, mAxisRect->width(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter, mLabel); + else if (type == QCPAxis::atTop) + painter->drawText(origin.x(), origin.y()-margin-labelBounds.height(), alignmentRect.width(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter, label); + else if (type == QCPAxis::atBottom) + painter->drawText(origin.x(), origin.y()+margin, alignmentRect.width(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter, label); } // set selection boxes: - int selAxisOutSize = qMax(qMax(mTickLengthOut, mSubTickLengthOut), mParentPlot->selectionTolerance()); - int selAxisInSize = mParentPlot->selectionTolerance(); - int selTickLabelSize = (orientation()==Qt::Horizontal ? tickLabelsSize.height() : tickLabelsSize.width()); - int selTickLabelOffset = qMax(mTickLengthOut, mSubTickLengthOut)+mTickLabelPadding; + int selectionTolerance = 0; + if (mParentPlot) + selectionTolerance = mParentPlot->selectionTolerance(); + else + qDebug() << Q_FUNC_INFO << "mParentPlot is null"; + int selAxisOutSize = qMax(qMax(tickLengthOut, subTickLengthOut), selectionTolerance); + int selAxisInSize = selectionTolerance; + int selTickLabelSize = (QCPAxis::orientation(type) == Qt::Horizontal ? tickLabelsSize.height() : tickLabelsSize.width()); + int selTickLabelOffset = qMax(tickLengthOut, subTickLengthOut)+tickLabelPadding; int selLabelSize = labelBounds.height(); - int selLabelOffset = selTickLabelOffset+selTickLabelSize+mLabelPadding; - if (mAxisType == atLeft) + int selLabelOffset = selTickLabelOffset+selTickLabelSize+labelPadding; + if (type == QCPAxis::atLeft) { - mAxisSelectionBox.setCoords(origin.x()-selAxisOutSize, mAxisRect->top(), origin.x()+selAxisInSize, mAxisRect->bottom()); - mTickLabelsSelectionBox.setCoords(origin.x()-selTickLabelOffset-selTickLabelSize, mAxisRect->top(), origin.x()-selTickLabelOffset, mAxisRect->bottom()); - mLabelSelectionBox.setCoords(origin.x()-selLabelOffset-selLabelSize, mAxisRect->top(), origin.x()-selLabelOffset, mAxisRect->bottom()); - } else if (mAxisType == atRight) - { - mAxisSelectionBox.setCoords(origin.x()-selAxisInSize, mAxisRect->top(), origin.x()+selAxisOutSize, mAxisRect->bottom()); - mTickLabelsSelectionBox.setCoords(origin.x()+selTickLabelOffset+selTickLabelSize, mAxisRect->top(), origin.x()+selTickLabelOffset, mAxisRect->bottom()); - mLabelSelectionBox.setCoords(origin.x()+selLabelOffset+selLabelSize, mAxisRect->top(), origin.x()+selLabelOffset, mAxisRect->bottom()); - } else if (mAxisType == atTop) - { - mAxisSelectionBox.setCoords(mAxisRect->left(), origin.y()-selAxisOutSize, mAxisRect->right(), origin.y()+selAxisInSize); - mTickLabelsSelectionBox.setCoords(mAxisRect->left(), origin.y()-selTickLabelOffset-selTickLabelSize, mAxisRect->right(), origin.y()-selTickLabelOffset); - mLabelSelectionBox.setCoords(mAxisRect->left(), origin.y()-selLabelOffset-selLabelSize, mAxisRect->right(), origin.y()-selLabelOffset); - } else if (mAxisType == atBottom) - { - mAxisSelectionBox.setCoords(mAxisRect->left(), origin.y()-selAxisInSize, mAxisRect->right(), origin.y()+selAxisOutSize); - mTickLabelsSelectionBox.setCoords(mAxisRect->left(), origin.y()+selTickLabelOffset+selTickLabelSize, mAxisRect->right(), origin.y()+selTickLabelOffset); - mLabelSelectionBox.setCoords(mAxisRect->left(), origin.y()+selLabelOffset+selLabelSize, mAxisRect->right(), origin.y()+selLabelOffset); + mAxisSelectionBox.setCoords(origin.x()-selAxisOutSize, alignmentRect.top(), origin.x()+selAxisInSize, alignmentRect.bottom()); + mTickLabelsSelectionBox.setCoords(origin.x()-selTickLabelOffset-selTickLabelSize, alignmentRect.top(), origin.x()-selTickLabelOffset, alignmentRect.bottom()); + mLabelSelectionBox.setCoords(origin.x()-selLabelOffset-selLabelSize, alignmentRect.top(), origin.x()-selLabelOffset, alignmentRect.bottom()); + } else if (type == QCPAxis::atRight) + { + mAxisSelectionBox.setCoords(origin.x()-selAxisInSize, alignmentRect.top(), origin.x()+selAxisOutSize, alignmentRect.bottom()); + mTickLabelsSelectionBox.setCoords(origin.x()+selTickLabelOffset+selTickLabelSize, alignmentRect.top(), origin.x()+selTickLabelOffset, alignmentRect.bottom()); + mLabelSelectionBox.setCoords(origin.x()+selLabelOffset+selLabelSize, alignmentRect.top(), origin.x()+selLabelOffset, alignmentRect.bottom()); + } else if (type == QCPAxis::atTop) + { + mAxisSelectionBox.setCoords(alignmentRect.left(), origin.y()-selAxisOutSize, alignmentRect.right(), origin.y()+selAxisInSize); + mTickLabelsSelectionBox.setCoords(alignmentRect.left(), origin.y()-selTickLabelOffset-selTickLabelSize, alignmentRect.right(), origin.y()-selTickLabelOffset); + mLabelSelectionBox.setCoords(alignmentRect.left(), origin.y()-selLabelOffset-selLabelSize, alignmentRect.right(), origin.y()-selLabelOffset); + } else if (type == QCPAxis::atBottom) + { + mAxisSelectionBox.setCoords(alignmentRect.left(), origin.y()-selAxisInSize, alignmentRect.right(), origin.y()+selAxisOutSize); + mTickLabelsSelectionBox.setCoords(alignmentRect.left(), origin.y()+selTickLabelOffset+selTickLabelSize, alignmentRect.right(), origin.y()+selTickLabelOffset); + mLabelSelectionBox.setCoords(alignmentRect.left(), origin.y()+selLabelOffset+selLabelSize, alignmentRect.right(), origin.y()+selLabelOffset); } // draw hitboxes for debug purposes: //painter->setBrush(Qt::NoBrush); @@ -5886,6 +6362,70 @@ /*! \internal + Returns the size ("margin" in QCPAxisRect context, so measured perpendicular to the axis backbone + direction) needed to fit the axis. +*/ +int QCPAxisPainterPrivate::size() const +{ + int result = 0; + + // get length of tick marks pointing outwards: + if (!tickPositions.isEmpty()) + result += qMax(0, qMax(tickLengthOut, subTickLengthOut)); + + // calculate size of tick labels: + QSize tickLabelsSize(0, 0); + if (!tickLabels.isEmpty()) + { + for (int i=0; ileft()-distanceToAxis-mOffset, position); break; - case atRight: labelAnchor = QPointF(mAxisRect->right()+distanceToAxis+mOffset, position); break; - case atTop: labelAnchor = QPointF(position, mAxisRect->top()-distanceToAxis-mOffset); break; - case atBottom: labelAnchor = QPointF(position, mAxisRect->bottom()+distanceToAxis+mOffset); break; + case QCPAxis::atLeft: labelAnchor = QPointF(alignmentRect.left()-distanceToAxis-offset, position); break; + case QCPAxis::atRight: labelAnchor = QPointF(alignmentRect.right()+distanceToAxis+offset, position); break; + case QCPAxis::atTop: labelAnchor = QPointF(position, alignmentRect.top()-distanceToAxis-offset); break; + case QCPAxis::atBottom: labelAnchor = QPointF(position, alignmentRect.bottom()+distanceToAxis+offset); break; } - if (parentPlot()->plottingHints().testFlag(QCP::phCacheLabels) && !painter->modes().testFlag(QCPPainter::pmNoCaching)) // label caching enabled + if (mParentPlot->plottingHints().testFlag(QCP::phCacheLabels) && !painter->modes().testFlag(QCPPainter::pmNoCaching)) // label caching enabled { if (!mLabelCache.contains(text)) // no cached label exists, create it { @@ -5935,15 +6474,15 @@ // draw cached label: const CachedLabel *cachedLabel = mLabelCache.object(text); // if label would be partly clipped by widget border on sides, don't draw it: - if (orientation() == Qt::Horizontal) + if (QCPAxis::orientation(type) == Qt::Horizontal) { - if (labelAnchor.x()+cachedLabel->offset.x()+cachedLabel->pixmap.width() > mParentPlot->viewport().right() || - labelAnchor.x()+cachedLabel->offset.x() < mParentPlot->viewport().left()) + if (labelAnchor.x()+cachedLabel->offset.x()+cachedLabel->pixmap.width() > viewportRect.right() || + labelAnchor.x()+cachedLabel->offset.x() < viewportRect.left()) return; } else { - if (labelAnchor.y()+cachedLabel->offset.y()+cachedLabel->pixmap.height() > mParentPlot->viewport().bottom() || - labelAnchor.y()+cachedLabel->offset.y() < mParentPlot->viewport().top()) + if (labelAnchor.y()+cachedLabel->offset.y()+cachedLabel->pixmap.height() >viewportRect.bottom() || + labelAnchor.y()+cachedLabel->offset.y() < viewportRect.top()) return; } painter->drawPixmap(labelAnchor+cachedLabel->offset, cachedLabel->pixmap); @@ -5953,15 +6492,15 @@ TickLabelData labelData = getTickLabelData(painter->font(), text); QPointF finalPosition = labelAnchor + getTickLabelDrawOffset(labelData); // if label would be partly clipped by widget border on sides, don't draw it: - if (orientation() == Qt::Horizontal) + if (QCPAxis::orientation(type) == Qt::Horizontal) { - if (finalPosition.x()+(labelData.rotatedTotalBounds.width()+labelData.rotatedTotalBounds.left()) > mParentPlot->viewport().right() || - finalPosition.x()+labelData.rotatedTotalBounds.left() < mParentPlot->viewport().left()) + if (finalPosition.x()+(labelData.rotatedTotalBounds.width()+labelData.rotatedTotalBounds.left()) > viewportRect.right() || + finalPosition.x()+labelData.rotatedTotalBounds.left() < viewportRect.left()) return; } else { - if (finalPosition.y()+(labelData.rotatedTotalBounds.height()+labelData.rotatedTotalBounds.top()) > mParentPlot->viewport().bottom() || - finalPosition.y()+labelData.rotatedTotalBounds.top() < mParentPlot->viewport().top()) + if (finalPosition.y()+(labelData.rotatedTotalBounds.height()+labelData.rotatedTotalBounds.top()) > viewportRect.bottom() || + finalPosition.y()+labelData.rotatedTotalBounds.top() < viewportRect.top()) return; } drawTickLabel(painter, finalPosition.x(), finalPosition.y(), labelData); @@ -5969,7 +6508,7 @@ } // expand passed tickLabelsSize if current tick label is larger: - if (finalSize.width() > tickLabelsSize->width()) + if (finalSize.width() > tickLabelsSize->width()) tickLabelsSize->setWidth(finalSize.width()); if (finalSize.height() > tickLabelsSize->height()) tickLabelsSize->setHeight(finalSize.height()); @@ -5984,7 +6523,7 @@ directly draw the labels on the QCustomPlot surface when label caching is disabled, i.e. when QCP::phCacheLabels plotting hint is not set. */ -void QCPAxis::drawTickLabel(QCPPainter *painter, double x, double y, const QCPAxis::TickLabelData &labelData) const +void QCPAxisPainterPrivate::drawTickLabel(QCPPainter *painter, double x, double y, const TickLabelData &labelData) const { // backup painter settings that we're about to change: QTransform oldTransform = painter->transform(); @@ -5992,8 +6531,8 @@ // transform painter to position/rotation: painter->translate(x, y); - if (!qFuzzyIsNull(mTickLabelRotation)) - painter->rotate(mTickLabelRotation); + if (!qFuzzyIsNull(tickLabelRotation)) + painter->rotate(tickLabelRotation); // draw text: if (!labelData.expPart.isEmpty()) // indicator that beautiful powers must be used @@ -6019,16 +6558,16 @@ Transforms the passed \a text and \a font to a tickLabelData structure that can then be further processed by \ref getTickLabelDrawOffset and \ref drawTickLabel. It splits the text into base and - exponent if necessary (see \ref setNumberFormat) and calculates appropriate bounding boxes. + exponent if necessary (member substituteExponent) and calculates appropriate bounding boxes. */ -QCPAxis::TickLabelData QCPAxis::getTickLabelData(const QFont &font, const QString &text) const +QCPAxisPainterPrivate::TickLabelData QCPAxisPainterPrivate::getTickLabelData(const QFont &font, const QString &text) const { TickLabelData result; // determine whether beautiful decimal powers should be used bool useBeautifulPowers = false; int ePos = -1; - if (mAutoTickLabels && mNumberBeautifulPowers && mTickLabelType == ltNumber) + if (substituteExponent) { ePos = text.indexOf('e'); if (ePos > -1) @@ -6037,21 +6576,22 @@ // calculate text bounding rects and do string preparation for beautiful decimal powers: result.baseFont = font; - result.baseFont.setPointSizeF(result.baseFont.pointSizeF()+0.05); // QFontMetrics.boundingRect has a bug for exact point sizes that make the results oscillate due to internal rounding + if (result.baseFont.pointSizeF() > 0) // On some rare systems, this sometimes is initialized with -1 (Qt bug?), so we check here before possibly setting a negative value in the next line + result.baseFont.setPointSizeF(result.baseFont.pointSizeF()+0.05); // QFontMetrics.boundingRect has a bug for exact point sizes that make the results oscillate due to internal rounding if (useBeautifulPowers) { // split text into parts of number/symbol that will be drawn normally and part that will be drawn as exponent: result.basePart = text.left(ePos); // in log scaling, we want to turn "1*10^n" into "10^n", else add multiplication sign and decimal base: - if (mScaleType == stLogarithmic && result.basePart == "1") + if (abbreviateDecimalPowers && result.basePart == "1") result.basePart = "10"; else - result.basePart += (mNumberMultiplyCross ? QString(QChar(215)) : QString(QChar(183))) + "10"; + result.basePart += (numberMultiplyCross ? QString(QChar(215)) : QString(QChar(183))) + "10"; result.expPart = text.mid(ePos+1); // clip "+" and leading zeros off expPart: - while (result.expPart.at(1) == '0' && result.expPart.length() > 2) // length > 2 so we leave one zero when numberFormatChar is 'e' + while (result.expPart.length() > 2 && result.expPart.at(1) == '0') // length > 2 so we leave one zero when numberFormatChar is 'e' result.expPart.remove(1, 1); - if (result.expPart.at(0) == mPositiveSignChar) + if (!result.expPart.isEmpty() && result.expPart.at(0) == '+') result.expPart.remove(0, 1); // prepare smaller font for exponent: result.expFont = font; @@ -6069,10 +6609,10 @@ // calculate possibly different bounding rect after rotation: result.rotatedTotalBounds = result.totalBounds; - if (!qFuzzyIsNull(mTickLabelRotation)) + if (!qFuzzyIsNull(tickLabelRotation)) { QTransform transform; - transform.rotate(mTickLabelRotation); + transform.rotate(tickLabelRotation); result.rotatedTotalBounds = transform.mapRect(result.rotatedTotalBounds); } @@ -6089,7 +6629,7 @@ This function is thus responsible for e.g. centering tick labels under ticks and positioning them appropriately when they are rotated. */ -QPointF QCPAxis::getTickLabelDrawOffset(const QCPAxis::TickLabelData &labelData) const +QPointF QCPAxisPainterPrivate::getTickLabelDrawOffset(const TickLabelData &labelData) const { /* calculate label offset from base point at tick (non-trivial, for best visual appearance): short @@ -6101,15 +6641,15 @@ time, a 45 degree rotated text will "point toward" its tick, as is typical for rotated tick labels. */ - bool doRotation = !qFuzzyIsNull(mTickLabelRotation); - bool flip = qFuzzyCompare(qAbs(mTickLabelRotation), 90.0); // perfect +/-90 degree flip. Indicates vertical label centering on vertical axes. - double radians = mTickLabelRotation/180.0*M_PI; + bool doRotation = !qFuzzyIsNull(tickLabelRotation); + bool flip = qFuzzyCompare(qAbs(tickLabelRotation), 90.0); // perfect +/-90 degree flip. Indicates vertical label centering on vertical axes. + double radians = tickLabelRotation/180.0*M_PI; int x=0, y=0; - if (mAxisType == atLeft) + if (type == QCPAxis::atLeft) { if (doRotation) { - if (mTickLabelRotation > 0) + if (tickLabelRotation > 0) { x = -qCos(radians)*labelData.totalBounds.width(); y = flip ? -labelData.totalBounds.width()/2.0 : -qSin(radians)*labelData.totalBounds.width()-qCos(radians)*labelData.totalBounds.height()/2.0; @@ -6123,11 +6663,11 @@ x = -labelData.totalBounds.width(); y = -labelData.totalBounds.height()/2.0; } - } else if (mAxisType == atRight) + } else if (type == QCPAxis::atRight) { if (doRotation) { - if (mTickLabelRotation > 0) + if (tickLabelRotation > 0) { x = +qSin(radians)*labelData.totalBounds.height(); y = flip ? -labelData.totalBounds.width()/2.0 : -qCos(radians)*labelData.totalBounds.height()/2.0; @@ -6141,11 +6681,11 @@ x = 0; y = -labelData.totalBounds.height()/2.0; } - } else if (mAxisType == atTop) + } else if (type == QCPAxis::atTop) { if (doRotation) { - if (mTickLabelRotation > 0) + if (tickLabelRotation > 0) { x = -qCos(radians)*labelData.totalBounds.width()+qSin(radians)*labelData.totalBounds.height()/2.0; y = -qSin(radians)*labelData.totalBounds.width()-qCos(radians)*labelData.totalBounds.height(); @@ -6159,11 +6699,11 @@ x = -labelData.totalBounds.width()/2.0; y = -labelData.totalBounds.height(); } - } else if (mAxisType == atBottom) + } else if (type == QCPAxis::atBottom) { if (doRotation) { - if (mTickLabelRotation > 0) + if (tickLabelRotation > 0) { x = +qSin(radians)*labelData.totalBounds.height()/2.0; y = 0; @@ -6189,11 +6729,11 @@ margin calculation, the passed \a tickLabelsSize is only expanded, if it's currently set to a smaller width/height. */ -void QCPAxis::getMaxTickLabelSize(const QFont &font, const QString &text, QSize *tickLabelsSize) const +void QCPAxisPainterPrivate::getMaxTickLabelSize(const QFont &font, const QString &text, QSize *tickLabelsSize) const { // note: this function must return the same tick label sizes as the placeTickLabel function. QSize finalSize; - if (parentPlot()->plottingHints().testFlag(QCP::phCacheLabels) && mLabelCache.contains(text)) // label caching enabled and have cached label + if (mParentPlot->plottingHints().testFlag(QCP::phCacheLabels) && mLabelCache.contains(text)) // label caching enabled and have cached label { const CachedLabel *cachedLabel = mLabelCache.object(text); finalSize = cachedLabel->pixmap.size(); @@ -6204,256 +6744,12 @@ } // expand passed tickLabelsSize if current tick label is larger: - if (finalSize.width() > tickLabelsSize->width()) + if (finalSize.width() > tickLabelsSize->width()) tickLabelsSize->setWidth(finalSize.width()); if (finalSize.height() > tickLabelsSize->height()) tickLabelsSize->setHeight(finalSize.height()); } -/* inherits documentation from base class */ -void QCPAxis::selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) -{ - Q_UNUSED(event) - SelectablePart part = details.value(); - if (mSelectableParts.testFlag(part)) - { - SelectableParts selBefore = mSelectedParts; - setSelectedParts(additive ? mSelectedParts^part : part); - if (selectionStateChanged) - *selectionStateChanged = mSelectedParts != selBefore; - } -} - -/* inherits documentation from base class */ -void QCPAxis::deselectEvent(bool *selectionStateChanged) -{ - SelectableParts selBefore = mSelectedParts; - setSelectedParts(mSelectedParts & ~mSelectableParts); - if (selectionStateChanged) - *selectionStateChanged = mSelectedParts != selBefore; -} - -/*! \internal - - A convenience function to easily set the QPainter::Antialiased hint on the provided \a painter - before drawing axis lines. - - This is the antialiasing state the painter passed to the \ref draw method is in by default. - - This function takes into account the local setting of the antialiasing flag as well as the - overrides set with \ref QCustomPlot::setAntialiasedElements and \ref - QCustomPlot::setNotAntialiasedElements. - - \see setAntialiased -*/ -void QCPAxis::applyDefaultAntialiasingHint(QCPPainter *painter) const -{ - applyAntialiasingHint(painter, mAntialiased, QCP::aeAxes); -} - -/*! \internal - - Returns via \a lowIndex and \a highIndex, which ticks in the current tick vector are visible in - the current range. The return values are indices of the tick vector, not the positions of the - ticks themselves. - - The actual use of this function is when an external tick vector is provided, since it might - exceed far beyond the currently displayed range, and would cause unnecessary calculations e.g. of - subticks. - - If all ticks are outside the axis range, an inverted range is returned, i.e. highIndex will be - smaller than lowIndex. There is one case, where this function returns indices that are not really - visible in the current axis range: When the tick spacing is larger than the axis range size and - one tick is below the axis range and the next tick is already above the axis range. Because in - such cases it is usually desirable to know the tick pair, to draw proper subticks. -*/ -void QCPAxis::visibleTickBounds(int &lowIndex, int &highIndex) const -{ - bool lowFound = false; - bool highFound = false; - lowIndex = 0; - highIndex = -1; - - for (int i=0; i < mTickVector.size(); ++i) - { - if (mTickVector.at(i) >= mRange.lower) - { - lowFound = true; - lowIndex = i; - break; - } - } - for (int i=mTickVector.size()-1; i >= 0; --i) - { - if (mTickVector.at(i) <= mRange.upper) - { - highFound = true; - highIndex = i; - break; - } - } - - if (!lowFound && highFound) - lowIndex = highIndex+1; - else if (lowFound && !highFound) - highIndex = lowIndex-1; -} - -/*! \internal - - A log function with the base mScaleLogBase, used mostly for coordinate transforms in logarithmic - scales with arbitrary log base. Uses the buffered mScaleLogBaseLogInv for faster calculation. - This is set to 1.0/qLn(mScaleLogBase) in \ref setScaleLogBase. - - \see basePow, setScaleLogBase, setScaleType -*/ -double QCPAxis::baseLog(double value) const -{ - return qLn(value)*mScaleLogBaseLogInv; -} - -/*! \internal - - A power function with the base mScaleLogBase, used mostly for coordinate transforms in - logarithmic scales with arbitrary log base. - - \see baseLog, setScaleLogBase, setScaleType -*/ -double QCPAxis::basePow(double value) const -{ - return qPow(mScaleLogBase, value); -} - -/*! \internal - - Returns the pen that is used to draw the axis base line. Depending on the selection state, this - is either mSelectedBasePen or mBasePen. -*/ -QPen QCPAxis::getBasePen() const -{ - return mSelectedParts.testFlag(spAxis) ? mSelectedBasePen : mBasePen; -} - -/*! \internal - - Returns the pen that is used to draw the (major) ticks. Depending on the selection state, this - is either mSelectedTickPen or mTickPen. -*/ -QPen QCPAxis::getTickPen() const -{ - return mSelectedParts.testFlag(spAxis) ? mSelectedTickPen : mTickPen; -} - -/*! \internal - - Returns the pen that is used to draw the subticks. Depending on the selection state, this - is either mSelectedSubTickPen or mSubTickPen. -*/ -QPen QCPAxis::getSubTickPen() const -{ - return mSelectedParts.testFlag(spAxis) ? mSelectedSubTickPen : mSubTickPen; -} - -/*! \internal - - Returns the font that is used to draw the tick labels. Depending on the selection state, this - is either mSelectedTickLabelFont or mTickLabelFont. -*/ -QFont QCPAxis::getTickLabelFont() const -{ - return mSelectedParts.testFlag(spTickLabels) ? mSelectedTickLabelFont : mTickLabelFont; -} - -/*! \internal - - Returns the font that is used to draw the axis label. Depending on the selection state, this - is either mSelectedLabelFont or mLabelFont. -*/ -QFont QCPAxis::getLabelFont() const -{ - return mSelectedParts.testFlag(spAxisLabel) ? mSelectedLabelFont : mLabelFont; -} - -/*! \internal - - Returns the color that is used to draw the tick labels. Depending on the selection state, this - is either mSelectedTickLabelColor or mTickLabelColor. -*/ -QColor QCPAxis::getTickLabelColor() const -{ - return mSelectedParts.testFlag(spTickLabels) ? mSelectedTickLabelColor : mTickLabelColor; -} - -/*! \internal - - Returns the color that is used to draw the axis label. Depending on the selection state, this - is either mSelectedLabelColor or mLabelColor. -*/ -QColor QCPAxis::getLabelColor() const -{ - return mSelectedParts.testFlag(spAxisLabel) ? mSelectedLabelColor : mLabelColor; -} - -/*! \internal - - Returns the appropriate outward margin for this axis. It is needed if \ref - QCPAxisRect::setAutoMargins is set to true on the parent axis rect. An axis with axis type \ref - atLeft will return an appropriate left margin, \ref atBottom will return an appropriate bottom - margin and so forth. For the calculation, this function goes through similar steps as \ref draw, - so changing one function likely requires the modification of the other one as well. - - The margin consists of the outward tick length, tick label padding, tick label size, label - padding, label size, and padding. - - The margin is cached internally, so repeated calls while leaving the axis range, fonts, etc. - unchanged are very fast. -*/ -int QCPAxis::calculateMargin() -{ - if (mCachedMarginValid) - return mCachedMargin; - - // run through similar steps as QCPAxis::draw, and caluclate margin needed to fit axis and its labels - int margin = 0; - - if (mVisible) - { - int lowTick, highTick; - visibleTickBounds(lowTick, highTick); - // get length of tick marks pointing outwards: - if (mTicks) - margin += qMax(0, qMax(mTickLengthOut, mSubTickLengthOut)); - // calculate size of tick labels: - QSize tickLabelsSize(0, 0); - if (mTickLabels) - { - for (int i=lowTick; i<=highTick; ++i) - getMaxTickLabelSize(mTickLabelFont, mTickVectorLabels.at(i), &tickLabelsSize); // don't use getTickLabelFont() because we don't want margin to possibly change on selection - margin += orientation() == Qt::Horizontal ? tickLabelsSize.height() : tickLabelsSize.width(); - margin += mTickLabelPadding; - } - // calculate size of axis label (only height needed, because left/right labels are rotated by 90 degrees): - if (!mLabel.isEmpty()) - { - QFontMetrics fontMetrics(mLabelFont); // don't use getLabelFont() because we don't want margin to possibly change on selection - QRect bounds; - bounds = fontMetrics.boundingRect(0, 0, 0, 0, Qt::TextDontClip | Qt::AlignHCenter | Qt::AlignVCenter, mLabel); - margin += bounds.height() + mLabelPadding; - } - } - margin += mPadding; - - mCachedMargin = margin; - mCachedMarginValid = true; - return margin; -} - -/* inherits documentation from base class */ -QCP::Interaction QCPAxis::selectionCategory() const -{ - return QCP::iSelectAxes; -} - //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPAbstractPlottable @@ -6517,7 +6813,7 @@ QPointer\b mKeyAxis, \b mValueAxis The key and value axes this plottable is attached to. Call their QCPAxis::coordToPixel functions to translate coordinates to pixels in either the key or value dimension. - Make sure to check whether the weak pointer is null before using it. If one of the axes is null, don't draw the plottable. + Make sure to check whether the pointer is null before using it. If one of the axes is null, don't draw the plottable. bool \b mSelected indicates whether the plottable is selected or not. @@ -6538,30 +6834,36 @@ of this plottable inside \a rect, next to the plottable name. */ -/*! \fn QCPRange QCPAbstractPlottable::getKeyRange(bool &validRange, SignDomain inSignDomain) const = 0 +/*! \fn QCPRange QCPAbstractPlottable::getKeyRange(bool &foundRange, SignDomain inSignDomain) const = 0 \internal called by rescaleAxes functions to get the full data key bounds. For logarithmic plots, one can set \a inSignDomain to either \ref sdNegative or \ref sdPositive in order to restrict the returned range to that sign domain. E.g. when only negative range is wanted, set \a inSignDomain to \ref sdNegative and all positive points will be ignored for range calculation. For no - restriction, just set \a inSignDomain to \ref sdBoth (default). \a validRange is an output - parameter that indicates whether a proper range could be found or not. If this is false, you - shouldn't use the returned range (e.g. no points in data). + restriction, just set \a inSignDomain to \ref sdBoth (default). \a foundRange is an output + parameter that indicates whether a range could be found or not. If this is false, you shouldn't + use the returned range (e.g. no points in data). + + Note that \a foundRange is not the same as \ref QCPRange::validRange, since the range returned by + this function may have size zero, which wouldn't count as a valid range. \see rescaleAxes, getValueRange */ -/*! \fn QCPRange QCPAbstractPlottable::getValueRange(bool &validRange, SignDomain inSignDomain) const = 0 +/*! \fn QCPRange QCPAbstractPlottable::getValueRange(bool &foundRange, SignDomain inSignDomain) const = 0 \internal called by rescaleAxes functions to get the full data value bounds. For logarithmic plots, one can set \a inSignDomain to either \ref sdNegative or \ref sdPositive in order to restrict the returned range to that sign domain. E.g. when only negative range is wanted, set \a inSignDomain to \ref sdNegative and all positive points will be ignored for range calculation. For no - restriction, just set \a inSignDomain to \ref sdBoth (default). \a validRange is an output - parameter that indicates whether a proper range could be found or not. If this is false, you - shouldn't use the returned range (e.g. no points in data). + restriction, just set \a inSignDomain to \ref sdBoth (default). \a foundRange is an output + parameter that indicates whether a range could be found or not. If this is false, you shouldn't + use the returned range (e.g. no points in data). + + Note that \a foundRange is not the same as \ref QCPRange::validRange, since the range returned by + this function may have size zero, which wouldn't count as a valid range. \see rescaleAxes, getKeyRange */ @@ -6571,8 +6873,15 @@ /*! \fn void QCPAbstractPlottable::selectionChanged(bool selected) - This signal is emitted when the selection state of this plottable has changed to \a selected, - either by user interaction or by a direct call to \ref setSelected. + This signal is emitted when the selection state of this plottable has changed, either by user + interaction or by a direct call to \ref setSelected. +*/ + +/*! \fn void QCPAbstractPlottable::selectableChanged(bool selectable); + + This signal is emitted when the selectability of this plottable has changed. + + \see setSelectable */ /* end of documentation of signals */ @@ -6745,7 +7054,11 @@ */ void QCPAbstractPlottable::setSelectable(bool selectable) { - mSelectable = selectable; + if (mSelectable != selectable) + { + mSelectable = selectable; + emit selectableChanged(mSelectable); + } } /*! @@ -6804,12 +7117,25 @@ if (keyAxis->scaleType() == QCPAxis::stLogarithmic) signDomain = (keyAxis->range().upper < 0 ? sdNegative : sdPositive); - bool rangeValid; - QCPRange newRange = getKeyRange(rangeValid, signDomain); - if (rangeValid) + bool foundRange; + QCPRange newRange = getKeyRange(foundRange, signDomain); + if (foundRange) { if (onlyEnlarge) newRange.expand(keyAxis->range()); + if (!QCPRange::validRange(newRange)) // likely due to range being zero (plottable has only constant data in this axis dimension), shift current range to at least center the plottable + { + double center = (newRange.lower+newRange.upper)*0.5; // upper and lower should be equal anyway, but just to make sure, incase validRange returned false for other reason + if (keyAxis->scaleType() == QCPAxis::stLinear) + { + newRange.lower = center-keyAxis->range().size()/2.0; + newRange.upper = center+keyAxis->range().size()/2.0; + } else // scaleType() == stLogarithmic + { + newRange.lower = center/qSqrt(keyAxis->range().upper/keyAxis->range().lower); + newRange.upper = center*qSqrt(keyAxis->range().upper/keyAxis->range().lower); + } + } keyAxis->setRange(newRange); } } @@ -6831,12 +7157,25 @@ if (valueAxis->scaleType() == QCPAxis::stLogarithmic) signDomain = (valueAxis->range().upper < 0 ? sdNegative : sdPositive); - bool rangeValid; - QCPRange newRange = getValueRange(rangeValid, signDomain); - if (rangeValid) + bool foundRange; + QCPRange newRange = getValueRange(foundRange, signDomain); + if (foundRange) { if (onlyEnlarge) newRange.expand(valueAxis->range()); + if (!QCPRange::validRange(newRange)) // likely due to range being zero (plottable has only constant data in this axis dimension), shift current range to at least center the plottable + { + double center = (newRange.lower+newRange.upper)*0.5; // upper and lower should be equal anyway, but just to make sure, incase validRange returned false for other reason + if (valueAxis->scaleType() == QCPAxis::stLinear) + { + newRange.lower = center-valueAxis->range().size()/2.0; + newRange.upper = center+valueAxis->range().size()/2.0; + } else // scaleType() == stLogarithmic + { + newRange.lower = center/qSqrt(valueAxis->range().upper/valueAxis->range().lower); + newRange.upper = center*qSqrt(valueAxis->range().upper/valueAxis->range().lower); + } + } valueAxis->setRange(newRange); } } @@ -6866,7 +7205,7 @@ return false; } -/*! +/*! Removes the plottable from the legend of the parent QCustomPlot. This means the QCPAbstractLegendItem (usually a QCPPlottableLegendItem) that is associated with this plottable is removed. @@ -6929,7 +7268,7 @@ } } -/*! \internal +/*! \internal \overload Returns the input as pixel coordinates in a QPointF. @@ -7316,7 +7655,7 @@ \li The position is fixed on the QCustomPlot surface, i.e. independent of axis ranges. This corresponds to all other types, i.e. \ref ptAbsolute, \ref ptViewportRatio and \ref ptAxisRectRatio. They differ only in the way the absolute position is described, see the - documentation of PositionType for details. For \ref ptAxisRectRatio, note that you can specify + documentation of \ref PositionType for details. For \ref ptAxisRectRatio, note that you can specify the axis rect with \ref setAxisRect. By default this is set to the main axis rect. Note that the position type \ref ptPlotCoords is only available (and sensible) when the position @@ -7925,7 +8264,11 @@ */ void QCPAbstractItem::setSelectable(bool selectable) { - mSelectable = selectable; + if (mSelectable != selectable) + { + mSelectable = selectable; + emit selectableChanged(mSelectable); + } } /*! @@ -7959,7 +8302,7 @@ positions direcly by their member pointers (which typically have the same variable name as \a name). - \see positions, anchor + \see positions, anchor */ QCPItemPosition *QCPAbstractItem::position(const QString &name) const { @@ -7980,7 +8323,7 @@ anchors direcly by their member pointers (which typically have the same variable name as \a name). - \see anchors, position + \see anchors, position */ QCPItemAnchor *QCPAbstractItem::anchor(const QString &name) const { @@ -7999,7 +8342,7 @@ Note that you can check for positions with this function, too. This is because every position is also an anchor (QCPItemPosition inherits from QCPItemAnchor). - \see anchor, position + \see anchor, position */ bool QCPAbstractItem::hasAnchor(const QString &name) const { @@ -8232,7 +8575,7 @@ -/*! \mainpage %QCustomPlot 1.1.0 Documentation +/*! \mainpage %QCustomPlot 1.2.0 Documentation \image html qcp-doc-logo.png @@ -8248,9 +8591,10 @@ the most important classes of the QCustomPlot library. The central widget which displays the plottables and axes on its surface is QCustomPlot. Every - QCustomPlot contains four axes by default. They can be accessed via the members xAxis, yAxis, - xAxis2 and yAxis2, and are of type QCPAxis. QCustomPlot supports an arbitrary number of axes and - axis rects, see the documentation of QCPAxisRect for details. + QCustomPlot contains four axes by default. They can be accessed via the members \ref + QCustomPlot::xAxis "xAxis", \ref QCustomPlot::yAxis "yAxis", \ref QCustomPlot::xAxis2 "xAxis2" + and \ref QCustomPlot::yAxis2 "yAxis2", and are of type QCPAxis. QCustomPlot supports an arbitrary + number of axes and axis rects, see the documentation of QCPAxisRect for details. \section mainpage-plottables Plottables @@ -8277,7 +8621,8 @@ usual, if the cast returns zero, the plottable wasn't of that specific subclass.) All further interfacing with plottables (e.g how to set data) is specific to the plottable type. - See the documentations of the subclasses: QCPGraph, QCPCurve, QCPBars, QCPStatisticalBox. + See the documentations of the subclasses: QCPGraph, QCPCurve, QCPBars, QCPStatisticalBox, + QCPColorMap. \section mainpage-axes Controlling the Axes @@ -8304,20 +8649,20 @@ \section mainpage-legend Plot Legend - Every QCustomPlot owns one QCPLegend (as \a legend) by default. A legend is a small layout - element inside the plot which lists the plottables with an icon of the plottable line/symbol and - a description. The Description is retrieved from the plottable name - (QCPAbstractPlottable::setName). Plottables can be added and removed from the legend via \ref - QCPAbstractPlottable::addToLegend and \ref QCPAbstractPlottable::removeFromLegend. By default, - adding a plottable to QCustomPlot automatically adds it to the legend, too. This behaviour can be - modified with the QCustomPlot::setAutoAddPlottableToLegend property. + Every QCustomPlot has one QCPLegend (as \ref QCustomPlot::legend) by default. A legend is a small + layout element inside the plot which lists the plottables with an icon of the plottable + line/symbol and a name (QCPAbstractPlottable::setName). Plottables can be added and removed from + the main legend via \ref QCPAbstractPlottable::addToLegend and \ref + QCPAbstractPlottable::removeFromLegend. By default, adding a plottable to QCustomPlot + automatically adds it to the legend, too. This behaviour can be modified with the + QCustomPlot::setAutoAddPlottableToLegend property. The QCPLegend provides an interface to access, add and remove legend items directly, too. See QCPLegend::item, QCPLegend::itemWithPlottable, QCPLegend::addItem, QCPLegend::removeItem for example. - Multiple legends are supported via the layout system (as a QCPLegend simply is a normal layout - element). + Multiple legends are supported via the \link thelayoutsystem layout system\endlink (as a + QCPLegend simply is a normal layout element). \section mainpage-userinteraction User Interactions @@ -8356,7 +8701,7 @@ the axis rect(s), legends and the plot title. They are all based on \ref QCPLayoutElement and are arranged by placing them inside a \ref QCPLayout. - Details on this topic are given on the dedicated page about \ref thelayoutsystem "the layout system". + Details on this topic are given on the dedicated page about \link thelayoutsystem the layout system\endlink. \section mainpage-performancetweaks Performance Tweaks @@ -8646,6 +8991,80 @@ */ /* end of documentation of signals */ +/* start of documentation of public members */ + +/*! \var QCPAxis *QCustomPlot::xAxis + + A pointer to the primary x Axis (bottom) of the main axis rect of the plot. + + QCustomPlot offers convenient pointers to the axes (\ref xAxis, \ref yAxis, \ref xAxis2, \ref + yAxis2) and the \ref legend. They make it very easy working with plots that only have a single + axis rect and at most one axis at each axis rect side. If you use \link thelayoutsystem the + layout system\endlink to add multiple axis rects or multiple axes to one side, use the \ref + QCPAxisRect::axis interface to access the new axes. If one of the four default axes or the + default legend is removed due to manipulation of the layout system (e.g. by removing the main + axis rect), the corresponding pointers become 0. +*/ + +/*! \var QCPAxis *QCustomPlot::yAxis + + A pointer to the primary y Axis (left) of the main axis rect of the plot. + + QCustomPlot offers convenient pointers to the axes (\ref xAxis, \ref yAxis, \ref xAxis2, \ref + yAxis2) and the \ref legend. They make it very easy working with plots that only have a single + axis rect and at most one axis at each axis rect side. If you use \link thelayoutsystem the + layout system\endlink to add multiple axis rects or multiple axes to one side, use the \ref + QCPAxisRect::axis interface to access the new axes. If one of the four default axes or the + default legend is removed due to manipulation of the layout system (e.g. by removing the main + axis rect), the corresponding pointers become 0. +*/ + +/*! \var QCPAxis *QCustomPlot::xAxis2 + + A pointer to the secondary x Axis (top) of the main axis rect of the plot. Secondary axes are + invisible by default. Use QCPAxis::setVisible to change this (or use \ref + QCPAxisRect::setupFullAxesBox). + + QCustomPlot offers convenient pointers to the axes (\ref xAxis, \ref yAxis, \ref xAxis2, \ref + yAxis2) and the \ref legend. They make it very easy working with plots that only have a single + axis rect and at most one axis at each axis rect side. If you use \link thelayoutsystem the + layout system\endlink to add multiple axis rects or multiple axes to one side, use the \ref + QCPAxisRect::axis interface to access the new axes. If one of the four default axes or the + default legend is removed due to manipulation of the layout system (e.g. by removing the main + axis rect), the corresponding pointers become 0. +*/ + +/*! \var QCPAxis *QCustomPlot::yAxis2 + + A pointer to the secondary y Axis (right) of the main axis rect of the plot. Secondary axes are + invisible by default. Use QCPAxis::setVisible to change this (or use \ref + QCPAxisRect::setupFullAxesBox). + + QCustomPlot offers convenient pointers to the axes (\ref xAxis, \ref yAxis, \ref xAxis2, \ref + yAxis2) and the \ref legend. They make it very easy working with plots that only have a single + axis rect and at most one axis at each axis rect side. If you use \link thelayoutsystem the + layout system\endlink to add multiple axis rects or multiple axes to one side, use the \ref + QCPAxisRect::axis interface to access the new axes. If one of the four default axes or the + default legend is removed due to manipulation of the layout system (e.g. by removing the main + axis rect), the corresponding pointers become 0. +*/ + +/*! \var QCPLegend *QCustomPlot::legend + + A pointer to the default legend of the main axis rect. The legend is invisible by default. Use + QCPLegend::setVisible to change this. + + QCustomPlot offers convenient pointers to the axes (\ref xAxis, \ref yAxis, \ref xAxis2, \ref + yAxis2) and the \ref legend. They make it very easy working with plots that only have a single + axis rect and at most one axis at each axis rect side. If you use \link thelayoutsystem the + layout system\endlink to add multiple legends to the plot, use the layout system interface to + access the new legend. For example, legends can be placed inside an axis rect's \ref + QCPAxisRect::insetLayout "inset layout", and must then also be accessed via the inset layout. If + the default legend is removed due to manipulation of the layout system (e.g. by removing the main + axis rect), the corresponding pointer becomes 0. +*/ + +/* end of documentation of public members */ /*! Constructs a QCustomPlot and sets reasonable default values. @@ -8668,7 +9087,7 @@ mBackgroundScaled(true), mBackgroundScaledMode(Qt::KeepAspectRatioByExpanding), mCurrentLayer(0), - mPlottingHints(QCP::phCacheLabels), + mPlottingHints(QCP::phCacheLabels|QCP::phForceRepaint), mMultiSelectModifier(Qt::ControlModifier), mPaintBuffer(size()), mMouseEventElement(0), @@ -8694,6 +9113,7 @@ mPlotLayout = new QCPLayoutGrid; mPlotLayout->initializeParentPlot(this); mPlotLayout->setParent(this); // important because if parent is QWidget, QCPLayout::sizeConstraintsChanged will call QWidget::updateGeometry + mPlotLayout->setLayer("main"); QCPAxisRect *defaultAxisRect = new QCPAxisRect(this, true); mPlotLayout->addElement(0, 0, defaultAxisRect); xAxis = defaultAxisRect->axis(QCPAxis::atBottom); @@ -8718,10 +9138,6 @@ setViewport(rect()); // needs to be called after mPlotLayout has been created -#ifdef Q_OS_WIN - setPlottingHint(QCP::phForceRepaint); -#endif - replot(); } @@ -9232,10 +9648,10 @@ QList QCustomPlot::selectedPlottables() const { QList result; - for (int i=0; iselected()) - result.append(mPlottables.at(i)); + if (plottable->selected()) + result.append(plottable); } return result; } @@ -9257,17 +9673,16 @@ QCPAbstractPlottable *resultPlottable = 0; double resultDistance = mSelectionTolerance; // only regard clicks with distances smaller than mSelectionTolerance as selections, so initialize with that value - for (int i=0; iselectable()) // we could have also passed onlySelectable to the selectTest function, but checking here is faster, because we have access to QCPabstractPlottable::selectable + if (onlySelectable && !plottable->selectable()) // we could have also passed onlySelectable to the selectTest function, but checking here is faster, because we have access to QCPabstractPlottable::selectable continue; - if ((currentPlottable->keyAxis()->axisRect()->rect() & currentPlottable->valueAxis()->axisRect()->rect()).contains(pos.toPoint())) // only consider clicks inside the rect that is spanned by the plottable's key/value axes + if ((plottable->keyAxis()->axisRect()->rect() & plottable->valueAxis()->axisRect()->rect()).contains(pos.toPoint())) // only consider clicks inside the rect that is spanned by the plottable's key/value axes { - double currentDistance = currentPlottable->selectTest(pos, false); + double currentDistance = plottable->selectTest(pos, false); if (currentDistance >= 0 && currentDistance < resultDistance) { - resultPlottable = currentPlottable; + resultPlottable = plottable; resultDistance = currentDistance; } } @@ -9423,10 +9838,10 @@ QList QCustomPlot::selectedGraphs() const { QList result; - for (int i=0; iselected()) - result.append(mGraphs.at(i)); + if (graph->selected()) + result.append(graph); } return result; } @@ -9557,10 +9972,10 @@ QList QCustomPlot::selectedItems() const { QList result; - for (int i=0; iselected()) - result.append(mItems.at(i)); + if (item->selected()) + result.append(item); } return result; } @@ -9583,17 +9998,16 @@ QCPAbstractItem *resultItem = 0; double resultDistance = mSelectionTolerance; // only regard clicks with distances smaller than mSelectionTolerance as selections, so initialize with that value - for (int i=0; iselectable()) // we could have also passed onlySelectable to the selectTest function, but checking here is faster, because we have access to QCPAbstractItem::selectable + if (onlySelectable && !item->selectable()) // we could have also passed onlySelectable to the selectTest function, but checking here is faster, because we have access to QCPAbstractItem::selectable continue; - if (!currentItem->clipToAxisRect() || currentItem->clipRect().contains(pos.toPoint())) // only consider clicks inside axis cliprect of the item if actually clipped to it + if (!item->clipToAxisRect() || item->clipRect().contains(pos.toPoint())) // only consider clicks inside axis cliprect of the item if actually clipped to it { - double currentDistance = currentItem->selectTest(pos, false); + double currentDistance = item->selectTest(pos, false); if (currentDistance >= 0 && currentDistance < resultDistance) { - resultItem = currentItem; + resultItem = item; resultDistance = currentDistance; } } @@ -9622,10 +10036,10 @@ */ QCPLayer *QCustomPlot::layer(const QString &name) const { - for (int i=0; iname() == name) - return mLayers.at(i); + if (layer->name() == name) + return layer; } return 0; } @@ -9653,7 +10067,7 @@ */ QCPLayer *QCustomPlot::currentLayer() const { - return mCurrentLayer; + return mCurrentLayer; } /*! @@ -9870,10 +10284,9 @@ while (!elementStack.isEmpty()) { - QList subElements = elementStack.pop()->elements(false); - for (int i=0; ielements(false)) { - if (QCPLayoutElement *element = subElements.at(i)) + if (element) { elementStack.push(element); if (QCPAxisRect *ar = qobject_cast(element)) @@ -9896,23 +10309,22 @@ */ QCPLayoutElement *QCustomPlot::layoutElementAt(const QPointF &pos) const { - QCPLayoutElement *current = mPlotLayout; + QCPLayoutElement *currentElement = mPlotLayout; bool searchSubElements = true; - while (searchSubElements && current) + while (searchSubElements && currentElement) { searchSubElements = false; - const QList elements = current->elements(false); - for (int i=0; ielements(false)) { - if (elements.at(i) && elements.at(i)->realVisibility() && elements.at(i)->selectTest(pos, false) >= 0) + if (subElement && subElement->realVisibility() && subElement->selectTest(pos, false) >= 0) { - current = elements.at(i); + currentElement = subElement; searchSubElements = true; break; } } } - return current; + return currentElement; } /*! @@ -9925,14 +10337,13 @@ QList QCustomPlot::selectedAxes() const { QList result, allAxes; - QList rects = axisRects(); - for (int i=0; iaxes(); + foreach (QCPAxisRect *rect, axisRects()) + allAxes << rect->axes(); - for (int i=0; iselectedParts() != QCPAxis::spNone) - result.append(allAxes.at(i)); + if (axis->selectedParts() != QCPAxis::spNone) + result.append(axis); } return result; @@ -9955,13 +10366,12 @@ while (!elementStack.isEmpty()) { - QList subElements = elementStack.pop()->elements(false); - for (int i=0; ielements(false)) { - if (QCPLayoutElement *element = subElements.at(i)) + if (subElement) { - elementStack.push(element); - if (QCPLegend *leg = qobject_cast(element)) + elementStack.push(subElement); + if (QCPLegend *leg = qobject_cast(subElement)) { if (leg->selectedParts() != QCPLegend::spNone) result.append(leg); @@ -9984,11 +10394,10 @@ */ void QCustomPlot::deselectAll() { - for (int i=0; i layerables = mLayers.at(i)->children(); - for (int k=0; kdeselectEvent(0); + foreach (QCPLayerable *layerable, layer->children()) + layerable->deselectEvent(0); } } @@ -10005,28 +10414,30 @@ signals on two QCustomPlots to make them replot synchronously, it won't cause an infinite recursion. */ -void QCustomPlot::replot() +void QCustomPlot::replot(QCustomPlot::RefreshPriority refreshPriority) { if (mReplotting) // incase signals loop back to replot slot return; mReplotting = true; emit beforeReplot(); + mPaintBuffer.fill(mBackgroundBrush.style() == Qt::SolidPattern ? mBackgroundBrush.color() : Qt::transparent); QCPPainter painter; painter.begin(&mPaintBuffer); - if (painter.isActive()) + if (painter.isActive()) { painter.setRenderHint(QPainter::HighQualityAntialiasing); // to make Antialiasing look good if using the OpenGL graphicssystem if (mBackgroundBrush.style() != Qt::SolidPattern && mBackgroundBrush.style() != Qt::NoBrush) painter.fillRect(mViewport, mBackgroundBrush); draw(&painter); painter.end(); - if (mPlottingHints.testFlag(QCP::phForceRepaint)) + if ((refreshPriority == rpHint && mPlottingHints.testFlag(QCP::phForceRepaint)) || refreshPriority==rpImmediate) repaint(); else update(); } else // might happen if QCustomPlot has width or height zero qDebug() << Q_FUNC_INFO << "Couldn't activate painter on buffer"; + emit afterReplot(); mReplotting = false; } @@ -10041,15 +10452,12 @@ */ void QCustomPlot::rescaleAxes(bool onlyVisiblePlottables) { - // get a list of all axes in the plot: - QList axes; - QList rects = axisRects(); - for (int i=0; iaxes(); - - // call rescale on all axes: - for (int i=0; irescale(onlyVisiblePlottables); + QList allAxes; + foreach (QCPAxisRect *rect, axisRects()) + allAxes << rect->axes(); + + foreach (QCPAxis *axis, allAxes) + axis->rescale(onlyVisiblePlottables); } /*! @@ -10081,11 +10489,15 @@ aren't defined yet inside the constructor, so you would get an image that has strange widths/heights. - \note On Android systems, this method does nothing and issues an according qDebug warning message. + \a pdfCreator and \a pdfTitle may be used to set the according metadata fields in the resulting + PDF file. + + \note On Android systems, this method does nothing and issues an according qDebug warning + message. This is also the case if for other reasons the define flag QT_NO_PRINTER is set. \see savePng, saveBmp, saveJpg, saveRastered */ -bool QCustomPlot::savePdf(const QString &fileName, bool noCosmeticPen, int width, int height) +bool QCustomPlot::savePdf(const QString &fileName, bool noCosmeticPen, int width, int height, const QString &pdfCreator, const QString &pdfTitle) { bool success = false; #ifdef QT_NO_PRINTER @@ -10110,6 +10522,9 @@ printer.setOutputFileName(fileName); printer.setOutputFormat(QPrinter::PdfFormat); printer.setFullPage(true); + printer.setColorMode(QPrinter::Color); + printer.printEngine()->setProperty(QPrintEngine::PPK_Creator, pdfCreator); + printer.printEngine()->setProperty(QPrintEngine::PPK_DocumentName, pdfTitle); QRect oldViewport = viewport(); setViewport(QRect(0, 0, newWidth, newHeight)); printer.setPaperSize(viewport().size(), QPrinter::DevicePixel); @@ -10172,7 +10587,7 @@ \see savePdf, saveBmp, saveJpg, saveRastered */ bool QCustomPlot::savePng(const QString &fileName, int width, int height, double scale, int quality) -{ +{ return saveRastered(fileName, width, height, scale, "PNG", quality); } @@ -10297,7 +10712,7 @@ // resize and repaint the buffer: mPaintBuffer = QPixmap(event->size()); setViewport(rect()); - replot(); + replot(rpQueued); // queued update is important here, to prevent painting issues in some contexts } /*! \internal @@ -10412,30 +10827,29 @@ QCPLayerable *clickedLayerable = layerableAt(event->pos(), true, &details); bool selectionStateChanged = false; bool additive = mInteractions.testFlag(QCP::iMultiSelect) && event->modifiers().testFlag(mMultiSelectModifier); - if (clickedLayerable && mInteractions.testFlag(clickedLayerable->selectionCategory())) - { - // a layerable was actually clicked, call its selectEvent: - bool selChanged = false; - clickedLayerable->selectEvent(event, additive, details, &selChanged); - selectionStateChanged |= selChanged; - } // deselect all other layerables if not additive selection: if (!additive) { - for (int i=0; i layerables = mLayers.at(i)->children(); - for (int k=0; kchildren()) { - if (layerables.at(k) != clickedLayerable && mInteractions.testFlag(layerables.at(k)->selectionCategory())) + if (layerable != clickedLayerable && mInteractions.testFlag(layerable->selectionCategory())) { bool selChanged = false; - layerables.at(k)->deselectEvent(&selChanged); + layerable->deselectEvent(&selChanged); selectionStateChanged |= selChanged; } } } } + if (clickedLayerable && mInteractions.testFlag(clickedLayerable->selectionCategory())) + { + // a layerable was actually clicked, call its selectEvent: + bool selChanged = false; + clickedLayerable->selectEvent(event, additive, details, &selChanged); + selectionStateChanged |= selChanged; + } doReplot = true; if (selectionStateChanged) emit selectionChangedByUser(); @@ -10497,28 +10911,19 @@ */ void QCustomPlot::draw(QCPPainter *painter) { - // update all axis tick vectors: - QList rects = axisRects(); - for (int i=0; i axes = rects.at(i)->axes(); - for (int k=0; ksetupTickVectors(); - } - - // recalculate layout: - mPlotLayout->update(); + // run through layout phases: + mPlotLayout->update(QCPLayoutElement::upPreparation); + mPlotLayout->update(QCPLayoutElement::upMargins); + mPlotLayout->update(QCPLayoutElement::upLayout); // draw viewport background pixmap: drawBackground(painter); // draw all layered objects (grid, axes, plottables, items, legend,...): - for (int layerIndex=0; layerIndex < mLayers.size(); ++layerIndex) + foreach (QCPLayer *layer, mLayers) { - QList layerChildren = mLayers.at(layerIndex)->children(); - for (int k=0; k < layerChildren.size(); ++k) + foreach (QCPLayerable *child, layer->children()) { - QCPLayerable *child = layerChildren.at(k); if (child->realVisibility()) { painter->save(); @@ -10529,6 +10934,17 @@ } } } + + /* Debug code to draw all layout element rects + foreach (QCPLayoutElement* el, findChildren()) + { + painter->setBrush(Qt::NoBrush); + painter->setPen(QPen(QColor(0, 0, 0, 100), 0, Qt::DashLine)); + painter->drawRect(el->rect()); + painter->setPen(QPen(QColor(255, 0, 0, 100), 0, Qt::DashLine)); + painter->drawRect(el->outerRect()); + } + */ } /*! \internal @@ -10540,7 +10956,7 @@ the viewport with the provided \a painter. The scaled version is buffered in mScaledBackgroundPixmap to prevent expensive rescaling at every redraw. It is only updated, when the axis rect has changed in a way that requires a rescale of the background pixmap (this is - dependant on the \ref setBackgroundScaledMode), or when a differend axis backgroud pixmap was + dependent on the \ref setBackgroundScaledMode), or when a differend axis background pixmap was set. Note that this function does not draw a fill with the background brush (\ref setBackground(const @@ -10681,7 +11097,7 @@ */ QPixmap QCustomPlot::toPixmap(int width, int height, double scale) { - // this method is somewhat similar to toPainter. Change something here, and a change in toPainter might be necessary, too. + // this method is somewhat similar to toPainter. Change something here, and a change in toPainter might be necessary, too. int newWidth, newHeight; if (width == 0 || height == 0) { @@ -10737,7 +11153,7 @@ */ void QCustomPlot::toPainter(QCPPainter *painter, int width, int height) { - // this method is somewhat similar to toPixmap. Change something here, and a change in toPixmap might be necessary, too. + // this method is somewhat similar to toPixmap. Change something here, and a change in toPixmap might be necessary, too. int newWidth, newHeight; if (width == 0 || height == 0) { @@ -10766,8034 +11182,10189 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////// QCPData +//////////////////// QCPColorGradient //////////////////////////////////////////////////////////////////////////////////////////////////// -/*! \class QCPData - \brief Holds the data of one single data point for QCPGraph. +/*! \class QCPColorGradient + \brief Defines a color gradient for use with e.g. \ref QCPColorMap - The container for storing multiple data points is \ref QCPDataMap. - - The stored data is: - \li \a key: coordinate on the key axis of this data point - \li \a value: coordinate on the value axis of this data point - \li \a keyErrorMinus: negative error in the key dimension (for error bars) - \li \a keyErrorPlus: positive error in the key dimension (for error bars) - \li \a valueErrorMinus: negative error in the value dimension (for error bars) - \li \a valueErrorPlus: positive error in the value dimension (for error bars) + This class describes a color gradient which can be used to encode data with color. For example, + QCPColorMap and QCPColorScale have a \ref QCPColorMap::setGradient "setGradient" method which + takes an instance of this class. Colors are set with \ref setColorStopAt(double position, const QColor &color) + with a \a position from 0 to 1. In between these defined color positions, the + color will be interpolated linearly either in RGB or HSV space, see \ref setColorInterpolation. + + Alternatively, load one of the preset color gradients shown in the image below, with \ref + loadPreset, or by directly specifying the preset in the constructor. + + \image html QCPColorGradient.png + + The fact that the \ref QCPColorGradient(GradientPreset preset) constructor allows directly + converting a \ref GradientPreset to a QCPColorGradient, you can also directly pass \ref + GradientPreset to all the \a setGradient methods, e.g.: + \code + colorMap->setGradient(QCPColorGradient::gpHot); + \endcode - \see QCPDataMap + The total number of levels used in the gradient can be set with \ref setLevelCount. Whether the + color gradient shall be applied periodically (wrapping around) to data values that lie outside + the data range specified on the plottable instance can be controlled with \ref setPeriodic. */ /*! - Constructs a data point with key, value and all errors set to zero. + Constructs a new QCPColorGradient initialized with the colors and color interpolation according + to \a preset. + + The color level count is initialized to 350. */ -QCPData::QCPData() : - key(0), - value(0), - keyErrorPlus(0), - keyErrorMinus(0), - valueErrorPlus(0), - valueErrorMinus(0) +QCPColorGradient::QCPColorGradient(GradientPreset preset) : + mLevelCount(350), + mColorInterpolation(ciRGB), + mPeriodic(false), + mColorBufferInvalidated(true) { + mColorBuffer.fill(qRgb(0, 0, 0), mLevelCount); + loadPreset(preset); } -/*! - Constructs a data point with the specified \a key and \a value. All errors are set to zero. -*/ -QCPData::QCPData(double key, double value) : - key(key), - value(value), - keyErrorPlus(0), - keyErrorMinus(0), - valueErrorPlus(0), - valueErrorMinus(0) +/* undocumented operator */ +bool QCPColorGradient::operator==(const QCPColorGradient &other) const { + return ((other.mLevelCount == this->mLevelCount) && + (other.mColorInterpolation == this->mColorInterpolation) && + (other.mPeriodic == this->mPeriodic) && + (other.mColorStops == this->mColorStops)); } - -//////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////// QCPGraph -//////////////////////////////////////////////////////////////////////////////////////////////////// - -/*! \class QCPGraph - \brief A plottable representing a graph in a plot. - - \image html QCPGraph.png +/*! + Sets the number of discretization levels of the color gradient to \a n. The default is 350 which + is typically enough to create a smooth appearance. - Usually QCustomPlot creates graphs internally via QCustomPlot::addGraph and the resulting - instance is accessed via QCustomPlot::graph. + \image html QCPColorGradient-levelcount.png +*/ +void QCPColorGradient::setLevelCount(int n) +{ + if (n < 2) + { + qDebug() << Q_FUNC_INFO << "n must be greater or equal 2 but was" << n; + n = 2; + } + if (n != mLevelCount) + { + mLevelCount = n; + mColorBufferInvalidated = true; + } +} - To plot data, assign it with the \ref setData or \ref addData functions. - - Graphs are used to display single-valued data. Single-valued means that there should only be one - data point per unique key coordinate. In other words, the graph can't have \a loops. If you do - want to plot non-single-valued curves, rather use the QCPCurve plottable. - - \section appearance Changing the appearance - - The appearance of the graph is mainly determined by the line style, scatter style, brush and pen - of the graph (\ref setLineStyle, \ref setScatterStyle, \ref setBrush, \ref setPen). - - \subsection filling Filling under or between graphs +/*! + Sets at which positions from 0 to 1 which color shall occur. The positions are the keys, the + colors are the values of the passed QMap \a colorStops. In between these color stops, the color + is interpolated according to \ref setColorInterpolation. - QCPGraph knows two types of fills: Normal graph fills towards the zero-value-line parallel to - the key axis of the graph, and fills between two graphs, called channel fills. To enable a fill, - just set a brush with \ref setBrush which is neither Qt::NoBrush nor fully transparent. + A more convenient way to create a custom gradient may be to clear all color stops with \ref + clearColorStops and then adding them one by one with \ref setColorStopAt. - By default, a normal fill towards the zero-value-line will be drawn. To set up a channel fill - between this graph and another one, call \ref setChannelFillGraph with the other graph as - parameter. - - \see QCustomPlot::addGraph, QCustomPlot::graph, QCPLegend::addGraph + \see clearColorStops */ +void QCPColorGradient::setColorStops(const QMap &colorStops) +{ + mColorStops = colorStops; + mColorBufferInvalidated = true; +} /*! - Constructs a graph which uses \a keyAxis as its key axis ("x") and \a valueAxis as its value - axis ("y"). \a keyAxis and \a valueAxis must reside in the same QCustomPlot instance and not have - the same orientation. If either of these restrictions is violated, a corresponding message is - printed to the debug output (qDebug), the construction is not aborted, though. - - The constructed QCPGraph can be added to the plot with QCustomPlot::addPlottable, QCustomPlot - then takes ownership of the graph. + Sets the \a color the gradient will have at the specified \a position (from 0 to 1). In between + these color stops, the color is interpolated according to \ref setColorInterpolation. - To directly create a graph inside a plot, you can also use the simpler QCustomPlot::addGraph function. + \see setColorStops, clearColorStops */ -QCPGraph::QCPGraph(QCPAxis *keyAxis, QCPAxis *valueAxis) : - QCPAbstractPlottable(keyAxis, valueAxis) +void QCPColorGradient::setColorStopAt(double position, const QColor &color) { - mData = new QCPDataMap; - - setPen(QPen(Qt::blue, 0)); - setErrorPen(QPen(Qt::black)); - setBrush(Qt::NoBrush); - setSelectedPen(QPen(QColor(80, 80, 255), 2.5)); - setSelectedBrush(Qt::NoBrush); + mColorStops.insert(position, color); + mColorBufferInvalidated = true; +} + +/*! + Sets whether the colors in between the configured color stops (see \ref setColorStopAt) shall be + interpolated linearly in RGB or in HSV color space. - setLineStyle(lsLine); - setErrorType(etNone); - setErrorBarSize(6); - setErrorBarSkipSymbol(true); - setChannelFillGraph(0); + For example, a sweep in RGB space from red to green will have a muddy brown intermediate color, + whereas in HSV space the intermediate color is yellow. +*/ +void QCPColorGradient::setColorInterpolation(QCPColorGradient::ColorInterpolation interpolation) +{ + if (interpolation != mColorInterpolation) + { + mColorInterpolation = interpolation; + mColorBufferInvalidated = true; + } } -QCPGraph::~QCPGraph() +/*! + Sets whether data points that are outside the configured data range (e.g. \ref + QCPColorMap::setDataRange) are colored by periodically repeating the color gradient or whether + they all have the same color, corresponding to the respective gradient boundary color. + + \image html QCPColorGradient-periodic.png + + As shown in the image above, gradients that have the same start and end color are especially + suitable for a periodic gradient mapping, since they produce smooth color transitions throughout + the color map. A preset that has this property is \ref gpHues. + + In practice, using periodic color gradients makes sense when the data corresponds to a periodic + dimension, such as an angle or a phase. If this is not the case, the color encoding might become + ambiguous, because multiple different data values are shown as the same color. +*/ +void QCPColorGradient::setPeriodic(bool enabled) { - delete mData; + mPeriodic = enabled; } /*! - Replaces the current data with the provided \a data. + This method is used to quickly convert a \a data array to colors. The colors will be output in + the array \a scanLine. Both \a data and \a scanLine must have the length \a n when passed to this + function. The data range that shall be used for mapping the data value to the gradient is passed + in \a range. \a logarithmic indicates whether the data values shall be mapped to colors + logarithmically. - If \a copy is set to true, data points in \a data will only be copied. if false, the graph - takes ownership of the passed data and replaces the internal data pointer with it. This is - significantly faster than copying for large datasets. + if \a data actually contains 2D-data linearized via [row*columnCount + column], you can + set \a dataIndexFactor to columnCount to convert a column instead of a row of the data + array, in \a scanLine. \a scanLine will remain a regular (1D) array. This works because \a data + is addressed data[i*dataIndexFactor]. */ -void QCPGraph::setData(QCPDataMap *data, bool copy) +void QCPColorGradient::colorize(const double *data, const QCPRange &range, QRgb *scanLine, int n, int dataIndexFactor, bool logarithmic) { - if (copy) + // If you change something here, make sure to also adapt ::color() + if (!data) { - *mData = *data; - } else + qDebug() << Q_FUNC_INFO << "null pointer given as data"; + return; + } + if (!scanLine) { - delete mData; - mData = data; + qDebug() << Q_FUNC_INFO << "null pointer given as scanLine"; + return; + } + if (mColorBufferInvalidated) + updateColorBuffer(); + + if (!logarithmic) + { + const double posToIndexFactor = mLevelCount/range.size(); + if (mPeriodic) + { + for (int i=0; i= mLevelCount) + index = mLevelCount-1; + scanLine[i] = mColorBuffer.at(index); + } + } + } else // logarithmic == true + { + if (mPeriodic) + { + for (int i=0; i= mLevelCount) + index = mLevelCount-1; + scanLine[i] = mColorBuffer.at(index); + } + } } } -/*! \overload +/*! \internal - Replaces the current data with the provided points in \a key and \a value pairs. The provided - vectors should have equal length. Else, the number of added points will be the size of the - smallest vector. + This method is used to colorize a single data value given in \a position, to colors. The data + range that shall be used for mapping the data value to the gradient is passed in \a range. \a + logarithmic indicates whether the data value shall be mapped to a color logarithmically. + + If an entire array of data values shall be converted, rather use \ref colorize, for better + performance. */ -void QCPGraph::setData(const QVector &key, const QVector &value) +QRgb QCPColorGradient::color(double position, const QCPRange &range, bool logarithmic) { - mData->clear(); - int n = key.size(); - n = qMin(n, value.size()); - QCPData newData; - for (int i=0; iinsertMulti(newData.key, newData); + index = index % mLevelCount; + if (index < 0) + index += mLevelCount; + } else + { + if (index < 0) + index = 0; + else if (index >= mLevelCount) + index = mLevelCount-1; } + return mColorBuffer.at(index); } /*! - Replaces the current data with the provided points in \a key and \a value pairs. Additionally the - symmetrical value error of the data points are set to the values in \a valueError. - For error bars to show appropriately, see \ref setErrorType. - The provided vectors should have equal length. Else, the number of added points will be the size of the - smallest vector. + Clears the current color stops and loads the specified \a preset. A preset consists of predefined + color stops and the corresponding color interpolation method. - For asymmetrical errors (plus different from minus), see the overloaded version of this function. + The available presets are: + \image html QCPColorGradient.png */ -void QCPGraph::setDataValueError(const QVector &key, const QVector &value, const QVector &valueError) +void QCPColorGradient::loadPreset(GradientPreset preset) { - mData->clear(); - int n = key.size(); - n = qMin(n, value.size()); - n = qMin(n, valueError.size()); - QCPData newData; - for (int i=0; iinsertMulti(key[i], newData); + case gpGrayscale: + setColorInterpolation(ciRGB); + setColorStopAt(0, Qt::black); + setColorStopAt(1, Qt::white); + break; + case gpHot: + setColorInterpolation(ciRGB); + setColorStopAt(0, QColor(50, 0, 0)); + setColorStopAt(0.2, QColor(180, 10, 0)); + setColorStopAt(0.4, QColor(245, 50, 0)); + setColorStopAt(0.6, QColor(255, 150, 10)); + setColorStopAt(0.8, QColor(255, 255, 50)); + setColorStopAt(1, QColor(255, 255, 255)); + break; + case gpCold: + setColorInterpolation(ciRGB); + setColorStopAt(0, QColor(0, 0, 50)); + setColorStopAt(0.2, QColor(0, 10, 180)); + setColorStopAt(0.4, QColor(0, 50, 245)); + setColorStopAt(0.6, QColor(10, 150, 255)); + setColorStopAt(0.8, QColor(50, 255, 255)); + setColorStopAt(1, QColor(255, 255, 255)); + break; + case gpNight: + setColorInterpolation(ciHSV); + setColorStopAt(0, QColor(10, 20, 30)); + setColorStopAt(1, QColor(250, 255, 250)); + break; + case gpCandy: + setColorInterpolation(ciHSV); + setColorStopAt(0, QColor(0, 0, 255)); + setColorStopAt(1, QColor(255, 250, 250)); + break; + case gpGeography: + setColorInterpolation(ciRGB); + setColorStopAt(0, QColor(70, 170, 210)); + setColorStopAt(0.20, QColor(90, 160, 180)); + setColorStopAt(0.25, QColor(45, 130, 175)); + setColorStopAt(0.30, QColor(100, 140, 125)); + setColorStopAt(0.5, QColor(100, 140, 100)); + setColorStopAt(0.6, QColor(130, 145, 120)); + setColorStopAt(0.7, QColor(140, 130, 120)); + setColorStopAt(0.9, QColor(180, 190, 190)); + setColorStopAt(1, QColor(210, 210, 230)); + break; + case gpIon: + setColorInterpolation(ciHSV); + setColorStopAt(0, QColor(50, 10, 10)); + setColorStopAt(0.45, QColor(0, 0, 255)); + setColorStopAt(0.8, QColor(0, 255, 255)); + setColorStopAt(1, QColor(0, 255, 0)); + break; + case gpThermal: + setColorInterpolation(ciRGB); + setColorStopAt(0, QColor(0, 0, 50)); + setColorStopAt(0.15, QColor(20, 0, 120)); + setColorStopAt(0.33, QColor(200, 30, 140)); + setColorStopAt(0.6, QColor(255, 100, 0)); + setColorStopAt(0.85, QColor(255, 255, 40)); + setColorStopAt(1, QColor(255, 255, 255)); + break; + case gpPolar: + setColorInterpolation(ciRGB); + setColorStopAt(0, QColor(50, 255, 255)); + setColorStopAt(0.18, QColor(10, 70, 255)); + setColorStopAt(0.28, QColor(10, 10, 190)); + setColorStopAt(0.5, QColor(0, 0, 0)); + setColorStopAt(0.72, QColor(190, 10, 10)); + setColorStopAt(0.82, QColor(255, 70, 10)); + setColorStopAt(1, QColor(255, 255, 50)); + break; + case gpSpectrum: + setColorInterpolation(ciHSV); + setColorStopAt(0, QColor(50, 0, 50)); + setColorStopAt(0.15, QColor(0, 0, 255)); + setColorStopAt(0.35, QColor(0, 255, 255)); + setColorStopAt(0.6, QColor(255, 255, 0)); + setColorStopAt(0.75, QColor(255, 30, 0)); + setColorStopAt(1, QColor(50, 0, 0)); + break; + case gpJet: + setColorInterpolation(ciRGB); + setColorStopAt(0, QColor(0, 0, 100)); + setColorStopAt(0.15, QColor(0, 50, 255)); + setColorStopAt(0.35, QColor(0, 255, 255)); + setColorStopAt(0.65, QColor(255, 255, 0)); + setColorStopAt(0.85, QColor(255, 30, 0)); + setColorStopAt(1, QColor(100, 0, 0)); + break; + case gpHues: + setColorInterpolation(ciHSV); + setColorStopAt(0, QColor(255, 0, 0)); + setColorStopAt(1.0/3.0, QColor(0, 0, 255)); + setColorStopAt(2.0/3.0, QColor(0, 255, 0)); + setColorStopAt(1, QColor(255, 0, 0)); + break; } } /*! - \overload - Replaces the current data with the provided points in \a key and \a value pairs. Additionally the - negative value error of the data points are set to the values in \a valueErrorMinus, the positive - value error to \a valueErrorPlus. - For error bars to show appropriately, see \ref setErrorType. - The provided vectors should have equal length. Else, the number of added points will be the size of the - smallest vector. + Clears all color stops. + + \see setColorStops, setColorStopAt */ -void QCPGraph::setDataValueError(const QVector &key, const QVector &value, const QVector &valueErrorMinus, const QVector &valueErrorPlus) +void QCPColorGradient::clearColorStops() { - mData->clear(); - int n = key.size(); - n = qMin(n, value.size()); - n = qMin(n, valueErrorMinus.size()); - n = qMin(n, valueErrorPlus.size()); - QCPData newData; - for (int i=0; iinsertMulti(key[i], newData); - } + mColorStops.clear(); + mColorBufferInvalidated = true; } /*! - Replaces the current data with the provided points in \a key and \a value pairs. Additionally the - symmetrical key error of the data points are set to the values in \a keyError. - For error bars to show appropriately, see \ref setErrorType. - The provided vectors should have equal length. Else, the number of added points will be the size of the - smallest vector. + Returns an inverted gradient. The inverted gradient has all properties as this \ref + QCPColorGradient, but the order of the color stops is inverted. - For asymmetrical errors (plus different from minus), see the overloaded version of this function. + \see setColorStops, setColorStopAt */ -void QCPGraph::setDataKeyError(const QVector &key, const QVector &value, const QVector &keyError) +QCPColorGradient QCPColorGradient::inverted() const { - mData->clear(); - int n = key.size(); - n = qMin(n, value.size()); - n = qMin(n, keyError.size()); - QCPData newData; - for (int i=0; iinsertMulti(key[i], newData); - } + QCPColorGradient result(*this); + result.clearColorStops(); + for (QMap::const_iterator it=mColorStops.constBegin(); it!=mColorStops.constEnd(); ++it) + result.setColorStopAt(1.0-it.key(), it.value()); + return result; } -/*! - \overload - Replaces the current data with the provided points in \a key and \a value pairs. Additionally the - negative key error of the data points are set to the values in \a keyErrorMinus, the positive - key error to \a keyErrorPlus. - For error bars to show appropriately, see \ref setErrorType. - The provided vectors should have equal length. Else, the number of added points will be the size of the - smallest vector. +/*! \internal + + Updates the internal color buffer which will be used by \ref colorize and \ref color, to quickly + convert positions to colors. This is where the interpolation between color stops is calculated. */ -void QCPGraph::setDataKeyError(const QVector &key, const QVector &value, const QVector &keyErrorMinus, const QVector &keyErrorPlus) +void QCPColorGradient::updateColorBuffer() { - mData->clear(); - int n = key.size(); - n = qMin(n, value.size()); - n = qMin(n, keyErrorMinus.size()); - n = qMin(n, keyErrorPlus.size()); - QCPData newData; - for (int i=0; i 1) { - newData.key = key[i]; - newData.value = value[i]; - newData.keyErrorMinus = keyErrorMinus[i]; - newData.keyErrorPlus = keyErrorPlus[i]; - mData->insertMulti(key[i], newData); + double indexToPosFactor = 1.0/(double)(mLevelCount-1); + for (int i=0; i::const_iterator it = mColorStops.lowerBound(position); + if (it == mColorStops.constEnd()) // position is on or after last stop, use color of last stop + { + mColorBuffer[i] = (it-1).value().rgb(); + } else if (it == mColorStops.constBegin()) // position is on or before first stop, use color of first stop + { + mColorBuffer[i] = it.value().rgb(); + } else // position is in between stops (or on an intermediate stop), interpolate color + { + QMap::const_iterator high = it; + QMap::const_iterator low = it-1; + double t = (position-low.key())/(high.key()-low.key()); // interpolation factor 0..1 + switch (mColorInterpolation) + { + case ciRGB: + { + mColorBuffer[i] = qRgb((1-t)*low.value().red() + t*high.value().red(), + (1-t)*low.value().green() + t*high.value().green(), + (1-t)*low.value().blue() + t*high.value().blue()); + break; + } + case ciHSV: + { + QColor lowHsv = low.value().toHsv(); + QColor highHsv = high.value().toHsv(); + double hue = 0; + double hueDiff = highHsv.hueF()-lowHsv.hueF(); + if (hueDiff > 0.5) + hue = lowHsv.hueF() - t*(1.0-hueDiff); + else if (hueDiff < -0.5) + hue = lowHsv.hueF() + t*(1.0+hueDiff); + else + hue = lowHsv.hueF() + t*hueDiff; + if (hue < 0) hue += 1.0; + else if (hue >= 1.0) hue -= 1.0; + mColorBuffer[i] = QColor::fromHsvF(hue, (1-t)*lowHsv.saturationF() + t*highHsv.saturationF(), (1-t)*lowHsv.valueF() + t*highHsv.valueF()).rgb(); + break; + } + } + } + } + } else if (mColorStops.size() == 1) + { + mColorBuffer.fill(mColorStops.constBegin().value().rgb()); + } else // mColorStops is empty, fill color buffer with black + { + mColorBuffer.fill(qRgb(0, 0, 0)); } + mColorBufferInvalidated = false; } -/*! - Replaces the current data with the provided points in \a key and \a value pairs. Additionally the - symmetrical key and value errors of the data points are set to the values in \a keyError and \a valueError. - For error bars to show appropriately, see \ref setErrorType. - The provided vectors should have equal length. Else, the number of added points will be the size of the - smallest vector. + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPAxisRect +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPAxisRect + \brief Holds multiple axes and arranges them in a rectangular shape. - For asymmetrical errors (plus different from minus), see the overloaded version of this function. + This class represents an axis rect, a rectangular area that is bounded on all sides with an + arbitrary number of axes. + + Initially QCustomPlot has one axis rect, accessible via QCustomPlot::axisRect(). However, the + layout system allows to have multiple axis rects, e.g. arranged in a grid layout + (QCustomPlot::plotLayout). + + By default, QCPAxisRect comes with four axes, at bottom, top, left and right. They can be + accessed via \ref axis by providing the respective axis type (\ref QCPAxis::AxisType) and index. + If you need all axes in the axis rect, use \ref axes. The top and right axes are set to be + invisible initially (QCPAxis::setVisible). To add more axes to a side, use \ref addAxis or \ref + addAxes. To remove an axis, use \ref removeAxis. + + The axis rect layerable itself only draws a background pixmap or color, if specified (\ref + setBackground). It is placed on the "background" layer initially (see \ref QCPLayer for an + explanation of the QCustomPlot layer system). The axes that are held by the axis rect can be + placed on other layers, independently of the axis rect. + + Every axis rect has a child layout of type \ref QCPLayoutInset. It is accessible via \ref + insetLayout and can be used to have other layout elements (or even other layouts with multiple + elements) hovering inside the axis rect. + + If an axis rect is clicked and dragged, it processes this by moving certain axis ranges. The + behaviour can be controlled with \ref setRangeDrag and \ref setRangeDragAxes. If the mouse wheel + is scrolled while the cursor is on the axis rect, certain axes are scaled. This is controllable + via \ref setRangeZoom, \ref setRangeZoomAxes and \ref setRangeZoomFactor. These interactions are + only enabled if \ref QCustomPlot::setInteractions contains \ref QCP::iRangeDrag and \ref + QCP::iRangeZoom. + + \image html AxisRectSpacingOverview.png +
                                                                  Overview of the spacings and paddings that define the geometry of an axis. The dashed + line on the far left indicates the viewport/widget border.
                                                                  */ -void QCPGraph::setDataBothError(const QVector &key, const QVector &value, const QVector &keyError, const QVector &valueError) -{ - mData->clear(); - int n = key.size(); - n = qMin(n, value.size()); - n = qMin(n, valueError.size()); - n = qMin(n, keyError.size()); - QCPData newData; - for (int i=0; iinsertMulti(key[i], newData); - } -} -/*! - \overload - Replaces the current data with the provided points in \a key and \a value pairs. Additionally the - negative key and value errors of the data points are set to the values in \a keyErrorMinus and \a valueErrorMinus. The positive - key and value errors are set to the values in \a keyErrorPlus \a valueErrorPlus. - For error bars to show appropriately, see \ref setErrorType. - The provided vectors should have equal length. Else, the number of added points will be the size of the - smallest vector. +/* start documentation of inline functions */ + +/*! \fn QCPLayoutInset *QCPAxisRect::insetLayout() const + + Returns the inset layout of this axis rect. It can be used to place other layout elements (or + even layouts with multiple other elements) inside/on top of an axis rect. + + \see QCPLayoutInset */ -void QCPGraph::setDataBothError(const QVector &key, const QVector &value, const QVector &keyErrorMinus, const QVector &keyErrorPlus, const QVector &valueErrorMinus, const QVector &valueErrorPlus) -{ - mData->clear(); - int n = key.size(); - n = qMin(n, value.size()); - n = qMin(n, valueErrorMinus.size()); - n = qMin(n, valueErrorPlus.size()); - n = qMin(n, keyErrorMinus.size()); - n = qMin(n, keyErrorPlus.size()); - QCPData newData; - for (int i=0; iinsertMulti(key[i], newData); - } -} +/*! \fn int QCPAxisRect::left() const + + Returns the pixel position of the left border of this axis rect. Margins are not taken into + account here, so the returned value is with respect to the inner \ref rect. +*/ -/*! - Sets how the single data points are connected in the plot. For scatter-only plots, set \a ls to - \ref lsNone and \ref setScatterStyle to the desired scatter style. +/*! \fn int QCPAxisRect::right() const - \see setScatterStyle + Returns the pixel position of the right border of this axis rect. Margins are not taken into + account here, so the returned value is with respect to the inner \ref rect. */ -void QCPGraph::setLineStyle(LineStyle ls) -{ - mLineStyle = ls; -} -/*! - Sets the visual appearance of single data points in the plot. If set to \ref QCPScatterStyle::ssNone, no scatter points - are drawn (e.g. for line-only-plots with appropriate line style). +/*! \fn int QCPAxisRect::top() const - \see QCPScatterStyle, setLineStyle + Returns the pixel position of the top border of this axis rect. Margins are not taken into + account here, so the returned value is with respect to the inner \ref rect. */ -void QCPGraph::setScatterStyle(const QCPScatterStyle &style) -{ - mScatterStyle = style; -} -/*! - Sets which kind of error bars (Key Error, Value Error or both) should be drawn on each data - point. If you set \a errorType to something other than \ref etNone, make sure to actually pass - error data via the specific setData functions along with the data points (e.g. \ref - setDataValueError, \ref setDataKeyError, \ref setDataBothError). +/*! \fn int QCPAxisRect::bottom() const + + Returns the pixel position of the bottom border of this axis rect. Margins are not taken into + account here, so the returned value is with respect to the inner \ref rect. +*/ - \see ErrorType +/*! \fn int QCPAxisRect::width() const + + Returns the pixel width of this axis rect. Margins are not taken into account here, so the + returned value is with respect to the inner \ref rect. */ -void QCPGraph::setErrorType(ErrorType errorType) -{ - mErrorType = errorType; -} -/*! - Sets the pen with which the error bars will be drawn. - \see setErrorBarSize, setErrorType +/*! \fn int QCPAxisRect::height() const + + Returns the pixel height of this axis rect. Margins are not taken into account here, so the + returned value is with respect to the inner \ref rect. */ -void QCPGraph::setErrorPen(const QPen &pen) -{ - mErrorPen = pen; -} -/*! - Sets the width of the handles at both ends of an error bar in pixels. +/*! \fn QSize QCPAxisRect::size() const + + Returns the pixel size of this axis rect. Margins are not taken into account here, so the + returned value is with respect to the inner \ref rect. */ -void QCPGraph::setErrorBarSize(double size) -{ - mErrorBarSize = size; -} -/*! - If \a enabled is set to true, the error bar will not be drawn as a solid line under the scatter symbol but - leave some free space around the symbol. +/*! \fn QPoint QCPAxisRect::topLeft() const - This feature uses the current scatter size (\ref QCPScatterStyle::setSize) to determine the size - of the area to leave blank. So when drawing Pixmaps as scatter points (\ref - QCPScatterStyle::ssPixmap), the scatter size must be set manually to a value corresponding to the - size of the Pixmap, if the error bars should leave gaps to its boundaries. + Returns the top left corner of this axis rect in pixels. Margins are not taken into account here, + so the returned value is with respect to the inner \ref rect. +*/ + +/*! \fn QPoint QCPAxisRect::topRight() const - \ref setErrorType, setErrorBarSize, setScatterStyle + Returns the top right corner of this axis rect in pixels. Margins are not taken into account + here, so the returned value is with respect to the inner \ref rect. */ -void QCPGraph::setErrorBarSkipSymbol(bool enabled) -{ - mErrorBarSkipSymbol = enabled; -} -/*! - Sets the target graph for filling the area between this graph and \a targetGraph with the current - brush (\ref setBrush). +/*! \fn QPoint QCPAxisRect::bottomLeft() const - When \a targetGraph is set to 0, a normal graph fill to the zero-value-line will be shown. To - disable any filling, set the brush to Qt::NoBrush. + Returns the bottom left corner of this axis rect in pixels. Margins are not taken into account + here, so the returned value is with respect to the inner \ref rect. +*/ - \see setBrush +/*! \fn QPoint QCPAxisRect::bottomRight() const + + Returns the bottom right corner of this axis rect in pixels. Margins are not taken into account + here, so the returned value is with respect to the inner \ref rect. */ -void QCPGraph::setChannelFillGraph(QCPGraph *targetGraph) -{ - // prevent setting channel target to this graph itself: - if (targetGraph == this) - { - qDebug() << Q_FUNC_INFO << "targetGraph is this graph itself"; - mChannelFillGraph = 0; - return; - } - // prevent setting channel target to a graph not in the plot: - if (targetGraph && targetGraph->mParentPlot != mParentPlot) - { - qDebug() << Q_FUNC_INFO << "targetGraph not in same plot"; - mChannelFillGraph = 0; - return; - } - - mChannelFillGraph = targetGraph; -} -/*! - Adds the provided data points in \a dataMap to the current data. - \see removeData +/*! \fn QPoint QCPAxisRect::center() const + + Returns the center of this axis rect in pixels. Margins are not taken into account here, so the + returned value is with respect to the inner \ref rect. */ -void QCPGraph::addData(const QCPDataMap &dataMap) -{ - mData->unite(dataMap); -} -/*! \overload - Adds the provided single data point in \a data to the current data. - \see removeData -*/ -void QCPGraph::addData(const QCPData &data) -{ - mData->insertMulti(data.key, data); -} +/* end documentation of inline functions */ -/*! \overload - Adds the provided single data point as \a key and \a value pair to the current data. - \see removeData +/*! + Creates a QCPAxisRect instance and sets default values. An axis is added for each of the four + sides, the top and right axes are set invisible initially. */ -void QCPGraph::addData(double key, double value) +QCPAxisRect::QCPAxisRect(QCustomPlot *parentPlot, bool setupDefaultAxes) : + QCPLayoutElement(parentPlot), + mBackgroundBrush(Qt::NoBrush), + mBackgroundScaled(true), + mBackgroundScaledMode(Qt::KeepAspectRatioByExpanding), + mInsetLayout(new QCPLayoutInset), + mRangeDrag(Qt::Horizontal|Qt::Vertical), + mRangeZoom(Qt::Horizontal|Qt::Vertical), + mRangeZoomFactorHorz(0.85), + mRangeZoomFactorVert(0.85), + mDragging(false) { - QCPData newData; - newData.key = key; - newData.value = value; - mData->insertMulti(newData.key, newData); + mInsetLayout->initializeParentPlot(mParentPlot); + mInsetLayout->setParentLayerable(this); + mInsetLayout->setParent(this); + + setMinimumSize(50, 50); + setMinimumMargins(QMargins(15, 15, 15, 15)); + mAxes.insert(QCPAxis::atLeft, QList()); + mAxes.insert(QCPAxis::atRight, QList()); + mAxes.insert(QCPAxis::atTop, QList()); + mAxes.insert(QCPAxis::atBottom, QList()); + + if (setupDefaultAxes) + { + QCPAxis *xAxis = addAxis(QCPAxis::atBottom); + QCPAxis *yAxis = addAxis(QCPAxis::atLeft); + QCPAxis *xAxis2 = addAxis(QCPAxis::atTop); + QCPAxis *yAxis2 = addAxis(QCPAxis::atRight); + setRangeDragAxes(xAxis, yAxis); + setRangeZoomAxes(xAxis, yAxis); + xAxis2->setVisible(false); + yAxis2->setVisible(false); + xAxis->grid()->setVisible(true); + yAxis->grid()->setVisible(true); + xAxis2->grid()->setVisible(false); + yAxis2->grid()->setVisible(false); + xAxis2->grid()->setZeroLinePen(Qt::NoPen); + yAxis2->grid()->setZeroLinePen(Qt::NoPen); + xAxis2->grid()->setVisible(false); + yAxis2->grid()->setVisible(false); + } } -/*! \overload - Adds the provided data points as \a key and \a value pairs to the current data. - \see removeData -*/ -void QCPGraph::addData(const QVector &keys, const QVector &values) +QCPAxisRect::~QCPAxisRect() { - int n = qMin(keys.size(), values.size()); - QCPData newData; - for (int i=0; iinsertMulti(newData.key, newData); - } + delete mInsetLayout; + mInsetLayout = 0; + + QList axesList = axes(); + for (int i=0; ibegin(); - while (it != mData->end() && it.key() < key) - it = mData->erase(it); + return mAxes.value(type).size(); } /*! - Removes all data points with keys greater than \a key. - \see addData, clearData + Returns the axis with the given \a index on the axis rect side specified with \a type. + + \see axisCount, axes */ -void QCPGraph::removeDataAfter(double key) +QCPAxis *QCPAxisRect::axis(QCPAxis::AxisType type, int index) const { - if (mData->isEmpty()) return; - QCPDataMap::iterator it = mData->upperBound(key); - while (it != mData->end()) - it = mData->erase(it); + QList ax(mAxes.value(type)); + if (index >= 0 && index < ax.size()) + { + return ax.at(index); + } else + { + qDebug() << Q_FUNC_INFO << "Axis index out of bounds:" << index; + return 0; + } } /*! - Removes all data points with keys between \a fromKey and \a toKey. - if \a fromKey is greater or equal to \a toKey, the function does nothing. To remove - a single data point with known key, use \ref removeData(double key). + Returns all axes on the axis rect sides specified with \a types. - \see addData, clearData + \a types may be a single \ref QCPAxis::AxisType or an or-combination, to get the axes of + multiple sides. + + \see axis */ -void QCPGraph::removeData(double fromKey, double toKey) +QList QCPAxisRect::axes(QCPAxis::AxisTypes types) const { - if (fromKey >= toKey || mData->isEmpty()) return; - QCPDataMap::iterator it = mData->upperBound(fromKey); - QCPDataMap::iterator itEnd = mData->upperBound(toKey); - while (it != itEnd) - it = mData->erase(it); + QList result; + if (types.testFlag(QCPAxis::atLeft)) + result << mAxes.value(QCPAxis::atLeft); + if (types.testFlag(QCPAxis::atRight)) + result << mAxes.value(QCPAxis::atRight); + if (types.testFlag(QCPAxis::atTop)) + result << mAxes.value(QCPAxis::atTop); + if (types.testFlag(QCPAxis::atBottom)) + result << mAxes.value(QCPAxis::atBottom); + return result; } /*! \overload - Removes a single data point at \a key. If the position is not known with absolute precision, - consider using \ref removeData(double fromKey, double toKey) with a small fuzziness interval around - the suspected position, depeding on the precision with which the key is known. - - \see addData, clearData + Returns all axes of this axis rect. */ -void QCPGraph::removeData(double key) +QList QCPAxisRect::axes() const { - mData->remove(key); + QList result; + QHashIterator > it(mAxes); + while (it.hasNext()) + { + it.next(); + result << it.value(); + } + return result; } /*! - Removes all data points. - \see removeData, removeDataAfter, removeDataBefore + Adds a new axis to the axis rect side specified with \a type, and returns it. + + If an axis rect side already contains one or more axes, the lower and upper endings of the new + axis (\ref QCPAxis::setLowerEnding, \ref QCPAxis::setUpperEnding) are initialized to \ref + QCPLineEnding::esHalfBar. + + \see addAxes, setupFullAxesBox */ -void QCPGraph::clearData() -{ - mData->clear(); -} - -/* inherits documentation from base class */ -double QCPGraph::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +QCPAxis *QCPAxisRect::addAxis(QCPAxis::AxisType type) { - Q_UNUSED(details) - if ((onlySelectable && !mSelectable) || mData->isEmpty()) - return -1; - - return pointDistance(pos); + QCPAxis *newAxis = new QCPAxis(this, type); + if (mAxes[type].size() > 0) // multiple axes on one side, add half-bar axis ending to additional axes with offset + { + bool invert = (type == QCPAxis::atRight) || (type == QCPAxis::atBottom); + newAxis->setLowerEnding(QCPLineEnding(QCPLineEnding::esHalfBar, 6, 10, !invert)); + newAxis->setUpperEnding(QCPLineEnding(QCPLineEnding::esHalfBar, 6, 10, invert)); + } + mAxes[type].append(newAxis); + return newAxis; } -/*! \overload +/*! + Adds a new axis with \ref addAxis to each axis rect side specified in \a types. This may be an + or-combination of QCPAxis::AxisType, so axes can be added to multiple sides at once. - Allows to define whether error bars are taken into consideration when determining the new axis - range. + Returns a list of the added axes. - \see rescaleKeyAxis, rescaleValueAxis, QCPAbstractPlottable::rescaleAxes, QCustomPlot::rescaleAxes + \see addAxis, setupFullAxesBox */ -void QCPGraph::rescaleAxes(bool onlyEnlarge, bool includeErrorBars) const +QList QCPAxisRect::addAxes(QCPAxis::AxisTypes types) { - rescaleKeyAxis(onlyEnlarge, includeErrorBars); - rescaleValueAxis(onlyEnlarge, includeErrorBars); + QList result; + if (types.testFlag(QCPAxis::atLeft)) + result << addAxis(QCPAxis::atLeft); + if (types.testFlag(QCPAxis::atRight)) + result << addAxis(QCPAxis::atRight); + if (types.testFlag(QCPAxis::atTop)) + result << addAxis(QCPAxis::atTop); + if (types.testFlag(QCPAxis::atBottom)) + result << addAxis(QCPAxis::atBottom); + return result; } -/*! \overload +/*! + Removes the specified \a axis from the axis rect and deletes it. - Allows to define whether error bars (of kind \ref QCPGraph::etKey) are taken into consideration - when determining the new axis range. + Returns true on success, i.e. if \a axis was a valid axis in this axis rect. - \see rescaleAxes, QCPAbstractPlottable::rescaleKeyAxis + \see addAxis */ -void QCPGraph::rescaleKeyAxis(bool onlyEnlarge, bool includeErrorBars) const +bool QCPAxisRect::removeAxis(QCPAxis *axis) { - // this code is a copy of QCPAbstractPlottable::rescaleKeyAxis with the only change - // that getKeyRange is passed the includeErrorBars value. - if (mData->isEmpty()) return; - - QCPAxis *keyAxis = mKeyAxis.data(); - if (!keyAxis) { qDebug() << Q_FUNC_INFO << "invalid key axis"; return; } - - SignDomain signDomain = sdBoth; - if (keyAxis->scaleType() == QCPAxis::stLogarithmic) - signDomain = (keyAxis->range().upper < 0 ? sdNegative : sdPositive); - - bool validRange; - QCPRange newRange = getKeyRange(validRange, signDomain, includeErrorBars); - - if (validRange) - { - if (onlyEnlarge) + // don't access axis->axisType() to provide safety when axis is an invalid pointer, rather go through all axis containers: + QHashIterator > it(mAxes); + while (it.hasNext()) + { + it.next(); + if (it.value().contains(axis)) { - if (keyAxis->range().lower < newRange.lower) - newRange.lower = keyAxis->range().lower; - if (keyAxis->range().upper > newRange.upper) - newRange.upper = keyAxis->range().upper; + mAxes[it.key()].removeOne(axis); + if (qobject_cast(parentPlot())) // make sure this isn't called from QObject dtor when QCustomPlot is already destructed (happens when the axis rect is not in any layout and thus QObject-child of QCustomPlot) + parentPlot()->axisRemoved(axis); + delete axis; + return true; } - keyAxis->setRange(newRange); } + qDebug() << Q_FUNC_INFO << "Axis isn't in axis rect:" << reinterpret_cast(axis); + return false; } -/*! \overload +/*! + Convenience function to create an axis on each side that doesn't have any axes yet and set their + visibility to true. Further, the top/right axes are assigned the following properties of the + bottom/left axes: - Allows to define whether error bars (of kind \ref QCPGraph::etValue) are taken into consideration - when determining the new axis range. + \li range (\ref QCPAxis::setRange) + \li range reversed (\ref QCPAxis::setRangeReversed) + \li scale type (\ref QCPAxis::setScaleType) + \li scale log base (\ref QCPAxis::setScaleLogBase) + \li ticks (\ref QCPAxis::setTicks) + \li auto (major) tick count (\ref QCPAxis::setAutoTickCount) + \li sub tick count (\ref QCPAxis::setSubTickCount) + \li auto sub ticks (\ref QCPAxis::setAutoSubTicks) + \li tick step (\ref QCPAxis::setTickStep) + \li auto tick step (\ref QCPAxis::setAutoTickStep) + \li number format (\ref QCPAxis::setNumberFormat) + \li number precision (\ref QCPAxis::setNumberPrecision) + \li tick label type (\ref QCPAxis::setTickLabelType) + \li date time format (\ref QCPAxis::setDateTimeFormat) + \li date time spec (\ref QCPAxis::setDateTimeSpec) - \see rescaleAxes, QCPAbstractPlottable::rescaleValueAxis + Tick labels (\ref QCPAxis::setTickLabels) of the right and top axes are set to false. + + If \a connectRanges is true, the \ref QCPAxis::rangeChanged "rangeChanged" signals of the bottom + and left axes are connected to the \ref QCPAxis::setRange slots of the top and right axes. */ -void QCPGraph::rescaleValueAxis(bool onlyEnlarge, bool includeErrorBars) const +void QCPAxisRect::setupFullAxesBox(bool connectRanges) { - // this code is a copy of QCPAbstractPlottable::rescaleValueAxis with the only change - // is that getValueRange is passed the includeErrorBars value. - if (mData->isEmpty()) return; + QCPAxis *xAxis, *yAxis, *xAxis2, *yAxis2; + if (axisCount(QCPAxis::atBottom) == 0) + xAxis = addAxis(QCPAxis::atBottom); + else + xAxis = axis(QCPAxis::atBottom); - QCPAxis *valueAxis = mValueAxis.data(); - if (!valueAxis) { qDebug() << Q_FUNC_INFO << "invalid value axis"; return; } - - SignDomain signDomain = sdBoth; - if (valueAxis->scaleType() == QCPAxis::stLogarithmic) - signDomain = (valueAxis->range().upper < 0 ? sdNegative : sdPositive); + if (axisCount(QCPAxis::atLeft) == 0) + yAxis = addAxis(QCPAxis::atLeft); + else + yAxis = axis(QCPAxis::atLeft); - bool validRange; - QCPRange newRange = getValueRange(validRange, signDomain, includeErrorBars); + if (axisCount(QCPAxis::atTop) == 0) + xAxis2 = addAxis(QCPAxis::atTop); + else + xAxis2 = axis(QCPAxis::atTop); - if (validRange) - { - if (onlyEnlarge) - { - if (valueAxis->range().lower < newRange.lower) - newRange.lower = valueAxis->range().lower; - if (valueAxis->range().upper > newRange.upper) - newRange.upper = valueAxis->range().upper; - } - valueAxis->setRange(newRange); - } -} - -/* inherits documentation from base class */ -void QCPGraph::draw(QCPPainter *painter) -{ - if (!mKeyAxis || !mValueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } - if (mKeyAxis.data()->range().size() <= 0 || mData->isEmpty()) return; - if (mLineStyle == lsNone && mScatterStyle.isNone()) return; + if (axisCount(QCPAxis::atRight) == 0) + yAxis2 = addAxis(QCPAxis::atRight); + else + yAxis2 = axis(QCPAxis::atRight); - // allocate line and (if necessary) point vectors: - QVector *lineData = new QVector; - QVector *pointData = 0; - if (!mScatterStyle.isNone()) - pointData = new QVector; + xAxis->setVisible(true); + yAxis->setVisible(true); + xAxis2->setVisible(true); + yAxis2->setVisible(true); + xAxis2->setTickLabels(false); + yAxis2->setTickLabels(false); - // fill vectors with data appropriate to plot style: - getPlotData(lineData, pointData); + xAxis2->setRange(xAxis->range()); + xAxis2->setRangeReversed(xAxis->rangeReversed()); + xAxis2->setScaleType(xAxis->scaleType()); + xAxis2->setScaleLogBase(xAxis->scaleLogBase()); + xAxis2->setTicks(xAxis->ticks()); + xAxis2->setAutoTickCount(xAxis->autoTickCount()); + xAxis2->setSubTickCount(xAxis->subTickCount()); + xAxis2->setAutoSubTicks(xAxis->autoSubTicks()); + xAxis2->setTickStep(xAxis->tickStep()); + xAxis2->setAutoTickStep(xAxis->autoTickStep()); + xAxis2->setNumberFormat(xAxis->numberFormat()); + xAxis2->setNumberPrecision(xAxis->numberPrecision()); + xAxis2->setTickLabelType(xAxis->tickLabelType()); + xAxis2->setDateTimeFormat(xAxis->dateTimeFormat()); + xAxis2->setDateTimeSpec(xAxis->dateTimeSpec()); + + yAxis2->setRange(yAxis->range()); + yAxis2->setRangeReversed(yAxis->rangeReversed()); + yAxis2->setScaleType(yAxis->scaleType()); + yAxis2->setScaleLogBase(yAxis->scaleLogBase()); + yAxis2->setTicks(yAxis->ticks()); + yAxis2->setAutoTickCount(yAxis->autoTickCount()); + yAxis2->setSubTickCount(yAxis->subTickCount()); + yAxis2->setAutoSubTicks(yAxis->autoSubTicks()); + yAxis2->setTickStep(yAxis->tickStep()); + yAxis2->setAutoTickStep(yAxis->autoTickStep()); + yAxis2->setNumberFormat(yAxis->numberFormat()); + yAxis2->setNumberPrecision(yAxis->numberPrecision()); + yAxis2->setTickLabelType(yAxis->tickLabelType()); + yAxis2->setDateTimeFormat(yAxis->dateTimeFormat()); + yAxis2->setDateTimeSpec(yAxis->dateTimeSpec()); - // check data validity if flag set: -#ifdef QCUSTOMPLOT_CHECK_DATA - QCPDataMap::const_iterator it; - for (it = mData->constBegin(); it != mData->constEnd(); ++it) + if (connectRanges) { - if (QCP::isInvalidData(it.value().key, it.value().value) || - QCP::isInvalidData(it.value().keyErrorPlus, it.value().keyErrorMinus) || - QCP::isInvalidData(it.value().valueErrorPlus, it.value().valueErrorPlus)) - qDebug() << Q_FUNC_INFO << "Data point at" << it.key() << "invalid." << "Plottable name:" << name(); + connect(xAxis, SIGNAL(rangeChanged(QCPRange)), xAxis2, SLOT(setRange(QCPRange))); + connect(yAxis, SIGNAL(rangeChanged(QCPRange)), yAxis2, SLOT(setRange(QCPRange))); } -#endif +} - // draw fill of graph: - drawFill(painter, lineData); - - // draw line: - if (mLineStyle == lsImpulse) - drawImpulsePlot(painter, lineData); - else if (mLineStyle != lsNone) - drawLinePlot(painter, lineData); // also step plots can be drawn as a line plot +/*! + Returns a list of all the plottables that are associated with this axis rect. - // draw scatters: - if (pointData) - drawScatterPlot(painter, pointData); + A plottable is considered associated with an axis rect if its key or value axis (or both) is in + this axis rect. - // free allocated line and point vectors: - delete lineData; - if (pointData) - delete pointData; -} - -/* inherits documentation from base class */ -void QCPGraph::drawLegendIcon(QCPPainter *painter, const QRectF &rect) const + \see graphs, items +*/ +QList QCPAxisRect::plottables() const { - // draw fill: - if (mBrush.style() != Qt::NoBrush) - { - applyFillAntialiasingHint(painter); - painter->fillRect(QRectF(rect.left(), rect.top()+rect.height()/2.0, rect.width(), rect.height()/3.0), mBrush); - } - // draw line vertically centered: - if (mLineStyle != lsNone) - { - applyDefaultAntialiasingHint(painter); - painter->setPen(mPen); - painter->drawLine(QLineF(rect.left(), rect.top()+rect.height()/2.0, rect.right()+5, rect.top()+rect.height()/2.0)); // +5 on x2 else last segment is missing from dashed/dotted pens - } - // draw scatter symbol: - if (!mScatterStyle.isNone()) + // Note: don't append all QCPAxis::plottables() into a list, because we might get duplicate entries + QList result; + for (int i=0; imPlottables.size(); ++i) { - applyScattersAntialiasingHint(painter); - // scale scatter pixmap if it's too large to fit in legend icon rect: - if (mScatterStyle.shape() == QCPScatterStyle::ssPixmap && (mScatterStyle.pixmap().size().width() > rect.width() || mScatterStyle.pixmap().size().height() > rect.height())) - { - QCPScatterStyle scaledStyle(mScatterStyle); - scaledStyle.setPixmap(scaledStyle.pixmap().scaled(rect.size().toSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation)); - scaledStyle.applyTo(painter, mPen); - scaledStyle.drawShape(painter, QRectF(rect).center()); - } else - { - mScatterStyle.applyTo(painter, mPen); - mScatterStyle.drawShape(painter, QRectF(rect).center()); - } + if (mParentPlot->mPlottables.at(i)->keyAxis()->axisRect() == this ||mParentPlot->mPlottables.at(i)->valueAxis()->axisRect() == this) + result.append(mParentPlot->mPlottables.at(i)); } + return result; } -/*! \internal - - This function branches out to the line style specific "get(...)PlotData" functions, according to - the line style of the graph. - - \a lineData will be filled with raw points that will be drawn with the according draw functions, - e.g. \ref drawLinePlot and \ref drawImpulsePlot. These aren't necessarily the original data - points, since for step plots for example, additional points are needed for drawing lines that - make up steps. If the line style of the graph is \ref lsNone, the \a lineData vector will be left - untouched. +/*! + Returns a list of all the graphs that are associated with this axis rect. - \a pointData will be filled with the original data points so \ref drawScatterPlot can draw the - scatter symbols accordingly. If no scatters need to be drawn, i.e. the scatter style's shape is - \ref QCPScatterStyle::ssNone, pass 0 as \a pointData, and this step will be skipped. + A graph is considered associated with an axis rect if its key or value axis (or both) is in + this axis rect. - \see getScatterPlotData, getLinePlotData, getStepLeftPlotData, getStepRightPlotData, - getStepCenterPlotData, getImpulsePlotData + \see plottables, items */ -void QCPGraph::getPlotData(QVector *lineData, QVector *pointData) const +QList QCPAxisRect::graphs() const { - switch(mLineStyle) + // Note: don't append all QCPAxis::graphs() into a list, because we might get duplicate entries + QList result; + for (int i=0; imGraphs.size(); ++i) { - case lsNone: getScatterPlotData(pointData); break; - case lsLine: getLinePlotData(lineData, pointData); break; - case lsStepLeft: getStepLeftPlotData(lineData, pointData); break; - case lsStepRight: getStepRightPlotData(lineData, pointData); break; - case lsStepCenter: getStepCenterPlotData(lineData, pointData); break; - case lsImpulse: getImpulsePlotData(lineData, pointData); break; + if (mParentPlot->mGraphs.at(i)->keyAxis()->axisRect() == this || mParentPlot->mGraphs.at(i)->valueAxis()->axisRect() == this) + result.append(mParentPlot->mGraphs.at(i)); } + return result; } -/*! \internal - - If line style is \ref lsNone and the scatter style's shape is not \ref QCPScatterStyle::ssNone, - this function serves at providing the visible data points in \a pointData, so the \ref - drawScatterPlot function can draw the scatter points accordingly. +/*! + Returns a list of all the items that are associated with this axis rect. - If line style is not \ref lsNone, this function is not called and the data for the scatter points - are (if needed) calculated inside the corresponding other "get(...)PlotData" functions. + An item is considered associated with an axis rect if any of its positions has key or value axis + set to an axis that is in this axis rect, or if any of its positions has \ref + QCPItemPosition::setAxisRect set to the axis rect, or if the clip axis rect (\ref + QCPAbstractItem::setClipAxisRect) is set to this axis rect. - \see drawScatterPlot + \see plottables, graphs */ -void QCPGraph::getScatterPlotData(QVector *pointData) const +QList QCPAxisRect::items() const { - if (!pointData) return; - QCPAxis *keyAxis = mKeyAxis.data(); - if (!keyAxis) { qDebug() << Q_FUNC_INFO << "invalid key axis"; return; } - - // get visible data range: - QCPDataMap::const_iterator lower, upper; - int dataCount = 0; - getVisibleDataBounds(lower, upper, dataCount); - if (dataCount > 0) + // Note: don't just append all QCPAxis::items() into a list, because we might get duplicate entries + // and miss those items that have this axis rect as clipAxisRect. + QList result; + for (int itemId=0; itemIdmItems.size(); ++itemId) { - // prepare vectors: - pointData->resize(dataCount); - - // position data points: - QCPDataMap::const_iterator it = lower; - QCPDataMap::const_iterator upperEnd = upper+1; - int i = 0; - while (it != upperEnd) + if (mParentPlot->mItems.at(itemId)->clipAxisRect() == this) { - (*pointData)[i] = it.value(); - ++i; - ++it; + result.append(mParentPlot->mItems.at(itemId)); + continue; + } + QList positions = mParentPlot->mItems.at(itemId)->positions(); + for (int posId=0; posIdaxisRect() == this || + positions.at(posId)->keyAxis()->axisRect() == this || + positions.at(posId)->valueAxis()->axisRect() == this) + { + result.append(mParentPlot->mItems.at(itemId)); + break; + } } } + return result; } -/*! \internal - - Places the raw data points needed for a normal linearly connected graph in \a lineData. - - As for all plot data retrieval functions, \a pointData just contains all unaltered data (scatter) - points that are visible for drawing scatter points, if necessary. If drawing scatter points is - disabled (i.e. the scatter style's shape is \ref QCPScatterStyle::ssNone), pass 0 as \a - pointData, and the function will skip filling the vector. +/*! + This method is called automatically upon replot and doesn't need to be called by users of + QCPAxisRect. - \see drawLinePlot + Calls the base class implementation to update the margins (see \ref QCPLayoutElement::update), + and finally passes the \ref rect to the inset layout (\ref insetLayout) and calls its + QCPInsetLayout::update function. */ -void QCPGraph::getLinePlotData(QVector *lineData, QVector *pointData) const +void QCPAxisRect::update(UpdatePhase phase) { - QCPAxis *keyAxis = mKeyAxis.data(); - QCPAxis *valueAxis = mValueAxis.data(); - if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } - if (!lineData) { qDebug() << Q_FUNC_INFO << "null pointer passed as lineData"; return; } + QCPLayoutElement::update(phase); - // get visible data range: - QCPDataMap::const_iterator lower, upper; - int dataCount = 0; - getVisibleDataBounds(lower, upper, dataCount); - if (dataCount > 0) - { - lineData->reserve(dataCount+2); // added 2 to reserve memory for lower/upper fill base points that might be needed for fill - lineData->resize(dataCount); - if (pointData) - pointData->resize(dataCount); - - // position data points: - QCPDataMap::const_iterator it = lower; - QCPDataMap::const_iterator upperEnd = upper+1; - int i = 0; - if (keyAxis->orientation() == Qt::Vertical) + switch (phase) + { + case upPreparation: { - while (it != upperEnd) - { - if (pointData) - (*pointData)[i] = it.value(); - (*lineData)[i].setX(valueAxis->coordToPixel(it.value().value)); - (*lineData)[i].setY(keyAxis->coordToPixel(it.key())); - ++i; - ++it; - } - } else // key axis is horizontal + QList allAxes = axes(); + for (int i=0; isetupTickVectors(); + break; + } + case upLayout: { - while (it != upperEnd) - { - if (pointData) - (*pointData)[i] = it.value(); - (*lineData)[i].setX(keyAxis->coordToPixel(it.key())); - (*lineData)[i].setY(valueAxis->coordToPixel(it.value().value)); - ++i; - ++it; - } + mInsetLayout->setOuterRect(rect()); + break; } + default: break; } -} - -/*! - \internal - Places the raw data points needed for a step plot with left oriented steps in \a lineData. - - As for all plot data retrieval functions, \a pointData just contains all unaltered data (scatter) - points that are visible for drawing scatter points, if necessary. If drawing scatter points is - disabled (i.e. the scatter style's shape is \ref QCPScatterStyle::ssNone), pass 0 as \a - pointData, and the function will skip filling the vector. - \see drawLinePlot -*/ -void QCPGraph::getStepLeftPlotData(QVector *lineData, QVector *pointData) const + // pass update call on to inset layout (doesn't happen automatically, because QCPAxisRect doesn't derive from QCPLayout): + mInsetLayout->update(phase); +} + +/* inherits documentation from base class */ +QList QCPAxisRect::elements(bool recursive) const { - QCPAxis *keyAxis = mKeyAxis.data(); - QCPAxis *valueAxis = mValueAxis.data(); - if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } - if (!lineData) { qDebug() << Q_FUNC_INFO << "null pointer passed as lineData"; return; } - - // get visible data range: - QCPDataMap::const_iterator lower, upper; - int dataCount = 0; - getVisibleDataBounds(lower, upper, dataCount); - if (dataCount > 0) - { - lineData->reserve(dataCount*2+2); // added 2 to reserve memory for lower/upper fill base points that might be needed for fill - lineData->resize(dataCount*2); // multiplied by 2 because step plot needs two polyline points per one actual data point - if (pointData) - pointData->resize(dataCount); - - // position data points: - QCPDataMap::const_iterator it = lower; - QCPDataMap::const_iterator upperEnd = upper+1; - int i = 0; - int ipoint = 0; - if (keyAxis->orientation() == Qt::Vertical) - { - double lastValue = valueAxis->coordToPixel(it.value().value); - double key; - while (it != upperEnd) - { - if (pointData) - { - (*pointData)[ipoint] = it.value(); - ++ipoint; - } - key = keyAxis->coordToPixel(it.key()); - (*lineData)[i].setX(lastValue); - (*lineData)[i].setY(key); - ++i; - lastValue = valueAxis->coordToPixel(it.value().value); - (*lineData)[i].setX(lastValue); - (*lineData)[i].setY(key); - ++i; - ++it; - } - } else // key axis is horizontal - { - double lastValue = valueAxis->coordToPixel(it.value().value); - double key; - while (it != upperEnd) - { - if (pointData) - { - (*pointData)[ipoint] = it.value(); - ++ipoint; - } - key = keyAxis->coordToPixel(it.key()); - (*lineData)[i].setX(key); - (*lineData)[i].setY(lastValue); - ++i; - lastValue = valueAxis->coordToPixel(it.value().value); - (*lineData)[i].setX(key); - (*lineData)[i].setY(lastValue); - ++i; - ++it; - } - } + QList result; + if (mInsetLayout) + { + result << mInsetLayout; + if (recursive) + result << mInsetLayout->elements(recursive); } + return result; } -/*! - \internal - Places the raw data points needed for a step plot with right oriented steps in \a lineData. +/* inherits documentation from base class */ +void QCPAxisRect::applyDefaultAntialiasingHint(QCPPainter *painter) const +{ + painter->setAntialiasing(false); +} - As for all plot data retrieval functions, \a pointData just contains all unaltered data (scatter) - points that are visible for drawing scatter points, if necessary. If drawing scatter points is - disabled (i.e. the scatter style's shape is \ref QCPScatterStyle::ssNone), pass 0 as \a - pointData, and the function will skip filling the vector. - - \see drawLinePlot -*/ -void QCPGraph::getStepRightPlotData(QVector *lineData, QVector *pointData) const +/* inherits documentation from base class */ +void QCPAxisRect::draw(QCPPainter *painter) { - QCPAxis *keyAxis = mKeyAxis.data(); - QCPAxis *valueAxis = mValueAxis.data(); - if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } - if (!lineData) { qDebug() << Q_FUNC_INFO << "null pointer passed as lineData"; return; } - - // get visible data range: - QCPDataMap::const_iterator lower, upper; - int dataCount = 0; - getVisibleDataBounds(lower, upper, dataCount); - if (dataCount > 0) - { - lineData->reserve(dataCount*2+2); // added 2 to reserve memory for lower/upper fill base points that might be needed for fill - lineData->resize(dataCount*2); // multiplied by 2 because step plot needs two polyline points per one actual data point - if (pointData) - pointData->resize(dataCount); - - // position points: - QCPDataMap::const_iterator it = lower; - QCPDataMap::const_iterator upperEnd = upper+1; - int i = 0; - int ipoint = 0; - if (keyAxis->orientation() == Qt::Vertical) - { - double lastKey = keyAxis->coordToPixel(it.key()); - double value; - while (it != upperEnd) - { - if (pointData) - { - (*pointData)[ipoint] = it.value(); - ++ipoint; - } - value = valueAxis->coordToPixel(it.value().value); - (*lineData)[i].setX(value); - (*lineData)[i].setY(lastKey); - ++i; - lastKey = keyAxis->coordToPixel(it.key()); - (*lineData)[i].setX(value); - (*lineData)[i].setY(lastKey); - ++i; - ++it; - } - } else // key axis is horizontal - { - double lastKey = keyAxis->coordToPixel(it.key()); - double value; - while (it != upperEnd) - { - if (pointData) - { - (*pointData)[ipoint] = it.value(); - ++ipoint; - } - value = valueAxis->coordToPixel(it.value().value); - (*lineData)[i].setX(lastKey); - (*lineData)[i].setY(value); - ++i; - lastKey = keyAxis->coordToPixel(it.key()); - (*lineData)[i].setX(lastKey); - (*lineData)[i].setY(value); - ++i; - ++it; - } - } - } + drawBackground(painter); } -/*! - \internal - Places the raw data points needed for a step plot with centered steps in \a lineData. +/*! + Sets \a pm as the axis background pixmap. The axis background pixmap will be drawn inside the + axis rect. Since axis rects place themselves on the "background" layer by default, the axis rect + backgrounds are usually drawn below everything else. - As for all plot data retrieval functions, \a pointData just contains all unaltered data (scatter) - points that are visible for drawing scatter points, if necessary. If drawing scatter points is - disabled (i.e. the scatter style's shape is \ref QCPScatterStyle::ssNone), pass 0 as \a - pointData, and the function will skip filling the vector. + For cases where the provided pixmap doesn't have the same size as the axis rect, scaling can be + enabled with \ref setBackgroundScaled and the scaling mode (i.e. whether and how the aspect ratio + is preserved) can be set with \ref setBackgroundScaledMode. To set all these options in one call, + consider using the overloaded version of this function. + + Below the pixmap, the axis rect may be optionally filled with a brush, if specified with \ref + setBackground(const QBrush &brush). - \see drawLinePlot + \see setBackgroundScaled, setBackgroundScaledMode, setBackground(const QBrush &brush) */ -void QCPGraph::getStepCenterPlotData(QVector *lineData, QVector *pointData) const +void QCPAxisRect::setBackground(const QPixmap &pm) { - QCPAxis *keyAxis = mKeyAxis.data(); - QCPAxis *valueAxis = mValueAxis.data(); - if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } - if (!lineData) { qDebug() << Q_FUNC_INFO << "null pointer passed as lineData"; return; } - - // get visible data range: - QCPDataMap::const_iterator lower, upper; - int dataCount = 0; - getVisibleDataBounds(lower, upper, dataCount); - if (dataCount > 0) - { - // added 2 to reserve memory for lower/upper fill base points that might be needed for base fill - // multiplied by 2 because step plot needs two polyline points per one actual data point - lineData->reserve(dataCount*2+2); - lineData->resize(dataCount*2); - if (pointData) - pointData->resize(dataCount); - - // position points: - QCPDataMap::const_iterator it = lower; - QCPDataMap::const_iterator upperEnd = upper+1; - int i = 0; - int ipoint = 0; - if (keyAxis->orientation() == Qt::Vertical) - { - double lastKey = keyAxis->coordToPixel(it.key()); - double lastValue = valueAxis->coordToPixel(it.value().value); - double key; - if (pointData) - { - (*pointData)[ipoint] = it.value(); - ++ipoint; - } - (*lineData)[i].setX(lastValue); - (*lineData)[i].setY(lastKey); - ++it; - ++i; - while (it != upperEnd) - { - if (pointData) - { - (*pointData)[ipoint] = it.value(); - ++ipoint; - } - key = (keyAxis->coordToPixel(it.key())-lastKey)*0.5 + lastKey; - (*lineData)[i].setX(lastValue); - (*lineData)[i].setY(key); - ++i; - lastValue = valueAxis->coordToPixel(it.value().value); - lastKey = keyAxis->coordToPixel(it.key()); - (*lineData)[i].setX(lastValue); - (*lineData)[i].setY(key); - ++it; - ++i; - } - (*lineData)[i].setX(lastValue); - (*lineData)[i].setY(lastKey); - } else // key axis is horizontal - { - double lastKey = keyAxis->coordToPixel(it.key()); - double lastValue = valueAxis->coordToPixel(it.value().value); - double key; - if (pointData) - { - (*pointData)[ipoint] = it.value(); - ++ipoint; - } - (*lineData)[i].setX(lastKey); - (*lineData)[i].setY(lastValue); - ++it; - ++i; - while (it != upperEnd) - { - if (pointData) - { - (*pointData)[ipoint] = it.value(); - ++ipoint; - } - key = (keyAxis->coordToPixel(it.key())-lastKey)*0.5 + lastKey; - (*lineData)[i].setX(key); - (*lineData)[i].setY(lastValue); - ++i; - lastValue = valueAxis->coordToPixel(it.value().value); - lastKey = keyAxis->coordToPixel(it.key()); - (*lineData)[i].setX(key); - (*lineData)[i].setY(lastValue); - ++it; - ++i; - } - (*lineData)[i].setX(lastKey); - (*lineData)[i].setY(lastValue); - } - } + mBackgroundPixmap = pm; + mScaledBackgroundPixmap = QPixmap(); } -/*! - \internal - Places the raw data points needed for an impulse plot in \a lineData. +/*! \overload + + Sets \a brush as the background brush. The axis rect background will be filled with this brush. + Since axis rects place themselves on the "background" layer by default, the axis rect backgrounds + are usually drawn below everything else. - As for all plot data retrieval functions, \a pointData just contains all unaltered data (scatter) - points that are visible for drawing scatter points, if necessary. If drawing scatter points is - disabled (i.e. the scatter style's shape is \ref QCPScatterStyle::ssNone), pass 0 as \a - pointData, and the function will skip filling the vector. + The brush will be drawn before (under) any background pixmap, which may be specified with \ref + setBackground(const QPixmap &pm). + + To disable drawing of a background brush, set \a brush to Qt::NoBrush. - \see drawImpulsePlot + \see setBackground(const QPixmap &pm) */ -void QCPGraph::getImpulsePlotData(QVector *lineData, QVector *pointData) const +void QCPAxisRect::setBackground(const QBrush &brush) { - QCPAxis *keyAxis = mKeyAxis.data(); - QCPAxis *valueAxis = mValueAxis.data(); - if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } - if (!lineData) { qDebug() << Q_FUNC_INFO << "null pointer passed as lineData"; return; } - - // get visible data range: - QCPDataMap::const_iterator lower, upper; - int dataCount = 0; - getVisibleDataBounds(lower, upper, dataCount); - if (dataCount > 0) - { - lineData->resize(dataCount*2); // no need to reserve 2 extra points, because there is no fill for impulse plot - if (pointData) - pointData->resize(dataCount); - - // position data points: - QCPDataMap::const_iterator it = lower; - QCPDataMap::const_iterator upperEnd = upper+1; - int i = 0; - int ipoint = 0; - if (keyAxis->orientation() == Qt::Vertical) - { - double zeroPointX = valueAxis->coordToPixel(0); - double key; - while (it != upperEnd) - { - if (pointData) - { - (*pointData)[ipoint] = it.value(); - ++ipoint; - } - key = keyAxis->coordToPixel(it.key()); - (*lineData)[i].setX(zeroPointX); - (*lineData)[i].setY(key); - ++i; - (*lineData)[i].setX(valueAxis->coordToPixel(it.value().value)); - (*lineData)[i].setY(key); - ++i; - ++it; - } - } else // key axis is horizontal - { - double zeroPointY = valueAxis->coordToPixel(0); - double key; - while (it != upperEnd) - { - if (pointData) - { - (*pointData)[ipoint] = it.value(); - ++ipoint; - } - key = keyAxis->coordToPixel(it.key()); - (*lineData)[i].setX(key); - (*lineData)[i].setY(zeroPointY); - ++i; - (*lineData)[i].setX(key); - (*lineData)[i].setY(valueAxis->coordToPixel(it.value().value)); - ++i; - ++it; - } - } - } + mBackgroundBrush = brush; } -/*! \internal +/*! \overload - Draws the fill of the graph with the specified brush. + Allows setting the background pixmap of the axis rect, whether it shall be scaled and how it + shall be scaled in one call. - If the fill is a normal fill towards the zero-value-line, only the \a lineData is required (and - two extra points at the zero-value-line, which are added by \ref addFillBasePoints and removed by - \ref removeFillBasePoints after the fill drawing is done). - - If the fill is a channel fill between this QCPGraph and another QCPGraph (mChannelFillGraph), the - more complex polygon is calculated with the \ref getChannelFillPolygon function. - - \see drawLinePlot + \see setBackground(const QPixmap &pm), setBackgroundScaled, setBackgroundScaledMode */ -void QCPGraph::drawFill(QCPPainter *painter, QVector *lineData) const +void QCPAxisRect::setBackground(const QPixmap &pm, bool scaled, Qt::AspectRatioMode mode) { - if (mLineStyle == lsImpulse) return; // fill doesn't make sense for impulse plot - if (mainBrush().style() == Qt::NoBrush || mainBrush().color().alpha() == 0) return; - - applyFillAntialiasingHint(painter); - if (!mChannelFillGraph) - { - // draw base fill under graph, fill goes all the way to the zero-value-line: - addFillBasePoints(lineData); - painter->setPen(Qt::NoPen); - painter->setBrush(mainBrush()); - painter->drawPolygon(QPolygonF(*lineData)); - removeFillBasePoints(lineData); - } else - { - // draw channel fill between this graph and mChannelFillGraph: - painter->setPen(Qt::NoPen); - painter->setBrush(mainBrush()); - painter->drawPolygon(getChannelFillPolygon(lineData)); - } + mBackgroundPixmap = pm; + mScaledBackgroundPixmap = QPixmap(); + mBackgroundScaled = scaled; + mBackgroundScaledMode = mode; } -/*! \internal +/*! + Sets whether the axis background pixmap shall be scaled to fit the axis rect or not. If \a scaled + is set to true, you may control whether and how the aspect ratio of the original pixmap is + preserved with \ref setBackgroundScaledMode. - Draws scatter symbols at every data point passed in \a pointData. scatter symbols are independent - of the line style and are always drawn if the scatter style's shape is not \ref - QCPScatterStyle::ssNone. Hence, the \a pointData vector is outputted by all "get(...)PlotData" - functions, together with the (line style dependent) line data. + Note that the scaled version of the original pixmap is buffered, so there is no performance + penalty on replots. (Except when the axis rect dimensions are changed continuously.) - \see drawLinePlot, drawImpulsePlot + \see setBackground, setBackgroundScaledMode */ -void QCPGraph::drawScatterPlot(QCPPainter *painter, QVector *pointData) const +void QCPAxisRect::setBackgroundScaled(bool scaled) { - QCPAxis *keyAxis = mKeyAxis.data(); - QCPAxis *valueAxis = mValueAxis.data(); - if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } - - // draw error bars: - if (mErrorType != etNone) - { - applyErrorBarsAntialiasingHint(painter); - painter->setPen(mErrorPen); - if (keyAxis->orientation() == Qt::Vertical) - { - for (int i=0; isize(); ++i) - drawError(painter, valueAxis->coordToPixel(pointData->at(i).value), keyAxis->coordToPixel(pointData->at(i).key), pointData->at(i)); - } else - { - for (int i=0; isize(); ++i) - drawError(painter, keyAxis->coordToPixel(pointData->at(i).key), valueAxis->coordToPixel(pointData->at(i).value), pointData->at(i)); - } - } - - // draw scatter point symbols: - applyScattersAntialiasingHint(painter); - mScatterStyle.applyTo(painter, mPen); - if (keyAxis->orientation() == Qt::Vertical) - { - for (int i=0; isize(); ++i) - mScatterStyle.drawShape(painter, valueAxis->coordToPixel(pointData->at(i).value), keyAxis->coordToPixel(pointData->at(i).key)); - } else - { - for (int i=0; isize(); ++i) - mScatterStyle.drawShape(painter, keyAxis->coordToPixel(pointData->at(i).key), valueAxis->coordToPixel(pointData->at(i).value)); - } + mBackgroundScaled = scaled; } -/*! \internal - - Draws line graphs from the provided data. It connects all points in \a lineData, which was - created by one of the "get(...)PlotData" functions for line styles that require simple line - connections between the point vector they create. These are for example \ref getLinePlotData, - \ref getStepLeftPlotData, \ref getStepRightPlotData and \ref getStepCenterPlotData. - - \see drawScatterPlot, drawImpulsePlot +/*! + If scaling of the axis background pixmap is enabled (\ref setBackgroundScaled), use this function to + define whether and how the aspect ratio of the original pixmap passed to \ref setBackground is preserved. + \see setBackground, setBackgroundScaled */ -void QCPGraph::drawLinePlot(QCPPainter *painter, QVector *lineData) const +void QCPAxisRect::setBackgroundScaledMode(Qt::AspectRatioMode mode) { - // draw line of graph: - if (mainPen().style() != Qt::NoPen && mainPen().color().alpha() != 0) - { - applyDefaultAntialiasingHint(painter); - painter->setPen(mainPen()); - painter->setBrush(Qt::NoBrush); - - /* Draws polyline in batches, currently not used: - int p = 0; - while (p < lineData->size()) - { - int batch = qMin(25, lineData->size()-p); - if (p != 0) - { - ++batch; - --p; // to draw the connection lines between two batches - } - painter->drawPolyline(lineData->constData()+p, batch); - p += batch; - } - */ - - // if drawing solid line and not in PDF, use much faster line drawing instead of polyline: - if (mParentPlot->plottingHints().testFlag(QCP::phFastPolylines) && - painter->pen().style() == Qt::SolidLine && - !painter->modes().testFlag(QCPPainter::pmVectorized)&& - !painter->modes().testFlag(QCPPainter::pmNoCaching)) - { - for (int i=1; isize(); ++i) - painter->drawLine(lineData->at(i-1), lineData->at(i)); - } else - { - painter->drawPolyline(QPolygonF(*lineData)); - } - } + mBackgroundScaledMode = mode; } -/*! \internal - - Draws impulses from the provided data, i.e. it connects all line pairs in \a lineData, which was - created by \ref getImpulsePlotData. +/*! + Returns the range drag axis of the \a orientation provided. - \see drawScatterPlot, drawLinePlot + \see setRangeDragAxes */ -void QCPGraph::drawImpulsePlot(QCPPainter *painter, QVector *lineData) const +QCPAxis *QCPAxisRect::rangeDragAxis(Qt::Orientation orientation) { - // draw impulses: - if (mainPen().style() != Qt::NoPen && mainPen().color().alpha() != 0) - { - applyDefaultAntialiasingHint(painter); - QPen pen = mainPen(); - pen.setCapStyle(Qt::FlatCap); // so impulse line doesn't reach beyond zero-line - painter->setPen(pen); - painter->setBrush(Qt::NoBrush); - painter->drawLines(*lineData); - } + return (orientation == Qt::Horizontal ? mRangeDragHorzAxis.data() : mRangeDragVertAxis.data()); } -/*! \internal +/*! + Returns the range zoom axis of the \a orientation provided. - called by the scatter drawing function (\ref drawScatterPlot) to draw the error bars on one data - point. \a x and \a y pixel positions of the data point are passed since they are already known in - pixel coordinates in the drawing function, so we save some extra coordToPixel transforms here. \a - data is therefore only used for the errors, not key and value. + \see setRangeZoomAxes */ -void QCPGraph::drawError(QCPPainter *painter, double x, double y, const QCPData &data) const +QCPAxis *QCPAxisRect::rangeZoomAxis(Qt::Orientation orientation) { - QCPAxis *keyAxis = mKeyAxis.data(); - QCPAxis *valueAxis = mValueAxis.data(); - if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } - - double a, b; // positions of error bar bounds in pixels - double barWidthHalf = mErrorBarSize*0.5; - double skipSymbolMargin = mScatterStyle.size(); // pixels left blank per side, when mErrorBarSkipSymbol is true - - if (keyAxis->orientation() == Qt::Vertical) - { - // draw key error vertically and value error horizontally - if (mErrorType == etKey || mErrorType == etBoth) - { - a = keyAxis->coordToPixel(data.key-data.keyErrorMinus); - b = keyAxis->coordToPixel(data.key+data.keyErrorPlus); - if (keyAxis->rangeReversed()) - qSwap(a,b); - // draw spine: - if (mErrorBarSkipSymbol) - { - if (a-y > skipSymbolMargin) // don't draw spine if error is so small it's within skipSymbolmargin - painter->drawLine(QLineF(x, a, x, y+skipSymbolMargin)); - if (y-b > skipSymbolMargin) - painter->drawLine(QLineF(x, y-skipSymbolMargin, x, b)); - } else - painter->drawLine(QLineF(x, a, x, b)); - // draw handles: - painter->drawLine(QLineF(x-barWidthHalf, a, x+barWidthHalf, a)); - painter->drawLine(QLineF(x-barWidthHalf, b, x+barWidthHalf, b)); - } - if (mErrorType == etValue || mErrorType == etBoth) - { - a = valueAxis->coordToPixel(data.value-data.valueErrorMinus); - b = valueAxis->coordToPixel(data.value+data.valueErrorPlus); - if (valueAxis->rangeReversed()) - qSwap(a,b); - // draw spine: - if (mErrorBarSkipSymbol) - { - if (x-a > skipSymbolMargin) // don't draw spine if error is so small it's within skipSymbolmargin - painter->drawLine(QLineF(a, y, x-skipSymbolMargin, y)); - if (b-x > skipSymbolMargin) - painter->drawLine(QLineF(x+skipSymbolMargin, y, b, y)); - } else - painter->drawLine(QLineF(a, y, b, y)); - // draw handles: - painter->drawLine(QLineF(a, y-barWidthHalf, a, y+barWidthHalf)); - painter->drawLine(QLineF(b, y-barWidthHalf, b, y+barWidthHalf)); - } - } else // mKeyAxis->orientation() is Qt::Horizontal - { - // draw value error vertically and key error horizontally - if (mErrorType == etKey || mErrorType == etBoth) - { - a = keyAxis->coordToPixel(data.key-data.keyErrorMinus); - b = keyAxis->coordToPixel(data.key+data.keyErrorPlus); - if (keyAxis->rangeReversed()) - qSwap(a,b); - // draw spine: - if (mErrorBarSkipSymbol) - { - if (x-a > skipSymbolMargin) // don't draw spine if error is so small it's within skipSymbolmargin - painter->drawLine(QLineF(a, y, x-skipSymbolMargin, y)); - if (b-x > skipSymbolMargin) - painter->drawLine(QLineF(x+skipSymbolMargin, y, b, y)); - } else - painter->drawLine(QLineF(a, y, b, y)); - // draw handles: - painter->drawLine(QLineF(a, y-barWidthHalf, a, y+barWidthHalf)); - painter->drawLine(QLineF(b, y-barWidthHalf, b, y+barWidthHalf)); - } - if (mErrorType == etValue || mErrorType == etBoth) - { - a = valueAxis->coordToPixel(data.value-data.valueErrorMinus); - b = valueAxis->coordToPixel(data.value+data.valueErrorPlus); - if (valueAxis->rangeReversed()) - qSwap(a,b); - // draw spine: - if (mErrorBarSkipSymbol) - { - if (a-y > skipSymbolMargin) // don't draw spine if error is so small it's within skipSymbolmargin - painter->drawLine(QLineF(x, a, x, y+skipSymbolMargin)); - if (y-b > skipSymbolMargin) - painter->drawLine(QLineF(x, y-skipSymbolMargin, x, b)); - } else - painter->drawLine(QLineF(x, a, x, b)); - // draw handles: - painter->drawLine(QLineF(x-barWidthHalf, a, x+barWidthHalf, a)); - painter->drawLine(QLineF(x-barWidthHalf, b, x+barWidthHalf, b)); - } - } + return (orientation == Qt::Horizontal ? mRangeZoomHorzAxis.data() : mRangeZoomVertAxis.data()); } -/*! \internal - - called by the specific plot data generating functions "get(...)PlotData" to determine which data - range is visible, so only that needs to be processed. - - \a lower returns an iterator to the lowest data point that needs to be taken into account when - plotting. Note that in order to get a clean plot all the way to the edge of the axes, \a lower - may still be outside the visible range. - - \a upper returns an iterator to the highest data point. Same as before, \a upper may also lie - outside of the visible range. - - \a count number of data points that need plotting, i.e. points between \a lower and \a upper, - including them. This is useful for allocating the array of QPointFs in the specific - drawing functions. +/*! + Returns the range zoom factor of the \a orientation provided. - if the graph contains no data, \a count is zero and both \a lower and \a upper point to constEnd. + \see setRangeZoomFactor */ -void QCPGraph::getVisibleDataBounds(QCPDataMap::const_iterator &lower, QCPDataMap::const_iterator &upper, int &count) const +double QCPAxisRect::rangeZoomFactor(Qt::Orientation orientation) { - if (!mKeyAxis) { qDebug() << Q_FUNC_INFO << "invalid key axis"; return; } - if (mData->isEmpty()) - { - lower = mData->constEnd(); - upper = mData->constEnd(); - count = 0; - return; - } - - // get visible data range as QMap iterators - QCPDataMap::const_iterator lbound = mData->lowerBound(mKeyAxis.data()->range().lower); - QCPDataMap::const_iterator ubound = mData->upperBound(mKeyAxis.data()->range().upper); - bool lowoutlier = lbound != mData->constBegin(); // indicates whether there exist points below axis range - bool highoutlier = ubound != mData->constEnd(); // indicates whether there exist points above axis range - - lower = (lowoutlier ? lbound-1 : lbound); // data point range that will be actually drawn - upper = (highoutlier ? ubound : ubound-1); // data point range that will be actually drawn - - // count number of points in range lower to upper (including them), so we can allocate array for them in draw functions: - QCPDataMap::const_iterator it = lower; - count = 1; - while (it != upper) - { - ++it; - ++count; - } + return (orientation == Qt::Horizontal ? mRangeZoomFactorHorz : mRangeZoomFactorVert); } -/*! \internal +/*! + Sets which axis orientation may be range dragged by the user with mouse interaction. + What orientation corresponds to which specific axis can be set with + \ref setRangeDragAxes(QCPAxis *horizontal, QCPAxis *vertical). By + default, the horizontal axis is the bottom axis (xAxis) and the vertical axis + is the left axis (yAxis). - The line data vector generated by e.g. getLinePlotData contains only the line that connects the - data points. If the graph needs to be filled, two additional points need to be added at the - value-zero-line in the lower and upper key positions of the graph. This function calculates these - points and adds them to the end of \a lineData. Since the fill is typically drawn before the line - stroke, these added points need to be removed again after the fill is done, with the - removeFillBasePoints function. + To disable range dragging entirely, pass 0 as \a orientations or remove \ref QCP::iRangeDrag from \ref + QCustomPlot::setInteractions. To enable range dragging for both directions, pass Qt::Horizontal | + Qt::Vertical as \a orientations. - The expanding of \a lineData by two points will not cause unnecessary memory reallocations, - because the data vector generation functions (getLinePlotData etc.) reserve two extra points when - they allocate memory for \a lineData. + In addition to setting \a orientations to a non-zero value, make sure \ref QCustomPlot::setInteractions + contains \ref QCP::iRangeDrag to enable the range dragging interaction. - \see removeFillBasePoints, lowerFillBasePoint, upperFillBasePoint + \see setRangeZoom, setRangeDragAxes, setNoAntialiasingOnDrag */ -void QCPGraph::addFillBasePoints(QVector *lineData) const +void QCPAxisRect::setRangeDrag(Qt::Orientations orientations) { - if (!mKeyAxis) { qDebug() << Q_FUNC_INFO << "invalid key axis"; return; } - - // append points that close the polygon fill at the key axis: - if (mKeyAxis.data()->orientation() == Qt::Vertical) - { - *lineData << upperFillBasePoint(lineData->last().y()); - *lineData << lowerFillBasePoint(lineData->first().y()); - } else - { - *lineData << upperFillBasePoint(lineData->last().x()); - *lineData << lowerFillBasePoint(lineData->first().x()); - } + mRangeDrag = orientations; } -/*! \internal +/*! + Sets which axis orientation may be zoomed by the user with the mouse wheel. What orientation + corresponds to which specific axis can be set with \ref setRangeZoomAxes(QCPAxis *horizontal, + QCPAxis *vertical). By default, the horizontal axis is the bottom axis (xAxis) and the vertical + axis is the left axis (yAxis). + + To disable range zooming entirely, pass 0 as \a orientations or remove \ref QCP::iRangeZoom from \ref + QCustomPlot::setInteractions. To enable range zooming for both directions, pass Qt::Horizontal | + Qt::Vertical as \a orientations. - removes the two points from \a lineData that were added by \ref addFillBasePoints. + In addition to setting \a orientations to a non-zero value, make sure \ref QCustomPlot::setInteractions + contains \ref QCP::iRangeZoom to enable the range zooming interaction. - \see addFillBasePoints, lowerFillBasePoint, upperFillBasePoint + \see setRangeZoomFactor, setRangeZoomAxes, setRangeDrag */ -void QCPGraph::removeFillBasePoints(QVector *lineData) const +void QCPAxisRect::setRangeZoom(Qt::Orientations orientations) { - lineData->remove(lineData->size()-2, 2); + mRangeZoom = orientations; } -/*! \internal +/*! + Sets the axes whose range will be dragged when \ref setRangeDrag enables mouse range dragging + on the QCustomPlot widget. - called by \ref addFillBasePoints to conveniently assign the point which closes the fill polygon - on the lower side of the zero-value-line parallel to the key axis. The logarithmic axis scale - case is a bit special, since the zero-value-line in pixel coordinates is in positive or negative - infinity. So this case is handled separately by just closing the fill polygon on the axis which - lies in the direction towards the zero value. + \see setRangeZoomAxes +*/ +void QCPAxisRect::setRangeDragAxes(QCPAxis *horizontal, QCPAxis *vertical) +{ + mRangeDragHorzAxis = horizontal; + mRangeDragVertAxis = vertical; +} + +/*! + Sets the axes whose range will be zoomed when \ref setRangeZoom enables mouse wheel zooming on the + QCustomPlot widget. The two axes can be zoomed with different strengths, when different factors + are passed to \ref setRangeZoomFactor(double horizontalFactor, double verticalFactor). - \a lowerKey will be the the key (in pixels) of the returned point. Depending on whether the key - axis is horizontal or vertical, \a lowerKey will end up as the x or y value of the returned - point, respectively. + \see setRangeDragAxes +*/ +void QCPAxisRect::setRangeZoomAxes(QCPAxis *horizontal, QCPAxis *vertical) +{ + mRangeZoomHorzAxis = horizontal; + mRangeZoomVertAxis = vertical; +} + +/*! + Sets how strong one rotation step of the mouse wheel zooms, when range zoom was activated with + \ref setRangeZoom. The two parameters \a horizontalFactor and \a verticalFactor provide a way to + let the horizontal axis zoom at different rates than the vertical axis. Which axis is horizontal + and which is vertical, can be set with \ref setRangeZoomAxes. + + When the zoom factor is greater than one, scrolling the mouse wheel backwards (towards the user) + will zoom in (make the currently visible range smaller). For zoom factors smaller than one, the + same scrolling direction will zoom out. +*/ +void QCPAxisRect::setRangeZoomFactor(double horizontalFactor, double verticalFactor) +{ + mRangeZoomFactorHorz = horizontalFactor; + mRangeZoomFactorVert = verticalFactor; +} + +/*! \overload - \see upperFillBasePoint, addFillBasePoints + Sets both the horizontal and vertical zoom \a factor. */ -QPointF QCPGraph::lowerFillBasePoint(double lowerKey) const +void QCPAxisRect::setRangeZoomFactor(double factor) { - QCPAxis *keyAxis = mKeyAxis.data(); - QCPAxis *valueAxis = mValueAxis.data(); - if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return QPointF(); } + mRangeZoomFactorHorz = factor; + mRangeZoomFactorVert = factor; +} + +/*! \internal - QPointF point; - if (valueAxis->scaleType() == QCPAxis::stLinear) + Draws the background of this axis rect. It may consist of a background fill (a QBrush) and a + pixmap. + + If a brush was given via \ref setBackground(const QBrush &brush), this function first draws an + according filling inside the axis rect with the provided \a painter. + + Then, if a pixmap was provided via \ref setBackground, this function buffers the scaled version + depending on \ref setBackgroundScaled and \ref setBackgroundScaledMode and then draws it inside + the axis rect with the provided \a painter. The scaled version is buffered in + mScaledBackgroundPixmap to prevent expensive rescaling at every redraw. It is only updated, when + the axis rect has changed in a way that requires a rescale of the background pixmap (this is + dependant on the \ref setBackgroundScaledMode), or when a differend axis backgroud pixmap was + set. + + \see setBackground, setBackgroundScaled, setBackgroundScaledMode +*/ +void QCPAxisRect::drawBackground(QCPPainter *painter) +{ + // draw background fill: + if (mBackgroundBrush != Qt::NoBrush) + painter->fillRect(mRect, mBackgroundBrush); + + // draw background pixmap (on top of fill, if brush specified): + if (!mBackgroundPixmap.isNull()) { - if (keyAxis->axisType() == QCPAxis::atLeft) - { - point.setX(valueAxis->coordToPixel(0)); - point.setY(lowerKey); - } else if (keyAxis->axisType() == QCPAxis::atRight) - { - point.setX(valueAxis->coordToPixel(0)); - point.setY(lowerKey); - } else if (keyAxis->axisType() == QCPAxis::atTop) + if (mBackgroundScaled) { - point.setX(lowerKey); - point.setY(valueAxis->coordToPixel(0)); - } else if (keyAxis->axisType() == QCPAxis::atBottom) + // check whether mScaledBackground needs to be updated: + QSize scaledSize(mBackgroundPixmap.size()); + scaledSize.scale(mRect.size(), mBackgroundScaledMode); + if (mScaledBackgroundPixmap.size() != scaledSize) + mScaledBackgroundPixmap = mBackgroundPixmap.scaled(mRect.size(), mBackgroundScaledMode, Qt::SmoothTransformation); + painter->drawPixmap(mRect.topLeft(), mScaledBackgroundPixmap, QRect(0, 0, mRect.width(), mRect.height()) & mScaledBackgroundPixmap.rect()); + } else { - point.setX(lowerKey); - point.setY(valueAxis->coordToPixel(0)); + painter->drawPixmap(mRect.topLeft(), mBackgroundPixmap, QRect(0, 0, mRect.width(), mRect.height())); } - } else // valueAxis->mScaleType == QCPAxis::stLogarithmic + } +} + +/*! \internal + + This function makes sure multiple axes on the side specified with \a type don't collide, but are + distributed according to their respective space requirement (QCPAxis::calculateMargin). + + It does this by setting an appropriate offset (\ref QCPAxis::setOffset) on all axes except the + one with index zero. + + This function is called by \ref calculateAutoMargin. +*/ +void QCPAxisRect::updateAxesOffset(QCPAxis::AxisType type) +{ + const QList axesList = mAxes.value(type); + if (axesList.isEmpty()) + return; + + bool isFirstVisible = !axesList.first()->visible(); // if the first axis is visible, the second axis (which is where the loop starts) isn't the first visible axis, so initialize with false + for (int i=1; iorientation() == Qt::Vertical) - { - if ((valueAxis->range().upper < 0 && !valueAxis->rangeReversed()) || - (valueAxis->range().upper > 0 && valueAxis->rangeReversed())) // if range is negative, zero is on opposite side of key axis - point.setX(keyAxis->axisRect()->right()); - else - point.setX(keyAxis->axisRect()->left()); - point.setY(lowerKey); - } else if (keyAxis->axisType() == QCPAxis::atTop || keyAxis->axisType() == QCPAxis::atBottom) + int offset = axesList.at(i-1)->offset() + axesList.at(i-1)->calculateMargin(); + if (axesList.at(i)->visible()) // only add inner tick length to offset if this axis is visible and it's not the first visible one (might happen if true first axis is invisible) { - point.setX(lowerKey); - if ((valueAxis->range().upper < 0 && !valueAxis->rangeReversed()) || - (valueAxis->range().upper > 0 && valueAxis->rangeReversed())) // if range is negative, zero is on opposite side of key axis - point.setY(keyAxis->axisRect()->top()); - else - point.setY(keyAxis->axisRect()->bottom()); + if (!isFirstVisible) + offset += axesList.at(i)->tickLengthIn(); + isFirstVisible = false; } + axesList.at(i)->setOffset(offset); } - return point; +} + +/* inherits documentation from base class */ +int QCPAxisRect::calculateAutoMargin(QCP::MarginSide side) +{ + if (!mAutoMargins.testFlag(side)) + qDebug() << Q_FUNC_INFO << "Called with side that isn't specified as auto margin"; + + updateAxesOffset(QCPAxis::marginSideToAxisType(side)); + + // note: only need to look at the last (outer most) axis to determine the total margin, due to updateAxisOffset call + const QList axesList = mAxes.value(QCPAxis::marginSideToAxisType(side)); + if (axesList.size() > 0) + return axesList.last()->offset() + axesList.last()->calculateMargin(); + else + return 0; } /*! \internal - called by \ref addFillBasePoints to conveniently assign the point which closes the fill - polygon on the upper side of the zero-value-line parallel to the key axis. The logarithmic axis - scale case is a bit special, since the zero-value-line in pixel coordinates is in positive or - negative infinity. So this case is handled separately by just closing the fill polygon on the - axis which lies in the direction towards the zero value. + Event handler for when a mouse button is pressed on the axis rect. If the left mouse button is + pressed, the range dragging interaction is initialized (the actual range manipulation happens in + the \ref mouseMoveEvent). - \a upperKey will be the the key (in pixels) of the returned point. Depending on whether the key - axis is horizontal or vertical, \a upperKey will end up as the x or y value of the returned - point, respectively. + The mDragging flag is set to true and some anchor points are set that are needed to determine the + distance the mouse was dragged in the mouse move/release events later. - \see lowerFillBasePoint, addFillBasePoints + \see mouseMoveEvent, mouseReleaseEvent */ -QPointF QCPGraph::upperFillBasePoint(double upperKey) const +void QCPAxisRect::mousePressEvent(QMouseEvent *event) { - QCPAxis *keyAxis = mKeyAxis.data(); - QCPAxis *valueAxis = mValueAxis.data(); - if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return QPointF(); } - - QPointF point; - if (valueAxis->scaleType() == QCPAxis::stLinear) + mDragStart = event->pos(); // need this even when not LeftButton is pressed, to determine in releaseEvent whether it was a full click (no position change between press and release) + if (event->buttons() & Qt::LeftButton) { - if (keyAxis->axisType() == QCPAxis::atLeft) - { - point.setX(valueAxis->coordToPixel(0)); - point.setY(upperKey); - } else if (keyAxis->axisType() == QCPAxis::atRight) - { - point.setX(valueAxis->coordToPixel(0)); - point.setY(upperKey); - } else if (keyAxis->axisType() == QCPAxis::atTop) - { - point.setX(upperKey); - point.setY(valueAxis->coordToPixel(0)); - } else if (keyAxis->axisType() == QCPAxis::atBottom) + mDragging = true; + // initialize antialiasing backup in case we start dragging: + if (mParentPlot->noAntialiasingOnDrag()) { - point.setX(upperKey); - point.setY(valueAxis->coordToPixel(0)); + mAADragBackup = mParentPlot->antialiasedElements(); + mNotAADragBackup = mParentPlot->notAntialiasedElements(); } - } else // valueAxis->mScaleType == QCPAxis::stLogarithmic - { - // In logarithmic scaling we can't just draw to value 0 so we just fill all the way - // to the axis which is in the direction towards 0 - if (keyAxis->orientation() == Qt::Vertical) - { - if ((valueAxis->range().upper < 0 && !valueAxis->rangeReversed()) || - (valueAxis->range().upper > 0 && valueAxis->rangeReversed())) // if range is negative, zero is on opposite side of key axis - point.setX(keyAxis->axisRect()->right()); - else - point.setX(keyAxis->axisRect()->left()); - point.setY(upperKey); - } else if (keyAxis->axisType() == QCPAxis::atTop || keyAxis->axisType() == QCPAxis::atBottom) + // Mouse range dragging interaction: + if (mParentPlot->interactions().testFlag(QCP::iRangeDrag)) { - point.setX(upperKey); - if ((valueAxis->range().upper < 0 && !valueAxis->rangeReversed()) || - (valueAxis->range().upper > 0 && valueAxis->rangeReversed())) // if range is negative, zero is on opposite side of key axis - point.setY(keyAxis->axisRect()->top()); - else - point.setY(keyAxis->axisRect()->bottom()); + if (mRangeDragHorzAxis) + mDragStartHorzRange = mRangeDragHorzAxis.data()->range(); + if (mRangeDragVertAxis) + mDragStartVertRange = mRangeDragVertAxis.data()->range(); } } - return point; } /*! \internal - Generates the polygon needed for drawing channel fills between this graph (data passed via \a - lineData) and the graph specified by mChannelFillGraph (data generated by calling its \ref - getPlotData function). May return an empty polygon if the key ranges have no overlap or fill - target graph and this graph don't have same orientation (i.e. both key axes horizontal or both - key axes vertical). For increased performance (due to implicit sharing), keep the returned - QPolygonF const. + Event handler for when the mouse is moved on the axis rect. If range dragging was activated in a + preceding \ref mousePressEvent, the range is moved accordingly. + + \see mousePressEvent, mouseReleaseEvent */ -const QPolygonF QCPGraph::getChannelFillPolygon(const QVector *lineData) const +void QCPAxisRect::mouseMoveEvent(QMouseEvent *event) { - if (!mChannelFillGraph) - return QPolygonF(); - - QCPAxis *keyAxis = mKeyAxis.data(); - QCPAxis *valueAxis = mValueAxis.data(); - if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return QPolygonF(); } - if (!mChannelFillGraph.data()->mKeyAxis) { qDebug() << Q_FUNC_INFO << "channel fill target key axis invalid"; return QPolygonF(); } - - if (mChannelFillGraph.data()->mKeyAxis.data()->orientation() != keyAxis->orientation()) - return QPolygonF(); // don't have same axis orientation, can't fill that (Note: if keyAxis fits, valueAxis will fit too, because it's always orthogonal to keyAxis) - - if (lineData->isEmpty()) return QPolygonF(); - QVector otherData; - mChannelFillGraph.data()->getPlotData(&otherData, 0); - if (otherData.isEmpty()) return QPolygonF(); - QVector thisData; - thisData.reserve(lineData->size()+otherData.size()); // because we will join both vectors at end of this function - for (int i=0; isize(); ++i) // don't use the vector<<(vector), it squeezes internally, which ruins the performance tuning with reserve() - thisData << lineData->at(i); - - // pointers to be able to swap them, depending which data range needs cropping: - QVector *staticData = &thisData; - QVector *croppedData = &otherData; - - // crop both vectors to ranges in which the keys overlap (which coord is key, depends on axisType): - if (keyAxis->orientation() == Qt::Horizontal) + // Mouse range dragging interaction: + if (mDragging && mParentPlot->interactions().testFlag(QCP::iRangeDrag)) { - // x is key - // if an axis range is reversed, the data point keys will be descending. Reverse them, since following algorithm assumes ascending keys: - if (staticData->first().x() > staticData->last().x()) - { - int size = staticData->size(); - for (int i=0; ifirst().x() > croppedData->last().x()) + if (mRangeDrag.testFlag(Qt::Horizontal)) { - int size = croppedData->size(); - for (int i=0; imScaleType == QCPAxis::stLinear) + { + double diff = rangeDragHorzAxis->pixelToCoord(mDragStart.x()) - rangeDragHorzAxis->pixelToCoord(event->pos().x()); + rangeDragHorzAxis->setRange(mDragStartHorzRange.lower+diff, mDragStartHorzRange.upper+diff); + } else if (rangeDragHorzAxis->mScaleType == QCPAxis::stLogarithmic) + { + double diff = rangeDragHorzAxis->pixelToCoord(mDragStart.x()) / rangeDragHorzAxis->pixelToCoord(event->pos().x()); + rangeDragHorzAxis->setRange(mDragStartHorzRange.lower*diff, mDragStartHorzRange.upper*diff); + } + } } - // crop lower bound: - if (staticData->first().x() < croppedData->first().x()) // other one must be cropped - qSwap(staticData, croppedData); - int lowBound = findIndexBelowX(croppedData, staticData->first().x()); - if (lowBound == -1) return QPolygonF(); // key ranges have no overlap - croppedData->remove(0, lowBound); - // set lowest point of cropped data to fit exactly key position of first static data - // point via linear interpolation: - if (croppedData->size() < 2) return QPolygonF(); // need at least two points for interpolation - double slope; - if (croppedData->at(1).x()-croppedData->at(0).x() != 0) - slope = (croppedData->at(1).y()-croppedData->at(0).y())/(croppedData->at(1).x()-croppedData->at(0).x()); - else - slope = 0; - (*croppedData)[0].setY(croppedData->at(0).y()+slope*(staticData->first().x()-croppedData->at(0).x())); - (*croppedData)[0].setX(staticData->first().x()); - - // crop upper bound: - if (staticData->last().x() > croppedData->last().x()) // other one must be cropped - qSwap(staticData, croppedData); - int highBound = findIndexAboveX(croppedData, staticData->last().x()); - if (highBound == -1) return QPolygonF(); // key ranges have no overlap - croppedData->remove(highBound+1, croppedData->size()-(highBound+1)); - // set highest point of cropped data to fit exactly key position of last static data - // point via linear interpolation: - if (croppedData->size() < 2) return QPolygonF(); // need at least two points for interpolation - int li = croppedData->size()-1; // last index - if (croppedData->at(li).x()-croppedData->at(li-1).x() != 0) - slope = (croppedData->at(li).y()-croppedData->at(li-1).y())/(croppedData->at(li).x()-croppedData->at(li-1).x()); - else - slope = 0; - (*croppedData)[li].setY(croppedData->at(li-1).y()+slope*(staticData->last().x()-croppedData->at(li-1).x())); - (*croppedData)[li].setX(staticData->last().x()); - } else // mKeyAxis->orientation() == Qt::Vertical - { - // y is key - // similar to "x is key" but switched x,y. Further, lower/upper meaning is inverted compared to x, - // because in pixel coordinates, y increases from top to bottom, not bottom to top like data coordinate. - // if an axis range is reversed, the data point keys will be descending. Reverse them, since following algorithm assumes ascending keys: - if (staticData->first().y() < staticData->last().y()) + if (mRangeDrag.testFlag(Qt::Vertical)) { - int size = staticData->size(); - for (int i=0; imScaleType == QCPAxis::stLinear) + { + double diff = rangeDragVertAxis->pixelToCoord(mDragStart.y()) - rangeDragVertAxis->pixelToCoord(event->pos().y()); + rangeDragVertAxis->setRange(mDragStartVertRange.lower+diff, mDragStartVertRange.upper+diff); + } else if (rangeDragVertAxis->mScaleType == QCPAxis::stLogarithmic) + { + double diff = rangeDragVertAxis->pixelToCoord(mDragStart.y()) / rangeDragVertAxis->pixelToCoord(event->pos().y()); + rangeDragVertAxis->setRange(mDragStartVertRange.lower*diff, mDragStartVertRange.upper*diff); + } + } } - if (croppedData->first().y() < croppedData->last().y()) + if (mRangeDrag != 0) // if either vertical or horizontal drag was enabled, do a replot { - int size = croppedData->size(); - for (int i=0; inoAntialiasingOnDrag()) + mParentPlot->setNotAntialiasedElements(QCP::aeAll); + mParentPlot->replot(); } - // crop lower bound: - if (staticData->first().y() > croppedData->first().y()) // other one must be cropped - qSwap(staticData, croppedData); - int lowBound = findIndexAboveY(croppedData, staticData->first().y()); - if (lowBound == -1) return QPolygonF(); // key ranges have no overlap - croppedData->remove(0, lowBound); - // set lowest point of cropped data to fit exactly key position of first static data - // point via linear interpolation: - if (croppedData->size() < 2) return QPolygonF(); // need at least two points for interpolation - double slope; - if (croppedData->at(1).y()-croppedData->at(0).y() != 0) // avoid division by zero in step plots - slope = (croppedData->at(1).x()-croppedData->at(0).x())/(croppedData->at(1).y()-croppedData->at(0).y()); - else - slope = 0; - (*croppedData)[0].setX(croppedData->at(0).x()+slope*(staticData->first().y()-croppedData->at(0).y())); - (*croppedData)[0].setY(staticData->first().y()); - - // crop upper bound: - if (staticData->last().y() < croppedData->last().y()) // other one must be cropped - qSwap(staticData, croppedData); - int highBound = findIndexBelowY(croppedData, staticData->last().y()); - if (highBound == -1) return QPolygonF(); // key ranges have no overlap - croppedData->remove(highBound+1, croppedData->size()-(highBound+1)); - // set highest point of cropped data to fit exactly key position of last static data - // point via linear interpolation: - if (croppedData->size() < 2) return QPolygonF(); // need at least two points for interpolation - int li = croppedData->size()-1; // last index - if (croppedData->at(li).y()-croppedData->at(li-1).y() != 0) // avoid division by zero in step plots - slope = (croppedData->at(li).x()-croppedData->at(li-1).x())/(croppedData->at(li).y()-croppedData->at(li-1).y()); - else - slope = 0; - (*croppedData)[li].setX(croppedData->at(li-1).x()+slope*(staticData->last().y()-croppedData->at(li-1).y())); - (*croppedData)[li].setY(staticData->last().y()); } - - // return joined: - for (int i=otherData.size()-1; i>=0; --i) // insert reversed, otherwise the polygon will be twisted - thisData << otherData.at(i); - return QPolygonF(thisData); } -/*! \internal - - Finds the smallest index of \a data, whose points x value is just above \a x. Assumes x values in - \a data points are ordered ascending, as is the case when plotting with horizontal key axis. - - Used to calculate the channel fill polygon, see \ref getChannelFillPolygon. -*/ -int QCPGraph::findIndexAboveX(const QVector *data, double x) const +/* inherits documentation from base class */ +void QCPAxisRect::mouseReleaseEvent(QMouseEvent *event) { - for (int i=data->size()-1; i>=0; --i) + Q_UNUSED(event) + mDragging = false; + if (mParentPlot->noAntialiasingOnDrag()) { - if (data->at(i).x() < x) - { - if (isize()-1) - return i+1; - else - return data->size()-1; - } + mParentPlot->setAntialiasedElements(mAADragBackup); + mParentPlot->setNotAntialiasedElements(mNotAADragBackup); } - return -1; } /*! \internal - Finds the highest index of \a data, whose points x value is just below \a x. Assumes x values in - \a data points are ordered ascending, as is the case when plotting with horizontal key axis. + Event handler for mouse wheel events. If rangeZoom is Qt::Horizontal, Qt::Vertical or both, the + ranges of the axes defined as rangeZoomHorzAxis and rangeZoomVertAxis are scaled. The center of + the scaling operation is the current cursor position inside the axis rect. The scaling factor is + dependant on the mouse wheel delta (which direction the wheel was rotated) to provide a natural + zooming feel. The Strength of the zoom can be controlled via \ref setRangeZoomFactor. - Used to calculate the channel fill polygon, see \ref getChannelFillPolygon. + Note, that event->delta() is usually +/-120 for single rotation steps. However, if the mouse + wheel is turned rapidly, many steps may bunch up to one event, so the event->delta() may then be + multiples of 120. This is taken into account here, by calculating \a wheelSteps and using it as + exponent of the range zoom factor. This takes care of the wheel direction automatically, by + inverting the factor, when the wheel step is negative (f^-1 = 1/f). */ -int QCPGraph::findIndexBelowX(const QVector *data, double x) const +void QCPAxisRect::wheelEvent(QWheelEvent *event) { - for (int i=0; isize(); ++i) + // Mouse range zooming interaction: + if (mParentPlot->interactions().testFlag(QCP::iRangeZoom)) { - if (data->at(i).x() > x) + if (mRangeZoom != 0) { - if (i>0) - return i-1; - else - return 0; + double factor; + double wheelSteps = event->delta()/120.0; // a single step delta is +/-120 usually + if (mRangeZoom.testFlag(Qt::Horizontal)) + { + factor = pow(mRangeZoomFactorHorz, wheelSteps); + if (mRangeZoomHorzAxis.data()) + mRangeZoomHorzAxis.data()->scaleRange(factor, mRangeZoomHorzAxis.data()->pixelToCoord(event->pos().x())); + } + if (mRangeZoom.testFlag(Qt::Vertical)) + { + factor = pow(mRangeZoomFactorVert, wheelSteps); + if (mRangeZoomVertAxis.data()) + mRangeZoomVertAxis.data()->scaleRange(factor, mRangeZoomVertAxis.data()->pixelToCoord(event->pos().y())); + } + mParentPlot->replot(); } } - return -1; } -/*! \internal + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPAbstractLegendItem +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPAbstractLegendItem + \brief The abstract base class for all entries in a QCPLegend. - Finds the smallest index of \a data, whose points y value is just above \a y. Assumes y values in - \a data points are ordered descending, as is the case when plotting with vertical key axis. + It defines a very basic interface for entries in a QCPLegend. For representing plottables in the + legend, the subclass \ref QCPPlottableLegendItem is more suitable. - Used to calculate the channel fill polygon, see \ref getChannelFillPolygon. -*/ -int QCPGraph::findIndexAboveY(const QVector *data, double y) const -{ - for (int i=0; isize(); ++i) - { - if (data->at(i).y() < y) - { - if (i>0) - return i-1; - else - return 0; - } - } - return -1; -} + Only derive directly from this class when you need absolute freedom (e.g. a custom legend entry + that's not even associated with a plottable). -/*! \internal - - Calculates the (minimum) distance (in pixels) the graph's representation has from the given \a - pixelPoint in pixels. This is used to determine whether the graph was clicked or not, e.g. in - \ref selectTest. + You must implement the following pure virtual functions: + \li \ref draw (from QCPLayerable) - If either the graph has no data or if the line style is \ref lsNone and the scatter style's shape - is \ref QCPScatterStyle::ssNone (i.e. there is no visual representation of the graph), returns - 500. + You inherit the following members you may use: + + + + + + + + +
                                                                  QCPLegend *\b mParentLegendA pointer to the parent QCPLegend.
                                                                  QFont \b mFontThe generic font of the item. You should use this font for all or at least the most prominent text of the item.
                                                                  */ -double QCPGraph::pointDistance(const QPointF &pixelPoint) const -{ - if (mData->isEmpty()) - { - qDebug() << Q_FUNC_INFO << "requested point distance on graph" << mName << "without data"; - return 500; - } - if (mData->size() == 1) - { - QPointF dataPoint = coordsToPixels(mData->constBegin().key(), mData->constBegin().value().value); - return QVector2D(dataPoint-pixelPoint).length(); - } - - if (mLineStyle == lsNone && mScatterStyle.isNone()) - return 500; - - // calculate minimum distances to graph representation: - if (mLineStyle == lsNone) - { - // no line displayed, only calculate distance to scatter points: - QVector *pointData = new QVector; - getScatterPlotData(pointData); - double minDistSqr = std::numeric_limits::max(); - QPointF ptA; - QPointF ptB = coordsToPixels(pointData->at(0).key, pointData->at(0).value); // getScatterPlotData returns in plot coordinates, so transform to pixels - for (int i=1; isize(); ++i) - { - ptA = ptB; - ptB = coordsToPixels(pointData->at(i).key, pointData->at(i).value); - double currentDistSqr = distSqrToLine(ptA, ptB, pixelPoint); - if (currentDistSqr < minDistSqr) - minDistSqr = currentDistSqr; - } - delete pointData; - return sqrt(minDistSqr); - } else - { - // line displayed calculate distance to line segments: - QVector *lineData = new QVector; - getPlotData(lineData, 0); // unlike with getScatterPlotData we get pixel coordinates here - double minDistSqr = std::numeric_limits::max(); - if (mLineStyle == lsImpulse) - { - // impulse plot differs from other line styles in that the lineData points are only pairwise connected: - for (int i=0; isize()-1; i+=2) // iterate pairs - { - double currentDistSqr = distSqrToLine(lineData->at(i), lineData->at(i+1), pixelPoint); - if (currentDistSqr < minDistSqr) - minDistSqr = currentDistSqr; - } - } else - { - // all other line plots (line and step) connect points directly: - for (int i=0; isize()-1; ++i) - { - double currentDistSqr = distSqrToLine(lineData->at(i), lineData->at(i+1), pixelPoint); - if (currentDistSqr < minDistSqr) - minDistSqr = currentDistSqr; - } - } - delete lineData; - return sqrt(minDistSqr); - } -} -/*! \internal +/* start of documentation of signals */ + +/*! \fn void QCPAbstractLegendItem::selectionChanged(bool selected) - Finds the highest index of \a data, whose points y value is just below \a y. Assumes y values in - \a data points are ordered descending, as is the case when plotting with vertical key axis (since - keys are ordered ascending). + This signal is emitted when the selection state of this legend item has changed, either by user + interaction or by a direct call to \ref setSelected. +*/ - Used to calculate the channel fill polygon, see \ref getChannelFillPolygon. +/* end of documentation of signals */ + +/*! + Constructs a QCPAbstractLegendItem and associates it with the QCPLegend \a parent. This does not + cause the item to be added to \a parent, so \ref QCPLegend::addItem must be called separately. */ -int QCPGraph::findIndexBelowY(const QVector *data, double y) const +QCPAbstractLegendItem::QCPAbstractLegendItem(QCPLegend *parent) : + QCPLayoutElement(parent->parentPlot()), + mParentLegend(parent), + mFont(parent->font()), + mTextColor(parent->textColor()), + mSelectedFont(parent->selectedFont()), + mSelectedTextColor(parent->selectedTextColor()), + mSelectable(true), + mSelected(false) { - for (int i=data->size()-1; i>=0; --i) - { - if (data->at(i).y() > y) - { - if (isize()-1) - return i+1; - else - return data->size()-1; - } - } - return -1; + setLayer("legend"); + setMargins(QMargins(8, 2, 8, 2)); } -/* inherits documentation from base class */ -QCPRange QCPGraph::getKeyRange(bool &validRange, SignDomain inSignDomain) const +/*! + Sets the default font of this specific legend item to \a font. + + \see setTextColor, QCPLegend::setFont +*/ +void QCPAbstractLegendItem::setFont(const QFont &font) { - // just call the specialized version which takes an additional argument whether error bars - // should also be taken into consideration for range calculation. We set this to true here. - return getKeyRange(validRange, inSignDomain, true); + mFont = font; } -/* inherits documentation from base class */ -QCPRange QCPGraph::getValueRange(bool &validRange, SignDomain inSignDomain) const +/*! + Sets the default text color of this specific legend item to \a color. + + \see setFont, QCPLegend::setTextColor +*/ +void QCPAbstractLegendItem::setTextColor(const QColor &color) { - // just call the specialized version which takes an additional argument whether error bars - // should also be taken into consideration for range calculation. We set this to true here. - return getValueRange(validRange, inSignDomain, true); + mTextColor = color; } -/*! \overload - - Allows to specify whether the error bars should be included in the range calculation. +/*! + When this legend item is selected, \a font is used to draw generic text, instead of the normal + font set with \ref setFont. - \see getKeyRange(bool &validRange, SignDomain inSignDomain) + \see setFont, QCPLegend::setSelectedFont */ -QCPRange QCPGraph::getKeyRange(bool &validRange, SignDomain inSignDomain, bool includeErrors) const +void QCPAbstractLegendItem::setSelectedFont(const QFont &font) { - QCPRange range; - bool haveLower = false; - bool haveUpper = false; + mSelectedFont = font; +} + +/*! + When this legend item is selected, \a color is used to draw generic text, instead of the normal + color set with \ref setTextColor. - double current, currentErrorMinus, currentErrorPlus; + \see setTextColor, QCPLegend::setSelectedTextColor +*/ +void QCPAbstractLegendItem::setSelectedTextColor(const QColor &color) +{ + mSelectedTextColor = color; +} + +/*! + Sets whether this specific legend item is selectable. - if (inSignDomain == sdBoth) // range may be anywhere - { - QCPDataMap::const_iterator it = mData->constBegin(); - while (it != mData->constEnd()) - { - current = it.value().key; - currentErrorMinus = (includeErrors ? it.value().keyErrorMinus : 0); - currentErrorPlus = (includeErrors ? it.value().keyErrorPlus : 0); - if (current-currentErrorMinus < range.lower || !haveLower) - { - range.lower = current-currentErrorMinus; - haveLower = true; - } - if (current+currentErrorPlus > range.upper || !haveUpper) - { - range.upper = current+currentErrorPlus; - haveUpper = true; - } - ++it; - } - } else if (inSignDomain == sdNegative) // range may only be in the negative sign domain - { - QCPDataMap::const_iterator it = mData->constBegin(); - while (it != mData->constEnd()) - { - current = it.value().key; - currentErrorMinus = (includeErrors ? it.value().keyErrorMinus : 0); - currentErrorPlus = (includeErrors ? it.value().keyErrorPlus : 0); - if ((current-currentErrorMinus < range.lower || !haveLower) && current-currentErrorMinus < 0) - { - range.lower = current-currentErrorMinus; - haveLower = true; - } - if ((current+currentErrorPlus > range.upper || !haveUpper) && current+currentErrorPlus < 0) - { - range.upper = current+currentErrorPlus; - haveUpper = true; - } - if (includeErrors) // in case point is in valid sign domain but errobars stretch beyond it, we still want to geht that point. - { - if ((current < range.lower || !haveLower) && current < 0) - { - range.lower = current; - haveLower = true; - } - if ((current > range.upper || !haveUpper) && current < 0) - { - range.upper = current; - haveUpper = true; - } - } - ++it; - } - } else if (inSignDomain == sdPositive) // range may only be in the positive sign domain + \see setSelectedParts, QCustomPlot::setInteractions +*/ +void QCPAbstractLegendItem::setSelectable(bool selectable) +{ + if (mSelectable != selectable) { - QCPDataMap::const_iterator it = mData->constBegin(); - while (it != mData->constEnd()) - { - current = it.value().key; - currentErrorMinus = (includeErrors ? it.value().keyErrorMinus : 0); - currentErrorPlus = (includeErrors ? it.value().keyErrorPlus : 0); - if ((current-currentErrorMinus < range.lower || !haveLower) && current-currentErrorMinus > 0) - { - range.lower = current-currentErrorMinus; - haveLower = true; - } - if ((current+currentErrorPlus > range.upper || !haveUpper) && current+currentErrorPlus > 0) - { - range.upper = current+currentErrorPlus; - haveUpper = true; - } - if (includeErrors) // in case point is in valid sign domain but errobars stretch beyond it, we still want to get that point. - { - if ((current < range.lower || !haveLower) && current > 0) - { - range.lower = current; - haveLower = true; - } - if ((current > range.upper || !haveUpper) && current > 0) - { - range.upper = current; - haveUpper = true; - } - } - ++it; - } + mSelectable = selectable; + emit selectableChanged(mSelectable); } - - validRange = haveLower && haveUpper; - return range; } -/*! \overload +/*! + Sets whether this specific legend item is selected. - Allows to specify whether the error bars should be included in the range calculation. + It is possible to set the selection state of this item by calling this function directly, even if + setSelectable is set to false. - \see getValueRange(bool &validRange, SignDomain inSignDomain) + \see setSelectableParts, QCustomPlot::setInteractions */ -QCPRange QCPGraph::getValueRange(bool &validRange, SignDomain inSignDomain, bool includeErrors) const +void QCPAbstractLegendItem::setSelected(bool selected) { - QCPRange range; - bool haveLower = false; - bool haveUpper = false; - - double current, currentErrorMinus, currentErrorPlus; - - if (inSignDomain == sdBoth) // range may be anywhere + if (mSelected != selected) { - QCPDataMap::const_iterator it = mData->constBegin(); - while (it != mData->constEnd()) - { - current = it.value().value; - currentErrorMinus = (includeErrors ? it.value().valueErrorMinus : 0); - currentErrorPlus = (includeErrors ? it.value().valueErrorPlus : 0); - if (current-currentErrorMinus < range.lower || !haveLower) - { - range.lower = current-currentErrorMinus; - haveLower = true; - } - if (current+currentErrorPlus > range.upper || !haveUpper) - { - range.upper = current+currentErrorPlus; - haveUpper = true; - } - ++it; - } - } else if (inSignDomain == sdNegative) // range may only be in the negative sign domain - { - QCPDataMap::const_iterator it = mData->constBegin(); - while (it != mData->constEnd()) - { - current = it.value().value; - currentErrorMinus = (includeErrors ? it.value().valueErrorMinus : 0); - currentErrorPlus = (includeErrors ? it.value().valueErrorPlus : 0); - if ((current-currentErrorMinus < range.lower || !haveLower) && current-currentErrorMinus < 0) - { - range.lower = current-currentErrorMinus; - haveLower = true; - } - if ((current+currentErrorPlus > range.upper || !haveUpper) && current+currentErrorPlus < 0) - { - range.upper = current+currentErrorPlus; - haveUpper = true; - } - if (includeErrors) // in case point is in valid sign domain but errobars stretch beyond it, we still want to get that point. - { - if ((current < range.lower || !haveLower) && current < 0) - { - range.lower = current; - haveLower = true; - } - if ((current > range.upper || !haveUpper) && current < 0) - { - range.upper = current; - haveUpper = true; - } - } - ++it; - } - } else if (inSignDomain == sdPositive) // range may only be in the positive sign domain - { - QCPDataMap::const_iterator it = mData->constBegin(); - while (it != mData->constEnd()) - { - current = it.value().value; - currentErrorMinus = (includeErrors ? it.value().valueErrorMinus : 0); - currentErrorPlus = (includeErrors ? it.value().valueErrorPlus : 0); - if ((current-currentErrorMinus < range.lower || !haveLower) && current-currentErrorMinus > 0) - { - range.lower = current-currentErrorMinus; - haveLower = true; - } - if ((current+currentErrorPlus > range.upper || !haveUpper) && current+currentErrorPlus > 0) - { - range.upper = current+currentErrorPlus; - haveUpper = true; - } - if (includeErrors) // in case point is in valid sign domain but errobars stretch beyond it, we still want to geht that point. - { - if ((current < range.lower || !haveLower) && current > 0) - { - range.lower = current; - haveLower = true; - } - if ((current > range.upper || !haveUpper) && current > 0) - { - range.upper = current; - haveUpper = true; - } - } - ++it; - } + mSelected = selected; + emit selectionChanged(mSelected); } - - validRange = haveLower && haveUpper; - return range; } - -//////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////// QCPCurveData -//////////////////////////////////////////////////////////////////////////////////////////////////// - -/*! \class QCPCurveData - \brief Holds the data of one single data point for QCPCurve. - - The container for storing multiple data points is \ref QCPCurveDataMap. - - The stored data is: - \li \a t: the free parameter of the curve at this curve point (cp. the mathematical vector (x(t), y(t))) - \li \a key: coordinate on the key axis of this curve point - \li \a value: coordinate on the value axis of this curve point +/* inherits documentation from base class */ +double QCPAbstractLegendItem::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + Q_UNUSED(details) + if (!mParentPlot) return -1; + if (onlySelectable && (!mSelectable || !mParentLegend->selectableParts().testFlag(QCPLegend::spItems))) + return -1; - \see QCPCurveDataMap -*/ + if (mRect.contains(pos.toPoint())) + return mParentPlot->selectionTolerance()*0.99; + else + return -1; +} -/*! - Constructs a curve data point with t, key and value set to zero. -*/ -QCPCurveData::QCPCurveData() : - t(0), - key(0), - value(0) +/* inherits documentation from base class */ +void QCPAbstractLegendItem::applyDefaultAntialiasingHint(QCPPainter *painter) const { + applyAntialiasingHint(painter, mAntialiased, QCP::aeLegendItems); } -/*! - Constructs a curve data point with the specified \a t, \a key and \a value. -*/ -QCPCurveData::QCPCurveData(double t, double key, double value) : - t(t), - key(key), - value(value) +/* inherits documentation from base class */ +QRect QCPAbstractLegendItem::clipRect() const +{ + return mOuterRect; +} + +/* inherits documentation from base class */ +void QCPAbstractLegendItem::selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) { + Q_UNUSED(event) + Q_UNUSED(details) + if (mSelectable && mParentLegend->selectableParts().testFlag(QCPLegend::spItems)) + { + bool selBefore = mSelected; + setSelected(additive ? !mSelected : true); + if (selectionStateChanged) + *selectionStateChanged = mSelected != selBefore; + } } +/* inherits documentation from base class */ +void QCPAbstractLegendItem::deselectEvent(bool *selectionStateChanged) +{ + if (mSelectable && mParentLegend->selectableParts().testFlag(QCPLegend::spItems)) + { + bool selBefore = mSelected; + setSelected(false); + if (selectionStateChanged) + *selectionStateChanged = mSelected != selBefore; + } +} //////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////// QCPCurve +//////////////////// QCPPlottableLegendItem //////////////////////////////////////////////////////////////////////////////////////////////////// -/*! \class QCPCurve - \brief A plottable representing a parametric curve in a plot. +/*! \class QCPPlottableLegendItem + \brief A legend item representing a plottable with an icon and the plottable name. - \image html QCPCurve.png + This is the standard legend item for plottables. It displays an icon of the plottable next to the + plottable name. The icon is drawn by the respective plottable itself (\ref + QCPAbstractPlottable::drawLegendIcon), and tries to give an intuitive symbol for the plottable. + For example, the QCPGraph draws a centered horizontal line and/or a single scatter point in the + middle. - Unlike QCPGraph, plottables of this type may have multiple points with the same key coordinate, - so their visual representation can have \a loops. This is realized by introducing a third - coordinate \a t, which defines the order of the points described by the other two coordinates \a - x and \a y. + Legend items of this type are always associated with one plottable (retrievable via the + plottable() function and settable with the constructor). You may change the font of the plottable + name with \ref setFont. Icon padding and border pen is taken from the parent QCPLegend, see \ref + QCPLegend::setIconBorderPen and \ref QCPLegend::setIconTextPadding. - To plot data, assign it with the \ref setData or \ref addData functions. - - \section appearance Changing the appearance - - The appearance of the curve is determined by the pen and the brush (\ref setPen, \ref setBrush). - \section usage Usage - - Like all data representing objects in QCustomPlot, the QCPCurve is a plottable (QCPAbstractPlottable). So - the plottable-interface of QCustomPlot applies (QCustomPlot::plottable, QCustomPlot::addPlottable, QCustomPlot::removePlottable, etc.) + The function \ref QCPAbstractPlottable::addToLegend/\ref QCPAbstractPlottable::removeFromLegend + creates/removes legend items of this type in the default implementation. However, these functions + may be reimplemented such that a different kind of legend item (e.g a direct subclass of + QCPAbstractLegendItem) is used for that plottable. - Usually, you first create an instance: - \code - QCPCurve *newCurve = new QCPCurve(customPlot->xAxis, customPlot->yAxis);\endcode - add it to the customPlot with QCustomPlot::addPlottable: - \code - customPlot->addPlottable(newCurve);\endcode - and then modify the properties of the newly created plottable, e.g.: - \code - newCurve->setName("Fermat's Spiral"); - newCurve->setData(tData, xData, yData);\endcode + Since QCPLegend is based on QCPLayoutGrid, a legend item itself is just a subclass of + QCPLayoutElement. While it could be added to a legend (or any other layout) via the normal layout + interface, QCPLegend has specialized functions for handling legend items conveniently, see the + documentation of \ref QCPLegend. */ /*! - Constructs a curve which uses \a keyAxis as its key axis ("x") and \a valueAxis as its value - axis ("y"). \a keyAxis and \a valueAxis must reside in the same QCustomPlot instance and not have - the same orientation. If either of these restrictions is violated, a corresponding message is - printed to the debug output (qDebug), the construction is not aborted, though. + Creates a new legend item associated with \a plottable. - The constructed QCPCurve can be added to the plot with QCustomPlot::addPlottable, QCustomPlot - then takes ownership of the graph. + Once it's created, it can be added to the legend via \ref QCPLegend::addItem. + + A more convenient way of adding/removing a plottable to/from the legend is via the functions \ref + QCPAbstractPlottable::addToLegend and \ref QCPAbstractPlottable::removeFromLegend. */ -QCPCurve::QCPCurve(QCPAxis *keyAxis, QCPAxis *valueAxis) : - QCPAbstractPlottable(keyAxis, valueAxis) +QCPPlottableLegendItem::QCPPlottableLegendItem(QCPLegend *parent, QCPAbstractPlottable *plottable) : + QCPAbstractLegendItem(parent), + mPlottable(plottable) { - mData = new QCPCurveDataMap; - mPen.setColor(Qt::blue); - mPen.setStyle(Qt::SolidLine); - mBrush.setColor(Qt::blue); - mBrush.setStyle(Qt::NoBrush); - mSelectedPen = mPen; - mSelectedPen.setWidthF(2.5); - mSelectedPen.setColor(QColor(80, 80, 255)); // lighter than Qt::blue of mPen - mSelectedBrush = mBrush; - - setScatterStyle(QCPScatterStyle()); - setLineStyle(lsLine); } -QCPCurve::~QCPCurve() +/*! \internal + + Returns the pen that shall be used to draw the icon border, taking into account the selection + state of this item. +*/ +QPen QCPPlottableLegendItem::getIconBorderPen() const { - delete mData; + return mSelected ? mParentLegend->selectedIconBorderPen() : mParentLegend->iconBorderPen(); } -/*! - Replaces the current data with the provided \a data. +/*! \internal - If \a copy is set to true, data points in \a data will only be copied. if false, the plottable - takes ownership of the passed data and replaces the internal data pointer with it. This is - significantly faster than copying for large datasets. + Returns the text color that shall be used to draw text, taking into account the selection state + of this item. */ -void QCPCurve::setData(QCPCurveDataMap *data, bool copy) +QColor QCPPlottableLegendItem::getTextColor() const { - if (copy) - { - *mData = *data; - } else - { - delete mData; - mData = data; - } + return mSelected ? mSelectedTextColor : mTextColor; } -/*! \overload +/*! \internal - Replaces the current data with the provided points in \a t, \a key and \a value tuples. The - provided vectors should have equal length. Else, the number of added points will be the size of - the smallest vector. + Returns the font that shall be used to draw text, taking into account the selection state of this + item. */ -void QCPCurve::setData(const QVector &t, const QVector &key, const QVector &value) +QFont QCPPlottableLegendItem::getFont() const { - mData->clear(); - int n = t.size(); - n = qMin(n, key.size()); - n = qMin(n, value.size()); - QCPCurveData newData; - for (int i=0; iinsertMulti(newData.t, newData); - } + return mSelected ? mSelectedFont : mFont; } -/*! \overload +/*! \internal - Replaces the current data with the provided \a key and \a value pairs. The t parameter - of each data point will be set to the integer index of the respective key/value pair. + Draws the item with \a painter. The size and position of the drawn legend item is defined by the + parent layout (typically a \ref QCPLegend) and the \ref minimumSizeHint and \ref maximumSizeHint + of this legend item. */ -void QCPCurve::setData(const QVector &key, const QVector &value) +void QCPPlottableLegendItem::draw(QCPPainter *painter) { - mData->clear(); - int n = key.size(); - n = qMin(n, value.size()); - QCPCurveData newData; - for (int i=0; isetFont(getFont()); + painter->setPen(QPen(getTextColor())); + QSizeF iconSize = mParentLegend->iconSize(); + QRectF textRect = painter->fontMetrics().boundingRect(0, 0, 0, iconSize.height(), Qt::TextDontClip, mPlottable->name()); + QRectF iconRect(mRect.topLeft(), iconSize); + int textHeight = qMax(textRect.height(), iconSize.height()); // if text has smaller height than icon, center text vertically in icon height, else align tops + painter->drawText(mRect.x()+iconSize.width()+mParentLegend->iconTextPadding(), mRect.y(), textRect.width(), textHeight, Qt::TextDontClip, mPlottable->name()); + // draw icon: + painter->save(); + painter->setClipRect(iconRect, Qt::IntersectClip); + mPlottable->drawLegendIcon(painter, iconRect); + painter->restore(); + // draw icon border: + if (getIconBorderPen().style() != Qt::NoPen) { - newData.t = i; // no t vector given, so we assign t the index of the key/value pair - newData.key = key[i]; - newData.value = value[i]; - mData->insertMulti(newData.t, newData); + painter->setPen(getIconBorderPen()); + painter->setBrush(Qt::NoBrush); + painter->drawRect(iconRect); } } -/*! - Sets the visual appearance of single data points in the plot. If set to \ref - QCPScatterStyle::ssNone, no scatter points are drawn (e.g. for line-only plots with appropriate - line style). +/*! \internal - \see QCPScatterStyle, setLineStyle + Calculates and returns the size of this item. This includes the icon, the text and the padding in + between. */ -void QCPCurve::setScatterStyle(const QCPScatterStyle &style) +QSize QCPPlottableLegendItem::minimumSizeHint() const { - mScatterStyle = style; + if (!mPlottable) return QSize(); + QSize result(0, 0); + QRect textRect; + QFontMetrics fontMetrics(getFont()); + QSize iconSize = mParentLegend->iconSize(); + textRect = fontMetrics.boundingRect(0, 0, 0, iconSize.height(), Qt::TextDontClip, mPlottable->name()); + result.setWidth(iconSize.width() + mParentLegend->iconTextPadding() + textRect.width() + mMargins.left() + mMargins.right()); + result.setHeight(qMax(textRect.height(), iconSize.height()) + mMargins.top() + mMargins.bottom()); + return result; } -/*! - Sets how the single data points are connected in the plot or how they are represented visually - apart from the scatter symbol. For scatter-only plots, set \a style to \ref lsNone and \ref - setScatterStyle to the desired scatter style. + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPLegend +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPLegend + \brief Manages a legend inside a QCustomPlot. + + A legend is a small box somewhere in the plot which lists plottables with their name and icon. - \see setScatterStyle -*/ -void QCPCurve::setLineStyle(QCPCurve::LineStyle style) -{ - mLineStyle = style; -} + Normally, the legend is populated by calling \ref QCPAbstractPlottable::addToLegend. The + respective legend item can be removed with \ref QCPAbstractPlottable::removeFromLegend. However, + QCPLegend also offers an interface to add and manipulate legend items directly: \ref item, \ref + itemWithPlottable, \ref itemCount, \ref addItem, \ref removeItem, etc. + + The QCPLegend derives from QCPLayoutGrid and as such can be placed in any position a + QCPLayoutElement may be positioned. The legend items are themselves QCPLayoutElements which are + placed in the grid layout of the legend. QCPLegend only adds an interface specialized for + handling child elements of type QCPAbstractLegendItem, as mentioned above. In principle, any + other layout elements may also be added to a legend via the normal \ref QCPLayoutGrid interface. + However, the QCPAbstractLegendItem-Interface will ignore those elements (e.g. \ref itemCount will + only return the number of items with QCPAbstractLegendItems type). -/*! - Adds the provided data points in \a dataMap to the current data. - \see removeData + By default, every QCustomPlot has one legend (QCustomPlot::legend) which is placed in the inset + layout of the main axis rect (\ref QCPAxisRect::insetLayout). To move the legend to another + position inside the axis rect, use the methods of the \ref QCPLayoutInset. To move the legend + outside of the axis rect, place it anywhere else with the QCPLayout/QCPLayoutElement interface. */ -void QCPCurve::addData(const QCPCurveDataMap &dataMap) -{ - mData->unite(dataMap); -} -/*! \overload - Adds the provided single data point in \a data to the current data. - \see removeData +/* start of documentation of signals */ + +/*! \fn void QCPLegend::selectionChanged(QCPLegend::SelectableParts selection); + + This signal is emitted when the selection state of this legend has changed. + + \see setSelectedParts, setSelectableParts */ -void QCPCurve::addData(const QCPCurveData &data) -{ - mData->insertMulti(data.t, data); -} -/*! \overload - Adds the provided single data point as \a t, \a key and \a value tuple to the current data - \see removeData +/* end of documentation of signals */ + +/*! + Constructs a new QCPLegend instance with \a parentPlot as the containing plot and default values. + + Note that by default, QCustomPlot already contains a legend ready to be used as + QCustomPlot::legend */ -void QCPCurve::addData(double t, double key, double value) +QCPLegend::QCPLegend() { - QCPCurveData newData; - newData.t = t; - newData.key = key; - newData.value = value; - mData->insertMulti(newData.t, newData); -} - -/*! \overload + setRowSpacing(0); + setColumnSpacing(10); + setMargins(QMargins(2, 3, 2, 2)); + setAntialiased(false); + setIconSize(32, 18); - Adds the provided single data point as \a key and \a value pair to the current data The t - parameter of the data point is set to the t of the last data point plus 1. If there is no last - data point, t will be set to 0. + setIconTextPadding(7); - \see removeData -*/ -void QCPCurve::addData(double key, double value) + setSelectableParts(spLegendBox | spItems); + setSelectedParts(spNone); + + setBorderPen(QPen(Qt::black)); + setSelectedBorderPen(QPen(Qt::blue, 2)); + setIconBorderPen(Qt::NoPen); + setSelectedIconBorderPen(QPen(Qt::blue, 2)); + setBrush(Qt::white); + setSelectedBrush(Qt::white); + setTextColor(Qt::black); + setSelectedTextColor(Qt::blue); +} + +QCPLegend::~QCPLegend() { - QCPCurveData newData; - if (!mData->isEmpty()) - newData.t = (mData->constEnd()-1).key()+1; - else - newData.t = 0; - newData.key = key; - newData.value = value; - mData->insertMulti(newData.t, newData); + clearItems(); + if (mParentPlot) + mParentPlot->legendRemoved(this); } -/*! \overload - Adds the provided data points as \a t, \a key and \a value tuples to the current data. - \see removeData -*/ -void QCPCurve::addData(const QVector &ts, const QVector &keys, const QVector &values) +/* no doc for getter, see setSelectedParts */ +QCPLegend::SelectableParts QCPLegend::selectedParts() const { - int n = ts.size(); - n = qMin(n, keys.size()); - n = qMin(n, values.size()); - QCPCurveData newData; - for (int i=0; iinsertMulti(newData.t, newData); + if (item(i) && item(i)->selected()) + { + hasSelectedItems = true; + break; + } } + if (hasSelectedItems) + return mSelectedParts | spItems; + else + return mSelectedParts & ~spItems; } /*! - Removes all data points with curve parameter t smaller than \a t. - \see addData, clearData + Sets the pen, the border of the entire legend is drawn with. */ -void QCPCurve::removeDataBefore(double t) +void QCPLegend::setBorderPen(const QPen &pen) { - QCPCurveDataMap::iterator it = mData->begin(); - while (it != mData->end() && it.key() < t) - it = mData->erase(it); + mBorderPen = pen; } /*! - Removes all data points with curve parameter t greater than \a t. - \see addData, clearData + Sets the brush of the legend background. */ -void QCPCurve::removeDataAfter(double t) +void QCPLegend::setBrush(const QBrush &brush) { - if (mData->isEmpty()) return; - QCPCurveDataMap::iterator it = mData->upperBound(t); - while (it != mData->end()) - it = mData->erase(it); + mBrush = brush; } /*! - Removes all data points with curve parameter t between \a fromt and \a tot. if \a fromt is - greater or equal to \a tot, the function does nothing. To remove a single data point with known - t, use \ref removeData(double t). + Sets the default font of legend text. Legend items that draw text (e.g. the name of a graph) will + use this font by default. However, a different font can be specified on a per-item-basis by + accessing the specific legend item. - \see addData, clearData + This function will also set \a font on all already existing legend items. + + \see QCPAbstractLegendItem::setFont */ -void QCPCurve::removeData(double fromt, double tot) +void QCPLegend::setFont(const QFont &font) { - if (fromt >= tot || mData->isEmpty()) return; - QCPCurveDataMap::iterator it = mData->upperBound(fromt); - QCPCurveDataMap::iterator itEnd = mData->upperBound(tot); - while (it != itEnd) - it = mData->erase(it); -} - -/*! \overload - - Removes a single data point at curve parameter \a t. If the position is not known with absolute - precision, consider using \ref removeData(double fromt, double tot) with a small fuzziness - interval around the suspected position, depeding on the precision with which the curve parameter - is known. + mFont = font; + for (int i=0; isetFont(mFont); + } +} + +/*! + Sets the default color of legend text. Legend items that draw text (e.g. the name of a graph) + will use this color by default. However, a different colors can be specified on a per-item-basis + by accessing the specific legend item. - \see addData, clearData + This function will also set \a color on all already existing legend items. + + \see QCPAbstractLegendItem::setTextColor */ -void QCPCurve::removeData(double t) +void QCPLegend::setTextColor(const QColor &color) { - mData->remove(t); + mTextColor = color; + for (int i=0; isetTextColor(color); + } } /*! - Removes all data points. - \see removeData, removeDataAfter, removeDataBefore + Sets the size of legend icons. Legend items that draw an icon (e.g. a visual + representation of the graph) will use this size by default. */ -void QCPCurve::clearData() +void QCPLegend::setIconSize(const QSize &size) { - mData->clear(); + mIconSize = size; } -/* inherits documentation from base class */ -double QCPCurve::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +/*! \overload +*/ +void QCPLegend::setIconSize(int width, int height) { - Q_UNUSED(details) - if ((onlySelectable && !mSelectable) || mData->isEmpty()) - return -1; - - return pointDistance(pos); + mIconSize.setWidth(width); + mIconSize.setHeight(height); } -/* inherits documentation from base class */ -void QCPCurve::draw(QCPPainter *painter) +/*! + Sets the horizontal space in pixels between the legend icon and the text next to it. + Legend items that draw an icon (e.g. a visual representation of the graph) and text (e.g. the + name of the graph) will use this space by default. +*/ +void QCPLegend::setIconTextPadding(int padding) { - if (mData->isEmpty()) return; + mIconTextPadding = padding; +} + +/*! + Sets the pen used to draw a border around each legend icon. Legend items that draw an + icon (e.g. a visual representation of the graph) will use this pen by default. - // allocate line vector: - QVector *lineData = new QVector; + If no border is wanted, set this to \a Qt::NoPen. +*/ +void QCPLegend::setIconBorderPen(const QPen &pen) +{ + mIconBorderPen = pen; +} + +/*! + Sets whether the user can (de-)select the parts in \a selectable by clicking on the QCustomPlot surface. + (When \ref QCustomPlot::setInteractions contains \ref QCP::iSelectLegend.) - // fill with curve data: - getCurveData(lineData); + However, even when \a selectable is set to a value not allowing the selection of a specific part, + it is still possible to set the selection of this part manually, by calling \ref setSelectedParts + directly. - // check data validity if flag set: -#ifdef QCUSTOMPLOT_CHECK_DATA - QCPCurveDataMap::const_iterator it; - for (it = mData->constBegin(); it != mData->constEnd(); ++it) + \see SelectablePart, setSelectedParts +*/ +void QCPLegend::setSelectableParts(const SelectableParts &selectable) +{ + if (mSelectableParts != selectable) { - if (QCP::isInvalidData(it.value().t) || - QCP::isInvalidData(it.value().key, it.value().value)) - qDebug() << Q_FUNC_INFO << "Data point at" << it.key() << "invalid." << "Plottable name:" << name(); + mSelectableParts = selectable; + emit selectableChanged(mSelectableParts); } -#endif +} + +/*! + Sets the selected state of the respective legend parts described by \ref SelectablePart. When a part + is selected, it uses a different pen/font and brush. If some legend items are selected and \a selected + doesn't contain \ref spItems, those items become deselected. - // draw curve fill: - if (mainBrush().style() != Qt::NoBrush && mainBrush().color().alpha() != 0) - { - applyFillAntialiasingHint(painter); - painter->setPen(Qt::NoPen); - painter->setBrush(mainBrush()); - painter->drawPolygon(QPolygonF(*lineData)); - } + The entire selection mechanism is handled automatically when \ref QCustomPlot::setInteractions + contains iSelectLegend. You only need to call this function when you wish to change the selection + state manually. - // draw curve line: - if (mLineStyle != lsNone && mainPen().style() != Qt::NoPen && mainPen().color().alpha() != 0) - { - applyDefaultAntialiasingHint(painter); - painter->setPen(mainPen()); - painter->setBrush(Qt::NoBrush); - // if drawing solid line and not in PDF, use much faster line drawing instead of polyline: - if (mParentPlot->plottingHints().testFlag(QCP::phFastPolylines) && - painter->pen().style() == Qt::SolidLine && - !painter->modes().testFlag(QCPPainter::pmVectorized) && - !painter->modes().testFlag(QCPPainter::pmNoCaching)) - { - for (int i=1; isize(); ++i) - painter->drawLine(lineData->at(i-1), lineData->at(i)); - } else - { - painter->drawPolyline(QPolygonF(*lineData)); - } - } + This function can change the selection state of a part even when \ref setSelectableParts was set to a + value that actually excludes the part. - // draw scatters: - if (!mScatterStyle.isNone()) - drawScatterPlot(painter, lineData); + emits the \ref selectionChanged signal when \a selected is different from the previous selection state. - // free allocated line data: - delete lineData; -} - -/* inherits documentation from base class */ -void QCPCurve::drawLegendIcon(QCPPainter *painter, const QRectF &rect) const + Note that it doesn't make sense to set the selected state \ref spItems here when it wasn't set + before, because there's no way to specify which exact items to newly select. Do this by calling + \ref QCPAbstractLegendItem::setSelected directly on the legend item you wish to select. + + \see SelectablePart, setSelectableParts, selectTest, setSelectedBorderPen, setSelectedIconBorderPen, setSelectedBrush, + setSelectedFont +*/ +void QCPLegend::setSelectedParts(const SelectableParts &selected) { - // draw fill: - if (mBrush.style() != Qt::NoBrush) - { - applyFillAntialiasingHint(painter); - painter->fillRect(QRectF(rect.left(), rect.top()+rect.height()/2.0, rect.width(), rect.height()/3.0), mBrush); - } - // draw line vertically centered: - if (mLineStyle != lsNone) - { - applyDefaultAntialiasingHint(painter); - painter->setPen(mPen); - painter->drawLine(QLineF(rect.left(), rect.top()+rect.height()/2.0, rect.right()+5, rect.top()+rect.height()/2.0)); // +5 on x2 else last segment is missing from dashed/dotted pens - } - // draw scatter symbol: - if (!mScatterStyle.isNone()) + SelectableParts newSelected = selected; + mSelectedParts = this->selectedParts(); // update mSelectedParts in case item selection changed + + if (mSelectedParts != newSelected) { - applyScattersAntialiasingHint(painter); - // scale scatter pixmap if it's too large to fit in legend icon rect: - if (mScatterStyle.shape() == QCPScatterStyle::ssPixmap && (mScatterStyle.pixmap().size().width() > rect.width() || mScatterStyle.pixmap().size().height() > rect.height())) + if (!mSelectedParts.testFlag(spItems) && newSelected.testFlag(spItems)) // attempt to set spItems flag (can't do that) { - QCPScatterStyle scaledStyle(mScatterStyle); - scaledStyle.setPixmap(scaledStyle.pixmap().scaled(rect.size().toSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation)); - scaledStyle.applyTo(painter, mPen); - scaledStyle.drawShape(painter, QRectF(rect).center()); - } else + qDebug() << Q_FUNC_INFO << "spItems flag can not be set, it can only be unset with this function"; + newSelected &= ~spItems; + } + if (mSelectedParts.testFlag(spItems) && !newSelected.testFlag(spItems)) // spItems flag was unset, so clear item selection { - mScatterStyle.applyTo(painter, mPen); - mScatterStyle.drawShape(painter, QRectF(rect).center()); + for (int i=0; isetSelected(false); + } } + mSelectedParts = newSelected; + emit selectionChanged(mSelectedParts); } } -/*! \internal - - Draws scatter symbols at every data point passed in \a pointData. scatter symbols are independent of - the line style and are always drawn if scatter shape is not \ref QCPScatterStyle::ssNone. +/*! + When the legend box is selected, this pen is used to draw the border instead of the normal pen + set via \ref setBorderPen. + + \see setSelectedParts, setSelectableParts, setSelectedBrush */ -void QCPCurve::drawScatterPlot(QCPPainter *painter, const QVector *pointData) const +void QCPLegend::setSelectedBorderPen(const QPen &pen) { - // draw scatter point symbols: - applyScattersAntialiasingHint(painter); - mScatterStyle.applyTo(painter, mPen); - for (int i=0; isize(); ++i) - mScatterStyle.drawShape(painter, pointData->at(i)); + mSelectedBorderPen = pen; } -/*! \internal +/*! + Sets the pen legend items will use to draw their icon borders, when they are selected. + + \see setSelectedParts, setSelectableParts, setSelectedFont +*/ +void QCPLegend::setSelectedIconBorderPen(const QPen &pen) +{ + mSelectedIconBorderPen = pen; +} + +/*! + When the legend box is selected, this brush is used to draw the legend background instead of the normal brush + set via \ref setBrush. + + \see setSelectedParts, setSelectableParts, setSelectedBorderPen +*/ +void QCPLegend::setSelectedBrush(const QBrush &brush) +{ + mSelectedBrush = brush; +} + +/*! + Sets the default font that is used by legend items when they are selected. - called by QCPCurve::draw to generate a point vector (pixels) which represents the line of the - curve. Line segments that aren't visible in the current axis rect are handled in an optimized - way. + This function will also set \a font on all already existing legend items. + + \see setFont, QCPAbstractLegendItem::setSelectedFont */ -void QCPCurve::getCurveData(QVector *lineData) const +void QCPLegend::setSelectedFont(const QFont &font) { - /* Extended sides of axis rect R divide space into 9 regions: - 1__|_4_|__7 - 2__|_R_|__8 - 3 | 6 | 9 - General idea: If the two points of a line segment are in the same region (that is not R), the line segment corner is removed. - Curves outside R become straight lines closely outside of R which greatly reduces drawing time, yet keeps the look of lines and - fills inside R consistent. - The region R has index 5. - */ - QCPAxis *keyAxis = mKeyAxis.data(); - QCPAxis *valueAxis = mValueAxis.data(); - if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + mSelectedFont = font; + for (int i=0; isetSelectedFont(font); + } +} + +/*! + Sets the default text color that is used by legend items when they are selected. - QRect axisRect = mKeyAxis.data()->axisRect()->rect() & mValueAxis.data()->axisRect()->rect(); - lineData->reserve(mData->size()); - QCPCurveDataMap::const_iterator it; - int lastRegion = 5; - int currentRegion = 5; - double RLeft = keyAxis->range().lower; - double RRight = keyAxis->range().upper; - double RBottom = valueAxis->range().lower; - double RTop = valueAxis->range().upper; - double x, y; // current key/value - bool addedLastAlready = true; - bool firstPoint = true; // first point must always be drawn, to make sure fill works correctly - for (it = mData->constBegin(); it != mData->constEnd(); ++it) - { - x = it.value().key; - y = it.value().value; - // determine current region: - if (x < RLeft) // region 123 - { - if (y > RTop) - currentRegion = 1; - else if (y < RBottom) - currentRegion = 3; - else - currentRegion = 2; - } else if (x > RRight) // region 789 - { - if (y > RTop) - currentRegion = 7; - else if (y < RBottom) - currentRegion = 9; - else - currentRegion = 8; - } else // region 456 - { - if (y > RTop) - currentRegion = 4; - else if (y < RBottom) - currentRegion = 6; - else - currentRegion = 5; - } - - /* - Watch out, the next part is very tricky. It modifies the curve such that it seems like the - whole thing is still drawn, but actually the points outside the axisRect are simplified - ("optimized") greatly. There are some subtle special cases when line segments are large and - thereby each subsequent point may be in a different region or even skip some. - */ - // determine whether to keep current point: - if (currentRegion == 5 || (firstPoint && mBrush.style() != Qt::NoBrush)) // current is in R, add current and last if it wasn't added already - { - if (!addedLastAlready) // in case curve just entered R, make sure the last point outside R is also drawn correctly - lineData->append(coordsToPixels((it-1).value().key, (it-1).value().value)); // add last point to vector - else if (lastRegion != 5) // added last already. If that's the case, we probably added it at optimized position. So go back and make sure it's at original position (else the angle changes under which this segment enters R) - { - if (!firstPoint) // because on firstPoint, currentRegion is 5 and addedLastAlready is true, although there is no last point - lineData->replace(lineData->size()-1, coordsToPixels((it-1).value().key, (it-1).value().value)); - } - lineData->append(coordsToPixels(it.value().key, it.value().value)); // add current point to vector - addedLastAlready = true; // so in next iteration, we don't add this point twice - } else if (currentRegion != lastRegion) // changed region, add current and last if not added already - { - // using outsideCoordsToPixels instead of coorsToPixels for optimized point placement (places points just outside axisRect instead of potentially far away) - - // if we're coming from R or we skip diagonally over the corner regions (so line might still be visible in R), we can't place points optimized - if (lastRegion == 5 || // coming from R - ((lastRegion==2 && currentRegion==4) || (lastRegion==4 && currentRegion==2)) || // skip top left diagonal - ((lastRegion==4 && currentRegion==8) || (lastRegion==8 && currentRegion==4)) || // skip top right diagonal - ((lastRegion==8 && currentRegion==6) || (lastRegion==6 && currentRegion==8)) || // skip bottom right diagonal - ((lastRegion==6 && currentRegion==2) || (lastRegion==2 && currentRegion==6)) // skip bottom left diagonal - ) - { - // always add last point if not added already, original: - if (!addedLastAlready) - lineData->append(coordsToPixels((it-1).value().key, (it-1).value().value)); - // add current point, original: - lineData->append(coordsToPixels(it.value().key, it.value().value)); - } else // no special case that forbids optimized point placement, so do it: - { - // always add last point if not added already, optimized: - if (!addedLastAlready) - lineData->append(outsideCoordsToPixels((it-1).value().key, (it-1).value().value, currentRegion, axisRect)); - // add current point, optimized: - lineData->append(outsideCoordsToPixels(it.value().key, it.value().value, currentRegion, axisRect)); - } - addedLastAlready = true; // so that if next point enters 5, or crosses another region boundary, we don't add this point twice - } else // neither in R, nor crossed a region boundary, skip current point - { - addedLastAlready = false; - } - lastRegion = currentRegion; - firstPoint = false; - } - // If curve ends outside R, we want to add very last point so the fill looks like it should when the curve started inside R: - if (lastRegion != 5 && mBrush.style() != Qt::NoBrush && !mData->isEmpty()) - lineData->append(coordsToPixels((mData->constEnd()-1).value().key, (mData->constEnd()-1).value().value)); -} + This function will also set \a color on all already existing legend items. -/*! \internal - - Calculates the (minimum) distance (in pixels) the curve's representation has from the given \a - pixelPoint in pixels. This is used to determine whether the curve was clicked or not, e.g. in - \ref selectTest. + \see setTextColor, QCPAbstractLegendItem::setSelectedTextColor */ -double QCPCurve::pointDistance(const QPointF &pixelPoint) const +void QCPLegend::setSelectedTextColor(const QColor &color) { - if (mData->isEmpty()) - { - qDebug() << Q_FUNC_INFO << "requested point distance on curve" << mName << "without data"; - return 500; - } - if (mData->size() == 1) - { - QPointF dataPoint = coordsToPixels(mData->constBegin().key(), mData->constBegin().value().value); - return QVector2D(dataPoint-pixelPoint).length(); - } - - // calculate minimum distance to line segments: - QVector *lineData = new QVector; - getCurveData(lineData); - double minDistSqr = std::numeric_limits::max(); - for (int i=0; isize()-1; ++i) + mSelectedTextColor = color; + for (int i=0; iat(i), lineData->at(i+1), pixelPoint); - if (currentDistSqr < minDistSqr) - minDistSqr = currentDistSqr; + if (item(i)) + item(i)->setSelectedTextColor(color); } - delete lineData; - return sqrt(minDistSqr); } -/*! \internal +/*! + Returns the item with index \a i. - This is a specialized \ref coordsToPixels function for points that are outside the visible - axisRect and just crossing a boundary (since \ref getCurveData reduces non-visible curve segments - to those line segments that cross region boundaries, see documentation there). It only uses the - coordinate parallel to the region boundary of the axisRect. The other coordinate is picked just - outside the axisRect (how far is determined by the scatter size and the line width). Together - with the optimization in \ref getCurveData this improves performance for large curves (or zoomed - in ones) significantly while keeping the illusion the whole curve and its filling is still being - drawn for the viewer. + \see itemCount */ -QPointF QCPCurve::outsideCoordsToPixels(double key, double value, int region, QRect axisRect) const +QCPAbstractLegendItem *QCPLegend::item(int index) const { - int margin = qCeil(qMax(mScatterStyle.size(), (double)mPen.widthF())) + 2; - QPointF result = coordsToPixels(key, value); - switch (region) - { - case 2: result.setX(axisRect.left()-margin); break; // left - case 8: result.setX(axisRect.right()+margin); break; // right - case 4: result.setY(axisRect.top()-margin); break; // top - case 6: result.setY(axisRect.bottom()+margin); break; // bottom - case 1: result.setX(axisRect.left()-margin); - result.setY(axisRect.top()-margin); break; // top left - case 7: result.setX(axisRect.right()+margin); - result.setY(axisRect.top()-margin); break; // top right - case 9: result.setX(axisRect.right()+margin); - result.setY(axisRect.bottom()+margin); break; // bottom right - case 3: result.setX(axisRect.left()-margin); - result.setY(axisRect.bottom()+margin); break; // bottom left - } - return result; + return qobject_cast(elementAt(index)); } -/* inherits documentation from base class */ -QCPRange QCPCurve::getKeyRange(bool &validRange, SignDomain inSignDomain) const -{ - QCPRange range; - bool haveLower = false; - bool haveUpper = false; - - double current; - - QCPCurveDataMap::const_iterator it = mData->constBegin(); - while (it != mData->constEnd()) - { - current = it.value().key; - if (inSignDomain == sdBoth || (inSignDomain == sdNegative && current < 0) || (inSignDomain == sdPositive && current > 0)) - { - if (current < range.lower || !haveLower) - { - range.lower = current; - haveLower = true; - } - if (current > range.upper || !haveUpper) - { - range.upper = current; - haveUpper = true; - } - } - ++it; - } +/*! + Returns the QCPPlottableLegendItem which is associated with \a plottable (e.g. a \ref QCPGraph*). + If such an item isn't in the legend, returns 0. - validRange = haveLower && haveUpper; - return range; -} - -/* inherits documentation from base class */ -QCPRange QCPCurve::getValueRange(bool &validRange, SignDomain inSignDomain) const + \see hasItemWithPlottable +*/ +QCPPlottableLegendItem *QCPLegend::itemWithPlottable(const QCPAbstractPlottable *plottable) const { - QCPRange range; - bool haveLower = false; - bool haveUpper = false; - - double current; - - QCPCurveDataMap::const_iterator it = mData->constBegin(); - while (it != mData->constEnd()) + for (int i=0; i 0)) + if (QCPPlottableLegendItem *pli = qobject_cast(item(i))) { - if (current < range.lower || !haveLower) - { - range.lower = current; - haveLower = true; - } - if (current > range.upper || !haveUpper) - { - range.upper = current; - haveUpper = true; - } + if (pli->plottable() == plottable) + return pli; } - ++it; } - - validRange = haveLower && haveUpper; - return range; + return 0; } - -//////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////// QCPBarData -//////////////////////////////////////////////////////////////////////////////////////////////////// - -/*! \class QCPBarData - \brief Holds the data of one single data point (one bar) for QCPBars. - - The container for storing multiple data points is \ref QCPBarDataMap. - - The stored data is: - \li \a key: coordinate on the key axis of this bar - \li \a value: height coordinate on the value axis of this bar - - \see QCPBarDataaMap -*/ - /*! - Constructs a bar data point with key and value set to zero. + Returns the number of items currently in the legend. + \see item */ -QCPBarData::QCPBarData() : - key(0), - value(0) +int QCPLegend::itemCount() const { + return elementCount(); } /*! - Constructs a bar data point with the specified \a key and \a value. + Returns whether the legend contains \a itm. */ -QCPBarData::QCPBarData(double key, double value) : - key(key), - value(value) +bool QCPLegend::hasItem(QCPAbstractLegendItem *item) const { + for (int i=0; iitem(i)) + return true; + } + return false; } - -//////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////// QCPBars -//////////////////////////////////////////////////////////////////////////////////////////////////// - -/*! \class QCPBars - \brief A plottable representing a bar chart in a plot. - - \image html QCPBars.png - - To plot data, assign it with the \ref setData or \ref addData functions. - - \section appearance Changing the appearance - - The appearance of the bars is determined by the pen and the brush (\ref setPen, \ref setBrush). - - Bar charts are stackable. This means, Two QCPBars plottables can be placed on top of each other - (see \ref QCPBars::moveAbove). Then, when two bars are at the same key position, they will appear - stacked. - - \section usage Usage - - Like all data representing objects in QCustomPlot, the QCPBars is a plottable - (QCPAbstractPlottable). So the plottable-interface of QCustomPlot applies - (QCustomPlot::plottable, QCustomPlot::addPlottable, QCustomPlot::removePlottable, etc.) - - Usually, you first create an instance: - \code - QCPBars *newBars = new QCPBars(customPlot->xAxis, customPlot->yAxis);\endcode - add it to the customPlot with QCustomPlot::addPlottable: - \code - customPlot->addPlottable(newBars);\endcode - and then modify the properties of the newly created plottable, e.g.: - \code - newBars->setName("Country population"); - newBars->setData(xData, yData);\endcode -*/ - -/*! \fn QCPBars *QCPBars::barBelow() const - Returns the bars plottable that is directly below this bars plottable. - If there is no such plottable, returns 0. - - \see barAbove, moveBelow, moveAbove -*/ - -/*! \fn QCPBars *QCPBars::barAbove() const - Returns the bars plottable that is directly above this bars plottable. - If there is no such plottable, returns 0. - - \see barBelow, moveBelow, moveAbove -*/ - /*! - Constructs a bar chart which uses \a keyAxis as its key axis ("x") and \a valueAxis as its value - axis ("y"). \a keyAxis and \a valueAxis must reside in the same QCustomPlot instance and not have - the same orientation. If either of these restrictions is violated, a corresponding message is - printed to the debug output (qDebug), the construction is not aborted, though. + Returns whether the legend contains a QCPPlottableLegendItem which is associated with \a plottable (e.g. a \ref QCPGraph*). + If such an item isn't in the legend, returns false. - The constructed QCPBars can be added to the plot with QCustomPlot::addPlottable, QCustomPlot - then takes ownership of the bar chart. + \see itemWithPlottable */ -QCPBars::QCPBars(QCPAxis *keyAxis, QCPAxis *valueAxis) : - QCPAbstractPlottable(keyAxis, valueAxis) -{ - mData = new QCPBarDataMap; - mPen.setColor(Qt::blue); - mPen.setStyle(Qt::SolidLine); - mBrush.setColor(QColor(40, 50, 255, 30)); - mBrush.setStyle(Qt::SolidPattern); - mSelectedPen = mPen; - mSelectedPen.setWidthF(2.5); - mSelectedPen.setColor(QColor(80, 80, 255)); // lighter than Qt::blue of mPen - mSelectedBrush = mBrush; - - mWidth = 0.75; -} - -QCPBars::~QCPBars() +bool QCPLegend::hasItemWithPlottable(const QCPAbstractPlottable *plottable) const { - if (mBarBelow || mBarAbove) - connectBars(mBarBelow.data(), mBarAbove.data()); // take this bar out of any stacking - delete mData; + return itemWithPlottable(plottable); } /*! - Sets the width of the bars in plot (key) coordinates. + Adds \a item to the legend, if it's not present already. + + Returns true on sucess, i.e. if the item wasn't in the list already and has been successfuly added. + + The legend takes ownership of the item. */ -void QCPBars::setWidth(double width) +bool QCPLegend::addItem(QCPAbstractLegendItem *item) { - mWidth = width; + if (!hasItem(item)) + { + return addElement(rowCount(), 0, item); + } else + return false; } /*! - Replaces the current data with the provided \a data. + Removes the item with index \a index from the legend. + + Returns true, if successful. - If \a copy is set to true, data points in \a data will only be copied. if false, the plottable - takes ownership of the passed data and replaces the internal data pointer with it. This is - significantly faster than copying for large datasets. + \see itemCount, clearItems */ -void QCPBars::setData(QCPBarDataMap *data, bool copy) +bool QCPLegend::removeItem(int index) { - if (copy) + if (QCPAbstractLegendItem *ali = item(index)) { - *mData = *data; + bool success = remove(ali); + simplify(); + return success; } else - { - delete mData; - mData = data; - } + return false; } /*! \overload - Replaces the current data with the provided points in \a key and \a value tuples. The - provided vectors should have equal length. Else, the number of added points will be the size of - the smallest vector. + Removes \a item from the legend. + + Returns true, if successful. + + \see clearItems */ -void QCPBars::setData(const QVector &key, const QVector &value) +bool QCPLegend::removeItem(QCPAbstractLegendItem *item) { - mData->clear(); - int n = key.size(); - n = qMin(n, value.size()); - QCPBarData newData; - for (int i=0; iinsertMulti(newData.key, newData); - } + bool success = remove(item); + simplify(); + return success; } /*! - Moves this bars plottable below \a bars. In other words, the bars of this plottable will appear - below the bars of \a bars. The move target \a bars must use the same key and value axis as this - plottable. - - Inserting into and removing from existing bar stacking is handled gracefully. If \a bars already - has a bars object below itself, this bars object is inserted between the two. If this bars object - is already between two other bars, the two other bars will be stacked on top of each other after - the operation. - - To remove this bars plottable from any stacking, set \a bars to 0. - - \see moveBelow, barAbove, barBelow + Removes all items from the legend. */ -void QCPBars::moveBelow(QCPBars *bars) +void QCPLegend::clearItems() { - if (bars == this) return; - if (bars && (bars->keyAxis() != mKeyAxis.data() || bars->valueAxis() != mValueAxis.data())) - { - qDebug() << Q_FUNC_INFO << "passed QCPBars* doesn't have same key and value axis as this QCPBars"; - return; - } - // remove from stacking: - connectBars(mBarBelow.data(), mBarAbove.data()); // Note: also works if one (or both) of them is 0 - // if new bar given, insert this bar below it: - if (bars) - { - if (bars->mBarBelow) - connectBars(bars->mBarBelow.data(), this); - connectBars(this, bars); - } + for (int i=itemCount()-1; i>=0; --i) + removeItem(i); } /*! - Moves this bars plottable above \a bars. In other words, the bars of this plottable will appear - above the bars of \a bars. The move target \a bars must use the same key and value axis as this - plottable. - - Inserting into and removing from existing bar stacking is handled gracefully. If \a bars already - has a bars object below itself, this bars object is inserted between the two. If this bars object - is already between two other bars, the two other bars will be stacked on top of each other after - the operation. - - To remove this bars plottable from any stacking, set \a bars to 0. + Returns the legend items that are currently selected. If no items are selected, + the list is empty. - \see moveBelow, barBelow, barAbove + \see QCPAbstractLegendItem::setSelected, setSelectable */ -void QCPBars::moveAbove(QCPBars *bars) +QList QCPLegend::selectedItems() const { - if (bars == this) return; - if (bars && (bars->keyAxis() != mKeyAxis.data() || bars->valueAxis() != mValueAxis.data())) - { - qDebug() << Q_FUNC_INFO << "passed QCPBars* doesn't have same key and value axis as this QCPBars"; - return; - } - // remove from stacking: - connectBars(mBarBelow.data(), mBarAbove.data()); // Note: also works if one (or both) of them is 0 - // if new bar given, insert this bar above it: - if (bars) + QList result; + for (int i=0; imBarAbove) - connectBars(this, bars->mBarAbove.data()); - connectBars(bars, this); + if (QCPAbstractLegendItem *ali = item(i)) + { + if (ali->selected()) + result.append(ali); + } } + return result; } -/*! - Adds the provided data points in \a dataMap to the current data. - \see removeData +/*! \internal + + A convenience function to easily set the QPainter::Antialiased hint on the provided \a painter + before drawing main legend elements. + + This is the antialiasing state the painter passed to the \ref draw method is in by default. + + This function takes into account the local setting of the antialiasing flag as well as the + overrides set with \ref QCustomPlot::setAntialiasedElements and \ref + QCustomPlot::setNotAntialiasedElements. + + \see setAntialiased */ -void QCPBars::addData(const QCPBarDataMap &dataMap) +void QCPLegend::applyDefaultAntialiasingHint(QCPPainter *painter) const { - mData->unite(dataMap); + applyAntialiasingHint(painter, mAntialiased, QCP::aeLegend); } -/*! \overload - Adds the provided single data point in \a data to the current data. - \see removeData +/*! \internal + + Returns the pen used to paint the border of the legend, taking into account the selection state + of the legend box. */ -void QCPBars::addData(const QCPBarData &data) +QPen QCPLegend::getBorderPen() const { - mData->insertMulti(data.key, data); + return mSelectedParts.testFlag(spLegendBox) ? mSelectedBorderPen : mBorderPen; } -/*! \overload - Adds the provided single data point as \a key and \a value tuple to the current data - \see removeData +/*! \internal + + Returns the brush used to paint the background of the legend, taking into account the selection + state of the legend box. */ -void QCPBars::addData(double key, double value) +QBrush QCPLegend::getBrush() const { - QCPBarData newData; - newData.key = key; - newData.value = value; - mData->insertMulti(newData.key, newData); + return mSelectedParts.testFlag(spLegendBox) ? mSelectedBrush : mBrush; } -/*! \overload - Adds the provided data points as \a key and \a value tuples to the current data. - \see removeData +/*! \internal + + Draws the legend box with the provided \a painter. The individual legend items are layerables + themselves, thus are drawn independently. */ -void QCPBars::addData(const QVector &keys, const QVector &values) +void QCPLegend::draw(QCPPainter *painter) { - int n = keys.size(); - n = qMin(n, values.size()); - QCPBarData newData; - for (int i=0; isetBrush(getBrush()); + painter->setPen(getBorderPen()); + painter->drawRect(mOuterRect); +} + +/* inherits documentation from base class */ +double QCPLegend::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + if (!mParentPlot) return -1; + if (onlySelectable && !mSelectableParts.testFlag(spLegendBox)) + return -1; + + if (mOuterRect.contains(pos.toPoint())) { - newData.key = keys[i]; - newData.value = values[i]; - mData->insertMulti(newData.key, newData); + if (details) details->setValue(spLegendBox); + return mParentPlot->selectionTolerance()*0.99; + } + return -1; +} + +/* inherits documentation from base class */ +void QCPLegend::selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) +{ + Q_UNUSED(event) + mSelectedParts = selectedParts(); // in case item selection has changed + if (details.value() == spLegendBox && mSelectableParts.testFlag(spLegendBox)) + { + SelectableParts selBefore = mSelectedParts; + setSelectedParts(additive ? mSelectedParts^spLegendBox : mSelectedParts|spLegendBox); // no need to unset spItems in !additive case, because they will be deselected by QCustomPlot (they're normal QCPLayerables with own deselectEvent) + if (selectionStateChanged) + *selectionStateChanged = mSelectedParts != selBefore; + } +} + +/* inherits documentation from base class */ +void QCPLegend::deselectEvent(bool *selectionStateChanged) +{ + mSelectedParts = selectedParts(); // in case item selection has changed + if (mSelectableParts.testFlag(spLegendBox)) + { + SelectableParts selBefore = mSelectedParts; + setSelectedParts(selectedParts() & ~spLegendBox); + if (selectionStateChanged) + *selectionStateChanged = mSelectedParts != selBefore; } } +/* inherits documentation from base class */ +QCP::Interaction QCPLegend::selectionCategory() const +{ + return QCP::iSelectLegend; +} + +/* inherits documentation from base class */ +QCP::Interaction QCPAbstractLegendItem::selectionCategory() const +{ + return QCP::iSelectLegend; +} + +/* inherits documentation from base class */ +void QCPLegend::parentPlotInitialized(QCustomPlot *parentPlot) +{ + Q_UNUSED(parentPlot) +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPPlotTitle +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPPlotTitle + \brief A layout element displaying a plot title text + + The text may be specified with \ref setText, theformatting can be controlled with \ref setFont + and \ref setTextColor. + + A plot title can be added as follows: + \code + customPlot->plotLayout()->insertRow(0); // inserts an empty row above the default axis rect + customPlot->plotLayout()->addElement(0, 0, new QCPPlotTitle(customPlot, "Your Plot Title")); + \endcode + + Since a plot title is a common requirement, QCustomPlot offers specialized selection signals for + easy interaction with QCPPlotTitle. If a layout element of type QCPPlotTitle is clicked, the + signal \ref QCustomPlot::titleClick is emitted. A double click emits the \ref + QCustomPlot::titleDoubleClick signal. +*/ + +/* start documentation of signals */ + +/*! \fn void QCPPlotTitle::selectionChanged(bool selected) + + This signal is emitted when the selection state has changed to \a selected, either by user + interaction or by a direct call to \ref setSelected. + + \see setSelected, setSelectable +*/ + +/* end documentation of signals */ + /*! - Removes all data points with key smaller than \a key. - \see addData, clearData + Creates a new QCPPlotTitle instance and sets default values. The initial text is empty (\ref setText). + + To set the title text in the constructor, rather use \ref QCPPlotTitle(QCustomPlot *parentPlot, const QString &text). */ -void QCPBars::removeDataBefore(double key) +QCPPlotTitle::QCPPlotTitle(QCustomPlot *parentPlot) : + QCPLayoutElement(parentPlot), + mFont(QFont("sans serif", 13*1.5, QFont::Bold)), + mTextColor(Qt::black), + mSelectedFont(QFont("sans serif", 13*1.6, QFont::Bold)), + mSelectedTextColor(Qt::blue), + mSelectable(false), + mSelected(false) { - QCPBarDataMap::iterator it = mData->begin(); - while (it != mData->end() && it.key() < key) - it = mData->erase(it); + if (parentPlot) + { + setLayer(parentPlot->currentLayer()); + mFont = QFont(parentPlot->font().family(), parentPlot->font().pointSize()*1.5, QFont::Bold); + mSelectedFont = QFont(parentPlot->font().family(), parentPlot->font().pointSize()*1.6, QFont::Bold); + } + setMargins(QMargins(5, 5, 5, 0)); +} + +/*! \overload + + Creates a new QCPPlotTitle instance and sets default values. The initial text is set to \a text. +*/ +QCPPlotTitle::QCPPlotTitle(QCustomPlot *parentPlot, const QString &text) : + QCPLayoutElement(parentPlot), + mText(text), + mFont(QFont(parentPlot->font().family(), parentPlot->font().pointSize()*1.5, QFont::Bold)), + mTextColor(Qt::black), + mSelectedFont(QFont(parentPlot->font().family(), parentPlot->font().pointSize()*1.6, QFont::Bold)), + mSelectedTextColor(Qt::blue), + mSelectable(false), + mSelected(false) +{ + setLayer("axes"); + setMargins(QMargins(5, 5, 5, 0)); } /*! - Removes all data points with key greater than \a key. - \see addData, clearData + Sets the text that will be displayed to \a text. Multiple lines can be created by insertion of "\n". + + \see setFont, setTextColor */ -void QCPBars::removeDataAfter(double key) +void QCPPlotTitle::setText(const QString &text) { - if (mData->isEmpty()) return; - QCPBarDataMap::iterator it = mData->upperBound(key); - while (it != mData->end()) - it = mData->erase(it); + mText = text; } /*! - Removes all data points with key between \a fromKey and \a toKey. if \a fromKey is - greater or equal to \a toKey, the function does nothing. To remove a single data point with known - key, use \ref removeData(double key). + Sets the \a font of the title text. - \see addData, clearData + \see setTextColor, setSelectedFont */ -void QCPBars::removeData(double fromKey, double toKey) +void QCPPlotTitle::setFont(const QFont &font) { - if (fromKey >= toKey || mData->isEmpty()) return; - QCPBarDataMap::iterator it = mData->upperBound(fromKey); - QCPBarDataMap::iterator itEnd = mData->upperBound(toKey); - while (it != itEnd) - it = mData->erase(it); + mFont = font; } -/*! \overload +/*! + Sets the \a color of the title text. - Removes a single data point at \a key. If the position is not known with absolute precision, - consider using \ref removeData(double fromKey, double toKey) with a small fuzziness interval - around the suspected position, depeding on the precision with which the key is known. + \see setFont, setSelectedTextColor +*/ +void QCPPlotTitle::setTextColor(const QColor &color) +{ + mTextColor = color; +} + +/*! + Sets the \a font of the title text that will be used if the plot title is selected (\ref setSelected). - \see addData, clearData + \see setFont */ -void QCPBars::removeData(double key) +void QCPPlotTitle::setSelectedFont(const QFont &font) { - mData->remove(key); + mSelectedFont = font; } /*! - Removes all data points. - \see removeData, removeDataAfter, removeDataBefore + Sets the \a color of the title text that will be used if the plot title is selected (\ref setSelected). + + \see setTextColor */ -void QCPBars::clearData() +void QCPPlotTitle::setSelectedTextColor(const QColor &color) { - mData->clear(); + mSelectedTextColor = color; } -/* inherits documentation from base class */ -double QCPBars::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +/*! + Sets whether the user may select this plot title to \a selectable. + + Note that even when \a selectable is set to false, the selection state may be changed + programmatically via \ref setSelected. +*/ +void QCPPlotTitle::setSelectable(bool selectable) { - Q_UNUSED(details) - if (onlySelectable && !mSelectable) - return -1; + if (mSelectable != selectable) + { + mSelectable = selectable; + emit selectableChanged(mSelectable); + } +} + +/*! + Sets the selection state of this plot title to \a selected. If the selection has changed, \ref + selectionChanged is emitted. - QCPBarDataMap::ConstIterator it; - double posKey, posValue; - pixelsToCoords(pos, posKey, posValue); - for (it = mData->constBegin(); it != mData->constEnd(); ++it) + Note that this function can change the selection state independently of the current \ref + setSelectable state. +*/ +void QCPPlotTitle::setSelected(bool selected) +{ + if (mSelected != selected) { - double baseValue = getBaseValue(it.key(), it.value().value >=0); - QCPRange keyRange(it.key()-mWidth*0.5, it.key()+mWidth*0.5); - QCPRange valueRange(baseValue, baseValue+it.value().value); - if (keyRange.contains(posKey) && valueRange.contains(posValue)) - return mParentPlot->selectionTolerance()*0.99; + mSelected = selected; + emit selectionChanged(mSelected); } - return -1; } /* inherits documentation from base class */ -void QCPBars::draw(QCPPainter *painter) +void QCPPlotTitle::applyDefaultAntialiasingHint(QCPPainter *painter) const { - if (!mKeyAxis || !mValueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } - if (mData->isEmpty()) return; - - QCPBarDataMap::const_iterator it; - for (it = mData->constBegin(); it != mData->constEnd(); ++it) - { - // skip bar if not visible in key axis range: - if (it.key()+mWidth*0.5 < mKeyAxis.data()->range().lower || it.key()-mWidth*0.5 > mKeyAxis.data()->range().upper) - continue; - // check data validity if flag set: -#ifdef QCUSTOMPLOT_CHECK_DATA - if (QCP::isInvalidData(it.value().key, it.value().value)) - qDebug() << Q_FUNC_INFO << "Data point at" << it.key() << "of drawn range invalid." << "Plottable name:" << name(); -#endif - QPolygonF barPolygon = getBarPolygon(it.key(), it.value().value); - // draw bar fill: - if (mainBrush().style() != Qt::NoBrush && mainBrush().color().alpha() != 0) - { - applyFillAntialiasingHint(painter); - painter->setPen(Qt::NoPen); - painter->setBrush(mainBrush()); - painter->drawPolygon(barPolygon); - } - // draw bar line: - if (mainPen().style() != Qt::NoPen && mainPen().color().alpha() != 0) - { - applyDefaultAntialiasingHint(painter); - painter->setPen(mainPen()); - painter->setBrush(Qt::NoBrush); - painter->drawPolyline(barPolygon); - } - } + applyAntialiasingHint(painter, mAntialiased, QCP::aeNone); } /* inherits documentation from base class */ -void QCPBars::drawLegendIcon(QCPPainter *painter, const QRectF &rect) const +void QCPPlotTitle::draw(QCPPainter *painter) { - // draw filled rect: - applyDefaultAntialiasingHint(painter); - painter->setBrush(mBrush); - painter->setPen(mPen); - QRectF r = QRectF(0, 0, rect.width()*0.67, rect.height()*0.67); - r.moveCenter(rect.center()); - painter->drawRect(r); + painter->setFont(mainFont()); + painter->setPen(QPen(mainTextColor())); + painter->drawText(mRect, Qt::AlignCenter, mText, &mTextBoundingRect); } -/*! \internal - - Returns the polygon of a single bar with \a key and \a value. The Polygon is open at the bottom - and shifted according to the bar stacking (see \ref moveAbove). -*/ -QPolygonF QCPBars::getBarPolygon(double key, double value) const +/* inherits documentation from base class */ +QSize QCPPlotTitle::minimumSizeHint() const { - QPolygonF result; - double baseValue = getBaseValue(key, value >= 0); - result << coordsToPixels(key-mWidth*0.5, baseValue); - result << coordsToPixels(key-mWidth*0.5, baseValue+value); - result << coordsToPixels(key+mWidth*0.5, baseValue+value); - result << coordsToPixels(key+mWidth*0.5, baseValue); + QFontMetrics metrics(mFont); + QSize result = metrics.boundingRect(0, 0, 0, 0, Qt::AlignCenter, mText).size(); + result.rwidth() += mMargins.left() + mMargins.right(); + result.rheight() += mMargins.top() + mMargins.bottom(); return result; } -/*! \internal - - This function is called to find at which value to start drawing the base of a bar at \a key, when - it is stacked on top of another QCPBars (e.g. with \ref moveAbove). - - positive and negative bars are separated per stack (positive are stacked above 0-value upwards, - negative are stacked below 0-value downwards). This can be indicated with \a positive. So if the - bar for which we need the base value is negative, set \a positive to false. -*/ -double QCPBars::getBaseValue(double key, bool positive) const +/* inherits documentation from base class */ +QSize QCPPlotTitle::maximumSizeHint() const { - if (mBarBelow) - { - double max = 0; - // find bars of mBarBelow that are approximately at key and find largest one: - QCPBarDataMap::const_iterator it = mBarBelow.data()->mData->lowerBound(key-mWidth*0.1); - QCPBarDataMap::const_iterator itEnd = mBarBelow.data()->mData->upperBound(key+mWidth*0.1); - while (it != itEnd) - { - if ((positive && it.value().value > max) || - (!positive && it.value().value < max)) - max = it.value().value; - ++it; - } - // recurse down the bar-stack to find the total height: - return max + mBarBelow.data()->getBaseValue(key, positive); - } else - return 0; + QFontMetrics metrics(mFont); + QSize result = metrics.boundingRect(0, 0, 0, 0, Qt::AlignCenter, mText).size(); + result.rheight() += mMargins.top() + mMargins.bottom(); + result.setWidth(QWIDGETSIZE_MAX); + return result; } -/*! \internal - - Connects \a below and \a above to each other via their mBarAbove/mBarBelow properties. - The bar(s) currently below lower and upper will become disconnected to lower/upper. - - If lower is zero, upper will be disconnected at the bottom. - If upper is zero, lower will be disconnected at the top. -*/ -void QCPBars::connectBars(QCPBars *lower, QCPBars *upper) +/* inherits documentation from base class */ +void QCPPlotTitle::selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) { - if (!lower && !upper) return; - - if (!lower) // disconnect upper at bottom - { - // disconnect old bar below upper: - if (upper->mBarBelow && upper->mBarBelow.data()->mBarAbove.data() == upper) - upper->mBarBelow.data()->mBarAbove = 0; - upper->mBarBelow = 0; - } else if (!upper) // disconnect lower at top - { - // disconnect old bar above lower: - if (lower->mBarAbove && lower->mBarAbove.data()->mBarBelow.data() == lower) - lower->mBarAbove.data()->mBarBelow = 0; - lower->mBarAbove = 0; - } else // connect lower and upper + Q_UNUSED(event) + Q_UNUSED(details) + if (mSelectable) { - // disconnect old bar above lower: - if (lower->mBarAbove && lower->mBarAbove.data()->mBarBelow.data() == lower) - lower->mBarAbove.data()->mBarBelow = 0; - // disconnect old bar below upper: - if (upper->mBarBelow && upper->mBarBelow.data()->mBarAbove.data() == upper) - upper->mBarBelow.data()->mBarAbove = 0; - lower->mBarAbove = upper; - upper->mBarBelow = lower; + bool selBefore = mSelected; + setSelected(additive ? !mSelected : true); + if (selectionStateChanged) + *selectionStateChanged = mSelected != selBefore; } } /* inherits documentation from base class */ -QCPRange QCPBars::getKeyRange(bool &validRange, SignDomain inSignDomain) const +void QCPPlotTitle::deselectEvent(bool *selectionStateChanged) { - QCPRange range; - bool haveLower = false; - bool haveUpper = false; - - double current; - double barWidthHalf = mWidth*0.5; - QCPBarDataMap::const_iterator it = mData->constBegin(); - while (it != mData->constEnd()) + if (mSelectable) { - current = it.value().key; - if (inSignDomain == sdBoth || (inSignDomain == sdNegative && current+barWidthHalf < 0) || (inSignDomain == sdPositive && current-barWidthHalf > 0)) - { - if (current-barWidthHalf < range.lower || !haveLower) - { - range.lower = current-barWidthHalf; - haveLower = true; - } - if (current+barWidthHalf > range.upper || !haveUpper) - { - range.upper = current+barWidthHalf; - haveUpper = true; - } - } - ++it; + bool selBefore = mSelected; + setSelected(false); + if (selectionStateChanged) + *selectionStateChanged = mSelected != selBefore; } - - validRange = haveLower && haveUpper; - return range; } /* inherits documentation from base class */ -QCPRange QCPBars::getValueRange(bool &validRange, SignDomain inSignDomain) const +double QCPPlotTitle::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { - QCPRange range; - bool haveLower = true; // set to true, because 0 should always be visible in bar charts - bool haveUpper = true; // set to true, because 0 should always be visible in bar charts + Q_UNUSED(details) + if (onlySelectable && !mSelectable) + return -1; - double current; + if (mTextBoundingRect.contains(pos.toPoint())) + return mParentPlot->selectionTolerance()*0.99; + else + return -1; +} + +/*! \internal - QCPBarDataMap::const_iterator it = mData->constBegin(); - while (it != mData->constEnd()) - { - current = it.value().value + getBaseValue(it.value().key, it.value().value >= 0); - if (inSignDomain == sdBoth || (inSignDomain == sdNegative && current < 0) || (inSignDomain == sdPositive && current > 0)) - { - if (current < range.lower || !haveLower) - { - range.lower = current; - haveLower = true; - } - if (current > range.upper || !haveUpper) - { - range.upper = current; - haveUpper = true; - } - } - ++it; - } + Returns the main font to be used. This is mSelectedFont if \ref setSelected is set to + true, else mFont is returned. +*/ +QFont QCPPlotTitle::mainFont() const +{ + return mSelected ? mSelectedFont : mFont; +} + +/*! \internal - validRange = range.lower < range.upper; - return range; + Returns the main color to be used. This is mSelectedTextColor if \ref setSelected is set to + true, else mTextColor is returned. +*/ +QColor QCPPlotTitle::mainTextColor() const +{ + return mSelected ? mSelectedTextColor : mTextColor; } //////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////// QCPStatisticalBox +//////////////////// QCPColorScale //////////////////////////////////////////////////////////////////////////////////////////////////// -/*! \class QCPStatisticalBox - \brief A plottable representing a single statistical box in a plot. +/*! \class QCPColorScale + \brief A color scale for use with color coding data such as QCPColorMap + + This layout element can be placed on the plot to correlate a color gradient with data values. It + is usually used in combination with one or multiple \ref QCPColorMap "QCPColorMaps". - \image html QCPStatisticalBox.png + \image html QCPColorScale.png - To plot data, assign it with the individual parameter functions or use \ref setData to set all - parameters at once. The individual funcions are: - \li \ref setMinimum - \li \ref setLowerQuartile - \li \ref setMedian - \li \ref setUpperQuartile - \li \ref setMaximum + The color scale can be either horizontal or vertical, as shown in the image above. The + orientation and the side where the numbers appear is controlled with \ref setType. - Additionally you can define a list of outliers, drawn as circle datapoints: - \li \ref setOutliers + Use \ref QCPColorMap::setColorScale to connect a color map with a color scale. Once they are + connected, they share their gradient, data range and data scale type (\ref setGradient, \ref + setDataRange, \ref setDataScaleType). Multiple color maps may be associated with a single color + scale, to make them all synchronize these properties. - \section appearance Changing the appearance + To have finer control over the number display and axis behaviour, you can directly access the + \ref axis. See the documentation of QCPAxis for details about configuring axes. For example, if + you want to change the number of automatically generated ticks, call + \code + colorScale->axis()->setAutoTickCount(3); + \endcode - The appearance of the box itself is controlled via \ref setPen and \ref setBrush. You may change - the width of the box with \ref setWidth in plot coordinates (not pixels). - - Analog functions exist for the minimum/maximum-whiskers: \ref setWhiskerPen, \ref - setWhiskerBarPen, \ref setWhiskerWidth. The whisker width is the width of the bar at the top - (maximum) and bottom (minimum). + Placing a color scale next to the main axis rect works like with any other layout element: + \code + QCPColorScale *colorScale = new QCPColorScale(customPlot); + customPlot->plotLayout()->addElement(0, 1, colorScale); + colorScale->setLabel("Some Label Text"); + \endcode + In this case we have placed it to the right of the default axis rect, so it wasn't necessary to + call \ref setType, since \ref QCPAxis::atRight is already the default. The text next to the color + scale can be set with \ref setLabel. - The median indicator line has its own pen, \ref setMedianPen. + For optimum appearance (like in the image above), it may be desirable to line up the axis rect and + the borders of the color scale. Use a \ref QCPMarginGroup to achieve this: + \code + QCPMarginGroup *group = new QCPMarginGroup(customPlot); + colorScale->setMarginGroup(QCP::msTop|QCP::msBottom, group); + customPlot->axisRect()->setMarginGroup(QCP::msTop|QCP::msBottom, group); + \endcode - If the whisker backbone pen is changed, make sure to set the capStyle to Qt::FlatCap. Else, the - backbone line might exceed the whisker bars by a few pixels due to the pen cap being not - perfectly flat. + Color scales are initialized with a non-zero minimum top and bottom margin (\ref + setMinimumMargins), because vertical color scales are most common and the minimum top/bottom + margin makes sure it keeps some distance to the top/bottom widget border. So if you change to a + horizontal color scale by setting \ref setType to \ref QCPAxis::atBottom or \ref QCPAxis::atTop, you + might want to also change the minimum margins accordingly, e.g. \ref + setMinimumMargins(QMargins(6, 0, 6, 0)). +*/ + +/* start documentation of inline functions */ + +/*! \fn QCPAxis *QCPColorScale::axis() const - The Outlier data points are drawn as normal scatter points. Their look can be controlled with - \ref setOutlierStyle + Returns the internal \ref QCPAxis instance of this color scale. You can access it to alter the + appearance and behaviour of the axis. \ref QCPColorScale duplicates some properties in its + interface for convenience. Those are \ref setDataRange (\ref QCPAxis::setRange), \ref + setDataScaleType (\ref QCPAxis::setScaleType), and the method \ref setLabel (\ref + QCPAxis::setLabel). As they each are connected, it does not matter whether you use the method on + the QCPColorScale or on its QCPAxis. - \section usage Usage + If the type of the color scale is changed with \ref setType, the axis returned by this method + will change, too, to either the left, right, bottom or top axis, depending on which type was set. +*/ + +/* end documentation of signals */ +/* start documentation of signals */ + +/*! \fn void QCPColorScale::dataRangeChanged(QCPRange newRange); - Like all data representing objects in QCustomPlot, the QCPStatisticalBox is a plottable - (QCPAbstractPlottable). So the plottable-interface of QCustomPlot applies - (QCustomPlot::plottable, QCustomPlot::addPlottable, QCustomPlot::removePlottable, etc.) + This signal is emitted when the data range changes. - Usually, you first create an instance: - \code - QCPStatisticalBox *newBox = new QCPStatisticalBox(customPlot->xAxis, customPlot->yAxis);\endcode - add it to the customPlot with QCustomPlot::addPlottable: - \code - customPlot->addPlottable(newBox);\endcode - and then modify the properties of the newly created plottable, e.g.: - \code - newBox->setName("Measurement Series 1"); - newBox->setData(1, 3, 4, 5, 7); - newBox->setOutliers(QVector() << 0.5 << 0.64 << 7.2 << 7.42);\endcode + \see setDataRange */ -/*! - Constructs a statistical box which uses \a keyAxis as its key axis ("x") and \a valueAxis as its - value axis ("y"). \a keyAxis and \a valueAxis must reside in the same QCustomPlot instance and - not have the same orientation. If either of these restrictions is violated, a corresponding - message is printed to the debug output (qDebug), the construction is not aborted, though. +/*! \fn void QCPColorScale::dataScaleTypeChanged(QCPAxis::ScaleType scaleType); - The constructed statistical box can be added to the plot with QCustomPlot::addPlottable, - QCustomPlot then takes ownership of the statistical box. + This signal is emitted when the data scale type changes. + + \see setDataScaleType */ -QCPStatisticalBox::QCPStatisticalBox(QCPAxis *keyAxis, QCPAxis *valueAxis) : - QCPAbstractPlottable(keyAxis, valueAxis), - mKey(0), - mMinimum(0), - mLowerQuartile(0), - mMedian(0), - mUpperQuartile(0), - mMaximum(0) -{ - setOutlierStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, Qt::blue, 6)); - setWhiskerWidth(0.2); - setWidth(0.5); + +/*! \fn void QCPColorScale::gradientChanged(QCPColorGradient newGradient); - setPen(QPen(Qt::black)); - setSelectedPen(QPen(Qt::blue, 2.5)); - setMedianPen(QPen(Qt::black, 3, Qt::SolidLine, Qt::FlatCap)); - setWhiskerPen(QPen(Qt::black, 0, Qt::DashLine, Qt::FlatCap)); - setWhiskerBarPen(QPen(Qt::black)); - setBrush(Qt::NoBrush); - setSelectedBrush(Qt::NoBrush); -} + This signal is emitted when the gradient changes. + + \see setGradient +*/ + +/* end documentation of signals */ /*! - Sets the key coordinate of the statistical box. + Constructs a new QCPColorScale. */ -void QCPStatisticalBox::setKey(double key) +QCPColorScale::QCPColorScale(QCustomPlot *parentPlot) : + QCPLayoutElement(parentPlot), + mType(QCPAxis::atTop), // set to atTop such that setType(QCPAxis::atRight) below doesn't skip work because it thinks it's already atRight + mDataScaleType(QCPAxis::stLinear), + mBarWidth(20), + mAxisRect(new QCPColorScaleAxisRectPrivate(this)) { - mKey = key; + setMinimumMargins(QMargins(0, 6, 0, 6)); // for default right color scale types, keep some room at bottom and top (important if no margin group is used) + setType(QCPAxis::atRight); + setDataRange(QCPRange(0, 6)); } -/*! - Sets the parameter "minimum" of the statistical box plot. This is the position of the lower - whisker, typically the minimum measurement of the sample that's not considered an outlier. - - \see setMaximum, setWhiskerPen, setWhiskerBarPen, setWhiskerWidth -*/ -void QCPStatisticalBox::setMinimum(double value) +QCPColorScale::~QCPColorScale() { - mMinimum = value; + delete mAxisRect; } -/*! - Sets the parameter "lower Quartile" of the statistical box plot. This is the lower end of the - box. The lower and the upper quartiles are the two statistical quartiles around the median of the - sample, they contain 50% of the sample data. - - \see setUpperQuartile, setPen, setBrush, setWidth -*/ -void QCPStatisticalBox::setLowerQuartile(double value) +/* undocumented getter */ +QString QCPColorScale::label() const { - mLowerQuartile = value; + if (!mColorAxis) + { + qDebug() << Q_FUNC_INFO << "internal color axis undefined"; + return QString(); + } + + return mColorAxis.data()->label(); } -/*! - Sets the parameter "median" of the statistical box plot. This is the value of the median mark - inside the quartile box. The median separates the sample data in half (50% of the sample data is - below/above the median). +/* undocumented getter */ +bool QCPColorScale::rangeDrag() const +{ + if (!mAxisRect) + { + qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; + return false; + } - \see setMedianPen -*/ -void QCPStatisticalBox::setMedian(double value) + return mAxisRect.data()->rangeDrag().testFlag(QCPAxis::orientation(mType)) && + mAxisRect.data()->rangeDragAxis(QCPAxis::orientation(mType)) && + mAxisRect.data()->rangeDragAxis(QCPAxis::orientation(mType))->orientation() == QCPAxis::orientation(mType); +} + +/* undocumented getter */ +bool QCPColorScale::rangeZoom() const { - mMedian = value; + if (!mAxisRect) + { + qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; + return false; + } + + return mAxisRect.data()->rangeZoom().testFlag(QCPAxis::orientation(mType)) && + mAxisRect.data()->rangeZoomAxis(QCPAxis::orientation(mType)) && + mAxisRect.data()->rangeZoomAxis(QCPAxis::orientation(mType))->orientation() == QCPAxis::orientation(mType); } /*! - Sets the parameter "upper Quartile" of the statistical box plot. This is the upper end of the - box. The lower and the upper quartiles are the two statistical quartiles around the median of the - sample, they contain 50% of the sample data. + Sets at which side of the color scale the axis is placed, and thus also its orientation. - \see setLowerQuartile, setPen, setBrush, setWidth + Note that after setting \a type to a different value, the axis returned by \ref axis() will + be a different one. The new axis will adopt the following properties from the previous axis: The + range, scale type, log base and label. */ -void QCPStatisticalBox::setUpperQuartile(double value) +void QCPColorScale::setType(QCPAxis::AxisType type) { - mUpperQuartile = value; + if (!mAxisRect) + { + qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; + return; + } + if (mType != type) + { + mType = type; + QCPRange rangeTransfer(0, 6); + double logBaseTransfer = 10; + QString labelTransfer; + // revert some settings on old axis: + if (mColorAxis) + { + rangeTransfer = mColorAxis.data()->range(); + labelTransfer = mColorAxis.data()->label(); + logBaseTransfer = mColorAxis.data()->scaleLogBase(); + mColorAxis.data()->setLabel(""); + disconnect(mColorAxis.data(), SIGNAL(rangeChanged(QCPRange)), this, SLOT(setDataRange(QCPRange))); + disconnect(mColorAxis.data(), SIGNAL(scaleTypeChanged(QCPAxis::ScaleType)), this, SLOT(setDataScaleType(QCPAxis::ScaleType))); + } + foreach (QCPAxis::AxisType atype, QList() << QCPAxis::atLeft << QCPAxis::atRight << QCPAxis::atBottom << QCPAxis::atTop) + { + mAxisRect.data()->axis(atype)->setTicks(atype == mType); + mAxisRect.data()->axis(atype)->setTickLabels(atype== mType); + } + // set new mColorAxis pointer: + mColorAxis = mAxisRect.data()->axis(mType); + // transfer settings to new axis: + mColorAxis.data()->setRange(rangeTransfer); // transfer range of old axis to new one (necessary if axis changes from vertical to horizontal or vice versa) + mColorAxis.data()->setLabel(labelTransfer); + mColorAxis.data()->setScaleLogBase(logBaseTransfer); // scaleType is synchronized among axes in realtime via signals (connected in QCPColorScale ctor), so we only need to take care of log base here + connect(mColorAxis.data(), SIGNAL(rangeChanged(QCPRange)), this, SLOT(setDataRange(QCPRange))); + connect(mColorAxis.data(), SIGNAL(scaleTypeChanged(QCPAxis::ScaleType)), this, SLOT(setDataScaleType(QCPAxis::ScaleType))); + mAxisRect.data()->setRangeDragAxes(QCPAxis::orientation(mType) == Qt::Horizontal ? mColorAxis.data() : 0, + QCPAxis::orientation(mType) == Qt::Vertical ? mColorAxis.data() : 0); + } } /*! - Sets the parameter "maximum" of the statistical box plot. This is the position of the upper - whisker, typically the maximum measurement of the sample that's not considered an outlier. + Sets the range spanned by the color gradient and that is shown by the axis in the color scale. - \see setMinimum, setWhiskerPen, setWhiskerBarPen, setWhiskerWidth + It is equivalent to calling QCPColorMap::setDataRange on any of the connected color maps. It is + also equivalent to directly accessing the \ref axis and setting its range with \ref + QCPAxis::setRange. + + \see setDataScaleType, setGradient, rescaleDataRange */ -void QCPStatisticalBox::setMaximum(double value) +void QCPColorScale::setDataRange(const QCPRange &dataRange) { - mMaximum = value; + if (mDataRange.lower != dataRange.lower || mDataRange.upper != dataRange.upper) + { + mDataRange = dataRange; + if (mColorAxis) + mColorAxis.data()->setRange(mDataRange); + emit dataRangeChanged(mDataRange); + } } /*! - Sets a vector of outlier values that will be drawn as circles. Any data points in the sample that - are not within the whiskers (\ref setMinimum, \ref setMaximum) should be considered outliers and - displayed as such. + Sets the scale type of the color scale, i.e. whether values are linearly associated with colors + or logarithmically. - \see setOutlierStyle + It is equivalent to calling QCPColorMap::setDataScaleType on any of the connected color maps. It is + also equivalent to directly accessing the \ref axis and setting its scale type with \ref + QCPAxis::setScaleType. + + \see setDataRange, setGradient */ -void QCPStatisticalBox::setOutliers(const QVector &values) +void QCPColorScale::setDataScaleType(QCPAxis::ScaleType scaleType) { - mOutliers = values; + if (mDataScaleType != scaleType) + { + mDataScaleType = scaleType; + if (mColorAxis) + mColorAxis.data()->setScaleType(mDataScaleType); + if (mDataScaleType == QCPAxis::stLogarithmic) + setDataRange(mDataRange.sanitizedForLogScale()); + emit dataScaleTypeChanged(mDataScaleType); + } } /*! - Sets all parameters of the statistical box plot at once. + Sets the color gradient that will be used to represent data values. - \see setKey, setMinimum, setLowerQuartile, setMedian, setUpperQuartile, setMaximum + It is equivalent to calling QCPColorMap::setGradient on any of the connected color maps. + + \see setDataRange, setDataScaleType */ -void QCPStatisticalBox::setData(double key, double minimum, double lowerQuartile, double median, double upperQuartile, double maximum) +void QCPColorScale::setGradient(const QCPColorGradient &gradient) { - setKey(key); - setMinimum(minimum); - setLowerQuartile(lowerQuartile); - setMedian(median); - setUpperQuartile(upperQuartile); - setMaximum(maximum); + if (mGradient != gradient) + { + mGradient = gradient; + if (mAxisRect) + mAxisRect.data()->mGradientImageInvalidated = true; + emit gradientChanged(mGradient); + } } /*! - Sets the width of the box in key coordinates. - - \see setWhiskerWidth + Sets the axis label of the color scale. This is equivalent to calling \ref QCPAxis::setLabel on + the internal \ref axis. */ -void QCPStatisticalBox::setWidth(double width) +void QCPColorScale::setLabel(const QString &str) { - mWidth = width; + if (!mColorAxis) + { + qDebug() << Q_FUNC_INFO << "internal color axis undefined"; + return; + } + + mColorAxis.data()->setLabel(str); } /*! - Sets the width of the whiskers (\ref setMinimum, \ref setMaximum) in key coordinates. - - \see setWidth + Sets the width (or height, for horizontal color scales) the bar where the gradient is displayed + will have. */ -void QCPStatisticalBox::setWhiskerWidth(double width) +void QCPColorScale::setBarWidth(int width) { - mWhiskerWidth = width; + mBarWidth = width; } /*! - Sets the pen used for drawing the whisker backbone (That's the line parallel to the value axis). + Sets whether the user can drag the data range (\ref setDataRange). - Make sure to set the \a pen capStyle to Qt::FlatCap to prevent the whisker backbone from reaching - a few pixels past the whisker bars, when using a non-zero pen width. - - \see setWhiskerBarPen + Note that \ref QCP::iRangeDrag must be in the QCustomPlot's interactions (\ref + QCustomPlot::setInteractions) to allow range dragging. */ -void QCPStatisticalBox::setWhiskerPen(const QPen &pen) +void QCPColorScale::setRangeDrag(bool enabled) { - mWhiskerPen = pen; + if (!mAxisRect) + { + qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; + return; + } + + if (enabled) + mAxisRect.data()->setRangeDrag(QCPAxis::orientation(mType)); + else + mAxisRect.data()->setRangeDrag(0); } /*! - Sets the pen used for drawing the whisker bars (Those are the lines parallel to the key axis at - each end of the whisker backbone). + Sets whether the user can zoom the data range (\ref setDataRange) by scrolling the mouse wheel. - \see setWhiskerPen + Note that \ref QCP::iRangeZoom must be in the QCustomPlot's interactions (\ref + QCustomPlot::setInteractions) to allow range dragging. */ -void QCPStatisticalBox::setWhiskerBarPen(const QPen &pen) +void QCPColorScale::setRangeZoom(bool enabled) { - mWhiskerBarPen = pen; + if (!mAxisRect) + { + qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; + return; + } + + if (enabled) + mAxisRect.data()->setRangeZoom(QCPAxis::orientation(mType)); + else + mAxisRect.data()->setRangeZoom(0); } /*! - Sets the pen used for drawing the median indicator line inside the statistical box. + Returns a list of all the color maps associated with this color scale. */ -void QCPStatisticalBox::setMedianPen(const QPen &pen) +QList QCPColorScale::colorMaps() const { - mMedianPen = pen; + QList result; + for (int i=0; iplottableCount(); ++i) + { + if (QCPColorMap *cm = qobject_cast(mParentPlot->plottable(i))) + if (cm->colorScale() == this) + result.append(cm); + } + return result; } /*! - Sets the appearance of the outlier data points. + Changes the data range such that all color maps associated with this color scale are fully mapped + to the gradient in the data dimension. - \see setOutliers + \see setDataRange */ -void QCPStatisticalBox::setOutlierStyle(const QCPScatterStyle &style) -{ - mOutlierStyle = style; -} - -/* inherits documentation from base class */ -void QCPStatisticalBox::clearData() +void QCPColorScale::rescaleDataRange(bool onlyVisibleMaps) { - setOutliers(QVector()); - setKey(0); - setMinimum(0); - setLowerQuartile(0); - setMedian(0); - setUpperQuartile(0); - setMaximum(0); + QList maps = colorMaps(); + QCPRange newRange; + bool haveRange = false; + int sign = 0; // TODO: should change this to QCPAbstractPlottable::SignDomain later (currently is protected, maybe move to QCP namespace) + if (mDataScaleType == QCPAxis::stLogarithmic) + sign = (mDataRange.upper < 0 ? -1 : 1); + for (int i=0; irealVisibility() && onlyVisibleMaps) + continue; + QCPRange mapRange; + if (maps.at(i)->colorScale() == this) + { + bool currentFoundRange = true; + mapRange = maps.at(i)->data()->dataBounds(); + if (sign == 1) + { + if (mapRange.lower <= 0 && mapRange.upper > 0) + mapRange.lower = mapRange.upper*1e-3; + else if (mapRange.lower <= 0 && mapRange.upper <= 0) + currentFoundRange = false; + } else if (sign == -1) + { + if (mapRange.upper >= 0 && mapRange.lower < 0) + mapRange.upper = mapRange.lower*1e-3; + else if (mapRange.upper >= 0 && mapRange.lower >= 0) + currentFoundRange = false; + } + if (currentFoundRange) + { + if (!haveRange) + newRange = mapRange; + else + newRange.expand(mapRange); + haveRange = true; + } + } + } + if (haveRange) + { + if (!QCPRange::validRange(newRange)) // likely due to range being zero (plottable has only constant data in this dimension), shift current range to at least center the data + { + double center = (newRange.lower+newRange.upper)*0.5; // upper and lower should be equal anyway, but just to make sure, incase validRange returned false for other reason + if (mDataScaleType == QCPAxis::stLinear) + { + newRange.lower = center-mDataRange.size()/2.0; + newRange.upper = center+mDataRange.size()/2.0; + } else // mScaleType == stLogarithmic + { + newRange.lower = center/qSqrt(mDataRange.upper/mDataRange.lower); + newRange.upper = center*qSqrt(mDataRange.upper/mDataRange.lower); + } + } + setDataRange(newRange); + } } /* inherits documentation from base class */ -double QCPStatisticalBox::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +void QCPColorScale::update(UpdatePhase phase) { - Q_UNUSED(details) - if (onlySelectable && !mSelectable) - return -1; - if (!mKeyAxis || !mValueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return -1; } - - double posKey, posValue; - pixelsToCoords(pos, posKey, posValue); - // quartile box: - QCPRange keyRange(mKey-mWidth*0.5, mKey+mWidth*0.5); - QCPRange valueRange(mLowerQuartile, mUpperQuartile); - if (keyRange.contains(posKey) && valueRange.contains(posValue)) - return mParentPlot->selectionTolerance()*0.99; + QCPLayoutElement::update(phase); + if (!mAxisRect) + { + qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; + return; + } - // min/max whiskers: - if (QCPRange(mMinimum, mMaximum).contains(posValue)) - return qAbs(mKeyAxis.data()->coordToPixel(mKey)-mKeyAxis.data()->coordToPixel(posKey)); + mAxisRect.data()->update(phase); - return -1; + switch (phase) + { + case upMargins: + { + if (mType == QCPAxis::atBottom || mType == QCPAxis::atTop) + { + setMaximumSize(QWIDGETSIZE_MAX, mBarWidth+mAxisRect.data()->margins().top()+mAxisRect.data()->margins().bottom()+margins().top()+margins().bottom()); + setMinimumSize(0, mBarWidth+mAxisRect.data()->margins().top()+mAxisRect.data()->margins().bottom()+margins().top()+margins().bottom()); + } else + { + setMaximumSize(mBarWidth+mAxisRect.data()->margins().left()+mAxisRect.data()->margins().right()+margins().left()+margins().right(), QWIDGETSIZE_MAX); + setMinimumSize(mBarWidth+mAxisRect.data()->margins().left()+mAxisRect.data()->margins().right()+margins().left()+margins().right(), 0); + } + break; + } + case upLayout: + { + mAxisRect.data()->setOuterRect(rect()); + break; + } + default: break; + } } /* inherits documentation from base class */ -void QCPStatisticalBox::draw(QCPPainter *painter) +void QCPColorScale::applyDefaultAntialiasingHint(QCPPainter *painter) const { - if (!mKeyAxis || !mValueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } - - // check data validity if flag set: -#ifdef QCUSTOMPLOT_CHECK_DATA - if (QCP::isInvalidData(mKey, mMedian) || - QCP::isInvalidData(mLowerQuartile, mUpperQuartile) || - QCP::isInvalidData(mMinimum, mMaximum)) - qDebug() << Q_FUNC_INFO << "Data point at" << mKey << "of drawn range has invalid data." << "Plottable name:" << name(); - for (int i=0; isave(); - painter->setClipRect(quartileBox, Qt::IntersectClip); - drawMedian(painter); - painter->restore(); - - drawWhiskers(painter); - drawOutliers(painter); + painter->setAntialiasing(false); } /* inherits documentation from base class */ -void QCPStatisticalBox::drawLegendIcon(QCPPainter *painter, const QRectF &rect) const +void QCPColorScale::mousePressEvent(QMouseEvent *event) { - // draw filled rect: - applyDefaultAntialiasingHint(painter); - painter->setPen(mPen); - painter->setBrush(mBrush); - QRectF r = QRectF(0, 0, rect.width()*0.67, rect.height()*0.67); - r.moveCenter(rect.center()); - painter->drawRect(r); + if (!mAxisRect) + { + qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; + return; + } + mAxisRect.data()->mousePressEvent(event); } -/*! \internal - - Draws the quartile box. \a box is an output parameter that returns the quartile box (in pixel - coordinates) which is used to set the clip rect of the painter before calling \ref drawMedian (so - the median doesn't draw outside the quartile box). -*/ -void QCPStatisticalBox::drawQuartileBox(QCPPainter *painter, QRectF *quartileBox) const +/* inherits documentation from base class */ +void QCPColorScale::mouseMoveEvent(QMouseEvent *event) { - QRectF box; - box.setTopLeft(coordsToPixels(mKey-mWidth*0.5, mUpperQuartile)); - box.setBottomRight(coordsToPixels(mKey+mWidth*0.5, mLowerQuartile)); - applyDefaultAntialiasingHint(painter); - painter->setPen(mainPen()); - painter->setBrush(mainBrush()); - painter->drawRect(box); - if (quartileBox) - *quartileBox = box; + if (!mAxisRect) + { + qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; + return; + } + mAxisRect.data()->mouseMoveEvent(event); } -/*! \internal - - Draws the median line inside the quartile box. -*/ -void QCPStatisticalBox::drawMedian(QCPPainter *painter) const +/* inherits documentation from base class */ +void QCPColorScale::mouseReleaseEvent(QMouseEvent *event) { - QLineF medianLine; - medianLine.setP1(coordsToPixels(mKey-mWidth*0.5, mMedian)); - medianLine.setP2(coordsToPixels(mKey+mWidth*0.5, mMedian)); - applyDefaultAntialiasingHint(painter); - painter->setPen(mMedianPen); - painter->drawLine(medianLine); + if (!mAxisRect) + { + qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; + return; + } + mAxisRect.data()->mouseReleaseEvent(event); } -/*! \internal +/* inherits documentation from base class */ +void QCPColorScale::wheelEvent(QWheelEvent *event) +{ + if (!mAxisRect) + { + qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; + return; + } + mAxisRect.data()->wheelEvent(event); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPColorScaleAxisRectPrivate +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPColorScaleAxisRectPrivate + + \internal + \brief An axis rect subclass for use in a QCPColorScale - Draws both whisker backbones and bars. + This is a private class and not part of the public QCustomPlot interface. + + It provides the axis rect functionality for the QCPColorScale class. */ -void QCPStatisticalBox::drawWhiskers(QCPPainter *painter) const + + +/*! + Creates a new instance, as a child of \a parentColorScale. +*/ +QCPColorScaleAxisRectPrivate::QCPColorScaleAxisRectPrivate(QCPColorScale *parentColorScale) : + QCPAxisRect(parentColorScale->parentPlot(), true), + mParentColorScale(parentColorScale), + mGradientImageInvalidated(true) { - QLineF backboneMin, backboneMax, barMin, barMax; - backboneMax.setPoints(coordsToPixels(mKey, mUpperQuartile), coordsToPixels(mKey, mMaximum)); - backboneMin.setPoints(coordsToPixels(mKey, mLowerQuartile), coordsToPixels(mKey, mMinimum)); - barMax.setPoints(coordsToPixels(mKey-mWhiskerWidth*0.5, mMaximum), coordsToPixels(mKey+mWhiskerWidth*0.5, mMaximum)); - barMin.setPoints(coordsToPixels(mKey-mWhiskerWidth*0.5, mMinimum), coordsToPixels(mKey+mWhiskerWidth*0.5, mMinimum)); - applyErrorBarsAntialiasingHint(painter); - painter->setPen(mWhiskerPen); - painter->drawLine(backboneMin); - painter->drawLine(backboneMax); - painter->setPen(mWhiskerBarPen); - painter->drawLine(barMin); - painter->drawLine(barMax); + setParentLayerable(parentColorScale); + setMinimumMargins(QMargins(0, 0, 0, 0)); + foreach (QCPAxis::AxisType type, QList() << QCPAxis::atBottom << QCPAxis::atTop << QCPAxis::atLeft << QCPAxis::atRight) + { + axis(type)->setVisible(true); + axis(type)->grid()->setVisible(false); + axis(type)->setPadding(0); + connect(axis(type), SIGNAL(selectionChanged(QCPAxis::SelectableParts)), this, SLOT(axisSelectionChanged(QCPAxis::SelectableParts))); + connect(axis(type), SIGNAL(selectableChanged(QCPAxis::SelectableParts)), this, SLOT(axisSelectableChanged(QCPAxis::SelectableParts))); + } + + connect(axis(QCPAxis::atLeft), SIGNAL(rangeChanged(QCPRange)), axis(QCPAxis::atRight), SLOT(setRange(QCPRange))); + connect(axis(QCPAxis::atRight), SIGNAL(rangeChanged(QCPRange)), axis(QCPAxis::atLeft), SLOT(setRange(QCPRange))); + connect(axis(QCPAxis::atBottom), SIGNAL(rangeChanged(QCPRange)), axis(QCPAxis::atTop), SLOT(setRange(QCPRange))); + connect(axis(QCPAxis::atTop), SIGNAL(rangeChanged(QCPRange)), axis(QCPAxis::atBottom), SLOT(setRange(QCPRange))); + connect(axis(QCPAxis::atLeft), SIGNAL(scaleTypeChanged(QCPAxis::ScaleType)), axis(QCPAxis::atRight), SLOT(setScaleType(QCPAxis::ScaleType))); + connect(axis(QCPAxis::atRight), SIGNAL(scaleTypeChanged(QCPAxis::ScaleType)), axis(QCPAxis::atLeft), SLOT(setScaleType(QCPAxis::ScaleType))); + connect(axis(QCPAxis::atBottom), SIGNAL(scaleTypeChanged(QCPAxis::ScaleType)), axis(QCPAxis::atTop), SLOT(setScaleType(QCPAxis::ScaleType))); + connect(axis(QCPAxis::atTop), SIGNAL(scaleTypeChanged(QCPAxis::ScaleType)), axis(QCPAxis::atBottom), SLOT(setScaleType(QCPAxis::ScaleType))); + + // make layer transfers of color scale transfer to axis rect and axes + // the axes must be set after axis rect, such that they appear above color gradient drawn by axis rect: + connect(parentColorScale, SIGNAL(layerChanged(QCPLayer*)), this, SLOT(setLayer(QCPLayer*))); + foreach (QCPAxis::AxisType type, QList() << QCPAxis::atBottom << QCPAxis::atTop << QCPAxis::atLeft << QCPAxis::atRight) + connect(parentColorScale, SIGNAL(layerChanged(QCPLayer*)), axis(type), SLOT(setLayer(QCPLayer*))); } /*! \internal - - Draws the outlier scatter points. + Updates the color gradient image if necessary, by calling \ref updateGradientImage, then draws + it. Then the axes are drawn by calling the \ref QCPAxisRect::draw base class implementation. */ -void QCPStatisticalBox::drawOutliers(QCPPainter *painter) const +void QCPColorScaleAxisRectPrivate::draw(QCPPainter *painter) { - applyScattersAntialiasingHint(painter); - mOutlierStyle.applyTo(painter, mPen); - for (int i=0; imColorAxis) + { + mirrorHorz = mParentColorScale->mColorAxis.data()->rangeReversed() && (mParentColorScale->type() == QCPAxis::atBottom || mParentColorScale->type() == QCPAxis::atTop); + mirrorVert = mParentColorScale->mColorAxis.data()->rangeReversed() && (mParentColorScale->type() == QCPAxis::atLeft || mParentColorScale->type() == QCPAxis::atRight); + } + + painter->drawImage(rect(), mGradientImage.mirrored(mirrorHorz, mirrorVert)); + QCPAxisRect::draw(painter); } -/* inherits documentation from base class */ -QCPRange QCPStatisticalBox::getKeyRange(bool &validRange, SignDomain inSignDomain) const +/*! \internal + + Uses the current gradient of the parent \ref QCPColorScale (specified in the constructor) to + generate a gradient image. This gradient image will be used in the \ref draw method. +*/ +void QCPColorScaleAxisRectPrivate::updateGradientImage() { - validRange = mWidth > 0; - if (inSignDomain == sdBoth) + if (rect().isEmpty()) + return; + + int n = mParentColorScale->mGradient.levelCount(); + int w, h; + QVector data(n); + for (int i=0; imType == QCPAxis::atBottom || mParentColorScale->mType == QCPAxis::atTop) { - return QCPRange(mKey-mWidth*0.5, mKey+mWidth*0.5); - } else if (inSignDomain == sdNegative) + w = n; + h = rect().height(); + mGradientImage = QImage(w, h, QImage::Format_RGB32); + QVector pixels; + for (int y=0; y(mGradientImage.scanLine(y))); + mParentColorScale->mGradient.colorize(data.constData(), QCPRange(0, n-1), pixels.first(), n); + for (int y=1; y(mGradientImage.scanLine(y)); + const QRgb lineColor = mParentColorScale->mGradient.color(data[h-1-y], QCPRange(0, n-1)); + for (int x=0; x() << QCPAxis::atBottom << QCPAxis::atTop << QCPAxis::atLeft << QCPAxis::atRight) { - if (mKey-mWidth*0.5 > 0) - return QCPRange(mKey-mWidth*0.5, mKey+mWidth*0.5); - else if (mKey > 0) - return QCPRange(mKey, mKey+mWidth*0.5); - else + if (QCPAxis *senderAxis = qobject_cast(sender())) + if (senderAxis->axisType() == type) + continue; + + if (axis(type)->selectableParts().testFlag(QCPAxis::spAxis)) { - validRange = false; - return QCPRange(); + if (selectedParts.testFlag(QCPAxis::spAxis)) + axis(type)->setSelectedParts(axis(type)->selectedParts() | QCPAxis::spAxis); + else + axis(type)->setSelectedParts(axis(type)->selectedParts() & ~QCPAxis::spAxis); } } - validRange = false; - return QCPRange(); } -/* inherits documentation from base class */ -QCPRange QCPStatisticalBox::getValueRange(bool &validRange, SignDomain inSignDomain) const +/*! \internal + + This slot is connected to the selectableChanged signals of the four axes in the constructor. It + synchronizes the selectability of the axes. +*/ +void QCPColorScaleAxisRectPrivate::axisSelectableChanged(QCPAxis::SelectableParts selectableParts) { - if (inSignDomain == sdBoth) - { - double lower = qMin(mMinimum, qMin(mMedian, mLowerQuartile)); - double upper = qMax(mMaximum, qMax(mMedian, mUpperQuartile)); - for (int i=0; i upper) - upper = mOutliers.at(i); - } - validRange = upper > lower; - return QCPRange(lower, upper); - } else + // synchronize axis base selectability: + foreach (QCPAxis::AxisType type, QList() << QCPAxis::atBottom << QCPAxis::atTop << QCPAxis::atLeft << QCPAxis::atRight) { - QVector values; // values that must be considered (i.e. all outliers and the five box-parameters) - values.reserve(mOutliers.size() + 5); - values << mMaximum << mUpperQuartile << mMedian << mLowerQuartile << mMinimum; - values << mOutliers; - // go through values and find the ones in legal range: - bool haveUpper = false; - bool haveLower = false; - double upper = 0; - double lower = 0; - for (int i=0; i 0)) - { - if (values.at(i) > upper || !haveUpper) - { - upper = values.at(i); - haveUpper = true; - } - if (values.at(i) < lower || !haveLower) - { - lower = values.at(i); - haveLower = true; - } - } - } - // return the bounds if we found some sensible values: - if (haveLower && haveUpper && lower < upper) - { - validRange = true; - return QCPRange(lower, upper); - } else + if (QCPAxis *senderAxis = qobject_cast(sender())) + if (senderAxis->axisType() == type) + continue; + + if (axis(type)->selectableParts().testFlag(QCPAxis::spAxis)) { - validRange = false; - return QCPRange(); + if (selectableParts.testFlag(QCPAxis::spAxis)) + axis(type)->setSelectableParts(axis(type)->selectableParts() | QCPAxis::spAxis); + else + axis(type)->setSelectableParts(axis(type)->selectableParts() & ~QCPAxis::spAxis); } } } //////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////// QCPItemStraightLine +//////////////////// QCPData //////////////////////////////////////////////////////////////////////////////////////////////////// -/*! \class QCPItemStraightLine - \brief A straight line that spans infinitely in both directions - - \image html QCPItemStraightLine.png "Straight line example. Blue dotted circles are anchors, solid blue discs are positions." - - It has two positions, \a point1 and \a point2, which define the straight line. -*/ - -/*! - Creates a straight line item and sets default values. +/*! \class QCPData + \brief Holds the data of one single data point for QCPGraph. - The constructed item can be added to the plot with QCustomPlot::addItem. -*/ -QCPItemStraightLine::QCPItemStraightLine(QCustomPlot *parentPlot) : - QCPAbstractItem(parentPlot), - point1(createPosition("point1")), - point2(createPosition("point2")) -{ - point1->setCoords(0, 0); - point2->setCoords(1, 1); + The container for storing multiple data points is \ref QCPDataMap. - setPen(QPen(Qt::black)); - setSelectedPen(QPen(Qt::blue,2)); -} - -QCPItemStraightLine::~QCPItemStraightLine() -{ -} + The stored data is: + \li \a key: coordinate on the key axis of this data point + \li \a value: coordinate on the value axis of this data point + \li \a keyErrorMinus: negative error in the key dimension (for error bars) + \li \a keyErrorPlus: positive error in the key dimension (for error bars) + \li \a valueErrorMinus: negative error in the value dimension (for error bars) + \li \a valueErrorPlus: positive error in the value dimension (for error bars) + + \see QCPDataMap +*/ /*! - Sets the pen that will be used to draw the line - - \see setSelectedPen + Constructs a data point with key, value and all errors set to zero. */ -void QCPItemStraightLine::setPen(const QPen &pen) +QCPData::QCPData() : + key(0), + value(0), + keyErrorPlus(0), + keyErrorMinus(0), + valueErrorPlus(0), + valueErrorMinus(0) { - mPen = pen; } /*! - Sets the pen that will be used to draw the line when selected - - \see setPen, setSelected + Constructs a data point with the specified \a key and \a value. All errors are set to zero. */ -void QCPItemStraightLine::setSelectedPen(const QPen &pen) +QCPData::QCPData(double key, double value) : + key(key), + value(value), + keyErrorPlus(0), + keyErrorMinus(0), + valueErrorPlus(0), + valueErrorMinus(0) { - mSelectedPen = pen; } -/* inherits documentation from base class */ -double QCPItemStraightLine::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const -{ - Q_UNUSED(details) - if (onlySelectable && !mSelectable) - return -1; - - return distToStraightLine(QVector2D(point1->pixelPoint()), QVector2D(point2->pixelPoint()-point1->pixelPoint()), QVector2D(pos)); -} -/* inherits documentation from base class */ -void QCPItemStraightLine::draw(QCPPainter *painter) -{ - QVector2D start(point1->pixelPoint()); - QVector2D end(point2->pixelPoint()); - // get visible segment of straight line inside clipRect: - double clipPad = mainPen().widthF(); - QLineF line = getRectClippedStraightLine(start, end-start, clipRect().adjusted(-clipPad, -clipPad, clipPad, clipPad)); - // paint visible segment, if existent: - if (!line.isNull()) - { - painter->setPen(mainPen()); - painter->drawLine(line); - } -} +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPGraph +//////////////////////////////////////////////////////////////////////////////////////////////////// -/*! \internal +/*! \class QCPGraph + \brief A plottable representing a graph in a plot. - finds the shortest distance of \a point to the straight line defined by the base point \a - base and the direction vector \a vec. + \image html QCPGraph.png - This is a helper function for \ref selectTest. -*/ -double QCPItemStraightLine::distToStraightLine(const QVector2D &base, const QVector2D &vec, const QVector2D &point) const -{ - return qAbs((base.y()-point.y())*vec.x()-(base.x()-point.x())*vec.y())/vec.length(); -} - -/*! \internal + Usually QCustomPlot creates graphs internally via QCustomPlot::addGraph and the resulting + instance is accessed via QCustomPlot::graph. - Returns the section of the straight line defined by \a base and direction vector \a - vec, that is visible in the specified \a rect. + To plot data, assign it with the \ref setData or \ref addData functions. Alternatively, you can + also access and modify the graph's data via the \ref data method, which returns a pointer to the + internal \ref QCPDataMap. - This is a helper function for \ref draw. -*/ -QLineF QCPItemStraightLine::getRectClippedStraightLine(const QVector2D &base, const QVector2D &vec, const QRect &rect) const -{ - double bx, by; - double gamma; - QLineF result; - if (vec.x() == 0 && vec.y() == 0) - return result; - if (qFuzzyIsNull(vec.x())) // line is vertical - { - // check top of rect: - bx = rect.left(); - by = rect.top(); - gamma = base.x()-bx + (by-base.y())*vec.x()/vec.y(); - if (gamma >= 0 && gamma <= rect.width()) - result.setLine(bx+gamma, rect.top(), bx+gamma, rect.bottom()); // no need to check bottom because we know line is vertical - } else if (qFuzzyIsNull(vec.y())) // line is horizontal - { - // check left of rect: - bx = rect.left(); - by = rect.top(); - gamma = base.y()-by + (bx-base.x())*vec.y()/vec.x(); - if (gamma >= 0 && gamma <= rect.height()) - result.setLine(rect.left(), by+gamma, rect.right(), by+gamma); // no need to check right because we know line is horizontal - } else // line is skewed - { - QList pointVectors; - // check top of rect: - bx = rect.left(); - by = rect.top(); - gamma = base.x()-bx + (by-base.y())*vec.x()/vec.y(); - if (gamma >= 0 && gamma <= rect.width()) - pointVectors.append(QVector2D(bx+gamma, by)); - // check bottom of rect: - bx = rect.left(); - by = rect.bottom(); - gamma = base.x()-bx + (by-base.y())*vec.x()/vec.y(); - if (gamma >= 0 && gamma <= rect.width()) - pointVectors.append(QVector2D(bx+gamma, by)); - // check left of rect: - bx = rect.left(); - by = rect.top(); - gamma = base.y()-by + (bx-base.x())*vec.y()/vec.x(); - if (gamma >= 0 && gamma <= rect.height()) - pointVectors.append(QVector2D(bx, by+gamma)); - // check right of rect: - bx = rect.right(); - by = rect.top(); - gamma = base.y()-by + (bx-base.x())*vec.y()/vec.x(); - if (gamma >= 0 && gamma <= rect.height()) - pointVectors.append(QVector2D(bx, by+gamma)); - - // evaluate points: - if (pointVectors.size() == 2) - { - result.setPoints(pointVectors.at(0).toPointF(), pointVectors.at(1).toPointF()); - } else if (pointVectors.size() > 2) - { - // line probably goes through corner of rect, and we got two points there. single out the point pair with greatest distance: - double distSqrMax = 0; - QVector2D pv1, pv2; - for (int i=0; i distSqrMax) - { - pv1 = pointVectors.at(i); - pv2 = pointVectors.at(k); - distSqrMax = distSqr; - } - } - } - result.setPoints(pv1.toPointF(), pv2.toPointF()); - } - } - return result; -} - -/*! \internal + Graphs are used to display single-valued data. Single-valued means that there should only be one + data point per unique key coordinate. In other words, the graph can't have \a loops. If you do + want to plot non-single-valued curves, rather use the QCPCurve plottable. + + \section appearance Changing the appearance + + The appearance of the graph is mainly determined by the line style, scatter style, brush and pen + of the graph (\ref setLineStyle, \ref setScatterStyle, \ref setBrush, \ref setPen). + + \subsection filling Filling under or between graphs + + QCPGraph knows two types of fills: Normal graph fills towards the zero-value-line parallel to + the key axis of the graph, and fills between two graphs, called channel fills. To enable a fill, + just set a brush with \ref setBrush which is neither Qt::NoBrush nor fully transparent. + + By default, a normal fill towards the zero-value-line will be drawn. To set up a channel fill + between this graph and another one, call \ref setChannelFillGraph with the other graph as + parameter. - Returns the pen that should be used for drawing lines. Returns mPen when the - item is not selected and mSelectedPen when it is. + \see QCustomPlot::addGraph, QCustomPlot::graph, QCPLegend::addGraph */ -QPen QCPItemStraightLine::mainPen() const -{ - return mSelected ? mSelectedPen : mPen; -} - - -//////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////// QCPItemLine -//////////////////////////////////////////////////////////////////////////////////////////////////// -/*! \class QCPItemLine - \brief A line from one point to another - - \image html QCPItemLine.png "Line example. Blue dotted circles are anchors, solid blue discs are positions." +/* start of documentation of inline functions */ - It has two positions, \a start and \a end, which define the end points of the line. +/*! \fn QCPDataMap *QCPGraph::data() const - With \ref setHead and \ref setTail you may set different line ending styles, e.g. to create an arrow. + Returns a pointer to the internal data storage of type \ref QCPDataMap. You may use it to + directly manipulate the data, which may be more convenient and faster than using the regular \ref + setData or \ref addData methods, in certain situations. */ +/* end of documentation of inline functions */ + /*! - Creates a line item and sets default values. + Constructs a graph which uses \a keyAxis as its key axis ("x") and \a valueAxis as its value + axis ("y"). \a keyAxis and \a valueAxis must reside in the same QCustomPlot instance and not have + the same orientation. If either of these restrictions is violated, a corresponding message is + printed to the debug output (qDebug), the construction is not aborted, though. - The constructed item can be added to the plot with QCustomPlot::addItem. + The constructed QCPGraph can be added to the plot with QCustomPlot::addPlottable, QCustomPlot + then takes ownership of the graph. + + To directly create a graph inside a plot, you can also use the simpler QCustomPlot::addGraph function. */ -QCPItemLine::QCPItemLine(QCustomPlot *parentPlot) : - QCPAbstractItem(parentPlot), - start(createPosition("start")), - end(createPosition("end")) +QCPGraph::QCPGraph(QCPAxis *keyAxis, QCPAxis *valueAxis) : + QCPAbstractPlottable(keyAxis, valueAxis) { - start->setCoords(0, 0); - end->setCoords(1, 1); + mData = new QCPDataMap; - setPen(QPen(Qt::black)); - setSelectedPen(QPen(Qt::blue,2)); + setPen(QPen(Qt::blue, 0)); + setErrorPen(QPen(Qt::black)); + setBrush(Qt::NoBrush); + setSelectedPen(QPen(QColor(80, 80, 255), 2.5)); + setSelectedBrush(Qt::NoBrush); + + setLineStyle(lsLine); + setErrorType(etNone); + setErrorBarSize(6); + setErrorBarSkipSymbol(true); + setChannelFillGraph(0); + setAdaptiveSampling(true); } -QCPItemLine::~QCPItemLine() +QCPGraph::~QCPGraph() { + delete mData; } /*! - Sets the pen that will be used to draw the line + Replaces the current data with the provided \a data. - \see setSelectedPen + If \a copy is set to true, data points in \a data will only be copied. if false, the graph + takes ownership of the passed data and replaces the internal data pointer with it. This is + significantly faster than copying for large datasets. + + Alternatively, you can also access and modify the graph's data via the \ref data method, which + returns a pointer to the internal \ref QCPDataMap. */ -void QCPItemLine::setPen(const QPen &pen) +void QCPGraph::setData(QCPDataMap *data, bool copy) { - mPen = pen; + if (copy) + { + *mData = *data; + } else + { + delete mData; + mData = data; + } } -/*! - Sets the pen that will be used to draw the line when selected +/*! \overload - \see setPen, setSelected + Replaces the current data with the provided points in \a key and \a value pairs. The provided + vectors should have equal length. Else, the number of added points will be the size of the + smallest vector. */ -void QCPItemLine::setSelectedPen(const QPen &pen) +void QCPGraph::setData(const QVector &key, const QVector &value) { - mSelectedPen = pen; + mData->clear(); + int n = key.size(); + n = qMin(n, value.size()); + QCPData newData; + for (int i=0; iinsertMulti(newData.key, newData); + } } /*! - Sets the line ending style of the head. The head corresponds to the \a end position. - - Note that due to the overloaded QCPLineEnding constructor, you may directly specify - a QCPLineEnding::EndingStyle here, e.g. \code setHead(QCPLineEnding::esSpikeArrow) \endcode + Replaces the current data with the provided points in \a key and \a value pairs. Additionally the + symmetrical value error of the data points are set to the values in \a valueError. + For error bars to show appropriately, see \ref setErrorType. + The provided vectors should have equal length. Else, the number of added points will be the size of the + smallest vector. - \see setTail + For asymmetrical errors (plus different from minus), see the overloaded version of this function. */ -void QCPItemLine::setHead(const QCPLineEnding &head) +void QCPGraph::setDataValueError(const QVector &key, const QVector &value, const QVector &valueError) { - mHead = head; + mData->clear(); + int n = key.size(); + n = qMin(n, value.size()); + n = qMin(n, valueError.size()); + QCPData newData; + for (int i=0; iinsertMulti(key[i], newData); + } } /*! - Sets the line ending style of the tail. The tail corresponds to the \a start position. - - Note that due to the overloaded QCPLineEnding constructor, you may directly specify - a QCPLineEnding::EndingStyle here, e.g. \code setTail(QCPLineEnding::esSpikeArrow) \endcode - - \see setHead + \overload + Replaces the current data with the provided points in \a key and \a value pairs. Additionally the + negative value error of the data points are set to the values in \a valueErrorMinus, the positive + value error to \a valueErrorPlus. + For error bars to show appropriately, see \ref setErrorType. + The provided vectors should have equal length. Else, the number of added points will be the size of the + smallest vector. */ -void QCPItemLine::setTail(const QCPLineEnding &tail) -{ - mTail = tail; -} - -/* inherits documentation from base class */ -double QCPItemLine::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +void QCPGraph::setDataValueError(const QVector &key, const QVector &value, const QVector &valueErrorMinus, const QVector &valueErrorPlus) { - Q_UNUSED(details) - if (onlySelectable && !mSelectable) - return -1; - - return qSqrt(distSqrToLine(start->pixelPoint(), end->pixelPoint(), pos)); -} - -/* inherits documentation from base class */ -void QCPItemLine::draw(QCPPainter *painter) -{ - QVector2D startVec(start->pixelPoint()); - QVector2D endVec(end->pixelPoint()); - if (startVec.toPoint() == endVec.toPoint()) - return; - // get visible segment of straight line inside clipRect: - double clipPad = qMax(mHead.boundingDistance(), mTail.boundingDistance()); - clipPad = qMax(clipPad, (double)mainPen().widthF()); - QLineF line = getRectClippedLine(startVec, endVec, clipRect().adjusted(-clipPad, -clipPad, clipPad, clipPad)); - // paint visible segment, if existent: - if (!line.isNull()) + mData->clear(); + int n = key.size(); + n = qMin(n, value.size()); + n = qMin(n, valueErrorMinus.size()); + n = qMin(n, valueErrorPlus.size()); + QCPData newData; + for (int i=0; isetPen(mainPen()); - painter->drawLine(line); - painter->setBrush(Qt::SolidPattern); - if (mTail.style() != QCPLineEnding::esNone) - mTail.draw(painter, startVec, startVec-endVec); - if (mHead.style() != QCPLineEnding::esNone) - mHead.draw(painter, endVec, endVec-startVec); + newData.key = key[i]; + newData.value = value[i]; + newData.valueErrorMinus = valueErrorMinus[i]; + newData.valueErrorPlus = valueErrorPlus[i]; + mData->insertMulti(key[i], newData); } } -/*! \internal - - Returns the section of the line defined by \a start and \a end, that is visible in the specified - \a rect. +/*! + Replaces the current data with the provided points in \a key and \a value pairs. Additionally the + symmetrical key error of the data points are set to the values in \a keyError. + For error bars to show appropriately, see \ref setErrorType. + The provided vectors should have equal length. Else, the number of added points will be the size of the + smallest vector. - This is a helper function for \ref draw. + For asymmetrical errors (plus different from minus), see the overloaded version of this function. */ -QLineF QCPItemLine::getRectClippedLine(const QVector2D &start, const QVector2D &end, const QRect &rect) const +void QCPGraph::setDataKeyError(const QVector &key, const QVector &value, const QVector &keyError) { - bool containsStart = rect.contains(start.x(), start.y()); - bool containsEnd = rect.contains(end.x(), end.y()); - if (containsStart && containsEnd) - return QLineF(start.toPointF(), end.toPointF()); - - QVector2D base = start; - QVector2D vec = end-start; - double bx, by; - double gamma, mu; - QLineF result; - QList pointVectors; - - if (!qFuzzyIsNull(vec.y())) // line is not horizontal + mData->clear(); + int n = key.size(); + n = qMin(n, value.size()); + n = qMin(n, keyError.size()); + QCPData newData; + for (int i=0; i= 0 && mu <= 1) - { - gamma = base.x()-bx + mu*vec.x(); - if (gamma >= 0 && gamma <= rect.width()) - pointVectors.append(QVector2D(bx+gamma, by)); - } - // check bottom of rect: - bx = rect.left(); - by = rect.bottom(); - mu = (by-base.y())/vec.y(); - if (mu >= 0 && mu <= 1) - { - gamma = base.x()-bx + mu*vec.x(); - if (gamma >= 0 && gamma <= rect.width()) - pointVectors.append(QVector2D(bx+gamma, by)); - } + newData.key = key[i]; + newData.value = value[i]; + newData.keyErrorMinus = keyError[i]; + newData.keyErrorPlus = keyError[i]; + mData->insertMulti(key[i], newData); } - if (!qFuzzyIsNull(vec.x())) // line is not vertical +} + +/*! + \overload + Replaces the current data with the provided points in \a key and \a value pairs. Additionally the + negative key error of the data points are set to the values in \a keyErrorMinus, the positive + key error to \a keyErrorPlus. + For error bars to show appropriately, see \ref setErrorType. + The provided vectors should have equal length. Else, the number of added points will be the size of the + smallest vector. +*/ +void QCPGraph::setDataKeyError(const QVector &key, const QVector &value, const QVector &keyErrorMinus, const QVector &keyErrorPlus) +{ + mData->clear(); + int n = key.size(); + n = qMin(n, value.size()); + n = qMin(n, keyErrorMinus.size()); + n = qMin(n, keyErrorPlus.size()); + QCPData newData; + for (int i=0; i= 0 && mu <= 1) - { - gamma = base.y()-by + mu*vec.y(); - if (gamma >= 0 && gamma <= rect.height()) - pointVectors.append(QVector2D(bx, by+gamma)); - } - // check right of rect: - bx = rect.right(); - by = rect.top(); - mu = (bx-base.x())/vec.x(); - if (mu >= 0 && mu <= 1) - { - gamma = base.y()-by + mu*vec.y(); - if (gamma >= 0 && gamma <= rect.height()) - pointVectors.append(QVector2D(bx, by+gamma)); - } + newData.key = key[i]; + newData.value = value[i]; + newData.keyErrorMinus = keyErrorMinus[i]; + newData.keyErrorPlus = keyErrorPlus[i]; + mData->insertMulti(key[i], newData); } +} + +/*! + Replaces the current data with the provided points in \a key and \a value pairs. Additionally the + symmetrical key and value errors of the data points are set to the values in \a keyError and \a valueError. + For error bars to show appropriately, see \ref setErrorType. + The provided vectors should have equal length. Else, the number of added points will be the size of the + smallest vector. - if (containsStart) - pointVectors.append(start); - if (containsEnd) - pointVectors.append(end); - - // evaluate points: - if (pointVectors.size() == 2) - { - result.setPoints(pointVectors.at(0).toPointF(), pointVectors.at(1).toPointF()); - } else if (pointVectors.size() > 2) + For asymmetrical errors (plus different from minus), see the overloaded version of this function. +*/ +void QCPGraph::setDataBothError(const QVector &key, const QVector &value, const QVector &keyError, const QVector &valueError) +{ + mData->clear(); + int n = key.size(); + n = qMin(n, value.size()); + n = qMin(n, valueError.size()); + n = qMin(n, keyError.size()); + QCPData newData; + for (int i=0; i distSqrMax) - { - pv1 = pointVectors.at(i); - pv2 = pointVectors.at(k); - distSqrMax = distSqr; - } - } - } - result.setPoints(pv1.toPointF(), pv2.toPointF()); + newData.key = key[i]; + newData.value = value[i]; + newData.keyErrorMinus = keyError[i]; + newData.keyErrorPlus = keyError[i]; + newData.valueErrorMinus = valueError[i]; + newData.valueErrorPlus = valueError[i]; + mData->insertMulti(key[i], newData); } - return result; } -/*! \internal - - Returns the pen that should be used for drawing lines. Returns mPen when the - item is not selected and mSelectedPen when it is. +/*! + \overload + Replaces the current data with the provided points in \a key and \a value pairs. Additionally the + negative key and value errors of the data points are set to the values in \a keyErrorMinus and \a valueErrorMinus. The positive + key and value errors are set to the values in \a keyErrorPlus \a valueErrorPlus. + For error bars to show appropriately, see \ref setErrorType. + The provided vectors should have equal length. Else, the number of added points will be the size of the + smallest vector. */ -QPen QCPItemLine::mainPen() const +void QCPGraph::setDataBothError(const QVector &key, const QVector &value, const QVector &keyErrorMinus, const QVector &keyErrorPlus, const QVector &valueErrorMinus, const QVector &valueErrorPlus) { - return mSelected ? mSelectedPen : mPen; + mData->clear(); + int n = key.size(); + n = qMin(n, value.size()); + n = qMin(n, valueErrorMinus.size()); + n = qMin(n, valueErrorPlus.size()); + n = qMin(n, keyErrorMinus.size()); + n = qMin(n, keyErrorPlus.size()); + QCPData newData; + for (int i=0; iinsertMulti(key[i], newData); + } } -//////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////// QCPItemCurve -//////////////////////////////////////////////////////////////////////////////////////////////////// - -/*! \class QCPItemCurve - \brief A curved line from one point to another - - \image html QCPItemCurve.png "Curve example. Blue dotted circles are anchors, solid blue discs are positions." - - It has four positions, \a start and \a end, which define the end points of the line, and two - control points which define the direction the line exits from the start and the direction from - which it approaches the end: \a startDir and \a endDir. - - With \ref setHead and \ref setTail you may set different line ending styles, e.g. to create an - arrow. +/*! + Sets how the single data points are connected in the plot. For scatter-only plots, set \a ls to + \ref lsNone and \ref setScatterStyle to the desired scatter style. - Often it is desirable for the control points to stay at fixed relative positions to the start/end - point. This can be achieved by setting the parent anchor e.g. of \a startDir simply to \a start, - and then specify the desired pixel offset with QCPItemPosition::setCoords on \a startDir. + \see setScatterStyle */ +void QCPGraph::setLineStyle(LineStyle ls) +{ + mLineStyle = ls; +} /*! - Creates a curve item and sets default values. + Sets the visual appearance of single data points in the plot. If set to \ref QCPScatterStyle::ssNone, no scatter points + are drawn (e.g. for line-only-plots with appropriate line style). - The constructed item can be added to the plot with QCustomPlot::addItem. + \see QCPScatterStyle, setLineStyle */ -QCPItemCurve::QCPItemCurve(QCustomPlot *parentPlot) : - QCPAbstractItem(parentPlot), - start(createPosition("start")), - startDir(createPosition("startDir")), - endDir(createPosition("endDir")), - end(createPosition("end")) -{ - start->setCoords(0, 0); - startDir->setCoords(0.5, 0); - endDir->setCoords(0, 0.5); - end->setCoords(1, 1); - - setPen(QPen(Qt::black)); - setSelectedPen(QPen(Qt::blue,2)); -} - -QCPItemCurve::~QCPItemCurve() +void QCPGraph::setScatterStyle(const QCPScatterStyle &style) { + mScatterStyle = style; } /*! - Sets the pen that will be used to draw the line - - \see setSelectedPen + Sets which kind of error bars (Key Error, Value Error or both) should be drawn on each data + point. If you set \a errorType to something other than \ref etNone, make sure to actually pass + error data via the specific setData functions along with the data points (e.g. \ref + setDataValueError, \ref setDataKeyError, \ref setDataBothError). + + \see ErrorType */ -void QCPItemCurve::setPen(const QPen &pen) +void QCPGraph::setErrorType(ErrorType errorType) { - mPen = pen; + mErrorType = errorType; } /*! - Sets the pen that will be used to draw the line when selected - - \see setPen, setSelected + Sets the pen with which the error bars will be drawn. + \see setErrorBarSize, setErrorType */ -void QCPItemCurve::setSelectedPen(const QPen &pen) +void QCPGraph::setErrorPen(const QPen &pen) { - mSelectedPen = pen; + mErrorPen = pen; } /*! - Sets the line ending style of the head. The head corresponds to the \a end position. - - Note that due to the overloaded QCPLineEnding constructor, you may directly specify - a QCPLineEnding::EndingStyle here, e.g. \code setHead(QCPLineEnding::esSpikeArrow) \endcode - - \see setTail + Sets the width of the handles at both ends of an error bar in pixels. */ -void QCPItemCurve::setHead(const QCPLineEnding &head) +void QCPGraph::setErrorBarSize(double size) { - mHead = head; + mErrorBarSize = size; } /*! - Sets the line ending style of the tail. The tail corresponds to the \a start position. + If \a enabled is set to true, the error bar will not be drawn as a solid line under the scatter symbol but + leave some free space around the symbol. - Note that due to the overloaded QCPLineEnding constructor, you may directly specify - a QCPLineEnding::EndingStyle here, e.g. \code setTail(QCPLineEnding::esSpikeArrow) \endcode + This feature uses the current scatter size (\ref QCPScatterStyle::setSize) to determine the size + of the area to leave blank. So when drawing Pixmaps as scatter points (\ref + QCPScatterStyle::ssPixmap), the scatter size must be set manually to a value corresponding to the + size of the Pixmap, if the error bars should leave gaps to its boundaries. - \see setHead + \ref setErrorType, setErrorBarSize, setScatterStyle */ -void QCPItemCurve::setTail(const QCPLineEnding &tail) +void QCPGraph::setErrorBarSkipSymbol(bool enabled) { - mTail = tail; + mErrorBarSkipSymbol = enabled; } -/* inherits documentation from base class */ -double QCPItemCurve::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const -{ - Q_UNUSED(details) - if (onlySelectable && !mSelectable) - return -1; - - QPointF startVec(start->pixelPoint()); - QPointF startDirVec(startDir->pixelPoint()); - QPointF endDirVec(endDir->pixelPoint()); - QPointF endVec(end->pixelPoint()); - - QPainterPath cubicPath(startVec); - cubicPath.cubicTo(startDirVec, endDirVec, endVec); +/*! + Sets the target graph for filling the area between this graph and \a targetGraph with the current + brush (\ref setBrush). - QPolygonF polygon = cubicPath.toSubpathPolygons().first(); - double minDistSqr = std::numeric_limits::max(); - for (int i=1; ipixelPoint()); - QPointF startDirVec(startDir->pixelPoint()); - QPointF endDirVec(endDir->pixelPoint()); - QPointF endVec(end->pixelPoint()); - if (QVector2D(endVec-startVec).length() > 1e10) // too large curves cause crash + // prevent setting channel target to this graph itself: + if (targetGraph == this) + { + qDebug() << Q_FUNC_INFO << "targetGraph is this graph itself"; + mChannelFillGraph = 0; return; - - QPainterPath cubicPath(startVec); - cubicPath.cubicTo(startDirVec, endDirVec, endVec); - - // paint visible segment, if existent: - QRect clip = clipRect().adjusted(-mainPen().widthF(), -mainPen().widthF(), mainPen().widthF(), mainPen().widthF()); - QRect cubicRect = cubicPath.controlPointRect().toRect(); - if (cubicRect.isEmpty()) // may happen when start and end exactly on same x or y position - cubicRect.adjust(0, 0, 1, 1); - if (clip.intersects(cubicRect)) + } + // prevent setting channel target to a graph not in the plot: + if (targetGraph && targetGraph->mParentPlot != mParentPlot) { - painter->setPen(mainPen()); - painter->drawPath(cubicPath); - painter->setBrush(Qt::SolidPattern); - if (mTail.style() != QCPLineEnding::esNone) - mTail.draw(painter, QVector2D(startVec), M_PI-cubicPath.angleAtPercent(0)/180.0*M_PI); - if (mHead.style() != QCPLineEnding::esNone) - mHead.draw(painter, QVector2D(endVec), -cubicPath.angleAtPercent(1)/180.0*M_PI); + qDebug() << Q_FUNC_INFO << "targetGraph not in same plot"; + mChannelFillGraph = 0; + return; } + + mChannelFillGraph = targetGraph; } -/*! \internal - - Returns the pen that should be used for drawing lines. Returns mPen when the - item is not selected and mSelectedPen when it is. +/*! + Sets whether adaptive sampling shall be used when plotting this graph. QCustomPlot's adaptive + sampling technique can drastically improve the replot performance for graphs with a larger number + of points (e.g. above 10,000), without notably changing the appearance of the graph. + + By default, adaptive sampling is enabled. Even if enabled, QCustomPlot decides whether adaptive + sampling shall actually be used on a per-graph basis. So leaving adaptive sampling enabled has no + disadvantage in almost all cases. + + \image html adaptive-sampling-line.png "A line plot of 500,000 points without and with adaptive sampling" + + As can be seen, line plots experience no visual degradation from adaptive sampling. Outliers are + reproduced reliably, as well as the overall shape of the data set. The replot time reduces + dramatically though. This allows QCustomPlot to display large amounts of data in realtime. + + \image html adaptive-sampling-scatter.png "A scatter plot of 100,000 points without and with adaptive sampling" + + Care must be taken when using high-density scatter plots in combination with adaptive sampling. + The adaptive sampling algorithm treats scatter plots more carefully than line plots which still + gives a significant reduction of replot times, but not quite as much as for line plots. This is + because scatter plots inherently need more data points to be preserved in order to still resemble + the original, non-adaptive-sampling plot. As shown above, the results still aren't quite + identical, as banding occurs for the outer data points. This is in fact intentional, such that + the boundaries of the data cloud stay visible to the viewer. How strong the banding appears, + depends on the point density, i.e. the number of points in the plot. + + For some situations with scatter plots it might thus be desirable to manually turn adaptive + sampling off. For example, when saving the plot to disk. This can be achieved by setting \a + enabled to false before issuing a command like \ref QCustomPlot::savePng, and setting \a enabled + back to true afterwards. */ -QPen QCPItemCurve::mainPen() const +void QCPGraph::setAdaptiveSampling(bool enabled) { - return mSelected ? mSelectedPen : mPen; + mAdaptiveSampling = enabled; } - -//////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////// QCPItemRect -//////////////////////////////////////////////////////////////////////////////////////////////////// - -/*! \class QCPItemRect - \brief A rectangle - - \image html QCPItemRect.png "Rectangle example. Blue dotted circles are anchors, solid blue discs are positions." - - It has two positions, \a topLeft and \a bottomRight, which define the rectangle. -*/ - /*! - Creates a rectangle item and sets default values. + Adds the provided data points in \a dataMap to the current data. - The constructed item can be added to the plot with QCustomPlot::addItem. + Alternatively, you can also access and modify the graph's data via the \ref data method, which + returns a pointer to the internal \ref QCPDataMap. + + \see removeData */ -QCPItemRect::QCPItemRect(QCustomPlot *parentPlot) : - QCPAbstractItem(parentPlot), - topLeft(createPosition("topLeft")), - bottomRight(createPosition("bottomRight")), - top(createAnchor("top", aiTop)), - topRight(createAnchor("topRight", aiTopRight)), - right(createAnchor("right", aiRight)), - bottom(createAnchor("bottom", aiBottom)), - bottomLeft(createAnchor("bottomLeft", aiBottomLeft)), - left(createAnchor("left", aiLeft)) +void QCPGraph::addData(const QCPDataMap &dataMap) { - topLeft->setCoords(0, 1); - bottomRight->setCoords(1, 0); + mData->unite(dataMap); +} + +/*! \overload + Adds the provided single data point in \a data to the current data. - setPen(QPen(Qt::black)); - setSelectedPen(QPen(Qt::blue,2)); - setBrush(Qt::NoBrush); - setSelectedBrush(Qt::NoBrush); + Alternatively, you can also access and modify the graph's data via the \ref data method, which + returns a pointer to the internal \ref QCPDataMap. + + \see removeData +*/ +void QCPGraph::addData(const QCPData &data) +{ + mData->insertMulti(data.key, data); } -QCPItemRect::~QCPItemRect() +/*! \overload + Adds the provided single data point as \a key and \a value pair to the current data. + + Alternatively, you can also access and modify the graph's data via the \ref data method, which + returns a pointer to the internal \ref QCPDataMap. + + \see removeData +*/ +void QCPGraph::addData(double key, double value) { + QCPData newData; + newData.key = key; + newData.value = value; + mData->insertMulti(newData.key, newData); } -/*! - Sets the pen that will be used to draw the line of the rectangle +/*! \overload + Adds the provided data points as \a key and \a value pairs to the current data. - \see setSelectedPen, setBrush + Alternatively, you can also access and modify the graph's data via the \ref data method, which + returns a pointer to the internal \ref QCPDataMap. + + \see removeData */ -void QCPItemRect::setPen(const QPen &pen) +void QCPGraph::addData(const QVector &keys, const QVector &values) { - mPen = pen; + int n = qMin(keys.size(), values.size()); + QCPData newData; + for (int i=0; iinsertMulti(newData.key, newData); + } } /*! - Sets the pen that will be used to draw the line of the rectangle when selected - - \see setPen, setSelected + Removes all data points with keys smaller than \a key. + \see addData, clearData */ -void QCPItemRect::setSelectedPen(const QPen &pen) +void QCPGraph::removeDataBefore(double key) { - mSelectedPen = pen; + QCPDataMap::iterator it = mData->begin(); + while (it != mData->end() && it.key() < key) + it = mData->erase(it); } /*! - Sets the brush that will be used to fill the rectangle. To disable filling, set \a brush to - Qt::NoBrush. - - \see setSelectedBrush, setPen + Removes all data points with keys greater than \a key. + \see addData, clearData */ -void QCPItemRect::setBrush(const QBrush &brush) +void QCPGraph::removeDataAfter(double key) { - mBrush = brush; + if (mData->isEmpty()) return; + QCPDataMap::iterator it = mData->upperBound(key); + while (it != mData->end()) + it = mData->erase(it); } /*! - Sets the brush that will be used to fill the rectangle when selected. To disable filling, set \a - brush to Qt::NoBrush. + Removes all data points with keys between \a fromKey and \a toKey. + if \a fromKey is greater or equal to \a toKey, the function does nothing. To remove + a single data point with known key, use \ref removeData(double key). - \see setBrush + \see addData, clearData */ -void QCPItemRect::setSelectedBrush(const QBrush &brush) +void QCPGraph::removeData(double fromKey, double toKey) { - mSelectedBrush = brush; + if (fromKey >= toKey || mData->isEmpty()) return; + QCPDataMap::iterator it = mData->upperBound(fromKey); + QCPDataMap::iterator itEnd = mData->upperBound(toKey); + while (it != itEnd) + it = mData->erase(it); +} + +/*! \overload + + Removes a single data point at \a key. If the position is not known with absolute precision, + consider using \ref removeData(double fromKey, double toKey) with a small fuzziness interval around + the suspected position, depeding on the precision with which the key is known. + + \see addData, clearData +*/ +void QCPGraph::removeData(double key) +{ + mData->remove(key); +} + +/*! + Removes all data points. + \see removeData, removeDataAfter, removeDataBefore +*/ +void QCPGraph::clearData() +{ + mData->clear(); } /* inherits documentation from base class */ -double QCPItemRect::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +double QCPGraph::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { Q_UNUSED(details) - if (onlySelectable && !mSelectable) + if ((onlySelectable && !mSelectable) || mData->isEmpty()) return -1; + if (!mKeyAxis || !mValueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return -1; } - QRectF rect = QRectF(topLeft->pixelPoint(), bottomRight->pixelPoint()).normalized(); - bool filledRect = mBrush.style() != Qt::NoBrush && mBrush.color().alpha() != 0; - return rectSelectTest(rect, pos, filledRect); + if (mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint())) + return pointDistance(pos); + else + return -1; } -/* inherits documentation from base class */ -void QCPItemRect::draw(QCPPainter *painter) +/*! \overload + + Allows to define whether error bars are taken into consideration when determining the new axis + range. + + \see rescaleKeyAxis, rescaleValueAxis, QCPAbstractPlottable::rescaleAxes, QCustomPlot::rescaleAxes +*/ +void QCPGraph::rescaleAxes(bool onlyEnlarge, bool includeErrorBars) const { - QPointF p1 = topLeft->pixelPoint(); - QPointF p2 = bottomRight->pixelPoint(); - if (p1.toPoint() == p2.toPoint()) - return; - QRectF rect = QRectF(p1, p2).normalized(); - double clipPad = mainPen().widthF(); - QRectF boundingRect = rect.adjusted(-clipPad, -clipPad, clipPad, clipPad); - if (boundingRect.intersects(clipRect())) // only draw if bounding rect of rect item is visible in cliprect + rescaleKeyAxis(onlyEnlarge, includeErrorBars); + rescaleValueAxis(onlyEnlarge, includeErrorBars); +} + +/*! \overload + + Allows to define whether error bars (of kind \ref QCPGraph::etKey) are taken into consideration + when determining the new axis range. + + \see rescaleAxes, QCPAbstractPlottable::rescaleKeyAxis +*/ +void QCPGraph::rescaleKeyAxis(bool onlyEnlarge, bool includeErrorBars) const +{ + // this code is a copy of QCPAbstractPlottable::rescaleKeyAxis with the only change + // that getKeyRange is passed the includeErrorBars value. + if (mData->isEmpty()) return; + + QCPAxis *keyAxis = mKeyAxis.data(); + if (!keyAxis) { qDebug() << Q_FUNC_INFO << "invalid key axis"; return; } + + SignDomain signDomain = sdBoth; + if (keyAxis->scaleType() == QCPAxis::stLogarithmic) + signDomain = (keyAxis->range().upper < 0 ? sdNegative : sdPositive); + + bool foundRange; + QCPRange newRange = getKeyRange(foundRange, signDomain, includeErrorBars); + + if (foundRange) { - painter->setPen(mainPen()); - painter->setBrush(mainBrush()); - painter->drawRect(rect); + if (onlyEnlarge) + { + if (keyAxis->range().lower < newRange.lower) + newRange.lower = keyAxis->range().lower; + if (keyAxis->range().upper > newRange.upper) + newRange.upper = keyAxis->range().upper; + } + keyAxis->setRange(newRange); + } +} + +/*! \overload + + Allows to define whether error bars (of kind \ref QCPGraph::etValue) are taken into consideration + when determining the new axis range. + + \see rescaleAxes, QCPAbstractPlottable::rescaleValueAxis +*/ +void QCPGraph::rescaleValueAxis(bool onlyEnlarge, bool includeErrorBars) const +{ + // this code is a copy of QCPAbstractPlottable::rescaleValueAxis with the only change + // is that getValueRange is passed the includeErrorBars value. + if (mData->isEmpty()) return; + + QCPAxis *valueAxis = mValueAxis.data(); + if (!valueAxis) { qDebug() << Q_FUNC_INFO << "invalid value axis"; return; } + + SignDomain signDomain = sdBoth; + if (valueAxis->scaleType() == QCPAxis::stLogarithmic) + signDomain = (valueAxis->range().upper < 0 ? sdNegative : sdPositive); + + bool foundRange; + QCPRange newRange = getValueRange(foundRange, signDomain, includeErrorBars); + + if (foundRange) + { + if (onlyEnlarge) + { + if (valueAxis->range().lower < newRange.lower) + newRange.lower = valueAxis->range().lower; + if (valueAxis->range().upper > newRange.upper) + newRange.upper = valueAxis->range().upper; + } + valueAxis->setRange(newRange); } } /* inherits documentation from base class */ -QPointF QCPItemRect::anchorPixelPoint(int anchorId) const +void QCPGraph::draw(QCPPainter *painter) { - QRectF rect = QRectF(topLeft->pixelPoint(), bottomRight->pixelPoint()); - switch (anchorId) + if (!mKeyAxis || !mValueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + if (mKeyAxis.data()->range().size() <= 0 || mData->isEmpty()) return; + if (mLineStyle == lsNone && mScatterStyle.isNone()) return; + + // allocate line and (if necessary) point vectors: + QVector *lineData = new QVector; + QVector *scatterData = 0; + if (!mScatterStyle.isNone()) + scatterData = new QVector; + + // fill vectors with data appropriate to plot style: + getPlotData(lineData, scatterData); + + // check data validity if flag set: +#ifdef QCUSTOMPLOT_CHECK_DATA + QCPDataMap::const_iterator it; + for (it = mData->constBegin(); it != mData->constEnd(); ++it) { - case aiTop: return (rect.topLeft()+rect.topRight())*0.5; - case aiTopRight: return rect.topRight(); - case aiRight: return (rect.topRight()+rect.bottomRight())*0.5; - case aiBottom: return (rect.bottomLeft()+rect.bottomRight())*0.5; - case aiBottomLeft: return rect.bottomLeft(); - case aiLeft: return (rect.topLeft()+rect.bottomLeft())*0.5; + if (QCP::isInvalidData(it.value().key, it.value().value) || + QCP::isInvalidData(it.value().keyErrorPlus, it.value().keyErrorMinus) || + QCP::isInvalidData(it.value().valueErrorPlus, it.value().valueErrorPlus)) + qDebug() << Q_FUNC_INFO << "Data point at" << it.key() << "invalid." << "Plottable name:" << name(); } +#endif + + // draw fill of graph: + drawFill(painter, lineData); - qDebug() << Q_FUNC_INFO << "invalid anchorId" << anchorId; - return QPointF(); + // draw line: + if (mLineStyle == lsImpulse) + drawImpulsePlot(painter, lineData); + else if (mLineStyle != lsNone) + drawLinePlot(painter, lineData); // also step plots can be drawn as a line plot + + // draw scatters: + if (scatterData) + drawScatterPlot(painter, scatterData); + + // free allocated line and point vectors: + delete lineData; + if (scatterData) + delete scatterData; +} + +/* inherits documentation from base class */ +void QCPGraph::drawLegendIcon(QCPPainter *painter, const QRectF &rect) const +{ + // draw fill: + if (mBrush.style() != Qt::NoBrush) + { + applyFillAntialiasingHint(painter); + painter->fillRect(QRectF(rect.left(), rect.top()+rect.height()/2.0, rect.width(), rect.height()/3.0), mBrush); + } + // draw line vertically centered: + if (mLineStyle != lsNone) + { + applyDefaultAntialiasingHint(painter); + painter->setPen(mPen); + painter->drawLine(QLineF(rect.left(), rect.top()+rect.height()/2.0, rect.right()+5, rect.top()+rect.height()/2.0)); // +5 on x2 else last segment is missing from dashed/dotted pens + } + // draw scatter symbol: + if (!mScatterStyle.isNone()) + { + applyScattersAntialiasingHint(painter); + // scale scatter pixmap if it's too large to fit in legend icon rect: + if (mScatterStyle.shape() == QCPScatterStyle::ssPixmap && (mScatterStyle.pixmap().size().width() > rect.width() || mScatterStyle.pixmap().size().height() > rect.height())) + { + QCPScatterStyle scaledStyle(mScatterStyle); + scaledStyle.setPixmap(scaledStyle.pixmap().scaled(rect.size().toSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation)); + scaledStyle.applyTo(painter, mPen); + scaledStyle.drawShape(painter, QRectF(rect).center()); + } else + { + mScatterStyle.applyTo(painter, mPen); + mScatterStyle.drawShape(painter, QRectF(rect).center()); + } + } } /*! \internal - Returns the pen that should be used for drawing lines. Returns mPen when the item is not selected - and mSelectedPen when it is. + This function branches out to the line style specific "get(...)PlotData" functions, according to + the line style of the graph. + + \a lineData will be filled with raw points that will be drawn with the according draw functions, + e.g. \ref drawLinePlot and \ref drawImpulsePlot. These aren't necessarily the original data + points, since for step plots for example, additional points are needed for drawing lines that + make up steps. If the line style of the graph is \ref lsNone, the \a lineData vector will be left + untouched. + + \a scatterData will be filled with the original data points so \ref drawScatterPlot can draw the + scatter symbols accordingly. If no scatters need to be drawn, i.e. the scatter style's shape is + \ref QCPScatterStyle::ssNone, pass 0 as \a scatterData, and this step will be skipped. + + \see getScatterPlotData, getLinePlotData, getStepLeftPlotData, getStepRightPlotData, + getStepCenterPlotData, getImpulsePlotData */ -QPen QCPItemRect::mainPen() const +void QCPGraph::getPlotData(QVector *lineData, QVector *scatterData) const { - return mSelected ? mSelectedPen : mPen; + switch(mLineStyle) + { + case lsNone: getScatterPlotData(scatterData); break; + case lsLine: getLinePlotData(lineData, scatterData); break; + case lsStepLeft: getStepLeftPlotData(lineData, scatterData); break; + case lsStepRight: getStepRightPlotData(lineData, scatterData); break; + case lsStepCenter: getStepCenterPlotData(lineData, scatterData); break; + case lsImpulse: getImpulsePlotData(lineData, scatterData); break; + } +} + +/*! \internal + + If line style is \ref lsNone and the scatter style's shape is not \ref QCPScatterStyle::ssNone, + this function serves at providing the visible data points in \a scatterData, so the \ref + drawScatterPlot function can draw the scatter points accordingly. + + If line style is not \ref lsNone, this function is not called and the data for the scatter points + are (if needed) calculated inside the corresponding other "get(...)PlotData" functions. + + \see drawScatterPlot +*/ +void QCPGraph::getScatterPlotData(QVector *scatterData) const +{ + getPreparedData(0, scatterData); } /*! \internal + + Places the raw data points needed for a normal linearly connected graph in \a linePixelData. - Returns the brush that should be used for drawing fills of the item. Returns mBrush when the item - is not selected and mSelectedBrush when it is. + As for all plot data retrieval functions, \a scatterData just contains all unaltered data (scatter) + points that are visible for drawing scatter points, if necessary. If drawing scatter points is + disabled (i.e. the scatter style's shape is \ref QCPScatterStyle::ssNone), pass 0 as \a + scatterData, and the function will skip filling the vector. + + \see drawLinePlot */ -QBrush QCPItemRect::mainBrush() const +void QCPGraph::getLinePlotData(QVector *linePixelData, QVector *scatterData) const { - return mSelected ? mSelectedBrush : mBrush; + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + if (!linePixelData) { qDebug() << Q_FUNC_INFO << "null pointer passed as linePixelData"; return; } + + QVector lineData; + getPreparedData(&lineData, scatterData); + linePixelData->reserve(lineData.size()+2); // added 2 to reserve memory for lower/upper fill base points that might be needed for fill + linePixelData->resize(lineData.size()); + + // transform lineData points to pixels: + if (keyAxis->orientation() == Qt::Vertical) + { + for (int i=0; icoordToPixel(lineData.at(i).value)); + (*linePixelData)[i].setY(keyAxis->coordToPixel(lineData.at(i).key)); + } + } else // key axis is horizontal + { + for (int i=0; icoordToPixel(lineData.at(i).key)); + (*linePixelData)[i].setY(valueAxis->coordToPixel(lineData.at(i).value)); + } + } +} + +/*! + \internal + Places the raw data points needed for a step plot with left oriented steps in \a lineData. + + As for all plot data retrieval functions, \a scatterData just contains all unaltered data (scatter) + points that are visible for drawing scatter points, if necessary. If drawing scatter points is + disabled (i.e. the scatter style's shape is \ref QCPScatterStyle::ssNone), pass 0 as \a + scatterData, and the function will skip filling the vector. + + \see drawLinePlot +*/ +void QCPGraph::getStepLeftPlotData(QVector *linePixelData, QVector *scatterData) const +{ + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + if (!linePixelData) { qDebug() << Q_FUNC_INFO << "null pointer passed as lineData"; return; } + + QVector lineData; + getPreparedData(&lineData, scatterData); + linePixelData->reserve(lineData.size()*2+2); // added 2 to reserve memory for lower/upper fill base points that might be needed for fill + linePixelData->resize(lineData.size()*2); + + // calculate steps from lineData and transform to pixel coordinates: + if (keyAxis->orientation() == Qt::Vertical) + { + double lastValue = valueAxis->coordToPixel(lineData.first().value); + double key; + for (int i=0; icoordToPixel(lineData.at(i).key); + (*linePixelData)[i*2+0].setX(lastValue); + (*linePixelData)[i*2+0].setY(key); + lastValue = valueAxis->coordToPixel(lineData.at(i).value); + (*linePixelData)[i*2+1].setX(lastValue); + (*linePixelData)[i*2+1].setY(key); + } + } else // key axis is horizontal + { + double lastValue = valueAxis->coordToPixel(lineData.first().value); + double key; + for (int i=0; icoordToPixel(lineData.at(i).key); + (*linePixelData)[i*2+0].setX(key); + (*linePixelData)[i*2+0].setY(lastValue); + lastValue = valueAxis->coordToPixel(lineData.at(i).value); + (*linePixelData)[i*2+1].setX(key); + (*linePixelData)[i*2+1].setY(lastValue); + } + } +} + +/*! + \internal + Places the raw data points needed for a step plot with right oriented steps in \a lineData. + + As for all plot data retrieval functions, \a scatterData just contains all unaltered data (scatter) + points that are visible for drawing scatter points, if necessary. If drawing scatter points is + disabled (i.e. the scatter style's shape is \ref QCPScatterStyle::ssNone), pass 0 as \a + scatterData, and the function will skip filling the vector. + + \see drawLinePlot +*/ +void QCPGraph::getStepRightPlotData(QVector *linePixelData, QVector *scatterData) const +{ + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + if (!linePixelData) { qDebug() << Q_FUNC_INFO << "null pointer passed as lineData"; return; } + + QVector lineData; + getPreparedData(&lineData, scatterData); + linePixelData->reserve(lineData.size()*2+2); // added 2 to reserve memory for lower/upper fill base points that might be needed for fill + linePixelData->resize(lineData.size()*2); + + // calculate steps from lineData and transform to pixel coordinates: + if (keyAxis->orientation() == Qt::Vertical) + { + double lastKey = keyAxis->coordToPixel(lineData.first().key); + double value; + for (int i=0; icoordToPixel(lineData.at(i).value); + (*linePixelData)[i*2+0].setX(value); + (*linePixelData)[i*2+0].setY(lastKey); + lastKey = keyAxis->coordToPixel(lineData.at(i).key); + (*linePixelData)[i*2+1].setX(value); + (*linePixelData)[i*2+1].setY(lastKey); + } + } else // key axis is horizontal + { + double lastKey = keyAxis->coordToPixel(lineData.first().key); + double value; + for (int i=0; icoordToPixel(lineData.at(i).value); + (*linePixelData)[i*2+0].setX(lastKey); + (*linePixelData)[i*2+0].setY(value); + lastKey = keyAxis->coordToPixel(lineData.at(i).key); + (*linePixelData)[i*2+1].setX(lastKey); + (*linePixelData)[i*2+1].setY(value); + } + } +} + +/*! + \internal + Places the raw data points needed for a step plot with centered steps in \a lineData. + + As for all plot data retrieval functions, \a scatterData just contains all unaltered data (scatter) + points that are visible for drawing scatter points, if necessary. If drawing scatter points is + disabled (i.e. the scatter style's shape is \ref QCPScatterStyle::ssNone), pass 0 as \a + scatterData, and the function will skip filling the vector. + + \see drawLinePlot +*/ +void QCPGraph::getStepCenterPlotData(QVector *linePixelData, QVector *scatterData) const +{ + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + if (!linePixelData) { qDebug() << Q_FUNC_INFO << "null pointer passed as lineData"; return; } + + QVector lineData; + getPreparedData(&lineData, scatterData); + linePixelData->reserve(lineData.size()*2+2); // added 2 to reserve memory for lower/upper fill base points that might be needed for fill + linePixelData->resize(lineData.size()*2); + // calculate steps from lineData and transform to pixel coordinates: + if (keyAxis->orientation() == Qt::Vertical) + { + double lastKey = keyAxis->coordToPixel(lineData.first().key); + double lastValue = valueAxis->coordToPixel(lineData.first().value); + double key; + (*linePixelData)[0].setX(lastValue); + (*linePixelData)[0].setY(lastKey); + for (int i=1; icoordToPixel(lineData.at(i).key)+lastKey)*0.5; + (*linePixelData)[i*2-1].setX(lastValue); + (*linePixelData)[i*2-1].setY(key); + lastValue = valueAxis->coordToPixel(lineData.at(i).value); + lastKey = keyAxis->coordToPixel(lineData.at(i).key); + (*linePixelData)[i*2+0].setX(lastValue); + (*linePixelData)[i*2+0].setY(key); + } + (*linePixelData)[lineData.size()*2-1].setX(lastValue); + (*linePixelData)[lineData.size()*2-1].setY(lastKey); + } else // key axis is horizontal + { + double lastKey = keyAxis->coordToPixel(lineData.first().key); + double lastValue = valueAxis->coordToPixel(lineData.first().value); + double key; + (*linePixelData)[0].setX(lastKey); + (*linePixelData)[0].setY(lastValue); + for (int i=1; icoordToPixel(lineData.at(i).key)+lastKey)*0.5; + (*linePixelData)[i*2-1].setX(key); + (*linePixelData)[i*2-1].setY(lastValue); + lastValue = valueAxis->coordToPixel(lineData.at(i).value); + lastKey = keyAxis->coordToPixel(lineData.at(i).key); + (*linePixelData)[i*2+0].setX(key); + (*linePixelData)[i*2+0].setY(lastValue); + } + (*linePixelData)[lineData.size()*2-1].setX(lastKey); + (*linePixelData)[lineData.size()*2-1].setY(lastValue); + } + +} + +/*! + \internal + Places the raw data points needed for an impulse plot in \a lineData. + + As for all plot data retrieval functions, \a scatterData just contains all unaltered data (scatter) + points that are visible for drawing scatter points, if necessary. If drawing scatter points is + disabled (i.e. the scatter style's shape is \ref QCPScatterStyle::ssNone), pass 0 as \a + scatterData, and the function will skip filling the vector. + + \see drawImpulsePlot +*/ +void QCPGraph::getImpulsePlotData(QVector *linePixelData, QVector *scatterData) const +{ + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + if (!linePixelData) { qDebug() << Q_FUNC_INFO << "null pointer passed as linePixelData"; return; } + + QVector lineData; + getPreparedData(&lineData, scatterData); + linePixelData->resize(lineData.size()*2); // no need to reserve 2 extra points because impulse plot has no fill + + // transform lineData points to pixels: + if (keyAxis->orientation() == Qt::Vertical) + { + double zeroPointX = valueAxis->coordToPixel(0); + double key; + for (int i=0; icoordToPixel(lineData.at(i).key); + (*linePixelData)[i*2+0].setX(zeroPointX); + (*linePixelData)[i*2+0].setY(key); + (*linePixelData)[i*2+1].setX(valueAxis->coordToPixel(lineData.at(i).value)); + (*linePixelData)[i*2+1].setY(key); + } + } else // key axis is horizontal + { + double zeroPointY = valueAxis->coordToPixel(0); + double key; + for (int i=0; icoordToPixel(lineData.at(i).key); + (*linePixelData)[i*2+0].setX(key); + (*linePixelData)[i*2+0].setY(zeroPointY); + (*linePixelData)[i*2+1].setX(key); + (*linePixelData)[i*2+1].setY(valueAxis->coordToPixel(lineData.at(i).value)); + } + } +} + +/*! \internal + + Draws the fill of the graph with the specified brush. + + If the fill is a normal fill towards the zero-value-line, only the \a lineData is required (and + two extra points at the zero-value-line, which are added by \ref addFillBasePoints and removed by + \ref removeFillBasePoints after the fill drawing is done). + + If the fill is a channel fill between this QCPGraph and another QCPGraph (mChannelFillGraph), the + more complex polygon is calculated with the \ref getChannelFillPolygon function. + + \see drawLinePlot +*/ +void QCPGraph::drawFill(QCPPainter *painter, QVector *lineData) const +{ + if (mLineStyle == lsImpulse) return; // fill doesn't make sense for impulse plot + if (mainBrush().style() == Qt::NoBrush || mainBrush().color().alpha() == 0) return; + + applyFillAntialiasingHint(painter); + if (!mChannelFillGraph) + { + // draw base fill under graph, fill goes all the way to the zero-value-line: + addFillBasePoints(lineData); + painter->setPen(Qt::NoPen); + painter->setBrush(mainBrush()); + painter->drawPolygon(QPolygonF(*lineData)); + removeFillBasePoints(lineData); + } else + { + // draw channel fill between this graph and mChannelFillGraph: + painter->setPen(Qt::NoPen); + painter->setBrush(mainBrush()); + painter->drawPolygon(getChannelFillPolygon(lineData)); + } +} + +/*! \internal + + Draws scatter symbols at every data point passed in \a scatterData. scatter symbols are independent + of the line style and are always drawn if the scatter style's shape is not \ref + QCPScatterStyle::ssNone. Hence, the \a scatterData vector is outputted by all "get(...)PlotData" + functions, together with the (line style dependent) line data. + + \see drawLinePlot, drawImpulsePlot +*/ +void QCPGraph::drawScatterPlot(QCPPainter *painter, QVector *scatterData) const +{ + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + + // draw error bars: + if (mErrorType != etNone) + { + applyErrorBarsAntialiasingHint(painter); + painter->setPen(mErrorPen); + if (keyAxis->orientation() == Qt::Vertical) + { + for (int i=0; isize(); ++i) + drawError(painter, valueAxis->coordToPixel(scatterData->at(i).value), keyAxis->coordToPixel(scatterData->at(i).key), scatterData->at(i)); + } else + { + for (int i=0; isize(); ++i) + drawError(painter, keyAxis->coordToPixel(scatterData->at(i).key), valueAxis->coordToPixel(scatterData->at(i).value), scatterData->at(i)); + } + } + + // draw scatter point symbols: + applyScattersAntialiasingHint(painter); + mScatterStyle.applyTo(painter, mPen); + if (keyAxis->orientation() == Qt::Vertical) + { + for (int i=0; isize(); ++i) + mScatterStyle.drawShape(painter, valueAxis->coordToPixel(scatterData->at(i).value), keyAxis->coordToPixel(scatterData->at(i).key)); + } else + { + for (int i=0; isize(); ++i) + mScatterStyle.drawShape(painter, keyAxis->coordToPixel(scatterData->at(i).key), valueAxis->coordToPixel(scatterData->at(i).value)); + } +} + +/*! \internal + + Draws line graphs from the provided data. It connects all points in \a lineData, which was + created by one of the "get(...)PlotData" functions for line styles that require simple line + connections between the point vector they create. These are for example \ref getLinePlotData, + \ref getStepLeftPlotData, \ref getStepRightPlotData and \ref getStepCenterPlotData. + + \see drawScatterPlot, drawImpulsePlot +*/ +void QCPGraph::drawLinePlot(QCPPainter *painter, QVector *lineData) const +{ + // draw line of graph: + if (mainPen().style() != Qt::NoPen && mainPen().color().alpha() != 0) + { + applyDefaultAntialiasingHint(painter); + painter->setPen(mainPen()); + painter->setBrush(Qt::NoBrush); + + /* Draws polyline in batches, currently not used: + int p = 0; + while (p < lineData->size()) + { + int batch = qMin(25, lineData->size()-p); + if (p != 0) + { + ++batch; + --p; // to draw the connection lines between two batches + } + painter->drawPolyline(lineData->constData()+p, batch); + p += batch; + } + */ + + // if drawing solid line and not in PDF, use much faster line drawing instead of polyline: + if (mParentPlot->plottingHints().testFlag(QCP::phFastPolylines) && + painter->pen().style() == Qt::SolidLine && + !painter->modes().testFlag(QCPPainter::pmVectorized)&& + !painter->modes().testFlag(QCPPainter::pmNoCaching)) + { + for (int i=1; isize(); ++i) + painter->drawLine(lineData->at(i-1), lineData->at(i)); + } else + { + painter->drawPolyline(QPolygonF(*lineData)); + } + } +} + +/*! \internal + + Draws impulses from the provided data, i.e. it connects all line pairs in \a lineData, which was + created by \ref getImpulsePlotData. + + \see drawScatterPlot, drawLinePlot +*/ +void QCPGraph::drawImpulsePlot(QCPPainter *painter, QVector *lineData) const +{ + // draw impulses: + if (mainPen().style() != Qt::NoPen && mainPen().color().alpha() != 0) + { + applyDefaultAntialiasingHint(painter); + QPen pen = mainPen(); + pen.setCapStyle(Qt::FlatCap); // so impulse line doesn't reach beyond zero-line + painter->setPen(pen); + painter->setBrush(Qt::NoBrush); + painter->drawLines(*lineData); + } +} + +/*! \internal + + Returns the \a lineData and \a scatterData that need to be plotted for this graph taking into + consideration the current axis ranges and, if \ref setAdaptiveSampling is enabled, local point + densities. + + 0 may be passed as \a lineData or \a scatterData to indicate that the respective dataset isn't + needed. For example, if the scatter style (\ref setScatterStyle) is \ref QCPScatterStyle::ssNone, \a + scatterData should be 0 to prevent unnecessary calculations. + + This method is used by the various "get(...)PlotData" methods to get the basic working set of data. +*/ +void QCPGraph::getPreparedData(QVector *lineData, QVector *scatterData) const +{ + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + // get visible data range: + QCPDataMap::const_iterator lower, upper; // note that upper is the actual upper point, and not 1 step after the upper point + getVisibleDataBounds(lower, upper); + if (lower == mData->constEnd() || upper == mData->constEnd()) + return; + + // count points in visible range, taking into account that we only need to count to the limit maxCount if using adaptive sampling: + int maxCount = std::numeric_limits::max(); + if (mAdaptiveSampling) + { + int keyPixelSpan = qAbs(keyAxis->coordToPixel(lower.key())-keyAxis->coordToPixel(upper.key())); + maxCount = 2*keyPixelSpan+2; + } + int dataCount = countDataInBounds(lower, upper, maxCount); + + if (mAdaptiveSampling && dataCount >= maxCount) // use adaptive sampling only if there are at least two points per pixel on average + { + if (lineData) + { + QCPDataMap::const_iterator it = lower; + QCPDataMap::const_iterator upperEnd = upper+1; + double minValue = it.value().value; + double maxValue = it.value().value; + QCPDataMap::const_iterator currentIntervalFirstPoint = it; + int reversedFactor = keyAxis->rangeReversed() ? -1 : 1; // is used to calculate keyEpsilon pixel into the correct direction + int reversedRound = keyAxis->rangeReversed() ? 1 : 0; // is used to switch between floor (normal) and ceil (reversed) rounding of currentIntervalStartKey + double currentIntervalStartKey = keyAxis->pixelToCoord((int)(keyAxis->coordToPixel(lower.key())+reversedRound)); + double lastIntervalEndKey = currentIntervalStartKey; + double keyEpsilon = qAbs(currentIntervalStartKey-keyAxis->pixelToCoord(keyAxis->coordToPixel(currentIntervalStartKey)+1.0*reversedFactor)); // interval of one pixel on screen when mapped to plot key coordinates + bool keyEpsilonVariable = keyAxis->scaleType() == QCPAxis::stLogarithmic; // indicates whether keyEpsilon needs to be updated after every interval (for log axes) + int intervalDataCount = 1; + ++it; // advance iterator to second data point because adaptive sampling works in 1 point retrospect + while (it != upperEnd) + { + if (it.key() < currentIntervalStartKey+keyEpsilon) // data point is still within same pixel, so skip it and expand value span of this cluster if necessary + { + if (it.value().value < minValue) + minValue = it.value().value; + else if (it.value().value > maxValue) + maxValue = it.value().value; + ++intervalDataCount; + } else // new pixel interval started + { + if (intervalDataCount >= 2) // last pixel had multiple data points, consolidate them to a cluster + { + if (lastIntervalEndKey < currentIntervalStartKey-keyEpsilon) // last point is further away, so first point of this cluster must be at a real data point + lineData->append(QCPData(currentIntervalStartKey+keyEpsilon*0.2, currentIntervalFirstPoint.value().value)); + lineData->append(QCPData(currentIntervalStartKey+keyEpsilon*0.25, minValue)); + lineData->append(QCPData(currentIntervalStartKey+keyEpsilon*0.75, maxValue)); + if (it.key() > currentIntervalStartKey+keyEpsilon*2) // new pixel started further away from previous cluster, so make sure the last point of the cluster is at a real data point + lineData->append(QCPData(currentIntervalStartKey+keyEpsilon*0.8, (it-1).value().value)); + } else + lineData->append(QCPData(currentIntervalFirstPoint.key(), currentIntervalFirstPoint.value().value)); + lastIntervalEndKey = (it-1).value().key; + minValue = it.value().value; + maxValue = it.value().value; + currentIntervalFirstPoint = it; + currentIntervalStartKey = keyAxis->pixelToCoord((int)(keyAxis->coordToPixel(it.key())+reversedRound)); + if (keyEpsilonVariable) + keyEpsilon = qAbs(currentIntervalStartKey-keyAxis->pixelToCoord(keyAxis->coordToPixel(currentIntervalStartKey)+1.0*reversedFactor)); + intervalDataCount = 1; + } + ++it; + } + // handle last interval: + if (intervalDataCount >= 2) // last pixel had multiple data points, consolidate them to a cluster + { + if (lastIntervalEndKey < currentIntervalStartKey-keyEpsilon) // last point wasn't a cluster, so first point of this cluster must be at a real data point + lineData->append(QCPData(currentIntervalStartKey+keyEpsilon*0.2, currentIntervalFirstPoint.value().value)); + lineData->append(QCPData(currentIntervalStartKey+keyEpsilon*0.25, minValue)); + lineData->append(QCPData(currentIntervalStartKey+keyEpsilon*0.75, maxValue)); + } else + lineData->append(QCPData(currentIntervalFirstPoint.key(), currentIntervalFirstPoint.value().value)); + } + + if (scatterData) + { + double valueMaxRange = valueAxis->range().upper; + double valueMinRange = valueAxis->range().lower; + QCPDataMap::const_iterator it = lower; + QCPDataMap::const_iterator upperEnd = upper+1; + double minValue = it.value().value; + double maxValue = it.value().value; + QCPDataMap::const_iterator minValueIt = it; + QCPDataMap::const_iterator maxValueIt = it; + QCPDataMap::const_iterator currentIntervalStart = it; + int reversedFactor = keyAxis->rangeReversed() ? -1 : 1; // is used to calculate keyEpsilon pixel into the correct direction + int reversedRound = keyAxis->rangeReversed() ? 1 : 0; // is used to switch between floor (normal) and ceil (reversed) rounding of currentIntervalStartKey + double currentIntervalStartKey = keyAxis->pixelToCoord((int)(keyAxis->coordToPixel(lower.key())+reversedRound)); + double keyEpsilon = qAbs(currentIntervalStartKey-keyAxis->pixelToCoord(keyAxis->coordToPixel(currentIntervalStartKey)+1.0*reversedFactor)); // interval of one pixel on screen when mapped to plot key coordinates + bool keyEpsilonVariable = keyAxis->scaleType() == QCPAxis::stLogarithmic; // indicates whether keyEpsilon needs to be updated after every interval (for log axes) + int intervalDataCount = 1; + ++it; // advance iterator to second data point because adaptive sampling works in 1 point retrospect + while (it != upperEnd) + { + if (it.key() < currentIntervalStartKey+keyEpsilon) // data point is still within same pixel, so skip it and expand value span of this pixel if necessary + { + if (it.value().value < minValue && it.value().value > valueMinRange && it.value().value < valueMaxRange) + { + minValue = it.value().value; + minValueIt = it; + } else if (it.value().value > maxValue && it.value().value > valueMinRange && it.value().value < valueMaxRange) + { + maxValue = it.value().value; + maxValueIt = it; + } + ++intervalDataCount; + } else // new pixel started + { + if (intervalDataCount >= 2) // last pixel had multiple data points, consolidate them + { + // determine value pixel span and add as many points in interval to maintain certain vertical data density (this is specific to scatter plot): + double valuePixelSpan = qAbs(valueAxis->coordToPixel(minValue)-valueAxis->coordToPixel(maxValue)); + int dataModulo = qMax(1, qRound(intervalDataCount/(valuePixelSpan/4.0))); // approximately every 4 value pixels one data point on average + QCPDataMap::const_iterator intervalIt = currentIntervalStart; + int c = 0; + while (intervalIt != it) + { + if ((c % dataModulo == 0 || intervalIt == minValueIt || intervalIt == maxValueIt) && intervalIt.value().value > valueMinRange && intervalIt.value().value < valueMaxRange) + scatterData->append(intervalIt.value()); + ++c; + ++intervalIt; + } + } else if (currentIntervalStart.value().value > valueMinRange && currentIntervalStart.value().value < valueMaxRange) + scatterData->append(currentIntervalStart.value()); + minValue = it.value().value; + maxValue = it.value().value; + currentIntervalStart = it; + currentIntervalStartKey = keyAxis->pixelToCoord((int)(keyAxis->coordToPixel(it.key())+reversedRound)); + if (keyEpsilonVariable) + keyEpsilon = qAbs(currentIntervalStartKey-keyAxis->pixelToCoord(keyAxis->coordToPixel(currentIntervalStartKey)+1.0*reversedFactor)); + intervalDataCount = 1; + } + ++it; + } + // handle last interval: + if (intervalDataCount >= 2) // last pixel had multiple data points, consolidate them + { + // determine value pixel span and add as many points in interval to maintain certain vertical data density (this is specific to scatter plot): + double valuePixelSpan = qAbs(valueAxis->coordToPixel(minValue)-valueAxis->coordToPixel(maxValue)); + int dataModulo = qMax(1, qRound(intervalDataCount/(valuePixelSpan/4.0))); // approximately every 4 value pixels one data point on average + QCPDataMap::const_iterator intervalIt = currentIntervalStart; + int c = 0; + while (intervalIt != it) + { + if ((c % dataModulo == 0 || intervalIt == minValueIt || intervalIt == maxValueIt) && intervalIt.value().value > valueMinRange && intervalIt.value().value < valueMaxRange) + scatterData->append(intervalIt.value()); + ++c; + ++intervalIt; + } + } else if (currentIntervalStart.value().value > valueMinRange && currentIntervalStart.value().value < valueMaxRange) + scatterData->append(currentIntervalStart.value()); + } + } else // don't use adaptive sampling algorithm, transfer points one-to-one from the map into the output parameters + { + QVector *dataVector = 0; + if (lineData) + dataVector = lineData; + else if (scatterData) + dataVector = scatterData; + if (dataVector) + { + QCPDataMap::const_iterator it = lower; + QCPDataMap::const_iterator upperEnd = upper+1; + dataVector->reserve(dataCount+2); // +2 for possible fill end points + while (it != upperEnd) + { + dataVector->append(it.value()); + ++it; + } + } + if (lineData && scatterData) + *scatterData = *dataVector; + } +} + +/*! \internal + + called by the scatter drawing function (\ref drawScatterPlot) to draw the error bars on one data + point. \a x and \a y pixel positions of the data point are passed since they are already known in + pixel coordinates in the drawing function, so we save some extra coordToPixel transforms here. \a + data is therefore only used for the errors, not key and value. +*/ +void QCPGraph::drawError(QCPPainter *painter, double x, double y, const QCPData &data) const +{ + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + + double a, b; // positions of error bar bounds in pixels + double barWidthHalf = mErrorBarSize*0.5; + double skipSymbolMargin = mScatterStyle.size(); // pixels left blank per side, when mErrorBarSkipSymbol is true + + if (keyAxis->orientation() == Qt::Vertical) + { + // draw key error vertically and value error horizontally + if (mErrorType == etKey || mErrorType == etBoth) + { + a = keyAxis->coordToPixel(data.key-data.keyErrorMinus); + b = keyAxis->coordToPixel(data.key+data.keyErrorPlus); + if (keyAxis->rangeReversed()) + qSwap(a,b); + // draw spine: + if (mErrorBarSkipSymbol) + { + if (a-y > skipSymbolMargin) // don't draw spine if error is so small it's within skipSymbolmargin + painter->drawLine(QLineF(x, a, x, y+skipSymbolMargin)); + if (y-b > skipSymbolMargin) + painter->drawLine(QLineF(x, y-skipSymbolMargin, x, b)); + } else + painter->drawLine(QLineF(x, a, x, b)); + // draw handles: + painter->drawLine(QLineF(x-barWidthHalf, a, x+barWidthHalf, a)); + painter->drawLine(QLineF(x-barWidthHalf, b, x+barWidthHalf, b)); + } + if (mErrorType == etValue || mErrorType == etBoth) + { + a = valueAxis->coordToPixel(data.value-data.valueErrorMinus); + b = valueAxis->coordToPixel(data.value+data.valueErrorPlus); + if (valueAxis->rangeReversed()) + qSwap(a,b); + // draw spine: + if (mErrorBarSkipSymbol) + { + if (x-a > skipSymbolMargin) // don't draw spine if error is so small it's within skipSymbolmargin + painter->drawLine(QLineF(a, y, x-skipSymbolMargin, y)); + if (b-x > skipSymbolMargin) + painter->drawLine(QLineF(x+skipSymbolMargin, y, b, y)); + } else + painter->drawLine(QLineF(a, y, b, y)); + // draw handles: + painter->drawLine(QLineF(a, y-barWidthHalf, a, y+barWidthHalf)); + painter->drawLine(QLineF(b, y-barWidthHalf, b, y+barWidthHalf)); + } + } else // mKeyAxis->orientation() is Qt::Horizontal + { + // draw value error vertically and key error horizontally + if (mErrorType == etKey || mErrorType == etBoth) + { + a = keyAxis->coordToPixel(data.key-data.keyErrorMinus); + b = keyAxis->coordToPixel(data.key+data.keyErrorPlus); + if (keyAxis->rangeReversed()) + qSwap(a,b); + // draw spine: + if (mErrorBarSkipSymbol) + { + if (x-a > skipSymbolMargin) // don't draw spine if error is so small it's within skipSymbolmargin + painter->drawLine(QLineF(a, y, x-skipSymbolMargin, y)); + if (b-x > skipSymbolMargin) + painter->drawLine(QLineF(x+skipSymbolMargin, y, b, y)); + } else + painter->drawLine(QLineF(a, y, b, y)); + // draw handles: + painter->drawLine(QLineF(a, y-barWidthHalf, a, y+barWidthHalf)); + painter->drawLine(QLineF(b, y-barWidthHalf, b, y+barWidthHalf)); + } + if (mErrorType == etValue || mErrorType == etBoth) + { + a = valueAxis->coordToPixel(data.value-data.valueErrorMinus); + b = valueAxis->coordToPixel(data.value+data.valueErrorPlus); + if (valueAxis->rangeReversed()) + qSwap(a,b); + // draw spine: + if (mErrorBarSkipSymbol) + { + if (a-y > skipSymbolMargin) // don't draw spine if error is so small it's within skipSymbolmargin + painter->drawLine(QLineF(x, a, x, y+skipSymbolMargin)); + if (y-b > skipSymbolMargin) + painter->drawLine(QLineF(x, y-skipSymbolMargin, x, b)); + } else + painter->drawLine(QLineF(x, a, x, b)); + // draw handles: + painter->drawLine(QLineF(x-barWidthHalf, a, x+barWidthHalf, a)); + painter->drawLine(QLineF(x-barWidthHalf, b, x+barWidthHalf, b)); + } + } +} + +/*! \internal + + called by \ref getPreparedData to determine which data (key) range is visible at the current key + axis range setting, so only that needs to be processed. + + \a lower returns an iterator to the lowest data point that needs to be taken into account when + plotting. Note that in order to get a clean plot all the way to the edge of the axis rect, \a + lower may still be just outside the visible range. + + \a upper returns an iterator to the highest data point. Same as before, \a upper may also lie + just outside of the visible range. + + if the graph contains no data, both \a lower and \a upper point to constEnd. +*/ +void QCPGraph::getVisibleDataBounds(QCPDataMap::const_iterator &lower, QCPDataMap::const_iterator &upper) const +{ + if (!mKeyAxis) { qDebug() << Q_FUNC_INFO << "invalid key axis"; return; } + if (mData->isEmpty()) + { + lower = mData->constEnd(); + upper = mData->constEnd(); + return; + } + + // get visible data range as QMap iterators + QCPDataMap::const_iterator lbound = mData->lowerBound(mKeyAxis.data()->range().lower); + QCPDataMap::const_iterator ubound = mData->upperBound(mKeyAxis.data()->range().upper); + bool lowoutlier = lbound != mData->constBegin(); // indicates whether there exist points below axis range + bool highoutlier = ubound != mData->constEnd(); // indicates whether there exist points above axis range + + lower = (lowoutlier ? lbound-1 : lbound); // data point range that will be actually drawn + upper = (highoutlier ? ubound : ubound-1); // data point range that will be actually drawn +} + +/*! \internal + + Counts the number of data points between \a lower and \a upper (including them), up to a maximum + of \a maxCount. + + This function is used by \ref getPreparedData to determine whether adaptive sampling shall be + used (if enabled via \ref setAdaptiveSampling) or not. This is also why counting of data points + only needs to be done until \a maxCount is reached, which should be set to the number of data + points at which adaptive sampling sets in. +*/ +int QCPGraph::countDataInBounds(const QCPDataMap::const_iterator &lower, const QCPDataMap::const_iterator &upper, int maxCount) const +{ + if (upper == mData->constEnd() && lower == mData->constEnd()) + return 0; + QCPDataMap::const_iterator it = lower; + int count = 1; + while (it != upper && count < maxCount) + { + ++it; + ++count; + } + return count; +} + +/*! \internal + + The line data vector generated by e.g. getLinePlotData contains only the line that connects the + data points. If the graph needs to be filled, two additional points need to be added at the + value-zero-line in the lower and upper key positions of the graph. This function calculates these + points and adds them to the end of \a lineData. Since the fill is typically drawn before the line + stroke, these added points need to be removed again after the fill is done, with the + removeFillBasePoints function. + + The expanding of \a lineData by two points will not cause unnecessary memory reallocations, + because the data vector generation functions (getLinePlotData etc.) reserve two extra points when + they allocate memory for \a lineData. + + \see removeFillBasePoints, lowerFillBasePoint, upperFillBasePoint +*/ +void QCPGraph::addFillBasePoints(QVector *lineData) const +{ + if (!mKeyAxis) { qDebug() << Q_FUNC_INFO << "invalid key axis"; return; } + + // append points that close the polygon fill at the key axis: + if (mKeyAxis.data()->orientation() == Qt::Vertical) + { + *lineData << upperFillBasePoint(lineData->last().y()); + *lineData << lowerFillBasePoint(lineData->first().y()); + } else + { + *lineData << upperFillBasePoint(lineData->last().x()); + *lineData << lowerFillBasePoint(lineData->first().x()); + } +} + +/*! \internal + + removes the two points from \a lineData that were added by \ref addFillBasePoints. + + \see addFillBasePoints, lowerFillBasePoint, upperFillBasePoint +*/ +void QCPGraph::removeFillBasePoints(QVector *lineData) const +{ + lineData->remove(lineData->size()-2, 2); +} + +/*! \internal + + called by \ref addFillBasePoints to conveniently assign the point which closes the fill polygon + on the lower side of the zero-value-line parallel to the key axis. The logarithmic axis scale + case is a bit special, since the zero-value-line in pixel coordinates is in positive or negative + infinity. So this case is handled separately by just closing the fill polygon on the axis which + lies in the direction towards the zero value. + + \a lowerKey will be the the key (in pixels) of the returned point. Depending on whether the key + axis is horizontal or vertical, \a lowerKey will end up as the x or y value of the returned + point, respectively. + + \see upperFillBasePoint, addFillBasePoints +*/ +QPointF QCPGraph::lowerFillBasePoint(double lowerKey) const +{ + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return QPointF(); } + + QPointF point; + if (valueAxis->scaleType() == QCPAxis::stLinear) + { + if (keyAxis->axisType() == QCPAxis::atLeft) + { + point.setX(valueAxis->coordToPixel(0)); + point.setY(lowerKey); + } else if (keyAxis->axisType() == QCPAxis::atRight) + { + point.setX(valueAxis->coordToPixel(0)); + point.setY(lowerKey); + } else if (keyAxis->axisType() == QCPAxis::atTop) + { + point.setX(lowerKey); + point.setY(valueAxis->coordToPixel(0)); + } else if (keyAxis->axisType() == QCPAxis::atBottom) + { + point.setX(lowerKey); + point.setY(valueAxis->coordToPixel(0)); + } + } else // valueAxis->mScaleType == QCPAxis::stLogarithmic + { + // In logarithmic scaling we can't just draw to value zero so we just fill all the way + // to the axis which is in the direction towards zero + if (keyAxis->orientation() == Qt::Vertical) + { + if ((valueAxis->range().upper < 0 && !valueAxis->rangeReversed()) || + (valueAxis->range().upper > 0 && valueAxis->rangeReversed())) // if range is negative, zero is on opposite side of key axis + point.setX(keyAxis->axisRect()->right()); + else + point.setX(keyAxis->axisRect()->left()); + point.setY(lowerKey); + } else if (keyAxis->axisType() == QCPAxis::atTop || keyAxis->axisType() == QCPAxis::atBottom) + { + point.setX(lowerKey); + if ((valueAxis->range().upper < 0 && !valueAxis->rangeReversed()) || + (valueAxis->range().upper > 0 && valueAxis->rangeReversed())) // if range is negative, zero is on opposite side of key axis + point.setY(keyAxis->axisRect()->top()); + else + point.setY(keyAxis->axisRect()->bottom()); + } + } + return point; +} + +/*! \internal + + called by \ref addFillBasePoints to conveniently assign the point which closes the fill + polygon on the upper side of the zero-value-line parallel to the key axis. The logarithmic axis + scale case is a bit special, since the zero-value-line in pixel coordinates is in positive or + negative infinity. So this case is handled separately by just closing the fill polygon on the + axis which lies in the direction towards the zero value. + + \a upperKey will be the the key (in pixels) of the returned point. Depending on whether the key + axis is horizontal or vertical, \a upperKey will end up as the x or y value of the returned + point, respectively. + + \see lowerFillBasePoint, addFillBasePoints +*/ +QPointF QCPGraph::upperFillBasePoint(double upperKey) const +{ + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return QPointF(); } + + QPointF point; + if (valueAxis->scaleType() == QCPAxis::stLinear) + { + if (keyAxis->axisType() == QCPAxis::atLeft) + { + point.setX(valueAxis->coordToPixel(0)); + point.setY(upperKey); + } else if (keyAxis->axisType() == QCPAxis::atRight) + { + point.setX(valueAxis->coordToPixel(0)); + point.setY(upperKey); + } else if (keyAxis->axisType() == QCPAxis::atTop) + { + point.setX(upperKey); + point.setY(valueAxis->coordToPixel(0)); + } else if (keyAxis->axisType() == QCPAxis::atBottom) + { + point.setX(upperKey); + point.setY(valueAxis->coordToPixel(0)); + } + } else // valueAxis->mScaleType == QCPAxis::stLogarithmic + { + // In logarithmic scaling we can't just draw to value 0 so we just fill all the way + // to the axis which is in the direction towards 0 + if (keyAxis->orientation() == Qt::Vertical) + { + if ((valueAxis->range().upper < 0 && !valueAxis->rangeReversed()) || + (valueAxis->range().upper > 0 && valueAxis->rangeReversed())) // if range is negative, zero is on opposite side of key axis + point.setX(keyAxis->axisRect()->right()); + else + point.setX(keyAxis->axisRect()->left()); + point.setY(upperKey); + } else if (keyAxis->axisType() == QCPAxis::atTop || keyAxis->axisType() == QCPAxis::atBottom) + { + point.setX(upperKey); + if ((valueAxis->range().upper < 0 && !valueAxis->rangeReversed()) || + (valueAxis->range().upper > 0 && valueAxis->rangeReversed())) // if range is negative, zero is on opposite side of key axis + point.setY(keyAxis->axisRect()->top()); + else + point.setY(keyAxis->axisRect()->bottom()); + } + } + return point; +} + +/*! \internal + + Generates the polygon needed for drawing channel fills between this graph (data passed via \a + lineData) and the graph specified by mChannelFillGraph (data generated by calling its \ref + getPlotData function). May return an empty polygon if the key ranges have no overlap or fill + target graph and this graph don't have same orientation (i.e. both key axes horizontal or both + key axes vertical). For increased performance (due to implicit sharing), keep the returned + QPolygonF const. +*/ +const QPolygonF QCPGraph::getChannelFillPolygon(const QVector *lineData) const +{ + if (!mChannelFillGraph) + return QPolygonF(); + + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return QPolygonF(); } + if (!mChannelFillGraph.data()->mKeyAxis) { qDebug() << Q_FUNC_INFO << "channel fill target key axis invalid"; return QPolygonF(); } + + if (mChannelFillGraph.data()->mKeyAxis.data()->orientation() != keyAxis->orientation()) + return QPolygonF(); // don't have same axis orientation, can't fill that (Note: if keyAxis fits, valueAxis will fit too, because it's always orthogonal to keyAxis) + + if (lineData->isEmpty()) return QPolygonF(); + QVector otherData; + mChannelFillGraph.data()->getPlotData(&otherData, 0); + if (otherData.isEmpty()) return QPolygonF(); + QVector thisData; + thisData.reserve(lineData->size()+otherData.size()); // because we will join both vectors at end of this function + for (int i=0; isize(); ++i) // don't use the vector<<(vector), it squeezes internally, which ruins the performance tuning with reserve() + thisData << lineData->at(i); + + // pointers to be able to swap them, depending which data range needs cropping: + QVector *staticData = &thisData; + QVector *croppedData = &otherData; + + // crop both vectors to ranges in which the keys overlap (which coord is key, depends on axisType): + if (keyAxis->orientation() == Qt::Horizontal) + { + // x is key + // if an axis range is reversed, the data point keys will be descending. Reverse them, since following algorithm assumes ascending keys: + if (staticData->first().x() > staticData->last().x()) + { + int size = staticData->size(); + for (int i=0; ifirst().x() > croppedData->last().x()) + { + int size = croppedData->size(); + for (int i=0; ifirst().x() < croppedData->first().x()) // other one must be cropped + qSwap(staticData, croppedData); + int lowBound = findIndexBelowX(croppedData, staticData->first().x()); + if (lowBound == -1) return QPolygonF(); // key ranges have no overlap + croppedData->remove(0, lowBound); + // set lowest point of cropped data to fit exactly key position of first static data + // point via linear interpolation: + if (croppedData->size() < 2) return QPolygonF(); // need at least two points for interpolation + double slope; + if (croppedData->at(1).x()-croppedData->at(0).x() != 0) + slope = (croppedData->at(1).y()-croppedData->at(0).y())/(croppedData->at(1).x()-croppedData->at(0).x()); + else + slope = 0; + (*croppedData)[0].setY(croppedData->at(0).y()+slope*(staticData->first().x()-croppedData->at(0).x())); + (*croppedData)[0].setX(staticData->first().x()); + + // crop upper bound: + if (staticData->last().x() > croppedData->last().x()) // other one must be cropped + qSwap(staticData, croppedData); + int highBound = findIndexAboveX(croppedData, staticData->last().x()); + if (highBound == -1) return QPolygonF(); // key ranges have no overlap + croppedData->remove(highBound+1, croppedData->size()-(highBound+1)); + // set highest point of cropped data to fit exactly key position of last static data + // point via linear interpolation: + if (croppedData->size() < 2) return QPolygonF(); // need at least two points for interpolation + int li = croppedData->size()-1; // last index + if (croppedData->at(li).x()-croppedData->at(li-1).x() != 0) + slope = (croppedData->at(li).y()-croppedData->at(li-1).y())/(croppedData->at(li).x()-croppedData->at(li-1).x()); + else + slope = 0; + (*croppedData)[li].setY(croppedData->at(li-1).y()+slope*(staticData->last().x()-croppedData->at(li-1).x())); + (*croppedData)[li].setX(staticData->last().x()); + } else // mKeyAxis->orientation() == Qt::Vertical + { + // y is key + // similar to "x is key" but switched x,y. Further, lower/upper meaning is inverted compared to x, + // because in pixel coordinates, y increases from top to bottom, not bottom to top like data coordinate. + // if an axis range is reversed, the data point keys will be descending. Reverse them, since following algorithm assumes ascending keys: + if (staticData->first().y() < staticData->last().y()) + { + int size = staticData->size(); + for (int i=0; ifirst().y() < croppedData->last().y()) + { + int size = croppedData->size(); + for (int i=0; ifirst().y() > croppedData->first().y()) // other one must be cropped + qSwap(staticData, croppedData); + int lowBound = findIndexAboveY(croppedData, staticData->first().y()); + if (lowBound == -1) return QPolygonF(); // key ranges have no overlap + croppedData->remove(0, lowBound); + // set lowest point of cropped data to fit exactly key position of first static data + // point via linear interpolation: + if (croppedData->size() < 2) return QPolygonF(); // need at least two points for interpolation + double slope; + if (croppedData->at(1).y()-croppedData->at(0).y() != 0) // avoid division by zero in step plots + slope = (croppedData->at(1).x()-croppedData->at(0).x())/(croppedData->at(1).y()-croppedData->at(0).y()); + else + slope = 0; + (*croppedData)[0].setX(croppedData->at(0).x()+slope*(staticData->first().y()-croppedData->at(0).y())); + (*croppedData)[0].setY(staticData->first().y()); + + // crop upper bound: + if (staticData->last().y() < croppedData->last().y()) // other one must be cropped + qSwap(staticData, croppedData); + int highBound = findIndexBelowY(croppedData, staticData->last().y()); + if (highBound == -1) return QPolygonF(); // key ranges have no overlap + croppedData->remove(highBound+1, croppedData->size()-(highBound+1)); + // set highest point of cropped data to fit exactly key position of last static data + // point via linear interpolation: + if (croppedData->size() < 2) return QPolygonF(); // need at least two points for interpolation + int li = croppedData->size()-1; // last index + if (croppedData->at(li).y()-croppedData->at(li-1).y() != 0) // avoid division by zero in step plots + slope = (croppedData->at(li).x()-croppedData->at(li-1).x())/(croppedData->at(li).y()-croppedData->at(li-1).y()); + else + slope = 0; + (*croppedData)[li].setX(croppedData->at(li-1).x()+slope*(staticData->last().y()-croppedData->at(li-1).y())); + (*croppedData)[li].setY(staticData->last().y()); + } + + // return joined: + for (int i=otherData.size()-1; i>=0; --i) // insert reversed, otherwise the polygon will be twisted + thisData << otherData.at(i); + return QPolygonF(thisData); +} + +/*! \internal + + Finds the smallest index of \a data, whose points x value is just above \a x. Assumes x values in + \a data points are ordered ascending, as is the case when plotting with horizontal key axis. + + Used to calculate the channel fill polygon, see \ref getChannelFillPolygon. +*/ +int QCPGraph::findIndexAboveX(const QVector *data, double x) const +{ + for (int i=data->size()-1; i>=0; --i) + { + if (data->at(i).x() < x) + { + if (isize()-1) + return i+1; + else + return data->size()-1; + } + } + return -1; +} + +/*! \internal + + Finds the highest index of \a data, whose points x value is just below \a x. Assumes x values in + \a data points are ordered ascending, as is the case when plotting with horizontal key axis. + + Used to calculate the channel fill polygon, see \ref getChannelFillPolygon. +*/ +int QCPGraph::findIndexBelowX(const QVector *data, double x) const +{ + for (int i=0; isize(); ++i) + { + if (data->at(i).x() > x) + { + if (i>0) + return i-1; + else + return 0; + } + } + return -1; +} + +/*! \internal + + Finds the smallest index of \a data, whose points y value is just above \a y. Assumes y values in + \a data points are ordered descending, as is the case when plotting with vertical key axis. + + Used to calculate the channel fill polygon, see \ref getChannelFillPolygon. +*/ +int QCPGraph::findIndexAboveY(const QVector *data, double y) const +{ + for (int i=0; isize(); ++i) + { + if (data->at(i).y() < y) + { + if (i>0) + return i-1; + else + return 0; + } + } + return -1; +} + +/*! \internal + + Calculates the (minimum) distance (in pixels) the graph's representation has from the given \a + pixelPoint in pixels. This is used to determine whether the graph was clicked or not, e.g. in + \ref selectTest. + + If either the graph has no data or if the line style is \ref lsNone and the scatter style's shape + is \ref QCPScatterStyle::ssNone (i.e. there is no visual representation of the graph), returns + 500. +*/ +double QCPGraph::pointDistance(const QPointF &pixelPoint) const +{ + if (mData->isEmpty()) + { + qDebug() << Q_FUNC_INFO << "requested point distance on graph" << mName << "without data"; + return 500; + } + if (mData->size() == 1) + { + QPointF dataPoint = coordsToPixels(mData->constBegin().key(), mData->constBegin().value().value); + return QVector2D(dataPoint-pixelPoint).length(); + } + + if (mLineStyle == lsNone && mScatterStyle.isNone()) + return 500; + + // calculate minimum distances to graph representation: + if (mLineStyle == lsNone) + { + // no line displayed, only calculate distance to scatter points: + QVector *scatterData = new QVector; + getScatterPlotData(scatterData); + double minDistSqr = std::numeric_limits::max(); + QPointF ptA; + QPointF ptB = coordsToPixels(scatterData->at(0).key, scatterData->at(0).value); // getScatterPlotData returns in plot coordinates, so transform to pixels + for (int i=1; isize(); ++i) + { + ptA = ptB; + ptB = coordsToPixels(scatterData->at(i).key, scatterData->at(i).value); + double currentDistSqr = distSqrToLine(ptA, ptB, pixelPoint); + if (currentDistSqr < minDistSqr) + minDistSqr = currentDistSqr; + } + delete scatterData; + return sqrt(minDistSqr); + } else + { + // line displayed calculate distance to line segments: + QVector *lineData = new QVector; + getPlotData(lineData, 0); // unlike with getScatterPlotData we get pixel coordinates here + double minDistSqr = std::numeric_limits::max(); + if (mLineStyle == lsImpulse) + { + // impulse plot differs from other line styles in that the lineData points are only pairwise connected: + for (int i=0; isize()-1; i+=2) // iterate pairs + { + double currentDistSqr = distSqrToLine(lineData->at(i), lineData->at(i+1), pixelPoint); + if (currentDistSqr < minDistSqr) + minDistSqr = currentDistSqr; + } + } else + { + // all other line plots (line and step) connect points directly: + for (int i=0; isize()-1; ++i) + { + double currentDistSqr = distSqrToLine(lineData->at(i), lineData->at(i+1), pixelPoint); + if (currentDistSqr < minDistSqr) + minDistSqr = currentDistSqr; + } + } + delete lineData; + return sqrt(minDistSqr); + } +} + +/*! \internal + + Finds the highest index of \a data, whose points y value is just below \a y. Assumes y values in + \a data points are ordered descending, as is the case when plotting with vertical key axis (since + keys are ordered ascending). + + Used to calculate the channel fill polygon, see \ref getChannelFillPolygon. +*/ +int QCPGraph::findIndexBelowY(const QVector *data, double y) const +{ + for (int i=data->size()-1; i>=0; --i) + { + if (data->at(i).y() > y) + { + if (isize()-1) + return i+1; + else + return data->size()-1; + } + } + return -1; +} + +/* inherits documentation from base class */ +QCPRange QCPGraph::getKeyRange(bool &foundRange, SignDomain inSignDomain) const +{ + // just call the specialized version which takes an additional argument whether error bars + // should also be taken into consideration for range calculation. We set this to true here. + return getKeyRange(foundRange, inSignDomain, true); +} + +/* inherits documentation from base class */ +QCPRange QCPGraph::getValueRange(bool &foundRange, SignDomain inSignDomain) const +{ + // just call the specialized version which takes an additional argument whether error bars + // should also be taken into consideration for range calculation. We set this to true here. + return getValueRange(foundRange, inSignDomain, true); +} + +/*! \overload + + Allows to specify whether the error bars should be included in the range calculation. + + \see getKeyRange(bool &foundRange, SignDomain inSignDomain) +*/ +QCPRange QCPGraph::getKeyRange(bool &foundRange, SignDomain inSignDomain, bool includeErrors) const +{ + QCPRange range; + bool haveLower = false; + bool haveUpper = false; + + double current, currentErrorMinus, currentErrorPlus; + + if (inSignDomain == sdBoth) // range may be anywhere + { + QCPDataMap::const_iterator it = mData->constBegin(); + while (it != mData->constEnd()) + { + current = it.value().key; + currentErrorMinus = (includeErrors ? it.value().keyErrorMinus : 0); + currentErrorPlus = (includeErrors ? it.value().keyErrorPlus : 0); + if (current-currentErrorMinus < range.lower || !haveLower) + { + range.lower = current-currentErrorMinus; + haveLower = true; + } + if (current+currentErrorPlus > range.upper || !haveUpper) + { + range.upper = current+currentErrorPlus; + haveUpper = true; + } + ++it; + } + } else if (inSignDomain == sdNegative) // range may only be in the negative sign domain + { + QCPDataMap::const_iterator it = mData->constBegin(); + while (it != mData->constEnd()) + { + current = it.value().key; + currentErrorMinus = (includeErrors ? it.value().keyErrorMinus : 0); + currentErrorPlus = (includeErrors ? it.value().keyErrorPlus : 0); + if ((current-currentErrorMinus < range.lower || !haveLower) && current-currentErrorMinus < 0) + { + range.lower = current-currentErrorMinus; + haveLower = true; + } + if ((current+currentErrorPlus > range.upper || !haveUpper) && current+currentErrorPlus < 0) + { + range.upper = current+currentErrorPlus; + haveUpper = true; + } + if (includeErrors) // in case point is in valid sign domain but errobars stretch beyond it, we still want to geht that point. + { + if ((current < range.lower || !haveLower) && current < 0) + { + range.lower = current; + haveLower = true; + } + if ((current > range.upper || !haveUpper) && current < 0) + { + range.upper = current; + haveUpper = true; + } + } + ++it; + } + } else if (inSignDomain == sdPositive) // range may only be in the positive sign domain + { + QCPDataMap::const_iterator it = mData->constBegin(); + while (it != mData->constEnd()) + { + current = it.value().key; + currentErrorMinus = (includeErrors ? it.value().keyErrorMinus : 0); + currentErrorPlus = (includeErrors ? it.value().keyErrorPlus : 0); + if ((current-currentErrorMinus < range.lower || !haveLower) && current-currentErrorMinus > 0) + { + range.lower = current-currentErrorMinus; + haveLower = true; + } + if ((current+currentErrorPlus > range.upper || !haveUpper) && current+currentErrorPlus > 0) + { + range.upper = current+currentErrorPlus; + haveUpper = true; + } + if (includeErrors) // in case point is in valid sign domain but errobars stretch beyond it, we still want to get that point. + { + if ((current < range.lower || !haveLower) && current > 0) + { + range.lower = current; + haveLower = true; + } + if ((current > range.upper || !haveUpper) && current > 0) + { + range.upper = current; + haveUpper = true; + } + } + ++it; + } + } + + foundRange = haveLower && haveUpper; + return range; +} + +/*! \overload + + Allows to specify whether the error bars should be included in the range calculation. + + \see getValueRange(bool &foundRange, SignDomain inSignDomain) +*/ +QCPRange QCPGraph::getValueRange(bool &foundRange, SignDomain inSignDomain, bool includeErrors) const +{ + QCPRange range; + bool haveLower = false; + bool haveUpper = false; + + double current, currentErrorMinus, currentErrorPlus; + + if (inSignDomain == sdBoth) // range may be anywhere + { + QCPDataMap::const_iterator it = mData->constBegin(); + while (it != mData->constEnd()) + { + current = it.value().value; + currentErrorMinus = (includeErrors ? it.value().valueErrorMinus : 0); + currentErrorPlus = (includeErrors ? it.value().valueErrorPlus : 0); + if (current-currentErrorMinus < range.lower || !haveLower) + { + range.lower = current-currentErrorMinus; + haveLower = true; + } + if (current+currentErrorPlus > range.upper || !haveUpper) + { + range.upper = current+currentErrorPlus; + haveUpper = true; + } + ++it; + } + } else if (inSignDomain == sdNegative) // range may only be in the negative sign domain + { + QCPDataMap::const_iterator it = mData->constBegin(); + while (it != mData->constEnd()) + { + current = it.value().value; + currentErrorMinus = (includeErrors ? it.value().valueErrorMinus : 0); + currentErrorPlus = (includeErrors ? it.value().valueErrorPlus : 0); + if ((current-currentErrorMinus < range.lower || !haveLower) && current-currentErrorMinus < 0) + { + range.lower = current-currentErrorMinus; + haveLower = true; + } + if ((current+currentErrorPlus > range.upper || !haveUpper) && current+currentErrorPlus < 0) + { + range.upper = current+currentErrorPlus; + haveUpper = true; + } + if (includeErrors) // in case point is in valid sign domain but errobars stretch beyond it, we still want to get that point. + { + if ((current < range.lower || !haveLower) && current < 0) + { + range.lower = current; + haveLower = true; + } + if ((current > range.upper || !haveUpper) && current < 0) + { + range.upper = current; + haveUpper = true; + } + } + ++it; + } + } else if (inSignDomain == sdPositive) // range may only be in the positive sign domain + { + QCPDataMap::const_iterator it = mData->constBegin(); + while (it != mData->constEnd()) + { + current = it.value().value; + currentErrorMinus = (includeErrors ? it.value().valueErrorMinus : 0); + currentErrorPlus = (includeErrors ? it.value().valueErrorPlus : 0); + if ((current-currentErrorMinus < range.lower || !haveLower) && current-currentErrorMinus > 0) + { + range.lower = current-currentErrorMinus; + haveLower = true; + } + if ((current+currentErrorPlus > range.upper || !haveUpper) && current+currentErrorPlus > 0) + { + range.upper = current+currentErrorPlus; + haveUpper = true; + } + if (includeErrors) // in case point is in valid sign domain but errobars stretch beyond it, we still want to geht that point. + { + if ((current < range.lower || !haveLower) && current > 0) + { + range.lower = current; + haveLower = true; + } + if ((current > range.upper || !haveUpper) && current > 0) + { + range.upper = current; + haveUpper = true; + } + } + ++it; + } + } + + foundRange = haveLower && haveUpper; + return range; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPCurveData +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPCurveData + \brief Holds the data of one single data point for QCPCurve. + + The container for storing multiple data points is \ref QCPCurveDataMap. + + The stored data is: + \li \a t: the free parameter of the curve at this curve point (cp. the mathematical vector (x(t), y(t))) + \li \a key: coordinate on the key axis of this curve point + \li \a value: coordinate on the value axis of this curve point + + \see QCPCurveDataMap +*/ + +/*! + Constructs a curve data point with t, key and value set to zero. +*/ +QCPCurveData::QCPCurveData() : + t(0), + key(0), + value(0) +{ +} + +/*! + Constructs a curve data point with the specified \a t, \a key and \a value. +*/ +QCPCurveData::QCPCurveData(double t, double key, double value) : + t(t), + key(key), + value(value) +{ +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPCurve +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPCurve + \brief A plottable representing a parametric curve in a plot. + + \image html QCPCurve.png + + Unlike QCPGraph, plottables of this type may have multiple points with the same key coordinate, + so their visual representation can have \a loops. This is realized by introducing a third + coordinate \a t, which defines the order of the points described by the other two coordinates \a + x and \a y. + + To plot data, assign it with the \ref setData or \ref addData functions. + + \section appearance Changing the appearance + + The appearance of the curve is determined by the pen and the brush (\ref setPen, \ref setBrush). + \section usage Usage + + Like all data representing objects in QCustomPlot, the QCPCurve is a plottable (QCPAbstractPlottable). So + the plottable-interface of QCustomPlot applies (QCustomPlot::plottable, QCustomPlot::addPlottable, QCustomPlot::removePlottable, etc.) + + Usually, you first create an instance: + \code + QCPCurve *newCurve = new QCPCurve(customPlot->xAxis, customPlot->yAxis);\endcode + add it to the customPlot with QCustomPlot::addPlottable: + \code + customPlot->addPlottable(newCurve);\endcode + and then modify the properties of the newly created plottable, e.g.: + \code + newCurve->setName("Fermat's Spiral"); + newCurve->setData(tData, xData, yData);\endcode +*/ + +/*! + Constructs a curve which uses \a keyAxis as its key axis ("x") and \a valueAxis as its value + axis ("y"). \a keyAxis and \a valueAxis must reside in the same QCustomPlot instance and not have + the same orientation. If either of these restrictions is violated, a corresponding message is + printed to the debug output (qDebug), the construction is not aborted, though. + + The constructed QCPCurve can be added to the plot with QCustomPlot::addPlottable, QCustomPlot + then takes ownership of the graph. +*/ +QCPCurve::QCPCurve(QCPAxis *keyAxis, QCPAxis *valueAxis) : + QCPAbstractPlottable(keyAxis, valueAxis) +{ + mData = new QCPCurveDataMap; + mPen.setColor(Qt::blue); + mPen.setStyle(Qt::SolidLine); + mBrush.setColor(Qt::blue); + mBrush.setStyle(Qt::NoBrush); + mSelectedPen = mPen; + mSelectedPen.setWidthF(2.5); + mSelectedPen.setColor(QColor(80, 80, 255)); // lighter than Qt::blue of mPen + mSelectedBrush = mBrush; + + setScatterStyle(QCPScatterStyle()); + setLineStyle(lsLine); +} + +QCPCurve::~QCPCurve() +{ + delete mData; +} + +/*! + Replaces the current data with the provided \a data. + + If \a copy is set to true, data points in \a data will only be copied. if false, the plottable + takes ownership of the passed data and replaces the internal data pointer with it. This is + significantly faster than copying for large datasets. +*/ +void QCPCurve::setData(QCPCurveDataMap *data, bool copy) +{ + if (copy) + { + *mData = *data; + } else + { + delete mData; + mData = data; + } +} + +/*! \overload + + Replaces the current data with the provided points in \a t, \a key and \a value tuples. The + provided vectors should have equal length. Else, the number of added points will be the size of + the smallest vector. +*/ +void QCPCurve::setData(const QVector &t, const QVector &key, const QVector &value) +{ + mData->clear(); + int n = t.size(); + n = qMin(n, key.size()); + n = qMin(n, value.size()); + QCPCurveData newData; + for (int i=0; iinsertMulti(newData.t, newData); + } +} + +/*! \overload + + Replaces the current data with the provided \a key and \a value pairs. The t parameter + of each data point will be set to the integer index of the respective key/value pair. +*/ +void QCPCurve::setData(const QVector &key, const QVector &value) +{ + mData->clear(); + int n = key.size(); + n = qMin(n, value.size()); + QCPCurveData newData; + for (int i=0; iinsertMulti(newData.t, newData); + } +} + +/*! + Sets the visual appearance of single data points in the plot. If set to \ref + QCPScatterStyle::ssNone, no scatter points are drawn (e.g. for line-only plots with appropriate + line style). + + \see QCPScatterStyle, setLineStyle +*/ +void QCPCurve::setScatterStyle(const QCPScatterStyle &style) +{ + mScatterStyle = style; +} + +/*! + Sets how the single data points are connected in the plot or how they are represented visually + apart from the scatter symbol. For scatter-only plots, set \a style to \ref lsNone and \ref + setScatterStyle to the desired scatter style. + + \see setScatterStyle +*/ +void QCPCurve::setLineStyle(QCPCurve::LineStyle style) +{ + mLineStyle = style; +} + +/*! + Adds the provided data points in \a dataMap to the current data. + \see removeData +*/ +void QCPCurve::addData(const QCPCurveDataMap &dataMap) +{ + mData->unite(dataMap); +} + +/*! \overload + Adds the provided single data point in \a data to the current data. + \see removeData +*/ +void QCPCurve::addData(const QCPCurveData &data) +{ + mData->insertMulti(data.t, data); +} + +/*! \overload + Adds the provided single data point as \a t, \a key and \a value tuple to the current data + \see removeData +*/ +void QCPCurve::addData(double t, double key, double value) +{ + QCPCurveData newData; + newData.t = t; + newData.key = key; + newData.value = value; + mData->insertMulti(newData.t, newData); +} + +/*! \overload + + Adds the provided single data point as \a key and \a value pair to the current data The t + parameter of the data point is set to the t of the last data point plus 1. If there is no last + data point, t will be set to 0. + + \see removeData +*/ +void QCPCurve::addData(double key, double value) +{ + QCPCurveData newData; + if (!mData->isEmpty()) + newData.t = (mData->constEnd()-1).key()+1; + else + newData.t = 0; + newData.key = key; + newData.value = value; + mData->insertMulti(newData.t, newData); +} + +/*! \overload + Adds the provided data points as \a t, \a key and \a value tuples to the current data. + \see removeData +*/ +void QCPCurve::addData(const QVector &ts, const QVector &keys, const QVector &values) +{ + int n = ts.size(); + n = qMin(n, keys.size()); + n = qMin(n, values.size()); + QCPCurveData newData; + for (int i=0; iinsertMulti(newData.t, newData); + } +} + +/*! + Removes all data points with curve parameter t smaller than \a t. + \see addData, clearData +*/ +void QCPCurve::removeDataBefore(double t) +{ + QCPCurveDataMap::iterator it = mData->begin(); + while (it != mData->end() && it.key() < t) + it = mData->erase(it); +} + +/*! + Removes all data points with curve parameter t greater than \a t. + \see addData, clearData +*/ +void QCPCurve::removeDataAfter(double t) +{ + if (mData->isEmpty()) return; + QCPCurveDataMap::iterator it = mData->upperBound(t); + while (it != mData->end()) + it = mData->erase(it); +} + +/*! + Removes all data points with curve parameter t between \a fromt and \a tot. if \a fromt is + greater or equal to \a tot, the function does nothing. To remove a single data point with known + t, use \ref removeData(double t). + + \see addData, clearData +*/ +void QCPCurve::removeData(double fromt, double tot) +{ + if (fromt >= tot || mData->isEmpty()) return; + QCPCurveDataMap::iterator it = mData->upperBound(fromt); + QCPCurveDataMap::iterator itEnd = mData->upperBound(tot); + while (it != itEnd) + it = mData->erase(it); +} + +/*! \overload + + Removes a single data point at curve parameter \a t. If the position is not known with absolute + precision, consider using \ref removeData(double fromt, double tot) with a small fuzziness + interval around the suspected position, depeding on the precision with which the curve parameter + is known. + + \see addData, clearData +*/ +void QCPCurve::removeData(double t) +{ + mData->remove(t); +} + +/*! + Removes all data points. + \see removeData, removeDataAfter, removeDataBefore +*/ +void QCPCurve::clearData() +{ + mData->clear(); +} + +/* inherits documentation from base class */ +double QCPCurve::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + Q_UNUSED(details) + if ((onlySelectable && !mSelectable) || mData->isEmpty()) + return -1; + if (!mKeyAxis || !mValueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return -1; } + + if (mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint())) + return pointDistance(pos); + else + return -1; +} + +/* inherits documentation from base class */ +void QCPCurve::draw(QCPPainter *painter) +{ + if (mData->isEmpty()) return; + + // allocate line vector: + QVector *lineData = new QVector; + + // fill with curve data: + getCurveData(lineData); + + // check data validity if flag set: +#ifdef QCUSTOMPLOT_CHECK_DATA + QCPCurveDataMap::const_iterator it; + for (it = mData->constBegin(); it != mData->constEnd(); ++it) + { + if (QCP::isInvalidData(it.value().t) || + QCP::isInvalidData(it.value().key, it.value().value)) + qDebug() << Q_FUNC_INFO << "Data point at" << it.key() << "invalid." << "Plottable name:" << name(); + } +#endif + + // draw curve fill: + if (mainBrush().style() != Qt::NoBrush && mainBrush().color().alpha() != 0) + { + applyFillAntialiasingHint(painter); + painter->setPen(Qt::NoPen); + painter->setBrush(mainBrush()); + painter->drawPolygon(QPolygonF(*lineData)); + } + + // draw curve line: + if (mLineStyle != lsNone && mainPen().style() != Qt::NoPen && mainPen().color().alpha() != 0) + { + applyDefaultAntialiasingHint(painter); + painter->setPen(mainPen()); + painter->setBrush(Qt::NoBrush); + // if drawing solid line and not in PDF, use much faster line drawing instead of polyline: + if (mParentPlot->plottingHints().testFlag(QCP::phFastPolylines) && + painter->pen().style() == Qt::SolidLine && + !painter->modes().testFlag(QCPPainter::pmVectorized) && + !painter->modes().testFlag(QCPPainter::pmNoCaching)) + { + for (int i=1; isize(); ++i) + painter->drawLine(lineData->at(i-1), lineData->at(i)); + } else + { + painter->drawPolyline(QPolygonF(*lineData)); + } + } + + // draw scatters: + if (!mScatterStyle.isNone()) + drawScatterPlot(painter, lineData); + + // free allocated line data: + delete lineData; +} + +/* inherits documentation from base class */ +void QCPCurve::drawLegendIcon(QCPPainter *painter, const QRectF &rect) const +{ + // draw fill: + if (mBrush.style() != Qt::NoBrush) + { + applyFillAntialiasingHint(painter); + painter->fillRect(QRectF(rect.left(), rect.top()+rect.height()/2.0, rect.width(), rect.height()/3.0), mBrush); + } + // draw line vertically centered: + if (mLineStyle != lsNone) + { + applyDefaultAntialiasingHint(painter); + painter->setPen(mPen); + painter->drawLine(QLineF(rect.left(), rect.top()+rect.height()/2.0, rect.right()+5, rect.top()+rect.height()/2.0)); // +5 on x2 else last segment is missing from dashed/dotted pens + } + // draw scatter symbol: + if (!mScatterStyle.isNone()) + { + applyScattersAntialiasingHint(painter); + // scale scatter pixmap if it's too large to fit in legend icon rect: + if (mScatterStyle.shape() == QCPScatterStyle::ssPixmap && (mScatterStyle.pixmap().size().width() > rect.width() || mScatterStyle.pixmap().size().height() > rect.height())) + { + QCPScatterStyle scaledStyle(mScatterStyle); + scaledStyle.setPixmap(scaledStyle.pixmap().scaled(rect.size().toSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation)); + scaledStyle.applyTo(painter, mPen); + scaledStyle.drawShape(painter, QRectF(rect).center()); + } else + { + mScatterStyle.applyTo(painter, mPen); + mScatterStyle.drawShape(painter, QRectF(rect).center()); + } + } +} + +/*! \internal + + Draws scatter symbols at every data point passed in \a pointData. scatter symbols are independent of + the line style and are always drawn if scatter shape is not \ref QCPScatterStyle::ssNone. +*/ +void QCPCurve::drawScatterPlot(QCPPainter *painter, const QVector *pointData) const +{ + // draw scatter point symbols: + applyScattersAntialiasingHint(painter); + mScatterStyle.applyTo(painter, mPen); + for (int i=0; isize(); ++i) + mScatterStyle.drawShape(painter, pointData->at(i)); +} + +/*! \internal + + called by QCPCurve::draw to generate a point vector (pixels) which represents the line of the + curve. Line segments that aren't visible in the current axis rect are handled in an optimized + way. +*/ +void QCPCurve::getCurveData(QVector *lineData) const +{ + /* Extended sides of axis rect R divide space into 9 regions: + 1__|_4_|__7 + 2__|_R_|__8 + 3 | 6 | 9 + General idea: If the two points of a line segment are in the same region (that is not R), the line segment corner is removed. + Curves outside R become straight lines closely outside of R which greatly reduces drawing time, yet keeps the look of lines and + fills inside R consistent. + The region R has index 5. + */ + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + + QRect axisRect = mKeyAxis.data()->axisRect()->rect() & mValueAxis.data()->axisRect()->rect(); + lineData->reserve(mData->size()); + QCPCurveDataMap::const_iterator it; + int lastRegion = 5; + int currentRegion = 5; + double RLeft = keyAxis->range().lower; + double RRight = keyAxis->range().upper; + double RBottom = valueAxis->range().lower; + double RTop = valueAxis->range().upper; + double x, y; // current key/value + bool addedLastAlready = true; + bool firstPoint = true; // first point must always be drawn, to make sure fill works correctly + for (it = mData->constBegin(); it != mData->constEnd(); ++it) + { + x = it.value().key; + y = it.value().value; + // determine current region: + if (x < RLeft) // region 123 + { + if (y > RTop) + currentRegion = 1; + else if (y < RBottom) + currentRegion = 3; + else + currentRegion = 2; + } else if (x > RRight) // region 789 + { + if (y > RTop) + currentRegion = 7; + else if (y < RBottom) + currentRegion = 9; + else + currentRegion = 8; + } else // region 456 + { + if (y > RTop) + currentRegion = 4; + else if (y < RBottom) + currentRegion = 6; + else + currentRegion = 5; + } + + /* + Watch out, the next part is very tricky. It modifies the curve such that it seems like the + whole thing is still drawn, but actually the points outside the axisRect are simplified + ("optimized") greatly. There are some subtle special cases when line segments are large and + thereby each subsequent point may be in a different region or even skip some. + */ + // determine whether to keep current point: + if (currentRegion == 5 || (firstPoint && mBrush.style() != Qt::NoBrush)) // current is in R, add current and last if it wasn't added already + { + if (!addedLastAlready) // in case curve just entered R, make sure the last point outside R is also drawn correctly + lineData->append(coordsToPixels((it-1).value().key, (it-1).value().value)); // add last point to vector + else if (lastRegion != 5) // added last already. If that's the case, we probably added it at optimized position. So go back and make sure it's at original position (else the angle changes under which this segment enters R) + { + if (!firstPoint) // because on firstPoint, currentRegion is 5 and addedLastAlready is true, although there is no last point + lineData->replace(lineData->size()-1, coordsToPixels((it-1).value().key, (it-1).value().value)); + } + lineData->append(coordsToPixels(it.value().key, it.value().value)); // add current point to vector + addedLastAlready = true; // so in next iteration, we don't add this point twice + } else if (currentRegion != lastRegion) // changed region, add current and last if not added already + { + // using outsideCoordsToPixels instead of coorsToPixels for optimized point placement (places points just outside axisRect instead of potentially far away) + + // if we're coming from R or we skip diagonally over the corner regions (so line might still be visible in R), we can't place points optimized + if (lastRegion == 5 || // coming from R + ((lastRegion==2 && currentRegion==4) || (lastRegion==4 && currentRegion==2)) || // skip top left diagonal + ((lastRegion==4 && currentRegion==8) || (lastRegion==8 && currentRegion==4)) || // skip top right diagonal + ((lastRegion==8 && currentRegion==6) || (lastRegion==6 && currentRegion==8)) || // skip bottom right diagonal + ((lastRegion==6 && currentRegion==2) || (lastRegion==2 && currentRegion==6)) // skip bottom left diagonal + ) + { + // always add last point if not added already, original: + if (!addedLastAlready) + lineData->append(coordsToPixels((it-1).value().key, (it-1).value().value)); + // add current point, original: + lineData->append(coordsToPixels(it.value().key, it.value().value)); + } else // no special case that forbids optimized point placement, so do it: + { + // always add last point if not added already, optimized: + if (!addedLastAlready) + lineData->append(outsideCoordsToPixels((it-1).value().key, (it-1).value().value, currentRegion, axisRect)); + // add current point, optimized: + lineData->append(outsideCoordsToPixels(it.value().key, it.value().value, currentRegion, axisRect)); + } + addedLastAlready = true; // so that if next point enters 5, or crosses another region boundary, we don't add this point twice + } else // neither in R, nor crossed a region boundary, skip current point + { + addedLastAlready = false; + } + lastRegion = currentRegion; + firstPoint = false; + } + // If curve ends outside R, we want to add very last point so the fill looks like it should when the curve started inside R: + if (lastRegion != 5 && mBrush.style() != Qt::NoBrush && !mData->isEmpty()) + lineData->append(coordsToPixels((mData->constEnd()-1).value().key, (mData->constEnd()-1).value().value)); +} + +/*! \internal + + Calculates the (minimum) distance (in pixels) the curve's representation has from the given \a + pixelPoint in pixels. This is used to determine whether the curve was clicked or not, e.g. in + \ref selectTest. +*/ +double QCPCurve::pointDistance(const QPointF &pixelPoint) const +{ + if (mData->isEmpty()) + { + qDebug() << Q_FUNC_INFO << "requested point distance on curve" << mName << "without data"; + return 500; + } + if (mData->size() == 1) + { + QPointF dataPoint = coordsToPixels(mData->constBegin().key(), mData->constBegin().value().value); + return QVector2D(dataPoint-pixelPoint).length(); + } + + // calculate minimum distance to line segments: + QVector *lineData = new QVector; + getCurveData(lineData); + double minDistSqr = std::numeric_limits::max(); + for (int i=0; isize()-1; ++i) + { + double currentDistSqr = distSqrToLine(lineData->at(i), lineData->at(i+1), pixelPoint); + if (currentDistSqr < minDistSqr) + minDistSqr = currentDistSqr; + } + delete lineData; + return sqrt(minDistSqr); +} + +/*! \internal + + This is a specialized \ref coordsToPixels function for points that are outside the visible + axisRect and just crossing a boundary (since \ref getCurveData reduces non-visible curve segments + to those line segments that cross region boundaries, see documentation there). It only uses the + coordinate parallel to the region boundary of the axisRect. The other coordinate is picked just + outside the axisRect (how far is determined by the scatter size and the line width). Together + with the optimization in \ref getCurveData this improves performance for large curves (or zoomed + in ones) significantly while keeping the illusion the whole curve and its filling is still being + drawn for the viewer. +*/ +QPointF QCPCurve::outsideCoordsToPixels(double key, double value, int region, QRect axisRect) const +{ + int margin = qCeil(qMax(mScatterStyle.size(), (double)mPen.widthF())) + 2; + QPointF result = coordsToPixels(key, value); + switch (region) + { + case 2: result.setX(axisRect.left()-margin); break; // left + case 8: result.setX(axisRect.right()+margin); break; // right + case 4: result.setY(axisRect.top()-margin); break; // top + case 6: result.setY(axisRect.bottom()+margin); break; // bottom + case 1: result.setX(axisRect.left()-margin); + result.setY(axisRect.top()-margin); break; // top left + case 7: result.setX(axisRect.right()+margin); + result.setY(axisRect.top()-margin); break; // top right + case 9: result.setX(axisRect.right()+margin); + result.setY(axisRect.bottom()+margin); break; // bottom right + case 3: result.setX(axisRect.left()-margin); + result.setY(axisRect.bottom()+margin); break; // bottom left + } + return result; +} + +/* inherits documentation from base class */ +QCPRange QCPCurve::getKeyRange(bool &foundRange, SignDomain inSignDomain) const +{ + QCPRange range; + bool haveLower = false; + bool haveUpper = false; + + double current; + + QCPCurveDataMap::const_iterator it = mData->constBegin(); + while (it != mData->constEnd()) + { + current = it.value().key; + if (inSignDomain == sdBoth || (inSignDomain == sdNegative && current < 0) || (inSignDomain == sdPositive && current > 0)) + { + if (current < range.lower || !haveLower) + { + range.lower = current; + haveLower = true; + } + if (current > range.upper || !haveUpper) + { + range.upper = current; + haveUpper = true; + } + } + ++it; + } + + foundRange = haveLower && haveUpper; + return range; +} + +/* inherits documentation from base class */ +QCPRange QCPCurve::getValueRange(bool &foundRange, SignDomain inSignDomain) const +{ + QCPRange range; + bool haveLower = false; + bool haveUpper = false; + + double current; + + QCPCurveDataMap::const_iterator it = mData->constBegin(); + while (it != mData->constEnd()) + { + current = it.value().value; + if (inSignDomain == sdBoth || (inSignDomain == sdNegative && current < 0) || (inSignDomain == sdPositive && current > 0)) + { + if (current < range.lower || !haveLower) + { + range.lower = current; + haveLower = true; + } + if (current > range.upper || !haveUpper) + { + range.upper = current; + haveUpper = true; + } + } + ++it; + } + + foundRange = haveLower && haveUpper; + return range; } //////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////// QCPItemText +//////////////////// QCPBarData //////////////////////////////////////////////////////////////////////////////////////////////////// -/*! \class QCPItemText - \brief A text label - - \image html QCPItemText.png "Text example. Blue dotted circles are anchors, solid blue discs are positions." - - Its position is defined by the member \a position and the setting of \ref setPositionAlignment. - The latter controls which part of the text rect shall be aligned with \a position. +/*! \class QCPBarData + \brief Holds the data of one single data point (one bar) for QCPBars. - The text alignment itself (i.e. left, center, right) can be controlled with \ref - setTextAlignment. + The container for storing multiple data points is \ref QCPBarDataMap. - The text may be rotated around the \a position point with \ref setRotation. -*/ - -/*! - Creates a text item and sets default values. + The stored data is: + \li \a key: coordinate on the key axis of this bar + \li \a value: height coordinate on the value axis of this bar - The constructed item can be added to the plot with QCustomPlot::addItem. + \see QCPBarDataaMap */ -QCPItemText::QCPItemText(QCustomPlot *parentPlot) : - QCPAbstractItem(parentPlot), - position(createPosition("position")), - topLeft(createAnchor("topLeft", aiTopLeft)), - top(createAnchor("top", aiTop)), - topRight(createAnchor("topRight", aiTopRight)), - right(createAnchor("right", aiRight)), - bottomRight(createAnchor("bottomRight", aiBottomRight)), - bottom(createAnchor("bottom", aiBottom)), - bottomLeft(createAnchor("bottomLeft", aiBottomLeft)), - left(createAnchor("left", aiLeft)) -{ - position->setCoords(0, 0); - - setRotation(0); - setTextAlignment(Qt::AlignTop|Qt::AlignHCenter); - setPositionAlignment(Qt::AlignCenter); - setText("text"); - - setPen(Qt::NoPen); - setSelectedPen(Qt::NoPen); - setBrush(Qt::NoBrush); - setSelectedBrush(Qt::NoBrush); - setColor(Qt::black); - setSelectedColor(Qt::blue); -} - -QCPItemText::~QCPItemText() -{ -} /*! - Sets the color of the text. + Constructs a bar data point with key and value set to zero. */ -void QCPItemText::setColor(const QColor &color) +QCPBarData::QCPBarData() : + key(0), + value(0) { - mColor = color; } /*! - Sets the color of the text that will be used when the item is selected. + Constructs a bar data point with the specified \a key and \a value. */ -void QCPItemText::setSelectedColor(const QColor &color) +QCPBarData::QCPBarData(double key, double value) : + key(key), + value(value) { - mSelectedColor = color; } -/*! - Sets the pen that will be used do draw a rectangular border around the text. To disable the - border, set \a pen to Qt::NoPen. - - \see setSelectedPen, setBrush, setPadding -*/ -void QCPItemText::setPen(const QPen &pen) -{ - mPen = pen; -} -/*! - Sets the pen that will be used do draw a rectangular border around the text, when the item is - selected. To disable the border, set \a pen to Qt::NoPen. - - \see setPen -*/ -void QCPItemText::setSelectedPen(const QPen &pen) -{ - mSelectedPen = pen; -} +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPBars +//////////////////////////////////////////////////////////////////////////////////////////////////// -/*! - Sets the brush that will be used do fill the background of the text. To disable the - background, set \a brush to Qt::NoBrush. - - \see setSelectedBrush, setPen, setPadding -*/ -void QCPItemText::setBrush(const QBrush &brush) -{ - mBrush = brush; -} +/*! \class QCPBars + \brief A plottable representing a bar chart in a plot. -/*! - Sets the brush that will be used do fill the background of the text, when the item is selected. To disable the - background, set \a brush to Qt::NoBrush. + \image html QCPBars.png - \see setBrush -*/ -void QCPItemText::setSelectedBrush(const QBrush &brush) -{ - mSelectedBrush = brush; -} - -/*! - Sets the font of the text. + To plot data, assign it with the \ref setData or \ref addData functions. - \see setSelectedFont, setColor + \section appearance Changing the appearance + + The appearance of the bars is determined by the pen and the brush (\ref setPen, \ref setBrush). + + Bar charts are stackable. This means, Two QCPBars plottables can be placed on top of each other + (see \ref QCPBars::moveAbove). Then, when two bars are at the same key position, they will appear + stacked. + + \section usage Usage + + Like all data representing objects in QCustomPlot, the QCPBars is a plottable + (QCPAbstractPlottable). So the plottable-interface of QCustomPlot applies + (QCustomPlot::plottable, QCustomPlot::addPlottable, QCustomPlot::removePlottable, etc.) + + Usually, you first create an instance: + \code + QCPBars *newBars = new QCPBars(customPlot->xAxis, customPlot->yAxis);\endcode + add it to the customPlot with QCustomPlot::addPlottable: + \code + customPlot->addPlottable(newBars);\endcode + and then modify the properties of the newly created plottable, e.g.: + \code + newBars->setName("Country population"); + newBars->setData(xData, yData);\endcode */ -void QCPItemText::setFont(const QFont &font) -{ - mFont = font; -} -/*! - Sets the font of the text that will be used when the item is selected. +/*! \fn QCPBars *QCPBars::barBelow() const + Returns the bars plottable that is directly below this bars plottable. + If there is no such plottable, returns 0. - \see setFont + \see barAbove, moveBelow, moveAbove */ -void QCPItemText::setSelectedFont(const QFont &font) -{ - mSelectedFont = font; -} -/*! - Sets the text that will be displayed. Multi-line texts are supported by inserting a line break - character, e.g. '\n'. +/*! \fn QCPBars *QCPBars::barAbove() const + Returns the bars plottable that is directly above this bars plottable. + If there is no such plottable, returns 0. - \see setFont, setColor, setTextAlignment + \see barBelow, moveBelow, moveAbove */ -void QCPItemText::setText(const QString &text) -{ - mText = text; -} /*! - Sets which point of the text rect shall be aligned with \a position. - - Examples: - \li If \a alignment is Qt::AlignHCenter | Qt::AlignTop, the text will be positioned such - that the top of the text rect will be horizontally centered on \a position. - \li If \a alignment is Qt::AlignLeft | Qt::AlignBottom, \a position will indicate the - bottom left corner of the text rect. + Constructs a bar chart which uses \a keyAxis as its key axis ("x") and \a valueAxis as its value + axis ("y"). \a keyAxis and \a valueAxis must reside in the same QCustomPlot instance and not have + the same orientation. If either of these restrictions is violated, a corresponding message is + printed to the debug output (qDebug), the construction is not aborted, though. - If you want to control the alignment of (multi-lined) text within the text rect, use \ref - setTextAlignment. + The constructed QCPBars can be added to the plot with QCustomPlot::addPlottable, QCustomPlot + then takes ownership of the bar chart. */ -void QCPItemText::setPositionAlignment(Qt::Alignment alignment) +QCPBars::QCPBars(QCPAxis *keyAxis, QCPAxis *valueAxis) : + QCPAbstractPlottable(keyAxis, valueAxis) { - mPositionAlignment = alignment; + mData = new QCPBarDataMap; + mPen.setColor(Qt::blue); + mPen.setStyle(Qt::SolidLine); + mBrush.setColor(QColor(40, 50, 255, 30)); + mBrush.setStyle(Qt::SolidPattern); + mSelectedPen = mPen; + mSelectedPen.setWidthF(2.5); + mSelectedPen.setColor(QColor(80, 80, 255)); // lighter than Qt::blue of mPen + mSelectedBrush = mBrush; + + mWidth = 0.75; } -/*! - Controls how (multi-lined) text is aligned inside the text rect (typically Qt::AlignLeft, Qt::AlignCenter or Qt::AlignRight). -*/ -void QCPItemText::setTextAlignment(Qt::Alignment alignment) +QCPBars::~QCPBars() { - mTextAlignment = alignment; + if (mBarBelow || mBarAbove) + connectBars(mBarBelow.data(), mBarAbove.data()); // take this bar out of any stacking + delete mData; } /*! - Sets the angle in degrees by which the text (and the text rectangle, if visible) will be rotated - around \a position. + Sets the width of the bars in plot (key) coordinates. */ -void QCPItemText::setRotation(double degrees) +void QCPBars::setWidth(double width) { - mRotation = degrees; + mWidth = width; } /*! - Sets the distance between the border of the text rectangle and the text. The appearance (and - visibility) of the text rectangle can be controlled with \ref setPen and \ref setBrush. + Replaces the current data with the provided \a data. + + If \a copy is set to true, data points in \a data will only be copied. if false, the plottable + takes ownership of the passed data and replaces the internal data pointer with it. This is + significantly faster than copying for large datasets. */ -void QCPItemText::setPadding(const QMargins &padding) -{ - mPadding = padding; -} - -/* inherits documentation from base class */ -double QCPItemText::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +void QCPBars::setData(QCPBarDataMap *data, bool copy) { - Q_UNUSED(details) - if (onlySelectable && !mSelectable) - return -1; - - // The rect may be rotated, so we transform the actual clicked pos to the rotated - // coordinate system, so we can use the normal rectSelectTest function for non-rotated rects: - QPointF positionPixels(position->pixelPoint()); - QTransform inputTransform; - inputTransform.translate(positionPixels.x(), positionPixels.y()); - inputTransform.rotate(-mRotation); - inputTransform.translate(-positionPixels.x(), -positionPixels.y()); - QPointF rotatedPos = inputTransform.map(pos); - QFontMetrics fontMetrics(mFont); - QRect textRect = fontMetrics.boundingRect(0, 0, 0, 0, Qt::TextDontClip|mTextAlignment, mText); - QRect textBoxRect = textRect.adjusted(-mPadding.left(), -mPadding.top(), mPadding.right(), mPadding.bottom()); - QPointF textPos = getTextDrawPoint(positionPixels, textBoxRect, mPositionAlignment); - textBoxRect.moveTopLeft(textPos.toPoint()); - - return rectSelectTest(textBoxRect, rotatedPos, true); + if (copy) + { + *mData = *data; + } else + { + delete mData; + mData = data; + } } -/* inherits documentation from base class */ -void QCPItemText::draw(QCPPainter *painter) +/*! \overload + + Replaces the current data with the provided points in \a key and \a value tuples. The + provided vectors should have equal length. Else, the number of added points will be the size of + the smallest vector. +*/ +void QCPBars::setData(const QVector &key, const QVector &value) { - QPointF pos(position->pixelPoint()); - QTransform transform = painter->transform(); - transform.translate(pos.x(), pos.y()); - if (!qFuzzyIsNull(mRotation)) - transform.rotate(mRotation); - painter->setFont(mainFont()); - QRect textRect = painter->fontMetrics().boundingRect(0, 0, 0, 0, Qt::TextDontClip|mTextAlignment, mText); - QRect textBoxRect = textRect.adjusted(-mPadding.left(), -mPadding.top(), mPadding.right(), mPadding.bottom()); - QPointF textPos = getTextDrawPoint(QPointF(0, 0), textBoxRect, mPositionAlignment); // 0, 0 because the transform does the translation - textRect.moveTopLeft(textPos.toPoint()+QPoint(mPadding.left(), mPadding.top())); - textBoxRect.moveTopLeft(textPos.toPoint()); - double clipPad = mainPen().widthF(); - QRect boundingRect = textBoxRect.adjusted(-clipPad, -clipPad, clipPad, clipPad); - if (transform.mapRect(boundingRect).intersects(painter->transform().mapRect(clipRect()))) + mData->clear(); + int n = key.size(); + n = qMin(n, value.size()); + QCPBarData newData; + for (int i=0; isetTransform(transform); - if ((mainBrush().style() != Qt::NoBrush && mainBrush().color().alpha() != 0) || - (mainPen().style() != Qt::NoPen && mainPen().color().alpha() != 0)) - { - painter->setPen(mainPen()); - painter->setBrush(mainBrush()); - painter->drawRect(textBoxRect); - } - painter->setBrush(Qt::NoBrush); - painter->setPen(QPen(mainColor())); - painter->drawText(textRect, Qt::TextDontClip|mTextAlignment, mText); + newData.key = key[i]; + newData.value = value[i]; + mData->insertMulti(newData.key, newData); } } -/* inherits documentation from base class */ -QPointF QCPItemText::anchorPixelPoint(int anchorId) const -{ - // get actual rect points (pretty much copied from draw function): - QPointF pos(position->pixelPoint()); - QTransform transform; - transform.translate(pos.x(), pos.y()); - if (!qFuzzyIsNull(mRotation)) - transform.rotate(mRotation); - QFontMetrics fontMetrics(mainFont()); - QRect textRect = fontMetrics.boundingRect(0, 0, 0, 0, Qt::TextDontClip|mTextAlignment, mText); - QRectF textBoxRect = textRect.adjusted(-mPadding.left(), -mPadding.top(), mPadding.right(), mPadding.bottom()); - QPointF textPos = getTextDrawPoint(QPointF(0, 0), textBoxRect, mPositionAlignment); // 0, 0 because the transform does the translation - textBoxRect.moveTopLeft(textPos.toPoint()); - QPolygonF rectPoly = transform.map(QPolygonF(textBoxRect)); +/*! + Moves this bars plottable below \a bars. In other words, the bars of this plottable will appear + below the bars of \a bars. The move target \a bars must use the same key and value axis as this + plottable. - switch (anchorId) + Inserting into and removing from existing bar stacking is handled gracefully. If \a bars already + has a bars object below itself, this bars object is inserted between the two. If this bars object + is already between two other bars, the two other bars will be stacked on top of each other after + the operation. + + To remove this bars plottable from any stacking, set \a bars to 0. + + \see moveBelow, barAbove, barBelow +*/ +void QCPBars::moveBelow(QCPBars *bars) +{ + if (bars == this) return; + if (bars && (bars->keyAxis() != mKeyAxis.data() || bars->valueAxis() != mValueAxis.data())) { - case aiTopLeft: return rectPoly.at(0); - case aiTop: return (rectPoly.at(0)+rectPoly.at(1))*0.5; - case aiTopRight: return rectPoly.at(1); - case aiRight: return (rectPoly.at(1)+rectPoly.at(2))*0.5; - case aiBottomRight: return rectPoly.at(2); - case aiBottom: return (rectPoly.at(2)+rectPoly.at(3))*0.5; - case aiBottomLeft: return rectPoly.at(3); - case aiLeft: return (rectPoly.at(3)+rectPoly.at(0))*0.5; + qDebug() << Q_FUNC_INFO << "passed QCPBars* doesn't have same key and value axis as this QCPBars"; + return; + } + // remove from stacking: + connectBars(mBarBelow.data(), mBarAbove.data()); // Note: also works if one (or both) of them is 0 + // if new bar given, insert this bar below it: + if (bars) + { + if (bars->mBarBelow) + connectBars(bars->mBarBelow.data(), this); + connectBars(this, bars); } - - qDebug() << Q_FUNC_INFO << "invalid anchorId" << anchorId; - return QPointF(); } -/*! \internal +/*! + Moves this bars plottable above \a bars. In other words, the bars of this plottable will appear + above the bars of \a bars. The move target \a bars must use the same key and value axis as this + plottable. - Returns the point that must be given to the QPainter::drawText function (which expects the top - left point of the text rect), according to the position \a pos, the text bounding box \a rect and - the requested \a positionAlignment. + Inserting into and removing from existing bar stacking is handled gracefully. If \a bars already + has a bars object below itself, this bars object is inserted between the two. If this bars object + is already between two other bars, the two other bars will be stacked on top of each other after + the operation. - For example, if \a positionAlignment is Qt::AlignLeft | Qt::AlignBottom the returned point - will be shifted upward by the height of \a rect, starting from \a pos. So if the text is finally - drawn at that point, the lower left corner of the resulting text rect is at \a pos. + To remove this bars plottable from any stacking, set \a bars to 0. + + \see moveBelow, barBelow, barAbove */ -QPointF QCPItemText::getTextDrawPoint(const QPointF &pos, const QRectF &rect, Qt::Alignment positionAlignment) const +void QCPBars::moveAbove(QCPBars *bars) { - if (positionAlignment == 0 || positionAlignment == (Qt::AlignLeft|Qt::AlignTop)) - return pos; - - QPointF result = pos; // start at top left - if (positionAlignment.testFlag(Qt::AlignHCenter)) - result.rx() -= rect.width()/2.0; - else if (positionAlignment.testFlag(Qt::AlignRight)) - result.rx() -= rect.width(); - if (positionAlignment.testFlag(Qt::AlignVCenter)) - result.ry() -= rect.height()/2.0; - else if (positionAlignment.testFlag(Qt::AlignBottom)) - result.ry() -= rect.height(); - return result; + if (bars == this) return; + if (bars && (bars->keyAxis() != mKeyAxis.data() || bars->valueAxis() != mValueAxis.data())) + { + qDebug() << Q_FUNC_INFO << "passed QCPBars* doesn't have same key and value axis as this QCPBars"; + return; + } + // remove from stacking: + connectBars(mBarBelow.data(), mBarAbove.data()); // Note: also works if one (or both) of them is 0 + // if new bar given, insert this bar above it: + if (bars) + { + if (bars->mBarAbove) + connectBars(this, bars->mBarAbove.data()); + connectBars(bars, this); + } } -/*! \internal - - Returns the font that should be used for drawing text. Returns mFont when the item is not selected - and mSelectedFont when it is. +/*! + Adds the provided data points in \a dataMap to the current data. + \see removeData */ -QFont QCPItemText::mainFont() const +void QCPBars::addData(const QCPBarDataMap &dataMap) { - return mSelected ? mSelectedFont : mFont; + mData->unite(dataMap); } -/*! \internal - - Returns the color that should be used for drawing text. Returns mColor when the item is not - selected and mSelectedColor when it is. +/*! \overload + Adds the provided single data point in \a data to the current data. + \see removeData */ -QColor QCPItemText::mainColor() const +void QCPBars::addData(const QCPBarData &data) { - return mSelected ? mSelectedColor : mColor; + mData->insertMulti(data.key, data); } -/*! \internal - - Returns the pen that should be used for drawing lines. Returns mPen when the item is not selected - and mSelectedPen when it is. +/*! \overload + Adds the provided single data point as \a key and \a value tuple to the current data + \see removeData */ -QPen QCPItemText::mainPen() const +void QCPBars::addData(double key, double value) { - return mSelected ? mSelectedPen : mPen; + QCPBarData newData; + newData.key = key; + newData.value = value; + mData->insertMulti(newData.key, newData); } -/*! \internal - - Returns the brush that should be used for drawing fills of the item. Returns mBrush when the item - is not selected and mSelectedBrush when it is. +/*! \overload + Adds the provided data points as \a key and \a value tuples to the current data. + \see removeData */ -QBrush QCPItemText::mainBrush() const +void QCPBars::addData(const QVector &keys, const QVector &values) { - return mSelected ? mSelectedBrush : mBrush; + int n = keys.size(); + n = qMin(n, values.size()); + QCPBarData newData; + for (int i=0; iinsertMulti(newData.key, newData); + } } - -//////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////// QCPItemEllipse -//////////////////////////////////////////////////////////////////////////////////////////////////// - -/*! \class QCPItemEllipse - \brief An ellipse - - \image html QCPItemEllipse.png "Ellipse example. Blue dotted circles are anchors, solid blue discs are positions." - - It has two positions, \a topLeft and \a bottomRight, which define the rect the ellipse will be drawn in. -*/ - /*! - Creates an ellipse item and sets default values. - - The constructed item can be added to the plot with QCustomPlot::addItem. + Removes all data points with key smaller than \a key. + \see addData, clearData */ -QCPItemEllipse::QCPItemEllipse(QCustomPlot *parentPlot) : - QCPAbstractItem(parentPlot), - topLeft(createPosition("topLeft")), - bottomRight(createPosition("bottomRight")), - topLeftRim(createAnchor("topLeftRim", aiTopLeftRim)), - top(createAnchor("top", aiTop)), - topRightRim(createAnchor("topRightRim", aiTopRightRim)), - right(createAnchor("right", aiRight)), - bottomRightRim(createAnchor("bottomRightRim", aiBottomRightRim)), - bottom(createAnchor("bottom", aiBottom)), - bottomLeftRim(createAnchor("bottomLeftRim", aiBottomLeftRim)), - left(createAnchor("left", aiLeft)), - center(createAnchor("center", aiCenter)) -{ - topLeft->setCoords(0, 1); - bottomRight->setCoords(1, 0); - - setPen(QPen(Qt::black)); - setSelectedPen(QPen(Qt::blue, 2)); - setBrush(Qt::NoBrush); - setSelectedBrush(Qt::NoBrush); -} - -QCPItemEllipse::~QCPItemEllipse() +void QCPBars::removeDataBefore(double key) { + QCPBarDataMap::iterator it = mData->begin(); + while (it != mData->end() && it.key() < key) + it = mData->erase(it); } /*! - Sets the pen that will be used to draw the line of the ellipse - - \see setSelectedPen, setBrush + Removes all data points with key greater than \a key. + \see addData, clearData */ -void QCPItemEllipse::setPen(const QPen &pen) +void QCPBars::removeDataAfter(double key) { - mPen = pen; + if (mData->isEmpty()) return; + QCPBarDataMap::iterator it = mData->upperBound(key); + while (it != mData->end()) + it = mData->erase(it); } /*! - Sets the pen that will be used to draw the line of the ellipse when selected + Removes all data points with key between \a fromKey and \a toKey. if \a fromKey is + greater or equal to \a toKey, the function does nothing. To remove a single data point with known + key, use \ref removeData(double key). - \see setPen, setSelected + \see addData, clearData */ -void QCPItemEllipse::setSelectedPen(const QPen &pen) +void QCPBars::removeData(double fromKey, double toKey) { - mSelectedPen = pen; + if (fromKey >= toKey || mData->isEmpty()) return; + QCPBarDataMap::iterator it = mData->upperBound(fromKey); + QCPBarDataMap::iterator itEnd = mData->upperBound(toKey); + while (it != itEnd) + it = mData->erase(it); } -/*! - Sets the brush that will be used to fill the ellipse. To disable filling, set \a brush to - Qt::NoBrush. +/*! \overload - \see setSelectedBrush, setPen + Removes a single data point at \a key. If the position is not known with absolute precision, + consider using \ref removeData(double fromKey, double toKey) with a small fuzziness interval + around the suspected position, depeding on the precision with which the key is known. + + \see addData, clearData */ -void QCPItemEllipse::setBrush(const QBrush &brush) +void QCPBars::removeData(double key) { - mBrush = brush; + mData->remove(key); } /*! - Sets the brush that will be used to fill the ellipse when selected. To disable filling, set \a - brush to Qt::NoBrush. - - \see setBrush + Removes all data points. + \see removeData, removeDataAfter, removeDataBefore */ -void QCPItemEllipse::setSelectedBrush(const QBrush &brush) +void QCPBars::clearData() { - mSelectedBrush = brush; + mData->clear(); } /* inherits documentation from base class */ -double QCPItemEllipse::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +double QCPBars::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { Q_UNUSED(details) if (onlySelectable && !mSelectable) return -1; + if (!mKeyAxis || !mValueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return -1; } - double result = -1; - QPointF p1 = topLeft->pixelPoint(); - QPointF p2 = bottomRight->pixelPoint(); - QPointF center((p1+p2)/2.0); - double a = qAbs(p1.x()-p2.x())/2.0; - double b = qAbs(p1.y()-p2.y())/2.0; - double x = pos.x()-center.x(); - double y = pos.y()-center.y(); - - // distance to border: - double c = 1.0/qSqrt(x*x/(a*a)+y*y/(b*b)); - result = qAbs(c-1)*qSqrt(x*x+y*y); - // filled ellipse, allow click inside to count as hit: - if (result > mParentPlot->selectionTolerance()*0.99 && mBrush.style() != Qt::NoBrush && mBrush.color().alpha() != 0) + if (mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint())) { - if (x*x/(a*a) + y*y/(b*b) <= 1) - result = mParentPlot->selectionTolerance()*0.99; + QCPBarDataMap::ConstIterator it; + double posKey, posValue; + pixelsToCoords(pos, posKey, posValue); + for (it = mData->constBegin(); it != mData->constEnd(); ++it) + { + double baseValue = getBaseValue(it.key(), it.value().value >=0); + QCPRange keyRange(it.key()-mWidth*0.5, it.key()+mWidth*0.5); + QCPRange valueRange(baseValue, baseValue+it.value().value); + if (keyRange.contains(posKey) && valueRange.contains(posValue)) + return mParentPlot->selectionTolerance()*0.99; + } } - return result; + return -1; } /* inherits documentation from base class */ -void QCPItemEllipse::draw(QCPPainter *painter) +void QCPBars::draw(QCPPainter *painter) { - QPointF p1 = topLeft->pixelPoint(); - QPointF p2 = bottomRight->pixelPoint(); - if (p1.toPoint() == p2.toPoint()) - return; - QRectF ellipseRect = QRectF(p1, p2).normalized(); - QRect clip = clipRect().adjusted(-mainPen().widthF(), -mainPen().widthF(), mainPen().widthF(), mainPen().widthF()); - if (ellipseRect.intersects(clip)) // only draw if bounding rect of ellipse is visible in cliprect + if (!mKeyAxis || !mValueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + if (mData->isEmpty()) return; + + QCPBarDataMap::const_iterator it; + for (it = mData->constBegin(); it != mData->constEnd(); ++it) { - painter->setPen(mainPen()); - painter->setBrush(mainBrush()); -#ifdef __EXCEPTIONS - try // drawEllipse sometimes throws exceptions if ellipse is too big - { + // skip bar if not visible in key axis range: + if (it.key()+mWidth*0.5 < mKeyAxis.data()->range().lower || it.key()-mWidth*0.5 > mKeyAxis.data()->range().upper) + continue; + // check data validity if flag set: +#ifdef QCUSTOMPLOT_CHECK_DATA + if (QCP::isInvalidData(it.value().key, it.value().value)) + qDebug() << Q_FUNC_INFO << "Data point at" << it.key() << "of drawn range invalid." << "Plottable name:" << name(); #endif - painter->drawEllipse(ellipseRect); -#ifdef __EXCEPTIONS - } catch (...) + QPolygonF barPolygon = getBarPolygon(it.key(), it.value().value); + // draw bar fill: + if (mainBrush().style() != Qt::NoBrush && mainBrush().color().alpha() != 0) { - qDebug() << Q_FUNC_INFO << "Item too large for memory, setting invisible"; - setVisible(false); + applyFillAntialiasingHint(painter); + painter->setPen(Qt::NoPen); + painter->setBrush(mainBrush()); + painter->drawPolygon(barPolygon); + } + // draw bar line: + if (mainPen().style() != Qt::NoPen && mainPen().color().alpha() != 0) + { + applyDefaultAntialiasingHint(painter); + painter->setPen(mainPen()); + painter->setBrush(Qt::NoBrush); + painter->drawPolyline(barPolygon); } -#endif } } /* inherits documentation from base class */ -QPointF QCPItemEllipse::anchorPixelPoint(int anchorId) const +void QCPBars::drawLegendIcon(QCPPainter *painter, const QRectF &rect) const { - QRectF rect = QRectF(topLeft->pixelPoint(), bottomRight->pixelPoint()); - switch (anchorId) - { - case aiTopLeftRim: return rect.center()+(rect.topLeft()-rect.center())*1/qSqrt(2); - case aiTop: return (rect.topLeft()+rect.topRight())*0.5; - case aiTopRightRim: return rect.center()+(rect.topRight()-rect.center())*1/qSqrt(2); - case aiRight: return (rect.topRight()+rect.bottomRight())*0.5; - case aiBottomRightRim: return rect.center()+(rect.bottomRight()-rect.center())*1/qSqrt(2); - case aiBottom: return (rect.bottomLeft()+rect.bottomRight())*0.5; - case aiBottomLeftRim: return rect.center()+(rect.bottomLeft()-rect.center())*1/qSqrt(2); - case aiLeft: return (rect.topLeft()+rect.bottomLeft())*0.5; - case aiCenter: return (rect.topLeft()+rect.bottomRight())*0.5; - } - - qDebug() << Q_FUNC_INFO << "invalid anchorId" << anchorId; - return QPointF(); + // draw filled rect: + applyDefaultAntialiasingHint(painter); + painter->setBrush(mBrush); + painter->setPen(mPen); + QRectF r = QRectF(0, 0, rect.width()*0.67, rect.height()*0.67); + r.moveCenter(rect.center()); + painter->drawRect(r); } /*! \internal - - Returns the pen that should be used for drawing lines. Returns mPen when the item is not selected - and mSelectedPen when it is. + + Returns the polygon of a single bar with \a key and \a value. The Polygon is open at the bottom + and shifted according to the bar stacking (see \ref moveAbove). */ -QPen QCPItemEllipse::mainPen() const +QPolygonF QCPBars::getBarPolygon(double key, double value) const { - return mSelected ? mSelectedPen : mPen; + QPolygonF result; + double baseValue = getBaseValue(key, value >= 0); + result << coordsToPixels(key-mWidth*0.5, baseValue); + result << coordsToPixels(key-mWidth*0.5, baseValue+value); + result << coordsToPixels(key+mWidth*0.5, baseValue+value); + result << coordsToPixels(key+mWidth*0.5, baseValue); + return result; } /*! \internal - - Returns the brush that should be used for drawing fills of the item. Returns mBrush when the item - is not selected and mSelectedBrush when it is. -*/ -QBrush QCPItemEllipse::mainBrush() const -{ - return mSelected ? mSelectedBrush : mBrush; -} - - -//////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////// QCPItemPixmap -//////////////////////////////////////////////////////////////////////////////////////////////////// - -/*! \class QCPItemPixmap - \brief An arbitrary pixmap - - \image html QCPItemPixmap.png "Pixmap example. Blue dotted circles are anchors, solid blue discs are positions." - - It has two positions, \a topLeft and \a bottomRight, which define the rectangle the pixmap will - be drawn in. Depending on the scale setting (\ref setScaled), the pixmap will be either scaled to - fit the rectangle or be drawn aligned to the topLeft position. - - If scaling is enabled and \a topLeft is further to the bottom/right than \a bottomRight (as shown - on the right side of the example image), the pixmap will be flipped in the respective - orientations. -*/ - -/*! - Creates a rectangle item and sets default values. - The constructed item can be added to the plot with QCustomPlot::addItem. -*/ -QCPItemPixmap::QCPItemPixmap(QCustomPlot *parentPlot) : - QCPAbstractItem(parentPlot), - topLeft(createPosition("topLeft")), - bottomRight(createPosition("bottomRight")), - top(createAnchor("top", aiTop)), - topRight(createAnchor("topRight", aiTopRight)), - right(createAnchor("right", aiRight)), - bottom(createAnchor("bottom", aiBottom)), - bottomLeft(createAnchor("bottomLeft", aiBottomLeft)), - left(createAnchor("left", aiLeft)) -{ - topLeft->setCoords(0, 1); - bottomRight->setCoords(1, 0); + This function is called to find at which value to start drawing the base of a bar at \a key, when + it is stacked on top of another QCPBars (e.g. with \ref moveAbove). - setPen(Qt::NoPen); - setSelectedPen(QPen(Qt::blue)); - setScaled(false, Qt::KeepAspectRatio); -} - -QCPItemPixmap::~QCPItemPixmap() -{ -} - -/*! - Sets the pixmap that will be displayed. -*/ -void QCPItemPixmap::setPixmap(const QPixmap &pixmap) -{ - mPixmap = pixmap; - if (mPixmap.isNull()) - qDebug() << Q_FUNC_INFO << "pixmap is null"; -} - -/*! - Sets whether the pixmap will be scaled to fit the rectangle defined by the \a topLeft and \a - bottomRight positions. + positive and negative bars are separated per stack (positive are stacked above 0-value upwards, + negative are stacked below 0-value downwards). This can be indicated with \a positive. So if the + bar for which we need the base value is negative, set \a positive to false. */ -void QCPItemPixmap::setScaled(bool scaled, Qt::AspectRatioMode aspectRatioMode) +double QCPBars::getBaseValue(double key, bool positive) const { - mScaled = scaled; - mAspectRatioMode = aspectRatioMode; - updateScaledPixmap(); + if (mBarBelow) + { + double max = 0; + // find bars of mBarBelow that are approximately at key and find largest one: + QCPBarDataMap::const_iterator it = mBarBelow.data()->mData->lowerBound(key-mWidth*0.1); + QCPBarDataMap::const_iterator itEnd = mBarBelow.data()->mData->upperBound(key+mWidth*0.1); + while (it != itEnd) + { + if ((positive && it.value().value > max) || + (!positive && it.value().value < max)) + max = it.value().value; + ++it; + } + // recurse down the bar-stack to find the total height: + return max + mBarBelow.data()->getBaseValue(key, positive); + } else + return 0; } -/*! - Sets the pen that will be used to draw a border around the pixmap. - - \see setSelectedPen, setBrush -*/ -void QCPItemPixmap::setPen(const QPen &pen) -{ - mPen = pen; -} +/*! \internal -/*! - Sets the pen that will be used to draw a border around the pixmap when selected + Connects \a below and \a above to each other via their mBarAbove/mBarBelow properties. + The bar(s) currently below lower and upper will become disconnected to lower/upper. - \see setPen, setSelected + If lower is zero, upper will be disconnected at the bottom. + If upper is zero, lower will be disconnected at the top. */ -void QCPItemPixmap::setSelectedPen(const QPen &pen) -{ - mSelectedPen = pen; -} - -/* inherits documentation from base class */ -double QCPItemPixmap::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +void QCPBars::connectBars(QCPBars *lower, QCPBars *upper) { - Q_UNUSED(details) - if (onlySelectable && !mSelectable) - return -1; + if (!lower && !upper) return; - return rectSelectTest(getFinalRect(), pos, true); + if (!lower) // disconnect upper at bottom + { + // disconnect old bar below upper: + if (upper->mBarBelow && upper->mBarBelow.data()->mBarAbove.data() == upper) + upper->mBarBelow.data()->mBarAbove = 0; + upper->mBarBelow = 0; + } else if (!upper) // disconnect lower at top + { + // disconnect old bar above lower: + if (lower->mBarAbove && lower->mBarAbove.data()->mBarBelow.data() == lower) + lower->mBarAbove.data()->mBarBelow = 0; + lower->mBarAbove = 0; + } else // connect lower and upper + { + // disconnect old bar above lower: + if (lower->mBarAbove && lower->mBarAbove.data()->mBarBelow.data() == lower) + lower->mBarAbove.data()->mBarBelow = 0; + // disconnect old bar below upper: + if (upper->mBarBelow && upper->mBarBelow.data()->mBarAbove.data() == upper) + upper->mBarBelow.data()->mBarAbove = 0; + lower->mBarAbove = upper; + upper->mBarBelow = lower; + } } /* inherits documentation from base class */ -void QCPItemPixmap::draw(QCPPainter *painter) +QCPRange QCPBars::getKeyRange(bool &foundRange, SignDomain inSignDomain) const { - bool flipHorz = false; - bool flipVert = false; - QRect rect = getFinalRect(&flipHorz, &flipVert); - double clipPad = mainPen().style() == Qt::NoPen ? 0 : mainPen().widthF(); - QRect boundingRect = rect.adjusted(-clipPad, -clipPad, clipPad, clipPad); - if (boundingRect.intersects(clipRect())) + QCPRange range; + bool haveLower = false; + bool haveUpper = false; + + double current; + double barWidthHalf = mWidth*0.5; + QCPBarDataMap::const_iterator it = mData->constBegin(); + while (it != mData->constEnd()) { - updateScaledPixmap(rect, flipHorz, flipVert); - painter->drawPixmap(rect.topLeft(), mScaled ? mScaledPixmap : mPixmap); - QPen pen = mainPen(); - if (pen.style() != Qt::NoPen) + current = it.value().key; + if (inSignDomain == sdBoth || (inSignDomain == sdNegative && current+barWidthHalf < 0) || (inSignDomain == sdPositive && current-barWidthHalf > 0)) { - painter->setPen(pen); - painter->setBrush(Qt::NoBrush); - painter->drawRect(rect); + if (current-barWidthHalf < range.lower || !haveLower) + { + range.lower = current-barWidthHalf; + haveLower = true; + } + if (current+barWidthHalf > range.upper || !haveUpper) + { + range.upper = current+barWidthHalf; + haveUpper = true; + } } + ++it; } + + foundRange = haveLower && haveUpper; + return range; } /* inherits documentation from base class */ -QPointF QCPItemPixmap::anchorPixelPoint(int anchorId) const +QCPRange QCPBars::getValueRange(bool &foundRange, SignDomain inSignDomain) const { - bool flipHorz; - bool flipVert; - QRect rect = getFinalRect(&flipHorz, &flipVert); - // we actually want denormal rects (negative width/height) here, so restore - // the flipped state: - if (flipHorz) - rect.adjust(rect.width(), 0, -rect.width(), 0); - if (flipVert) - rect.adjust(0, rect.height(), 0, -rect.height()); + QCPRange range; + bool haveLower = true; // set to true, because 0 should always be visible in bar charts + bool haveUpper = true; // set to true, because 0 should always be visible in bar charts - switch (anchorId) + double current; + + QCPBarDataMap::const_iterator it = mData->constBegin(); + while (it != mData->constEnd()) { - case aiTop: return (rect.topLeft()+rect.topRight())*0.5; - case aiTopRight: return rect.topRight(); - case aiRight: return (rect.topRight()+rect.bottomRight())*0.5; - case aiBottom: return (rect.bottomLeft()+rect.bottomRight())*0.5; - case aiBottomLeft: return rect.bottomLeft(); - case aiLeft: return (rect.topLeft()+rect.bottomLeft())*0.5;; + current = it.value().value + getBaseValue(it.value().key, it.value().value >= 0); + if (inSignDomain == sdBoth || (inSignDomain == sdNegative && current < 0) || (inSignDomain == sdPositive && current > 0)) + { + if (current < range.lower || !haveLower) + { + range.lower = current; + haveLower = true; + } + if (current > range.upper || !haveUpper) + { + range.upper = current; + haveUpper = true; + } + } + ++it; } - qDebug() << Q_FUNC_INFO << "invalid anchorId" << anchorId; - return QPointF(); + foundRange = true; // return true because bar charts always have the 0-line visible + return range; } -/*! \internal + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPStatisticalBox +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPStatisticalBox + \brief A plottable representing a single statistical box in a plot. + + \image html QCPStatisticalBox.png - Creates the buffered scaled image (\a mScaledPixmap) to fit the specified \a finalRect. The - parameters \a flipHorz and \a flipVert control whether the resulting image shall be flipped - horizontally or vertically. (This is used when \a topLeft is further to the bottom/right than \a - bottomRight.) + To plot data, assign it with the individual parameter functions or use \ref setData to set all + parameters at once. The individual functions are: + \li \ref setMinimum + \li \ref setLowerQuartile + \li \ref setMedian + \li \ref setUpperQuartile + \li \ref setMaximum - This function only creates the scaled pixmap when the buffered pixmap has a different size than - the expected result, so calling this function repeatedly, e.g. in the \ref draw function, does - not cause expensive rescaling every time. + Additionally you can define a list of outliers, drawn as scatter datapoints: + \li \ref setOutliers - If scaling is disabled, sets mScaledPixmap to a null QPixmap. -*/ -void QCPItemPixmap::updateScaledPixmap(QRect finalRect, bool flipHorz, bool flipVert) -{ - if (mPixmap.isNull()) - return; + \section appearance Changing the appearance - if (mScaled) - { - if (finalRect.isNull()) - finalRect = getFinalRect(&flipHorz, &flipVert); - if (finalRect.size() != mScaledPixmap.size()) - { - mScaledPixmap = mPixmap.scaled(finalRect.size(), mAspectRatioMode, Qt::SmoothTransformation); - if (flipHorz || flipVert) - mScaledPixmap = QPixmap::fromImage(mScaledPixmap.toImage().mirrored(flipHorz, flipVert)); - } - } else if (!mScaledPixmap.isNull()) - mScaledPixmap = QPixmap(); -} + The appearance of the box itself is controlled via \ref setPen and \ref setBrush. You may change + the width of the box with \ref setWidth in plot coordinates (not pixels). -/*! \internal + Analog functions exist for the minimum/maximum-whiskers: \ref setWhiskerPen, \ref + setWhiskerBarPen, \ref setWhiskerWidth. The whisker width is the width of the bar at the top + (maximum) and bottom (minimum). - Returns the final (tight) rect the pixmap is drawn in, depending on the current item positions - and scaling settings. + The median indicator line has its own pen, \ref setMedianPen. - The output parameters \a flippedHorz and \a flippedVert return whether the pixmap should be drawn - flipped horizontally or vertically in the returned rect. (The returned rect itself is always - normalized, i.e. the top left corner of the rect is actually further to the top/left than the - bottom right corner). This is the case when the item position \a topLeft is further to the - bottom/right than \a bottomRight. + If the whisker backbone pen is changed, make sure to set the capStyle to Qt::FlatCap. Else, the + backbone line might exceed the whisker bars by a few pixels due to the pen cap being not + perfectly flat. - If scaling is disabled, returns a rect with size of the original pixmap and the top left corner - aligned with the item position \a topLeft. The position \a bottomRight is ignored. + The Outlier data points are drawn as normal scatter points. Their look can be controlled with + \ref setOutlierStyle + + \section usage Usage + + Like all data representing objects in QCustomPlot, the QCPStatisticalBox is a plottable + (QCPAbstractPlottable). So the plottable-interface of QCustomPlot applies + (QCustomPlot::plottable, QCustomPlot::addPlottable, QCustomPlot::removePlottable, etc.) + + Usually, you first create an instance: + \code + QCPStatisticalBox *newBox = new QCPStatisticalBox(customPlot->xAxis, customPlot->yAxis);\endcode + add it to the customPlot with QCustomPlot::addPlottable: + \code + customPlot->addPlottable(newBox);\endcode + and then modify the properties of the newly created plottable, e.g.: + \code + newBox->setName("Measurement Series 1"); + newBox->setData(1, 3, 4, 5, 7); + newBox->setOutliers(QVector() << 0.5 << 0.64 << 7.2 << 7.42);\endcode */ -QRect QCPItemPixmap::getFinalRect(bool *flippedHorz, bool *flippedVert) const -{ - QRect result; - bool flipHorz = false; - bool flipVert = false; - QPoint p1 = topLeft->pixelPoint().toPoint(); - QPoint p2 = bottomRight->pixelPoint().toPoint(); - if (p1 == p2) - return QRect(p1, QSize(0, 0)); - if (mScaled) - { - QSize newSize = QSize(p2.x()-p1.x(), p2.y()-p1.y()); - QPoint topLeft = p1; - if (newSize.width() < 0) - { - flipHorz = true; - newSize.rwidth() *= -1; - topLeft.setX(p2.x()); - } - if (newSize.height() < 0) - { - flipVert = true; - newSize.rheight() *= -1; - topLeft.setY(p2.y()); - } - QSize scaledSize = mPixmap.size(); - scaledSize.scale(newSize, mAspectRatioMode); - result = QRect(topLeft, scaledSize); - } else - { - result = QRect(p1, mPixmap.size()); - } - if (flippedHorz) - *flippedHorz = flipHorz; - if (flippedVert) - *flippedVert = flipVert; - return result; + +/*! + Constructs a statistical box which uses \a keyAxis as its key axis ("x") and \a valueAxis as its + value axis ("y"). \a keyAxis and \a valueAxis must reside in the same QCustomPlot instance and + not have the same orientation. If either of these restrictions is violated, a corresponding + message is printed to the debug output (qDebug), the construction is not aborted, though. + + The constructed statistical box can be added to the plot with QCustomPlot::addPlottable, + QCustomPlot then takes ownership of the statistical box. +*/ +QCPStatisticalBox::QCPStatisticalBox(QCPAxis *keyAxis, QCPAxis *valueAxis) : + QCPAbstractPlottable(keyAxis, valueAxis), + mKey(0), + mMinimum(0), + mLowerQuartile(0), + mMedian(0), + mUpperQuartile(0), + mMaximum(0) +{ + setOutlierStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, Qt::blue, 6)); + setWhiskerWidth(0.2); + setWidth(0.5); + + setPen(QPen(Qt::black)); + setSelectedPen(QPen(Qt::blue, 2.5)); + setMedianPen(QPen(Qt::black, 3, Qt::SolidLine, Qt::FlatCap)); + setWhiskerPen(QPen(Qt::black, 0, Qt::DashLine, Qt::FlatCap)); + setWhiskerBarPen(QPen(Qt::black)); + setBrush(Qt::NoBrush); + setSelectedBrush(Qt::NoBrush); } -/*! \internal - - Returns the pen that should be used for drawing lines. Returns mPen when the item is not selected - and mSelectedPen when it is. +/*! + Sets the key coordinate of the statistical box. */ -QPen QCPItemPixmap::mainPen() const +void QCPStatisticalBox::setKey(double key) { - return mSelected ? mSelectedPen : mPen; + mKey = key; } - -//////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////// QCPItemTracer -//////////////////////////////////////////////////////////////////////////////////////////////////// - -/*! \class QCPItemTracer - \brief Item that sticks to QCPGraph data points - - \image html QCPItemTracer.png "Tracer example. Blue dotted circles are anchors, solid blue discs are positions." - - The tracer can be connected with a QCPGraph via \ref setGraph. Then it will automatically adopt - the coordinate axes of the graph and update its \a position to be on the graph's data. This means - the key stays controllable via \ref setGraphKey, but the value will follow the graph data. If a - QCPGraph is connected, note that setting the coordinates of the tracer item directly via \a - position will have no effect because they will be overriden in the next redraw (this is when the - coordinate update happens). +/*! + Sets the parameter "minimum" of the statistical box plot. This is the position of the lower + whisker, typically the minimum measurement of the sample that's not considered an outlier. - If the specified key in \ref setGraphKey is outside the key bounds of the graph, the tracer will - stay at the corresponding end of the graph. + \see setMaximum, setWhiskerPen, setWhiskerBarPen, setWhiskerWidth +*/ +void QCPStatisticalBox::setMinimum(double value) +{ + mMinimum = value; +} + +/*! + Sets the parameter "lower Quartile" of the statistical box plot. This is the lower end of the + box. The lower and the upper quartiles are the two statistical quartiles around the median of the + sample, they contain 50% of the sample data. - With \ref setInterpolating you may specify whether the tracer may only stay exactly on data - points or whether it interpolates data points linearly, if given a key that lies between two data - points of the graph. + \see setUpperQuartile, setPen, setBrush, setWidth +*/ +void QCPStatisticalBox::setLowerQuartile(double value) +{ + mLowerQuartile = value; +} + +/*! + Sets the parameter "median" of the statistical box plot. This is the value of the median mark + inside the quartile box. The median separates the sample data in half (50% of the sample data is + below/above the median). - The tracer has different visual styles, see \ref setStyle. It is also possible to make the tracer - have no own visual appearance (set the style to \ref tsNone), and just connect other item - positions to the tracer \a position (used as an anchor) via \ref - QCPItemPosition::setParentAnchor. + \see setMedianPen +*/ +void QCPStatisticalBox::setMedian(double value) +{ + mMedian = value; +} + +/*! + Sets the parameter "upper Quartile" of the statistical box plot. This is the upper end of the + box. The lower and the upper quartiles are the two statistical quartiles around the median of the + sample, they contain 50% of the sample data. - \note The tracer position is only automatically updated upon redraws. So when the data of the - graph changes and immediately afterwards (without a redraw) the a position coordinates of the - tracer are retrieved, they will not reflect the updated data of the graph. In this case \ref - updatePosition must be called manually, prior to reading the tracer coordinates. + \see setLowerQuartile, setPen, setBrush, setWidth */ +void QCPStatisticalBox::setUpperQuartile(double value) +{ + mUpperQuartile = value; +} /*! - Creates a tracer item and sets default values. + Sets the parameter "maximum" of the statistical box plot. This is the position of the upper + whisker, typically the maximum measurement of the sample that's not considered an outlier. - The constructed item can be added to the plot with QCustomPlot::addItem. + \see setMinimum, setWhiskerPen, setWhiskerBarPen, setWhiskerWidth */ -QCPItemTracer::QCPItemTracer(QCustomPlot *parentPlot) : - QCPAbstractItem(parentPlot), - position(createPosition("position")), - mGraph(0) +void QCPStatisticalBox::setMaximum(double value) { - position->setCoords(0, 0); + mMaximum = value; +} - setBrush(Qt::NoBrush); - setSelectedBrush(Qt::NoBrush); - setPen(QPen(Qt::black)); - setSelectedPen(QPen(Qt::blue, 2)); - setStyle(tsCrosshair); - setSize(6); - setInterpolating(false); - setGraphKey(0); +/*! + Sets a vector of outlier values that will be drawn as scatters. Any data points in the sample + that are not within the whiskers (\ref setMinimum, \ref setMaximum) should be considered outliers + and displayed as such. + + \see setOutlierStyle +*/ +void QCPStatisticalBox::setOutliers(const QVector &values) +{ + mOutliers = values; } -QCPItemTracer::~QCPItemTracer() +/*! + Sets all parameters of the statistical box plot at once. + + \see setKey, setMinimum, setLowerQuartile, setMedian, setUpperQuartile, setMaximum +*/ +void QCPStatisticalBox::setData(double key, double minimum, double lowerQuartile, double median, double upperQuartile, double maximum) { + setKey(key); + setMinimum(minimum); + setLowerQuartile(lowerQuartile); + setMedian(median); + setUpperQuartile(upperQuartile); + setMaximum(maximum); } /*! - Sets the pen that will be used to draw the line of the tracer + Sets the width of the box in key coordinates. - \see setSelectedPen, setBrush + \see setWhiskerWidth */ -void QCPItemTracer::setPen(const QPen &pen) +void QCPStatisticalBox::setWidth(double width) { - mPen = pen; + mWidth = width; } /*! - Sets the pen that will be used to draw the line of the tracer when selected + Sets the width of the whiskers (\ref setMinimum, \ref setMaximum) in key coordinates. - \see setPen, setSelected + \see setWidth */ -void QCPItemTracer::setSelectedPen(const QPen &pen) +void QCPStatisticalBox::setWhiskerWidth(double width) { - mSelectedPen = pen; + mWhiskerWidth = width; } /*! - Sets the brush that will be used to draw any fills of the tracer + Sets the pen used for drawing the whisker backbone (That's the line parallel to the value axis). - \see setSelectedBrush, setPen + Make sure to set the \a pen capStyle to Qt::FlatCap to prevent the whisker backbone from reaching + a few pixels past the whisker bars, when using a non-zero pen width. + + \see setWhiskerBarPen */ -void QCPItemTracer::setBrush(const QBrush &brush) +void QCPStatisticalBox::setWhiskerPen(const QPen &pen) { - mBrush = brush; + mWhiskerPen = pen; } /*! - Sets the brush that will be used to draw any fills of the tracer, when selected. + Sets the pen used for drawing the whisker bars (Those are the lines parallel to the key axis at + each end of the whisker backbone). - \see setBrush, setSelected + \see setWhiskerPen */ -void QCPItemTracer::setSelectedBrush(const QBrush &brush) +void QCPStatisticalBox::setWhiskerBarPen(const QPen &pen) { - mSelectedBrush = brush; + mWhiskerBarPen = pen; } /*! - Sets the size of the tracer in pixels, if the style supports setting a size (e.g. \ref tsSquare - does, \ref tsCrosshair does not). + Sets the pen used for drawing the median indicator line inside the statistical box. */ -void QCPItemTracer::setSize(double size) +void QCPStatisticalBox::setMedianPen(const QPen &pen) { - mSize = size; + mMedianPen = pen; +} + +/*! + Sets the appearance of the outlier data points. + + \see setOutliers +*/ +void QCPStatisticalBox::setOutlierStyle(const QCPScatterStyle &style) +{ + mOutlierStyle = style; +} + +/* inherits documentation from base class */ +void QCPStatisticalBox::clearData() +{ + setOutliers(QVector()); + setKey(0); + setMinimum(0); + setLowerQuartile(0); + setMedian(0); + setUpperQuartile(0); + setMaximum(0); +} + +/* inherits documentation from base class */ +double QCPStatisticalBox::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + Q_UNUSED(details) + if (onlySelectable && !mSelectable) + return -1; + if (!mKeyAxis || !mValueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return -1; } + + if (mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint())) + { + double posKey, posValue; + pixelsToCoords(pos, posKey, posValue); + // quartile box: + QCPRange keyRange(mKey-mWidth*0.5, mKey+mWidth*0.5); + QCPRange valueRange(mLowerQuartile, mUpperQuartile); + if (keyRange.contains(posKey) && valueRange.contains(posValue)) + return mParentPlot->selectionTolerance()*0.99; + + // min/max whiskers: + if (QCPRange(mMinimum, mMaximum).contains(posValue)) + return qAbs(mKeyAxis.data()->coordToPixel(mKey)-mKeyAxis.data()->coordToPixel(posKey)); + } + return -1; +} + +/* inherits documentation from base class */ +void QCPStatisticalBox::draw(QCPPainter *painter) +{ + if (!mKeyAxis || !mValueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + + // check data validity if flag set: +#ifdef QCUSTOMPLOT_CHECK_DATA + if (QCP::isInvalidData(mKey, mMedian) || + QCP::isInvalidData(mLowerQuartile, mUpperQuartile) || + QCP::isInvalidData(mMinimum, mMaximum)) + qDebug() << Q_FUNC_INFO << "Data point at" << mKey << "of drawn range has invalid data." << "Plottable name:" << name(); + for (int i=0; isave(); + painter->setClipRect(quartileBox, Qt::IntersectClip); + drawMedian(painter); + painter->restore(); + + drawWhiskers(painter); + drawOutliers(painter); +} + +/* inherits documentation from base class */ +void QCPStatisticalBox::drawLegendIcon(QCPPainter *painter, const QRectF &rect) const +{ + // draw filled rect: + applyDefaultAntialiasingHint(painter); + painter->setPen(mPen); + painter->setBrush(mBrush); + QRectF r = QRectF(0, 0, rect.width()*0.67, rect.height()*0.67); + r.moveCenter(rect.center()); + painter->drawRect(r); } -/*! - Sets the style/visual appearance of the tracer. +/*! \internal - If you only want to use the tracer \a position as an anchor for other items, set \a style to - \ref tsNone. + Draws the quartile box. \a box is an output parameter that returns the quartile box (in pixel + coordinates) which is used to set the clip rect of the painter before calling \ref drawMedian (so + the median doesn't draw outside the quartile box). */ -void QCPItemTracer::setStyle(QCPItemTracer::TracerStyle style) +void QCPStatisticalBox::drawQuartileBox(QCPPainter *painter, QRectF *quartileBox) const { - mStyle = style; + QRectF box; + box.setTopLeft(coordsToPixels(mKey-mWidth*0.5, mUpperQuartile)); + box.setBottomRight(coordsToPixels(mKey+mWidth*0.5, mLowerQuartile)); + applyDefaultAntialiasingHint(painter); + painter->setPen(mainPen()); + painter->setBrush(mainBrush()); + painter->drawRect(box); + if (quartileBox) + *quartileBox = box; } -/*! - Sets the QCPGraph this tracer sticks to. The tracer \a position will be set to type - QCPItemPosition::ptPlotCoords and the axes will be set to the axes of \a graph. - - To free the tracer from any graph, set \a graph to 0. The tracer \a position can then be placed - freely like any other item position. This is the state the tracer will assume when its graph gets - deleted while still attached to it. +/*! \internal - \see setGraphKey + Draws the median line inside the quartile box. */ -void QCPItemTracer::setGraph(QCPGraph *graph) +void QCPStatisticalBox::drawMedian(QCPPainter *painter) const { - if (graph) - { - if (graph->parentPlot() == mParentPlot) - { - position->setType(QCPItemPosition::ptPlotCoords); - position->setAxes(graph->keyAxis(), graph->valueAxis()); - mGraph = graph; - updatePosition(); - } else - qDebug() << Q_FUNC_INFO << "graph isn't in same QCustomPlot instance as this item"; - } else - { - mGraph = 0; - } + QLineF medianLine; + medianLine.setP1(coordsToPixels(mKey-mWidth*0.5, mMedian)); + medianLine.setP2(coordsToPixels(mKey+mWidth*0.5, mMedian)); + applyDefaultAntialiasingHint(painter); + painter->setPen(mMedianPen); + painter->drawLine(medianLine); } -/*! - Sets the key of the graph's data point the tracer will be positioned at. This is the only free - coordinate of a tracer when attached to a graph. - - Depending on \ref setInterpolating, the tracer will be either positioned on the data point - closest to \a key, or will stay exactly at \a key and interpolate the value linearly. +/*! \internal - \see setGraph, setInterpolating + Draws both whisker backbones and bars. */ -void QCPItemTracer::setGraphKey(double key) +void QCPStatisticalBox::drawWhiskers(QCPPainter *painter) const { - mGraphKey = key; + QLineF backboneMin, backboneMax, barMin, barMax; + backboneMax.setPoints(coordsToPixels(mKey, mUpperQuartile), coordsToPixels(mKey, mMaximum)); + backboneMin.setPoints(coordsToPixels(mKey, mLowerQuartile), coordsToPixels(mKey, mMinimum)); + barMax.setPoints(coordsToPixels(mKey-mWhiskerWidth*0.5, mMaximum), coordsToPixels(mKey+mWhiskerWidth*0.5, mMaximum)); + barMin.setPoints(coordsToPixels(mKey-mWhiskerWidth*0.5, mMinimum), coordsToPixels(mKey+mWhiskerWidth*0.5, mMinimum)); + applyErrorBarsAntialiasingHint(painter); + painter->setPen(mWhiskerPen); + painter->drawLine(backboneMin); + painter->drawLine(backboneMax); + painter->setPen(mWhiskerBarPen); + painter->drawLine(barMin); + painter->drawLine(barMax); } -/*! - Sets whether the value of the graph's data points shall be interpolated, when positioning the - tracer. - - If \a enabled is set to false and a key is given with \ref setGraphKey, the tracer is placed on - the data point of the graph which is closest to the key, but which is not necessarily exactly - there. If \a enabled is true, the tracer will be positioned exactly at the specified key, and - the appropriate value will be interpolated from the graph's data points linearly. +/*! \internal - \see setGraph, setGraphKey + Draws the outlier scatter points. */ -void QCPItemTracer::setInterpolating(bool enabled) +void QCPStatisticalBox::drawOutliers(QCPPainter *painter) const { - mInterpolating = enabled; + applyScattersAntialiasingHint(painter); + mOutlierStyle.applyTo(painter, mPen); + for (int i=0; ipixelPoint()); - double w = mSize/2.0; - QRect clip = clipRect(); - switch (mStyle) + foundRange = true; + if (inSignDomain == sdBoth) { - case tsNone: return -1; - case tsPlus: - { - if (clipRect().intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect())) - return qSqrt(qMin(distSqrToLine(center+QPointF(-w, 0), center+QPointF(w, 0), pos), - distSqrToLine(center+QPointF(0, -w), center+QPointF(0, w), pos))); - break; - } - case tsCrosshair: - { - return qSqrt(qMin(distSqrToLine(QPointF(clip.left(), center.y()), QPointF(clip.right(), center.y()), pos), - distSqrToLine(QPointF(center.x(), clip.top()), QPointF(center.x(), clip.bottom()), pos))); - } - case tsCircle: - { - if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect())) - { - // distance to border: - double centerDist = QVector2D(center-pos).length(); - double circleLine = w; - double result = qAbs(centerDist-circleLine); - // filled ellipse, allow click inside to count as hit: - if (result > mParentPlot->selectionTolerance()*0.99 && mBrush.style() != Qt::NoBrush && mBrush.color().alpha() != 0) - { - if (centerDist <= circleLine) - result = mParentPlot->selectionTolerance()*0.99; - } - return result; - } - break; - } - case tsSquare: - { - if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect())) - { - QRectF rect = QRectF(center-QPointF(w, w), center+QPointF(w, w)); - bool filledRect = mBrush.style() != Qt::NoBrush && mBrush.color().alpha() != 0; - return rectSelectTest(rect, pos, filledRect); - } - break; - } - } - return -1; -} - -/* inherits documentation from base class */ -void QCPItemTracer::draw(QCPPainter *painter) -{ - updatePosition(); - if (mStyle == tsNone) - return; - - painter->setPen(mainPen()); - painter->setBrush(mainBrush()); - QPointF center(position->pixelPoint()); - double w = mSize/2.0; - QRect clip = clipRect(); - switch (mStyle) + return QCPRange(mKey-mWidth*0.5, mKey+mWidth*0.5); + } else if (inSignDomain == sdNegative) { - case tsNone: return; - case tsPlus: - { - if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect())) - { - painter->drawLine(QLineF(center+QPointF(-w, 0), center+QPointF(w, 0))); - painter->drawLine(QLineF(center+QPointF(0, -w), center+QPointF(0, w))); - } - break; - } - case tsCrosshair: - { - if (center.y() > clip.top() && center.y() < clip.bottom()) - painter->drawLine(QLineF(clip.left(), center.y(), clip.right(), center.y())); - if (center.x() > clip.left() && center.x() < clip.right()) - painter->drawLine(QLineF(center.x(), clip.top(), center.x(), clip.bottom())); - break; - } - case tsCircle: + if (mKey+mWidth*0.5 < 0) + return QCPRange(mKey-mWidth*0.5, mKey+mWidth*0.5); + else if (mKey < 0) + return QCPRange(mKey-mWidth*0.5, mKey); + else { - if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect())) - painter->drawEllipse(center, w, w); - break; + foundRange = false; + return QCPRange(); } - case tsSquare: + } else if (inSignDomain == sdPositive) + { + if (mKey-mWidth*0.5 > 0) + return QCPRange(mKey-mWidth*0.5, mKey+mWidth*0.5); + else if (mKey > 0) + return QCPRange(mKey, mKey+mWidth*0.5); + else { - if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect())) - painter->drawRect(QRectF(center-QPointF(w, w), center+QPointF(w, w))); - break; + foundRange = false; + return QCPRange(); } } + foundRange = false; + return QCPRange(); } -/*! - If the tracer is connected with a graph (\ref setGraph), this function updates the tracer's \a - position to reside on the graph data, depending on the configured key (\ref setGraphKey). - - It is called automatically on every redraw and normally doesn't need to be called manually. One - exception is when you want to read the tracer coordinates via \a position and are not sure that - the graph's data (or the tracer key with \ref setGraphKey) hasn't changed since the last redraw. - In that situation, call this function before accessing \a position, to make sure you don't get - out-of-date coordinates. - - If there is no graph set on this tracer, this function does nothing. -*/ -void QCPItemTracer::updatePosition() +/* inherits documentation from base class */ +QCPRange QCPStatisticalBox::getValueRange(bool &foundRange, SignDomain inSignDomain) const { - if (mGraph) - { - if (mParentPlot->hasPlottable(mGraph)) - { - if (mGraph->data()->size() > 1) - { - QCPDataMap::const_iterator first = mGraph->data()->constBegin(); - QCPDataMap::const_iterator last = mGraph->data()->constEnd()-1; - if (mGraphKey < first.key()) - position->setCoords(first.key(), first.value().value); - else if (mGraphKey > last.key()) - position->setCoords(last.key(), last.value().value); - else - { - QCPDataMap::const_iterator it = mGraph->data()->lowerBound(mGraphKey); - if (it != first) // mGraphKey is somewhere between iterators - { - QCPDataMap::const_iterator prevIt = it-1; - if (mInterpolating) - { - // interpolate between iterators around mGraphKey: - double slope = (it.value().value-prevIt.value().value)/(it.key()-prevIt.key()); - position->setCoords(mGraphKey, (mGraphKey-prevIt.key())*slope+prevIt.value().value); - } else - { - // find iterator with key closest to mGraphKey: - if (mGraphKey < (prevIt.key()+it.key())*0.5) - it = prevIt; - position->setCoords(it.key(), it.value().value); - } - } else // mGraphKey is exactly on first iterator - position->setCoords(it.key(), it.value().value); - } - } else if (mGraph->data()->size() == 1) + QVector values; // values that must be considered (i.e. all outliers and the five box-parameters) + values.reserve(mOutliers.size() + 5); + values << mMaximum << mUpperQuartile << mMedian << mLowerQuartile << mMinimum; + values << mOutliers; + // go through values and find the ones in legal range: + bool haveUpper = false; + bool haveLower = false; + double upper = 0; + double lower = 0; + for (int i=0; i 0) || + (inSignDomain == sdBoth)) + { + if (values.at(i) > upper || !haveUpper) { - QCPDataMap::const_iterator it = mGraph->data()->constBegin(); - position->setCoords(it.key(), it.value().value); - } else - qDebug() << Q_FUNC_INFO << "graph has no data"; - } else - qDebug() << Q_FUNC_INFO << "graph not contained in QCustomPlot instance (anymore)"; + upper = values.at(i); + haveUpper = true; + } + if (values.at(i) < lower || !haveLower) + { + lower = values.at(i); + haveLower = true; + } + } + } + // return the bounds if we found some sensible values: + if (haveLower && haveUpper) + { + foundRange = true; + return QCPRange(lower, upper); + } else // might happen if all values are in other sign domain + { + foundRange = false; + return QCPRange(); } } -/*! \internal - Returns the pen that should be used for drawing lines. Returns mPen when the item is not selected - and mSelectedPen when it is. +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPColorMapData +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPColorMapData + \brief Holds the two-dimensional data of a QCPColorMap plottable. + + This class is a data storage for \ref QCPColorMap. It holds a two-dimensional array, which \ref + QCPColorMap then displays as a 2D image in the plot, where the array values are represented by a + color, depending on the value. + + The size of the array can be controlled via \ref setSize (or \ref setKeySize, \ref setValueSize). + Which plot coordinates these cells correspond to can be configured with \ref setRange (or \ref + setKeyRange, \ref setValueRange). + + The data cells can be accessed in two ways: They can be directly addressed by an integer index + with \ref setCell. This is the fastest method. Alternatively, they can be addressed by their plot + coordinate with \ref setData. plot coordinate to cell index transformations and vice versa are + provided by the functions \ref coordToCell and \ref cellToCoord. + + This class also buffers the minimum and maximum values that are in the data set, to provide + QCPColorMap::rescaleDataRange with the necessary information quickly. Setting a cell to a value + that is greater than the current maximum increases this maximum to the new value. However, + setting the cell that currently holds the maximum value to a smaller value doesn't decrease the + maximum again, because finding the true new maximum would require going through the entire data + array, which might be time consuming. The same holds for the data minimum. This functionality is + given by \ref recalculateDataBounds, such that you can decide when it is sensible to find the + true current minimum and maximum. The method QCPColorMap::rescaleDataRange offers a convenience + parameter \a recalculateDataBounds which may be set to true to automatically call \ref + recalculateDataBounds internally. */ -QPen QCPItemTracer::mainPen() const + +/* start of documentation of inline functions */ + +/*! \fn bool QCPColorMapData::isEmpty() const + + Returns whether this instance carries no data. This is equivalent to having a size where at least + one of the dimensions is 0 (see \ref setSize). +*/ + +/* end of documentation of inline functions */ + +/*! + Constructs a new QCPColorMapData instance. The instance has \a keySize cells in the key direction + and \a valueSize cells in the value direction. These cells will be displayed by the \ref QCPColorMap + at the coordinates \a keyRange and \a valueRange. + + \see setSize, setKeySize, setValueSize, setRange, setKeyRange, setValueRange +*/ +QCPColorMapData::QCPColorMapData(int keySize, int valueSize, const QCPRange &keyRange, const QCPRange &valueRange) : + mKeySize(0), + mValueSize(0), + mKeyRange(keyRange), + mValueRange(valueRange), + mIsEmpty(true), + mData(0), + mDataModified(true) { - return mSelected ? mSelectedPen : mPen; + setSize(keySize, valueSize); + fill(0); } -/*! \internal +QCPColorMapData::~QCPColorMapData() +{ + if (mData) + delete[] mData; +} - Returns the brush that should be used for drawing fills of the item. Returns mBrush when the item - is not selected and mSelectedBrush when it is. +/*! + Constructs a new QCPColorMapData instance copying the data and range of \a other. */ -QBrush QCPItemTracer::mainBrush() const +QCPColorMapData::QCPColorMapData(const QCPColorMapData &other) : + mKeySize(0), + mValueSize(0), + mIsEmpty(true), + mData(0), + mDataModified(true) { - return mSelected ? mSelectedBrush : mBrush; + *this = other; } +/*! + Overwrites this color map data instance with the data stored in \a other. +*/ +QCPColorMapData &QCPColorMapData::operator=(const QCPColorMapData &other) +{ + if (&other != this) + { + const int keySize = other.keySize(); + const int valueSize = other.valueSize(); + setSize(keySize, valueSize); + setRange(other.keyRange(), other.valueRange()); + if (!mIsEmpty) + memcpy(mData, other.mData, sizeof(mData[0])*keySize*valueSize); + mDataBounds = other.mDataBounds; + mDataModified = true; + } + return *this; +} -//////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////// QCPItemBracket -//////////////////////////////////////////////////////////////////////////////////////////////////// +/* undocumented getter */ +double QCPColorMapData::data(double key, double value) +{ + int keyCell = (key-mKeyRange.lower)/(mKeyRange.upper-mKeyRange.lower)*(mKeySize-1)+0.5; + int valueCell = (1.0-(value-mValueRange.lower)/(mValueRange.upper-mValueRange.lower))*(mValueSize-1)+0.5; + if (keyCell >= 0 && keyCell < mKeySize && valueCell >= 0 && valueCell < mValueSize) + return mData[valueCell*mKeySize + keyCell]; + else + return 0; +} -/*! \class QCPItemBracket - \brief A bracket for referencing/highlighting certain parts in the plot. +/* undocumented getter */ +double QCPColorMapData::cell(int keyIndex, int valueIndex) +{ + if (keyIndex >= 0 && keyIndex < mKeySize && valueIndex >= 0 && valueIndex < mValueSize) + return mData[valueIndex*mKeySize + keyIndex]; + else + return 0; +} - \image html QCPItemBracket.png "Bracket example. Blue dotted circles are anchors, solid blue discs are positions." +/*! + Resizes the data array to have \a keySize cells in the key dimension and \a valueSize cells in + the value dimension. - It has two positions, \a left and \a right, which define the span of the bracket. If \a left is - actually farther to the left than \a right, the bracket is opened to the bottom, as shown in the - example image. - - The bracket supports multiple styles via \ref setStyle. The length, i.e. how far the bracket - stretches away from the embraced span, can be controlled with \ref setLength. - - \image html QCPItemBracket-length.png -
                                                                  Demonstrating the effect of different values for \ref setLength, for styles \ref - bsCalligraphic and \ref bsSquare. Anchors and positions are displayed for reference.
                                                                  + The current data is discarded and the map cells are set to 0, unless the map had already the + requested size. - It provides an anchor \a center, to allow connection of other items, e.g. an arrow (QCPItemLine - or QCPItemCurve) or a text label (QCPItemText), to the bracket. + Setting at least one of \a keySize or \a valueSize to zero frees the internal data array and \ref + isEmpty returns true. + + \see setRange, setKeySize, setValueSize */ +void QCPColorMapData::setSize(int keySize, int valueSize) +{ + if (keySize != mKeySize || valueSize != mValueSize) + { + mKeySize = keySize; + mValueSize = valueSize; + if (mData) + delete[] mData; + mIsEmpty = mKeySize == 0 || mValueSize == 0; + if (!mIsEmpty) + { +#ifdef __EXCEPTIONS + try { // 2D arrays get memory intensive fast. So if the allocation fails, at least output debug message +#endif + mData = new double[mKeySize*mValueSize]; +#ifdef __EXCEPTIONS + } catch (...) { mData = 0; } +#endif + if (mData) + fill(0); + else + qDebug() << Q_FUNC_INFO << "out of memory for data dimensions "<< mKeySize << "*" << mValueSize; + } else + mData = 0; + mDataModified = true; + } +} /*! - Creates a bracket item and sets default values. + Resizes the data array to have \a keySize cells in the key dimension. + + The current data is discarded and the map cells are set to 0, unless the map had already the + requested size. - The constructed item can be added to the plot with QCustomPlot::addItem. + Setting \a keySize to zero frees the internal data array and \ref isEmpty returns true. + + \see setKeyRange, setSize, setValueSize */ -QCPItemBracket::QCPItemBracket(QCustomPlot *parentPlot) : - QCPAbstractItem(parentPlot), - left(createPosition("left")), - right(createPosition("right")), - center(createAnchor("center", aiCenter)) +void QCPColorMapData::setKeySize(int keySize) { - left->setCoords(0, 0); - right->setCoords(1, 1); - - setPen(QPen(Qt::black)); - setSelectedPen(QPen(Qt::blue, 2)); - setLength(8); - setStyle(bsCalligraphic); + setSize(keySize, mValueSize); } -QCPItemBracket::~QCPItemBracket() +/*! + Resizes the data array to have \a valueSize cells in the value dimension. + + The current data is discarded and the map cells are set to 0, unless the map had already the + requested size. + + Setting \a valueSize to zero frees the internal data array and \ref isEmpty returns true. + + \see setValueRange, setSize, setKeySize +*/ +void QCPColorMapData::setValueSize(int valueSize) { + setSize(mKeySize, valueSize); } /*! - Sets the pen that will be used to draw the bracket. - - Note that when the style is \ref bsCalligraphic, only the color will be taken from the pen, the - stroke and width are ignored. To change the apparent stroke width of a calligraphic bracket, use - \ref setLength, which has a similar effect. + Sets the coordinate ranges the data shall be distributed over. This defines the rectangular area + covered by the color map in plot coordinates. - \see setSelectedPen + The outer cells will be centered on the range boundaries given to this function. For example, if + the key size (\ref setKeySize) is 3 and \a keyRange is set to QCPRange(2, 3) there will + be cells centered on the key coordinates 2, 2.5 and 3. + + \see setSize */ -void QCPItemBracket::setPen(const QPen &pen) +void QCPColorMapData::setRange(const QCPRange &keyRange, const QCPRange &valueRange) { - mPen = pen; + setKeyRange(keyRange); + setValueRange(valueRange); } /*! - Sets the pen that will be used to draw the bracket when selected + Sets the coordinate range the data shall be distributed over in the key dimension. Together with + the value range, This defines the rectangular area covered by the color map in plot coordinates. - \see setPen, setSelected + The outer cells will be centered on the range boundaries given to this function. For example, if + the key size (\ref setKeySize) is 3 and \a keyRange is set to QCPRange(2, 3) there will + be cells centered on the key coordinates 2, 2.5 and 3. + + \see setRange, setValueRange, setSize */ -void QCPItemBracket::setSelectedPen(const QPen &pen) +void QCPColorMapData::setKeyRange(const QCPRange &keyRange) { - mSelectedPen = pen; + mKeyRange = keyRange; } /*! - Sets the \a length in pixels how far the bracket extends in the direction towards the embraced - span of the bracket (i.e. perpendicular to the left-right-direction) + Sets the coordinate range the data shall be distributed over in the value dimension. Together with + the key range, This defines the rectangular area covered by the color map in plot coordinates. - \image html QCPItemBracket-length.png -
                                                                  Demonstrating the effect of different values for \ref setLength, for styles \ref - bsCalligraphic and \ref bsSquare. Anchors and positions are displayed for reference.
                                                                  + The outer cells will be centered on the range boundaries given to this function. For example, if + the value size (\ref setValueSize) is 3 and \a valueRange is set to QCPRange(2, 3) there + will be cells centered on the value coordinates 2, 2.5 and 3. + + \see setRange, setKeyRange, setSize */ -void QCPItemBracket::setLength(double length) +void QCPColorMapData::setValueRange(const QCPRange &valueRange) { - mLength = length; + mValueRange = valueRange; } /*! - Sets the style of the bracket, i.e. the shape/visual appearance. - - \see setPen + Sets the data of the cell, which lies at the plot coordinates given by \a key and \a value, to \a + z. + + \see setCell, setRange */ -void QCPItemBracket::setStyle(QCPItemBracket::BracketStyle style) +void QCPColorMapData::setData(double key, double value, double z) { - mStyle = style; + int keyCell = (key-mKeyRange.lower)/(mKeyRange.upper-mKeyRange.lower)*(mKeySize-1)+0.5; + int valueCell = (value-mValueRange.lower)/(mValueRange.upper-mValueRange.lower)*(mValueSize-1)+0.5; + if (keyCell >= 0 && keyCell < mKeySize && valueCell >= 0 && valueCell < mValueSize) + { + mData[valueCell*mKeySize + keyCell] = z; + if (z < mDataBounds.lower) + mDataBounds.lower = z; + if (z > mDataBounds.upper) + mDataBounds.upper = z; + mDataModified = true; + } } -/* inherits documentation from base class */ -double QCPItemBracket::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const -{ - Q_UNUSED(details) - if (onlySelectable && !mSelectable) - return -1; - - QVector2D leftVec(left->pixelPoint()); - QVector2D rightVec(right->pixelPoint()); - if (leftVec.toPoint() == rightVec.toPoint()) - return -1; +/*! + Sets the data of the cell with indices \a keyIndex and \a valueIndex to \a z. The indices + enumerate the cells starting from zero, up to the map's size-1 in the respective dimension (see + \ref setSize). - QVector2D widthVec = (rightVec-leftVec)*0.5; - QVector2D lengthVec(-widthVec.y(), widthVec.x()); - lengthVec = lengthVec.normalized()*mLength; - QVector2D centerVec = (rightVec+leftVec)*0.5-lengthVec; + In the standard plot configuration (horizontal key axis and vertical value axis, both not + range-reversed), the cell with indices (0, 0) is in the bottom left corner and the cell with + indices (keySize-1, valueSize-1) is in the top right corner of the color map. - return qSqrt(distSqrToLine((centerVec-widthVec).toPointF(), (centerVec+widthVec).toPointF(), pos)); + \see setData, setSize +*/ +void QCPColorMapData::setCell(int keyIndex, int valueIndex, double z) +{ + if (keyIndex >= 0 && keyIndex < mKeySize && valueIndex >= 0 && valueIndex < mValueSize) + { + mData[valueIndex*mKeySize + keyIndex] = z; + if (z < mDataBounds.lower) + mDataBounds.lower = z; + if (z > mDataBounds.upper) + mDataBounds.upper = z; + mDataModified = true; + } } -/* inherits documentation from base class */ -void QCPItemBracket::draw(QCPPainter *painter) -{ - QVector2D leftVec(left->pixelPoint()); - QVector2D rightVec(right->pixelPoint()); - if (leftVec.toPoint() == rightVec.toPoint()) - return; +/*! + Goes through the data and updates the buffered minimum and maximum data values. - QVector2D widthVec = (rightVec-leftVec)*0.5; - QVector2D lengthVec(-widthVec.y(), widthVec.x()); - lengthVec = lengthVec.normalized()*mLength; - QVector2D centerVec = (rightVec+leftVec)*0.5-lengthVec; - - QPolygon boundingPoly; - boundingPoly << leftVec.toPoint() << rightVec.toPoint() - << (rightVec-lengthVec).toPoint() << (leftVec-lengthVec).toPoint(); - QRect clip = clipRect().adjusted(-mainPen().widthF(), -mainPen().widthF(), mainPen().widthF(), mainPen().widthF()); - if (clip.intersects(boundingPoly.boundingRect())) + Calling this method is only advised if you are about to call \ref QCPColorMap::rescaleDataRange + and can not guarantee that the cells holding the maximum or minimum data haven't been overwritten + with a smaller or larger value respectively, since the buffered maximum/minimum values have been + updated the last time. Why this is the case is explained in the class description (\ref + QCPColorMapData). + + Note that the method \ref QCPColorMap::rescaleDataRange provides a parameter \a + recalculateDataBounds for convenience. Setting this to true will call this method for you, before + doing the rescale. +*/ +void QCPColorMapData::recalculateDataBounds() +{ + if (mKeySize > 0 && mValueSize > 0) { - painter->setPen(mainPen()); - switch (mStyle) + double minHeight = mData[0]; + double maxHeight = mData[0]; + const int dataCount = mValueSize*mKeySize; + for (int i=0; idrawLine((centerVec+widthVec).toPointF(), (centerVec-widthVec).toPointF()); - painter->drawLine((centerVec+widthVec).toPointF(), (centerVec+widthVec+lengthVec).toPointF()); - painter->drawLine((centerVec-widthVec).toPointF(), (centerVec-widthVec+lengthVec).toPointF()); - break; - } - case bsRound: - { - painter->setBrush(Qt::NoBrush); - QPainterPath path; - path.moveTo((centerVec+widthVec+lengthVec).toPointF()); - path.cubicTo((centerVec+widthVec).toPointF(), (centerVec+widthVec).toPointF(), centerVec.toPointF()); - path.cubicTo((centerVec-widthVec).toPointF(), (centerVec-widthVec).toPointF(), (centerVec-widthVec+lengthVec).toPointF()); - painter->drawPath(path); - break; - } - case bsCurly: - { - painter->setBrush(Qt::NoBrush); - QPainterPath path; - path.moveTo((centerVec+widthVec+lengthVec).toPointF()); - path.cubicTo((centerVec+widthVec*1-lengthVec*0.8).toPointF(), (centerVec+0.4*widthVec+1*lengthVec).toPointF(), centerVec.toPointF()); - path.cubicTo((centerVec-0.4*widthVec+1*lengthVec).toPointF(), (centerVec-widthVec*1-lengthVec*0.8).toPointF(), (centerVec-widthVec+lengthVec).toPointF()); - painter->drawPath(path); - break; - } - case bsCalligraphic: - { - painter->setPen(Qt::NoPen); - painter->setBrush(QBrush(mainPen().color())); - QPainterPath path; - path.moveTo((centerVec+widthVec+lengthVec).toPointF()); - - path.cubicTo((centerVec+widthVec*1-lengthVec*0.8).toPointF(), (centerVec+0.4*widthVec+0.8*lengthVec).toPointF(), centerVec.toPointF()); - path.cubicTo((centerVec-0.4*widthVec+0.8*lengthVec).toPointF(), (centerVec-widthVec*1-lengthVec*0.8).toPointF(), (centerVec-widthVec+lengthVec).toPointF()); - - path.cubicTo((centerVec-widthVec*1-lengthVec*0.5).toPointF(), (centerVec-0.2*widthVec+1.2*lengthVec).toPointF(), (centerVec+lengthVec*0.2).toPointF()); - path.cubicTo((centerVec+0.2*widthVec+1.2*lengthVec).toPointF(), (centerVec+widthVec*1-lengthVec*0.5).toPointF(), (centerVec+widthVec+lengthVec).toPointF()); - - painter->drawPath(path); - break; - } + if (mData[i] > maxHeight) + maxHeight = mData[i]; + if (mData[i] < minHeight) + minHeight = mData[i]; } + mDataBounds.lower = minHeight; + mDataBounds.upper = maxHeight; } } -/* inherits documentation from base class */ -QPointF QCPItemBracket::anchorPixelPoint(int anchorId) const -{ - QVector2D leftVec(left->pixelPoint()); - QVector2D rightVec(right->pixelPoint()); - if (leftVec.toPoint() == rightVec.toPoint()) - return leftVec.toPointF(); - - QVector2D widthVec = (rightVec-leftVec)*0.5; - QVector2D lengthVec(-widthVec.y(), widthVec.x()); - lengthVec = lengthVec.normalized()*mLength; - QVector2D centerVec = (rightVec+leftVec)*0.5-lengthVec; +/*! + Frees the internal data memory. - switch (anchorId) - { - case aiCenter: - return centerVec.toPointF(); - } - qDebug() << Q_FUNC_INFO << "invalid anchorId" << anchorId; - return QPointF(); + This is equivalent to calling \ref setSize "setSize(0, 0)". +*/ +void QCPColorMapData::clear() +{ + setSize(0, 0); } -/*! \internal +/*! + Sets all cells to the value \a z. +*/ +void QCPColorMapData::fill(double z) +{ + const int dataCount = mValueSize*mKeySize; + for (int i=0; iOverview of the spacings and paddings that define the geometry of an axis. The dashed - line on the far left indicates the viewport/widget border. + Usually, you first create an instance: + \code + QCPColorMap *colorMap = new QCPColorMap(customPlot->xAxis, customPlot->yAxis);\endcode + add it to the customPlot with QCustomPlot::addPlottable: + \code + customPlot->addPlottable(colorMap);\endcode + and then modify the properties of the newly created color map, e.g.: + \code + colorMap->data()->setSize(50, 50); + colorMap->data()->setRange(QCPRange(0, 2), QCPRange(0, 2)); + for (int x=0; x<50; ++x) + for (int y=0; y<50; ++y) + colorMap->data()->setCell(x, y, qCos(x/10.0)+qSin(y/10.0)); + colorMap->setGradient(QCPColorGradient::gpPolar); + colorMap->rescaleDataRange(true); + customPlot->rescaleAxes(); + customPlot->replot(); + \endcode + + \note The QCPColorMap always displays the data at equal key/value intervals, even if the key or + value axis is set to a logarithmic scaling. If you want to use QCPColorMap with logarithmic axes, + you shouldn't use the \ref QCPColorMapData::setData method as it uses a linear transformation to + determine the cell index. Rather directly access the cell index with \ref + QCPColorMapData::setCell. */ /* start documentation of inline functions */ -/*! \fn QCPLayoutInset *QCPAxisRect::insetLayout() const +/*! \fn QCPColorMapData *QCPColorMap::data() const - Returns the inset layout of this axis rect. It can be used to place other layout elements (or - even layouts with multiple other elements) inside/on top of an axis rect. + Returns a pointer to the internal data storage of type \ref QCPColorMapData. Access this to + modify data points (cells) and the color map key/value range. - \see QCPLayoutInset + \see setData */ -/*! \fn int QCPAxisRect::left() const +/* end documentation of inline functions */ + +/* start documentation of signals */ + +/*! \fn void QCPColorMap::dataRangeChanged(QCPRange newRange); - Returns the pixel position of the left border of this axis rect. Margins are not taken into - account here, so the returned value is with respect to the inner \ref rect. + This signal is emitted when the data range changes. + + \see setDataRange */ -/*! \fn int QCPAxisRect::right() const +/*! \fn void QCPColorMap::dataScaleTypeChanged(QCPAxis::ScaleType scaleType); - Returns the pixel position of the right border of this axis rect. Margins are not taken into - account here, so the returned value is with respect to the inner \ref rect. + This signal is emitted when the data scale type changes. + + \see setDataScaleType */ -/*! \fn int QCPAxisRect::top() const +/*! \fn void QCPColorMap::gradientChanged(QCPColorGradient newGradient); - Returns the pixel position of the top border of this axis rect. Margins are not taken into - account here, so the returned value is with respect to the inner \ref rect. + This signal is emitted when the gradient changes. + + \see setGradient */ -/*! \fn int QCPAxisRect::bottom() const +/* end documentation of signals */ + +/*! + Constructs a color map with the specified \a keyAxis and \a valueAxis. - Returns the pixel position of the bottom border of this axis rect. Margins are not taken into - account here, so the returned value is with respect to the inner \ref rect. + The constructed QCPColorMap can be added to the plot with QCustomPlot::addPlottable, QCustomPlot + then takes ownership of the color map. */ +QCPColorMap::QCPColorMap(QCPAxis *keyAxis, QCPAxis *valueAxis) : + QCPAbstractPlottable(keyAxis, valueAxis), + mDataScaleType(QCPAxis::stLinear), + mMapData(new QCPColorMapData(10, 10, QCPRange(0, 5), QCPRange(0, 5))), + mInterpolate(true), + mTightBoundary(false), + mMapImageInvalidated(true) +{ +} -/*! \fn int QCPAxisRect::width() const +QCPColorMap::~QCPColorMap() +{ + delete mMapData; +} + +/*! + Replaces the current \ref data with the provided \a data. - Returns the pixel width of this axis rect. Margins are not taken into account here, so the - returned value is with respect to the inner \ref rect. + If \a copy is set to true, the \a data object will only be copied. if false, the color map + takes ownership of the passed data and replaces the internal data pointer with it. This is + significantly faster than copying for large datasets. */ +void QCPColorMap::setData(QCPColorMapData *data, bool copy) +{ + if (copy) + { + *mMapData = *data; + } else + { + delete mMapData; + mMapData = data; + } + mMapImageInvalidated = true; +} -/*! \fn int QCPAxisRect::height() const +/*! + Sets the data range of this color map to \a dataRange. The data range defines which data values + are mapped to the color gradient. - Returns the pixel height of this axis rect. Margins are not taken into account here, so the - returned value is with respect to the inner \ref rect. + To make the data range span the full range of the data set, use \ref rescaleDataRange. + + \see QCPColorScale::setDataRange */ +void QCPColorMap::setDataRange(const QCPRange &dataRange) +{ + if (!QCPRange::validRange(dataRange)) return; + if (mDataRange.lower != dataRange.lower || mDataRange.upper != dataRange.upper) + { + if (mDataScaleType == QCPAxis::stLogarithmic) + mDataRange = dataRange.sanitizedForLogScale(); + else + mDataRange = dataRange.sanitizedForLinScale(); + mMapImageInvalidated = true; + emit dataRangeChanged(mDataRange); + } +} -/*! \fn QSize QCPAxisRect::size() const +/*! + Sets whether the data is correlated with the color gradient linearly or logarithmically. - Returns the pixel size of this axis rect. Margins are not taken into account here, so the - returned value is with respect to the inner \ref rect. + \see QCPColorScale::setDataScaleType */ +void QCPColorMap::setDataScaleType(QCPAxis::ScaleType scaleType) +{ + if (mDataScaleType != scaleType) + { + mDataScaleType = scaleType; + mMapImageInvalidated = true; + emit dataScaleTypeChanged(mDataScaleType); + if (mDataScaleType == QCPAxis::stLogarithmic) + setDataRange(mDataRange.sanitizedForLogScale()); + } +} -/*! \fn QPoint QCPAxisRect::topLeft() const +/*! + Sets the color gradient that is used to represent the data. For more details on how to create an + own gradient or use one of the preset gradients, see \ref QCPColorGradient. - Returns the top left corner of this axis rect in pixels. Margins are not taken into account here, - so the returned value is with respect to the inner \ref rect. + The colors defined by the gradient will be used to represent data values in the currently set + data range, see \ref setDataRange. Data points that are outside this data range will either be + colored uniformly with the respective gradient boundary color, or the gradient will repeat, + depending on \ref QCPColorGradient::setPeriodic. + + \see QCPColorScale::setGradient */ +void QCPColorMap::setGradient(const QCPColorGradient &gradient) +{ + if (mGradient != gradient) + { + mGradient = gradient; + mMapImageInvalidated = true; + emit gradientChanged(mGradient); + } +} -/*! \fn QPoint QCPAxisRect::topRight() const +/*! + Sets whether the color map image shall use bicubic interpolation when displaying the color map + shrinked or expanded, and not at a 1:1 pixel-to-data scale. - Returns the top right corner of this axis rect in pixels. Margins are not taken into account - here, so the returned value is with respect to the inner \ref rect. + \image html QCPColorMap-interpolate.png "A 10*10 color map, with interpolation and without interpolation enabled" */ +void QCPColorMap::setInterpolate(bool enabled) +{ + mInterpolate = enabled; +} -/*! \fn QPoint QCPAxisRect::bottomLeft() const +/*! + Sets whether the outer most data rows and columns are clipped to the specified key and value + range (see \ref QCPColorMapData::setKeyRange, \ref QCPColorMapData::setValueRange). - Returns the bottom left corner of this axis rect in pixels. Margins are not taken into account - here, so the returned value is with respect to the inner \ref rect. + if \a enabled is set to false, the data points at the border of the color map are drawn with the + same width and height as all other data points. Since the data points are represented by + rectangles of one color centered on the data coordinate, this means that the shown color map + extends by half a data point over the specified key/value range in each direction. + + \image html QCPColorMap-tightboundary.png "A color map, with tight boundary enabled and disabled" */ +void QCPColorMap::setTightBoundary(bool enabled) +{ + mTightBoundary = enabled; +} -/*! \fn QPoint QCPAxisRect::bottomRight() const +/*! + Associates the color scale \a colorScale with this color map. - Returns the bottom right corner of this axis rect in pixels. Margins are not taken into account - here, so the returned value is with respect to the inner \ref rect. + This means that both the color scale and the color map synchronize their gradient, data range and + data scale type (\ref setGradient, \ref setDataRange, \ref setDataScaleType). Multiple color maps + can be associated with one single color scale. This causes the color maps to also synchronize + those properties, via the mutual color scale. + + This function causes the color map to adopt the current color gradient, data range and data scale + type of \a colorScale. After this call, you may change these properties at either the color map + or the color scale, and the setting will be applied to both. + + Pass 0 as \a colorScale to disconnect the color scale from this color map again. */ +void QCPColorMap::setColorScale(QCPColorScale *colorScale) +{ + if (mColorScale) // unconnect signals from old color scale + { + disconnect(this, SIGNAL(dataRangeChanged(QCPRange)), mColorScale.data(), SLOT(setDataRange(QCPRange))); + disconnect(this, SIGNAL(dataScaleTypeChanged(QCPAxis::ScaleType)), mColorScale.data(), SLOT(setDataScaleType(QCPAxis::ScaleType))); + disconnect(this, SIGNAL(gradientChanged(QCPColorGradient)), mColorScale.data(), SLOT(setGradient(QCPColorGradient))); + disconnect(mColorScale.data(), SIGNAL(dataRangeChanged(QCPRange)), this, SLOT(setDataRange(QCPRange))); + disconnect(mColorScale.data(), SIGNAL(gradientChanged(QCPColorGradient)), this, SLOT(setGradient(QCPColorGradient))); + disconnect(mColorScale.data(), SIGNAL(dataScaleTypeChanged(QCPAxis::ScaleType)), this, SLOT(setDataScaleType(QCPAxis::ScaleType))); + } + mColorScale = colorScale; + if (mColorScale) // connect signals to new color scale + { + setGradient(mColorScale.data()->gradient()); + setDataRange(mColorScale.data()->dataRange()); + setDataScaleType(mColorScale.data()->dataScaleType()); + connect(this, SIGNAL(dataRangeChanged(QCPRange)), mColorScale.data(), SLOT(setDataRange(QCPRange))); + connect(this, SIGNAL(dataScaleTypeChanged(QCPAxis::ScaleType)), mColorScale.data(), SLOT(setDataScaleType(QCPAxis::ScaleType))); + connect(this, SIGNAL(gradientChanged(QCPColorGradient)), mColorScale.data(), SLOT(setGradient(QCPColorGradient))); + connect(mColorScale.data(), SIGNAL(dataRangeChanged(QCPRange)), this, SLOT(setDataRange(QCPRange))); + connect(mColorScale.data(), SIGNAL(gradientChanged(QCPColorGradient)), this, SLOT(setGradient(QCPColorGradient))); + connect(mColorScale.data(), SIGNAL(dataScaleTypeChanged(QCPAxis::ScaleType)), this, SLOT(setDataScaleType(QCPAxis::ScaleType))); + } +} -/*! \fn QPoint QCPAxisRect::center() const +/*! + Sets the data range (\ref setDataRange) to span the minimum and maximum values that occur in the + current data set. This corresponds to the \ref rescaleKeyAxis or \ref rescaleValueAxis methods, + only for the third data dimension of the color map. - Returns the center of this axis rect in pixels. Margins are not taken into account here, so the - returned value is with respect to the inner \ref rect. + The minimum and maximum values of the data set are buffered in the internal QCPColorMapData + instance (\ref data). As data is updated via its \ref QCPColorMapData::setCell or \ref + QCPColorMapData::setData, the buffered minimum and maximum values are updated, too. For + performance reasons, however, they are only updated in an expanding fashion. So the buffered + maximum can only increase and the buffered minimum can only decrease. In consequence, changes to + the data that actually lower the maximum of the data set (by overwriting the cell holding the + current maximum with a smaller value), aren't recognized and the buffered maximum overestimates + the true maximum of the data set. The same happens for the buffered minimum. To recalculate the + true minimum and maximum by explicitly looking at each cell, the method + QCPColorMapData::recalculateDataBounds can be used. For convenience, setting the parameter \a + recalculateDataBounds calls this method before setting the data range to the buffered minimum and + maximum. + + \see setDataRange */ +void QCPColorMap::rescaleDataRange(bool recalculateDataBounds) +{ + if (recalculateDataBounds) + mMapData->recalculateDataBounds(); + setDataRange(mMapData->dataBounds()); +} -/* end documentation of inline functions */ +/*! + Takes the current appearance of the color map and updates the legend icon, which is used to + represent this color map in the legend (see \ref QCPLegend). + + The \a transformMode specifies whether the rescaling is done by a faster, low quality image + scaling algorithm (Qt::FastTransformation) or by a slower, higher quality algorithm + (Qt::SmoothTransformation). + + The current color map appearance is scaled down to \a thumbSize. Ideally, this should be equal to + the size of the legend icon (see \ref QCPLegend::setIconSize). If it isn't exactly the configured + legend icon size, the thumb will be rescaled during drawing of the legend item. + + \see setDataRange +*/ +void QCPColorMap::updateLegendIcon(Qt::TransformationMode transformMode, const QSize &thumbSize) +{ + if (mMapImage.isNull() && !data()->isEmpty()) + updateMapImage(); // try to update map image if it's null (happens if no draw has happened yet) + + if (!mMapImage.isNull()) // might still be null, e.g. if data is empty, so check here again + { + bool mirrorX = (keyAxis()->orientation() == Qt::Horizontal ? keyAxis() : valueAxis())->rangeReversed(); + bool mirrorY = (valueAxis()->orientation() == Qt::Vertical ? valueAxis() : keyAxis())->rangeReversed(); + mLegendIcon = QPixmap::fromImage(mMapImage.mirrored(mirrorX, mirrorY)).scaled(thumbSize, Qt::KeepAspectRatio, transformMode); + } +} /*! - Creates a QCPAxisRect instance and sets default values. An axis is added for each of the four - sides, the top and right axes are set invisible initially. + Clears the colormap data by calling \ref QCPColorMapData::clear() on the internal data. This also + resizes the map to 0x0 cells. */ -QCPAxisRect::QCPAxisRect(QCustomPlot *parentPlot, bool setupDefaultAxes) : - QCPLayoutElement(parentPlot), - mBackgroundBrush(Qt::NoBrush), - mBackgroundScaled(true), - mBackgroundScaledMode(Qt::KeepAspectRatioByExpanding), - mInsetLayout(new QCPLayoutInset), - mRangeDrag(Qt::Horizontal|Qt::Vertical), - mRangeZoom(Qt::Horizontal|Qt::Vertical), - mRangeZoomFactorHorz(0.85), - mRangeZoomFactorVert(0.85), - mDragging(false) +void QCPColorMap::clearData() { - mInsetLayout->initializeParentPlot(mParentPlot); - mInsetLayout->setParentLayerable(this); - mInsetLayout->setParent(this); + mMapData->clear(); +} + +/* inherits documentation from base class */ +double QCPColorMap::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + Q_UNUSED(details) + if (onlySelectable && !mSelectable) + return -1; + if (!mKeyAxis || !mValueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return -1; } - setMinimumSize(50, 50); - setMinimumMargins(QMargins(15, 15, 15, 15)); - mAxes.insert(QCPAxis::atLeft, QList()); - mAxes.insert(QCPAxis::atRight, QList()); - mAxes.insert(QCPAxis::atTop, QList()); - mAxes.insert(QCPAxis::atBottom, QList()); + if (mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint())) + { + double posKey, posValue; + pixelsToCoords(pos, posKey, posValue); + if (mMapData->keyRange().contains(posKey) && mMapData->valueRange().contains(posValue)) + return mParentPlot->selectionTolerance()*0.99; + } + return -1; +} + +/*! \internal - if (setupDefaultAxes) + Updates the internal map image buffer by going through the internal \ref QCPColorMapData and + turning the data values into color pixels with \ref QCPColorGradient::colorize. + + This method is called by \ref QCPColorMap::draw if either the data has been modified or the map image + has been invalidated for a different reason (e.g. a change of the data range with \ref + setDataRange). +*/ +void QCPColorMap::updateMapImage() +{ + QCPAxis *keyAxis = mKeyAxis.data(); + if (!keyAxis) return; + + // resize mMapImage to correct dimensions, according to key/value axes orientation: + if (keyAxis->orientation() == Qt::Horizontal && (mMapImage.size().width() != mMapData->keySize() || mMapImage.size().height() != mMapData->valueSize())) + mMapImage = QImage(QSize(mMapData->keySize(), mMapData->valueSize()), QImage::Format_RGB32); + else if (keyAxis->orientation() == Qt::Vertical && (mMapImage.size().width() != mMapData->valueSize() || mMapImage.size().height() != mMapData->keySize())) + mMapImage = QImage(QSize(mMapData->valueSize(), mMapData->keySize()), QImage::Format_RGB32); + + const int keySize = mMapData->keySize(); + const int valueSize = mMapData->valueSize(); + const double *rawData = mMapData->mData; + + if (keyAxis->orientation() == Qt::Horizontal) { - QCPAxis *xAxis = addAxis(QCPAxis::atBottom); - QCPAxis *yAxis = addAxis(QCPAxis::atLeft); - QCPAxis *xAxis2 = addAxis(QCPAxis::atTop); - QCPAxis *yAxis2 = addAxis(QCPAxis::atRight); - setRangeDragAxes(xAxis, yAxis); - setRangeZoomAxes(xAxis, yAxis); - xAxis2->setVisible(false); - yAxis2->setVisible(false); - xAxis->grid()->setVisible(true); - yAxis->grid()->setVisible(true); - xAxis2->grid()->setVisible(false); - yAxis2->grid()->setVisible(false); - xAxis2->grid()->setZeroLinePen(Qt::NoPen); - yAxis2->grid()->setZeroLinePen(Qt::NoPen); - xAxis2->grid()->setVisible(false); - yAxis2->grid()->setVisible(false); + const int lineCount = valueSize; + const int rowCount = keySize; + for (int line=0; line(mMapImage.scanLine(lineCount-1-line)); // invert scanline index because QImage counts scanlines from top, but our vertical index counts from bottom (mathematical coordinate system) + mGradient.colorize(rawData+line*rowCount, mDataRange, pixels, rowCount, 1, mDataScaleType==QCPAxis::stLogarithmic); + } + } else // keyAxis->orientation() == Qt::Vertical + { + const int lineCount = keySize; + const int rowCount = valueSize; + for (int line=0; line(mMapImage.scanLine(lineCount-1-line)); // invert scanline index because QImage counts scanlines from top, but our vertical index counts from bottom (mathematical coordinate system) + mGradient.colorize(rawData+line, mDataRange, pixels, rowCount, lineCount, mDataScaleType==QCPAxis::stLogarithmic); + } + } + + mMapData->mDataModified = false; + mMapImageInvalidated = false; +} + +/* inherits documentation from base class */ +void QCPColorMap::draw(QCPPainter *painter) +{ + if (mMapData->isEmpty()) return; + if (!mKeyAxis || !mValueAxis) return; + applyDefaultAntialiasingHint(painter); + + if (mMapData->mDataModified || mMapImageInvalidated) + updateMapImage(); + + double halfSampleKey = 0; + double halfSampleValue = 0; + if (mMapData->keySize() > 1) + halfSampleKey = 0.5*mMapData->keyRange().size()/(double)(mMapData->keySize()-1); + if (mMapData->valueSize() > 1) + halfSampleValue = 0.5*mMapData->valueRange().size()/(double)(mMapData->valueSize()-1); + QRectF imageRect(coordsToPixels(mMapData->keyRange().lower-halfSampleKey, mMapData->valueRange().lower-halfSampleValue), + coordsToPixels(mMapData->keyRange().upper+halfSampleKey, mMapData->valueRange().upper+halfSampleValue)); + imageRect = imageRect.normalized(); + bool mirrorX = (keyAxis()->orientation() == Qt::Horizontal ? keyAxis() : valueAxis())->rangeReversed(); + bool mirrorY = (valueAxis()->orientation() == Qt::Vertical ? valueAxis() : keyAxis())->rangeReversed(); + bool smoothBackup = painter->renderHints().testFlag(QPainter::SmoothPixmapTransform); + painter->setRenderHint(QPainter::SmoothPixmapTransform, mInterpolate); + QRegion clipBackup; + if (mTightBoundary) + { + clipBackup = painter->clipRegion(); + painter->setClipRect(QRectF(coordsToPixels(mMapData->keyRange().lower, mMapData->valueRange().lower), + coordsToPixels(mMapData->keyRange().upper, mMapData->valueRange().upper)).normalized(), Qt::IntersectClip); + } + painter->drawImage(imageRect, mMapImage.mirrored(mirrorX, mirrorY)); + if (mTightBoundary) + painter->setClipRegion(clipBackup); + painter->setRenderHint(QPainter::SmoothPixmapTransform, smoothBackup); +} + +/* inherits documentation from base class */ +void QCPColorMap::drawLegendIcon(QCPPainter *painter, const QRectF &rect) const +{ + applyDefaultAntialiasingHint(painter); + // draw map thumbnail: + if (!mLegendIcon.isNull()) + { + QPixmap scaledIcon = mLegendIcon.scaled(rect.size().toSize(), Qt::KeepAspectRatio, Qt::FastTransformation); + QRectF iconRect = QRectF(0, 0, scaledIcon.width(), scaledIcon.height()); + iconRect.moveCenter(rect.center()); + painter->drawPixmap(iconRect.topLeft(), scaledIcon); + } + /* + // draw frame: + painter->setBrush(Qt::NoBrush); + painter->setPen(Qt::black); + painter->drawRect(rect.adjusted(1, 1, 0, 0)); + */ +} + +/* inherits documentation from base class */ +QCPRange QCPColorMap::getKeyRange(bool &foundRange, SignDomain inSignDomain) const +{ + foundRange = true; + QCPRange result = mMapData->keyRange(); + result.normalize(); + if (inSignDomain == QCPAbstractPlottable::sdPositive) + { + if (result.lower <= 0 && result.upper > 0) + result.lower = result.upper*1e-3; + else if (result.lower <= 0 && result.upper <= 0) + foundRange = false; + } else if (inSignDomain == QCPAbstractPlottable::sdNegative) + { + if (result.upper >= 0 && result.lower < 0) + result.upper = result.lower*1e-3; + else if (result.upper >= 0 && result.lower >= 0) + foundRange = false; + } + return result; +} + +/* inherits documentation from base class */ +QCPRange QCPColorMap::getValueRange(bool &foundRange, SignDomain inSignDomain) const +{ + foundRange = true; + QCPRange result = mMapData->valueRange(); + result.normalize(); + if (inSignDomain == QCPAbstractPlottable::sdPositive) + { + if (result.lower <= 0 && result.upper > 0) + result.lower = result.upper*1e-3; + else if (result.lower <= 0 && result.upper <= 0) + foundRange = false; + } else if (inSignDomain == QCPAbstractPlottable::sdNegative) + { + if (result.upper >= 0 && result.lower < 0) + result.upper = result.lower*1e-3; + else if (result.upper >= 0 && result.lower >= 0) + foundRange = false; } + return result; } -QCPAxisRect::~QCPAxisRect() + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPItemStraightLine +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPItemStraightLine + \brief A straight line that spans infinitely in both directions + + \image html QCPItemStraightLine.png "Straight line example. Blue dotted circles are anchors, solid blue discs are positions." + + It has two positions, \a point1 and \a point2, which define the straight line. +*/ + +/*! + Creates a straight line item and sets default values. + + The constructed item can be added to the plot with QCustomPlot::addItem. +*/ +QCPItemStraightLine::QCPItemStraightLine(QCustomPlot *parentPlot) : + QCPAbstractItem(parentPlot), + point1(createPosition("point1")), + point2(createPosition("point2")) { - delete mInsetLayout; - mInsetLayout = 0; + point1->setCoords(0, 0); + point2->setCoords(1, 1); - QList axesList = axes(); - for (int i=0; i ax(mAxes.value(type)); - if (index >= 0 && index < ax.size()) - { - return ax.at(index); - } else + mSelectedPen = pen; +} + +/* inherits documentation from base class */ +double QCPItemStraightLine::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + Q_UNUSED(details) + if (onlySelectable && !mSelectable) + return -1; + + return distToStraightLine(QVector2D(point1->pixelPoint()), QVector2D(point2->pixelPoint()-point1->pixelPoint()), QVector2D(pos)); +} + +/* inherits documentation from base class */ +void QCPItemStraightLine::draw(QCPPainter *painter) +{ + QVector2D start(point1->pixelPoint()); + QVector2D end(point2->pixelPoint()); + // get visible segment of straight line inside clipRect: + double clipPad = mainPen().widthF(); + QLineF line = getRectClippedStraightLine(start, end-start, clipRect().adjusted(-clipPad, -clipPad, clipPad, clipPad)); + // paint visible segment, if existent: + if (!line.isNull()) { - qDebug() << Q_FUNC_INFO << "Axis index out of bounds:" << index; - return 0; + painter->setPen(mainPen()); + painter->drawLine(line); } } -/*! - Returns all axes on the axis rect sides specified with \a types. - - \a types may be a single \ref QCPAxis::AxisType or an or-combination, to get the axes of - multiple sides. +/*! \internal + + finds the shortest distance of \a point to the straight line defined by the base point \a + base and the direction vector \a vec. - \see axis + This is a helper function for \ref selectTest. */ -QList QCPAxisRect::axes(QCPAxis::AxisTypes types) const +double QCPItemStraightLine::distToStraightLine(const QVector2D &base, const QVector2D &vec, const QVector2D &point) const { - QList result; - if (types.testFlag(QCPAxis::atLeft)) - result << mAxes.value(QCPAxis::atLeft); - if (types.testFlag(QCPAxis::atRight)) - result << mAxes.value(QCPAxis::atRight); - if (types.testFlag(QCPAxis::atTop)) - result << mAxes.value(QCPAxis::atTop); - if (types.testFlag(QCPAxis::atBottom)) - result << mAxes.value(QCPAxis::atBottom); - return result; + return qAbs((base.y()-point.y())*vec.x()-(base.x()-point.x())*vec.y())/vec.length(); } -/*! \overload +/*! \internal + + Returns the section of the straight line defined by \a base and direction vector \a + vec, that is visible in the specified \a rect. - Returns all axes of this axis rect. + This is a helper function for \ref draw. */ -QList QCPAxisRect::axes() const +QLineF QCPItemStraightLine::getRectClippedStraightLine(const QVector2D &base, const QVector2D &vec, const QRect &rect) const { - QList result; - QHashIterator > it(mAxes); - while (it.hasNext()) + double bx, by; + double gamma; + QLineF result; + if (vec.x() == 0 && vec.y() == 0) + return result; + if (qFuzzyIsNull(vec.x())) // line is vertical { - it.next(); - result << it.value(); + // check top of rect: + bx = rect.left(); + by = rect.top(); + gamma = base.x()-bx + (by-base.y())*vec.x()/vec.y(); + if (gamma >= 0 && gamma <= rect.width()) + result.setLine(bx+gamma, rect.top(), bx+gamma, rect.bottom()); // no need to check bottom because we know line is vertical + } else if (qFuzzyIsNull(vec.y())) // line is horizontal + { + // check left of rect: + bx = rect.left(); + by = rect.top(); + gamma = base.y()-by + (bx-base.x())*vec.y()/vec.x(); + if (gamma >= 0 && gamma <= rect.height()) + result.setLine(rect.left(), by+gamma, rect.right(), by+gamma); // no need to check right because we know line is horizontal + } else // line is skewed + { + QList pointVectors; + // check top of rect: + bx = rect.left(); + by = rect.top(); + gamma = base.x()-bx + (by-base.y())*vec.x()/vec.y(); + if (gamma >= 0 && gamma <= rect.width()) + pointVectors.append(QVector2D(bx+gamma, by)); + // check bottom of rect: + bx = rect.left(); + by = rect.bottom(); + gamma = base.x()-bx + (by-base.y())*vec.x()/vec.y(); + if (gamma >= 0 && gamma <= rect.width()) + pointVectors.append(QVector2D(bx+gamma, by)); + // check left of rect: + bx = rect.left(); + by = rect.top(); + gamma = base.y()-by + (bx-base.x())*vec.y()/vec.x(); + if (gamma >= 0 && gamma <= rect.height()) + pointVectors.append(QVector2D(bx, by+gamma)); + // check right of rect: + bx = rect.right(); + by = rect.top(); + gamma = base.y()-by + (bx-base.x())*vec.y()/vec.x(); + if (gamma >= 0 && gamma <= rect.height()) + pointVectors.append(QVector2D(bx, by+gamma)); + + // evaluate points: + if (pointVectors.size() == 2) + { + result.setPoints(pointVectors.at(0).toPointF(), pointVectors.at(1).toPointF()); + } else if (pointVectors.size() > 2) + { + // line probably goes through corner of rect, and we got two points there. single out the point pair with greatest distance: + double distSqrMax = 0; + QVector2D pv1, pv2; + for (int i=0; i distSqrMax) + { + pv1 = pointVectors.at(i); + pv2 = pointVectors.at(k); + distSqrMax = distSqr; + } + } + } + result.setPoints(pv1.toPointF(), pv2.toPointF()); + } } return result; } -/*! - Adds a new axis to the axis rect side specified with \a type, and returns it. - - If an axis rect side already contains one or more axes, the lower and upper endings of the new - axis (\ref QCPAxis::setLowerEnding, \ref QCPAxis::setUpperEnding) are initialized to \ref - QCPLineEnding::esHalfBar. - - \see addAxes, setupFullAxesBox +/*! \internal + + Returns the pen that should be used for drawing lines. Returns mPen when the + item is not selected and mSelectedPen when it is. */ -QCPAxis *QCPAxisRect::addAxis(QCPAxis::AxisType type) +QPen QCPItemStraightLine::mainPen() const { - QCPAxis *newAxis = new QCPAxis(this, type); - if (mAxes[type].size() > 0) // multiple axes on one side, add half-bar axis ending to additional axes with offset - { - bool invert = (type == QCPAxis::atRight) || (type == QCPAxis::atBottom); - newAxis->setLowerEnding(QCPLineEnding(QCPLineEnding::esHalfBar, 6, 10, !invert)); - newAxis->setUpperEnding(QCPLineEnding(QCPLineEnding::esHalfBar, 6, 10, invert)); - } - mAxes[type].append(newAxis); - return newAxis; + return mSelected ? mSelectedPen : mPen; } -/*! - Adds a new axis with \ref addAxis to each axis rect side specified in \a types. This may be an - or-combination of QCPAxis::AxisType, so axes can be added to multiple sides at once. + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPItemLine +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPItemLine + \brief A line from one point to another + + \image html QCPItemLine.png "Line example. Blue dotted circles are anchors, solid blue discs are positions." + + It has two positions, \a start and \a end, which define the end points of the line. - Returns a list of the added axes. + With \ref setHead and \ref setTail you may set different line ending styles, e.g. to create an arrow. +*/ + +/*! + Creates a line item and sets default values. - \see addAxis, setupFullAxesBox + The constructed item can be added to the plot with QCustomPlot::addItem. */ -QList QCPAxisRect::addAxes(QCPAxis::AxisTypes types) +QCPItemLine::QCPItemLine(QCustomPlot *parentPlot) : + QCPAbstractItem(parentPlot), + start(createPosition("start")), + end(createPosition("end")) +{ + start->setCoords(0, 0); + end->setCoords(1, 1); + + setPen(QPen(Qt::black)); + setSelectedPen(QPen(Qt::blue,2)); +} + +QCPItemLine::~QCPItemLine() { - QList result; - if (types.testFlag(QCPAxis::atLeft)) - result << addAxis(QCPAxis::atLeft); - if (types.testFlag(QCPAxis::atRight)) - result << addAxis(QCPAxis::atRight); - if (types.testFlag(QCPAxis::atTop)) - result << addAxis(QCPAxis::atTop); - if (types.testFlag(QCPAxis::atBottom)) - result << addAxis(QCPAxis::atBottom); - return result; } /*! - Removes the specified \a axis from the axis rect and deletes it. - - Returns true on success, i.e. if \a axis was a valid axis in this axis rect. + Sets the pen that will be used to draw the line - \see addAxis + \see setSelectedPen */ -bool QCPAxisRect::removeAxis(QCPAxis *axis) +void QCPItemLine::setPen(const QPen &pen) { - // don't access axis->axisType() to provide safety when axis is an invalid pointer, rather go through all axis containers: - QHashIterator > it(mAxes); - while (it.hasNext()) - { - it.next(); - if (it.value().contains(axis)) - { - mAxes[it.key()].removeOne(axis); - if (qobject_cast(parentPlot())) // make sure this isn't called from QObject dtor when QCustomPlot is already destructed (happens when the axis rect is not in any layout and thus QObject-child of QCustomPlot) - parentPlot()->axisRemoved(axis); - delete axis; - return true; - } - } - qDebug() << Q_FUNC_INFO << "Axis isn't in axis rect:" << reinterpret_cast(axis); - return false; + mPen = pen; } /*! - Convenience function to create an axis on each side that doesn't have any axes yet, and assign - the top/right axes the following properties of the bottom/left axes (even if they already existed - and weren't created by this function): - - \li range (\ref QCPAxis::setRange) - \li range reversed (\ref QCPAxis::setRangeReversed) - \li scale type (\ref QCPAxis::setScaleType) - \li scale log base (\ref QCPAxis::setScaleLogBase) - \li ticks (\ref QCPAxis::setTicks) - \li auto (major) tick count (\ref QCPAxis::setAutoTickCount) - \li sub tick count (\ref QCPAxis::setSubTickCount) - \li auto sub ticks (\ref QCPAxis::setAutoSubTicks) - \li tick step (\ref QCPAxis::setTickStep) - \li auto tick step (\ref QCPAxis::setAutoTickStep) + Sets the pen that will be used to draw the line when selected - Tick labels (\ref QCPAxis::setTickLabels) of the right and top axes are set to false. - - If \a connectRanges is true, the rangeChanged signals of the bottom and left axes are connected - to the \ref QCPAxis::setRange slots of the top and right axes. + \see setPen, setSelected */ -void QCPAxisRect::setupFullAxesBox(bool connectRanges) +void QCPItemLine::setSelectedPen(const QPen &pen) { - QCPAxis *xAxis, *yAxis, *xAxis2, *yAxis2; - if (axisCount(QCPAxis::atBottom) == 0) - xAxis = addAxis(QCPAxis::atBottom); - else - xAxis = axis(QCPAxis::atBottom); - - if (axisCount(QCPAxis::atLeft) == 0) - yAxis = addAxis(QCPAxis::atLeft); - else - yAxis = axis(QCPAxis::atLeft); - - if (axisCount(QCPAxis::atTop) == 0) - xAxis2 = addAxis(QCPAxis::atTop); - else - xAxis2 = axis(QCPAxis::atTop); - - if (axisCount(QCPAxis::atRight) == 0) - yAxis2 = addAxis(QCPAxis::atRight); - else - yAxis2 = axis(QCPAxis::atRight); - - xAxis2->setVisible(true); - xAxis2->setTickLabels(false); - if (xAxis) - { - xAxis2->setAutoSubTicks(xAxis->autoSubTicks()); - xAxis2->setAutoTickCount(xAxis->autoTickCount()); - xAxis2->setAutoTickStep(xAxis->autoTickStep()); - xAxis2->setScaleType(xAxis->scaleType()); - xAxis2->setScaleLogBase(xAxis->scaleLogBase()); - xAxis2->setTicks(xAxis->ticks()); - xAxis2->setSubTickCount(xAxis->subTickCount()); - xAxis2->setTickStep(xAxis->tickStep()); - xAxis2->setRange(xAxis->range()); - xAxis2->setRangeReversed(xAxis->rangeReversed()); - } - - yAxis2->setVisible(true); - yAxis2->setTickLabels(false); - if (yAxis) - { - yAxis2->setAutoSubTicks(yAxis->autoSubTicks()); - yAxis2->setAutoTickCount(yAxis->autoTickCount()); - yAxis2->setAutoTickStep(yAxis->autoTickStep()); - yAxis2->setScaleType(yAxis->scaleType()); - yAxis2->setScaleLogBase(yAxis->scaleLogBase()); - yAxis2->setTicks(yAxis->ticks()); - yAxis2->setSubTickCount(yAxis->subTickCount()); - yAxis2->setTickStep(yAxis->tickStep()); - yAxis2->setRange(yAxis->range()); - yAxis2->setRangeReversed(yAxis->rangeReversed()); - } - - if (connectRanges) - { - connect(xAxis, SIGNAL(rangeChanged(QCPRange)), xAxis2, SLOT(setRange(QCPRange))); - connect(yAxis, SIGNAL(rangeChanged(QCPRange)), yAxis2, SLOT(setRange(QCPRange))); - } + mSelectedPen = pen; } /*! - Returns a list of all the plottables that are associated with this axis rect. + Sets the line ending style of the head. The head corresponds to the \a end position. - A plottable is considered associated with an axis rect if its key or value axis (or both) is in - this axis rect. + Note that due to the overloaded QCPLineEnding constructor, you may directly specify + a QCPLineEnding::EndingStyle here, e.g. \code setHead(QCPLineEnding::esSpikeArrow) \endcode - \see graphs, items + \see setTail */ -QList QCPAxisRect::plottables() const +void QCPItemLine::setHead(const QCPLineEnding &head) { - // Note: don't append all QCPAxis::plottables() into a list, because we might get duplicate entries - QList result; - for (int i=0; imPlottables.size(); ++i) - { - if (mParentPlot->mPlottables.at(i)->keyAxis()->axisRect() == this ||mParentPlot->mPlottables.at(i)->valueAxis()->axisRect() == this) - result.append(mParentPlot->mPlottables.at(i)); - } - return result; + mHead = head; } /*! - Returns a list of all the graphs that are associated with this axis rect. + Sets the line ending style of the tail. The tail corresponds to the \a start position. - A graph is considered associated with an axis rect if its key or value axis (or both) is in - this axis rect. + Note that due to the overloaded QCPLineEnding constructor, you may directly specify + a QCPLineEnding::EndingStyle here, e.g. \code setTail(QCPLineEnding::esSpikeArrow) \endcode - \see plottables, items + \see setHead */ -QList QCPAxisRect::graphs() const +void QCPItemLine::setTail(const QCPLineEnding &tail) { - // Note: don't append all QCPAxis::graphs() into a list, because we might get duplicate entries - QList result; - for (int i=0; imGraphs.size(); ++i) + mTail = tail; +} + +/* inherits documentation from base class */ +double QCPItemLine::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + Q_UNUSED(details) + if (onlySelectable && !mSelectable) + return -1; + + return qSqrt(distSqrToLine(start->pixelPoint(), end->pixelPoint(), pos)); +} + +/* inherits documentation from base class */ +void QCPItemLine::draw(QCPPainter *painter) +{ + QVector2D startVec(start->pixelPoint()); + QVector2D endVec(end->pixelPoint()); + if (startVec.toPoint() == endVec.toPoint()) + return; + // get visible segment of straight line inside clipRect: + double clipPad = qMax(mHead.boundingDistance(), mTail.boundingDistance()); + clipPad = qMax(clipPad, (double)mainPen().widthF()); + QLineF line = getRectClippedLine(startVec, endVec, clipRect().adjusted(-clipPad, -clipPad, clipPad, clipPad)); + // paint visible segment, if existent: + if (!line.isNull()) { - if (mParentPlot->mGraphs.at(i)->keyAxis()->axisRect() == this || mParentPlot->mGraphs.at(i)->valueAxis()->axisRect() == this) - result.append(mParentPlot->mGraphs.at(i)); + painter->setPen(mainPen()); + painter->drawLine(line); + painter->setBrush(Qt::SolidPattern); + if (mTail.style() != QCPLineEnding::esNone) + mTail.draw(painter, startVec, startVec-endVec); + if (mHead.style() != QCPLineEnding::esNone) + mHead.draw(painter, endVec, endVec-startVec); } - return result; } -/*! - Returns a list of all the items that are associated with this axis rect. - - An item is considered associated with an axis rect if any of its positions has key or value axis - set to an axis that is in this axis rect, or if any of its positions has \ref - QCPItemPosition::setAxisRect set to the axis rect, or if the clip axis rect (\ref - QCPAbstractItem::setClipAxisRect) is set to this axis rect. +/*! \internal + + Returns the section of the line defined by \a start and \a end, that is visible in the specified + \a rect. - \see plottables, graphs + This is a helper function for \ref draw. */ -QList QCPAxisRect::items() const +QLineF QCPItemLine::getRectClippedLine(const QVector2D &start, const QVector2D &end, const QRect &rect) const { - // Note: don't just append all QCPAxis::items() into a list, because we might get duplicate entries - // and miss those items that have this axis rect as clipAxisRect. - QList result; - for (int itemId=0; itemIdmItems.size(); ++itemId) + bool containsStart = rect.contains(start.x(), start.y()); + bool containsEnd = rect.contains(end.x(), end.y()); + if (containsStart && containsEnd) + return QLineF(start.toPointF(), end.toPointF()); + + QVector2D base = start; + QVector2D vec = end-start; + double bx, by; + double gamma, mu; + QLineF result; + QList pointVectors; + + if (!qFuzzyIsNull(vec.y())) // line is not horizontal { - if (mParentPlot->mItems.at(itemId)->clipAxisRect() == this) + // check top of rect: + bx = rect.left(); + by = rect.top(); + mu = (by-base.y())/vec.y(); + if (mu >= 0 && mu <= 1) { - result.append(mParentPlot->mItems.at(itemId)); - continue; + gamma = base.x()-bx + mu*vec.x(); + if (gamma >= 0 && gamma <= rect.width()) + pointVectors.append(QVector2D(bx+gamma, by)); } - QList positions = mParentPlot->mItems.at(itemId)->positions(); - for (int posId=0; posId= 0 && mu <= 1) { - if (positions.at(posId)->axisRect() == this || - positions.at(posId)->keyAxis()->axisRect() == this || - positions.at(posId)->valueAxis()->axisRect() == this) + gamma = base.x()-bx + mu*vec.x(); + if (gamma >= 0 && gamma <= rect.width()) + pointVectors.append(QVector2D(bx+gamma, by)); + } + } + if (!qFuzzyIsNull(vec.x())) // line is not vertical + { + // check left of rect: + bx = rect.left(); + by = rect.top(); + mu = (bx-base.x())/vec.x(); + if (mu >= 0 && mu <= 1) + { + gamma = base.y()-by + mu*vec.y(); + if (gamma >= 0 && gamma <= rect.height()) + pointVectors.append(QVector2D(bx, by+gamma)); + } + // check right of rect: + bx = rect.right(); + by = rect.top(); + mu = (bx-base.x())/vec.x(); + if (mu >= 0 && mu <= 1) + { + gamma = base.y()-by + mu*vec.y(); + if (gamma >= 0 && gamma <= rect.height()) + pointVectors.append(QVector2D(bx, by+gamma)); + } + } + + if (containsStart) + pointVectors.append(start); + if (containsEnd) + pointVectors.append(end); + + // evaluate points: + if (pointVectors.size() == 2) + { + result.setPoints(pointVectors.at(0).toPointF(), pointVectors.at(1).toPointF()); + } else if (pointVectors.size() > 2) + { + // line probably goes through corner of rect, and we got two points there. single out the point pair with greatest distance: + double distSqrMax = 0; + QVector2D pv1, pv2; + for (int i=0; imItems.at(itemId)); - break; + double distSqr = (pointVectors.at(i)-pointVectors.at(k)).lengthSquared(); + if (distSqr > distSqrMax) + { + pv1 = pointVectors.at(i); + pv2 = pointVectors.at(k); + distSqrMax = distSqr; + } } } + result.setPoints(pv1.toPointF(), pv2.toPointF()); } return result; } -/*! - This method is called automatically upon replot and doesn't need to be called by users of - QCPAxisRect. - - Calls the base class implementation to update the margins (see \ref QCPLayoutElement::update), - and finally passes the \ref rect to the inset layout (\ref insetLayout) and calls its - QCPInsetLayout::update function. -*/ -void QCPAxisRect::update() -{ - QCPLayoutElement::update(); - - // pass update call on to inset layout (doesn't happen automatically, because QCPAxisRect doesn't derive from QCPLayout): - mInsetLayout->setOuterRect(rect()); - mInsetLayout->update(); -} +/*! \internal -/* inherits documentation from base class */ -QList QCPAxisRect::elements(bool recursive) const + Returns the pen that should be used for drawing lines. Returns mPen when the + item is not selected and mSelectedPen when it is. +*/ +QPen QCPItemLine::mainPen() const { - QList result; - if (mInsetLayout) - { - result << mInsetLayout; - if (recursive) - result << mInsetLayout->elements(recursive); - } - return result; + return mSelected ? mSelectedPen : mPen; } -/* inherits documentation from base class */ -void QCPAxisRect::applyDefaultAntialiasingHint(QCPPainter *painter) const -{ - painter->setAntialiasing(false); -} -/* inherits documentation from base class */ -void QCPAxisRect::draw(QCPPainter *painter) -{ - drawBackground(painter); -} +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPItemCurve +//////////////////////////////////////////////////////////////////////////////////////////////////// -/*! - Sets \a pm as the axis background pixmap. The axis background pixmap will be drawn inside the - axis rect. Since axis rects place themselves on the "background" layer by default, the axis rect - backgrounds are usually drawn below everything else. +/*! \class QCPItemCurve + \brief A curved line from one point to another - For cases where the provided pixmap doesn't have the same size as the axis rect, scaling can be - enabled with \ref setBackgroundScaled and the scaling mode (i.e. whether and how the aspect ratio - is preserved) can be set with \ref setBackgroundScaledMode. To set all these options in one call, - consider using the overloaded version of this function. + \image html QCPItemCurve.png "Curve example. Blue dotted circles are anchors, solid blue discs are positions." - Below the pixmap, the axis rect may be optionally filled with a brush, if specified with \ref - setBackground(const QBrush &brush). + It has four positions, \a start and \a end, which define the end points of the line, and two + control points which define the direction the line exits from the start and the direction from + which it approaches the end: \a startDir and \a endDir. - \see setBackgroundScaled, setBackgroundScaledMode, setBackground(const QBrush &brush) -*/ -void QCPAxisRect::setBackground(const QPixmap &pm) -{ - mBackgroundPixmap = pm; - mScaledBackgroundPixmap = QPixmap(); -} - -/*! \overload + With \ref setHead and \ref setTail you may set different line ending styles, e.g. to create an + arrow. - Sets \a brush as the background brush. The axis rect background will be filled with this brush. - Since axis rects place themselves on the "background" layer by default, the axis rect backgrounds - are usually drawn below everything else. - - The brush will be drawn before (under) any background pixmap, which may be specified with \ref - setBackground(const QPixmap &pm). + Often it is desirable for the control points to stay at fixed relative positions to the start/end + point. This can be achieved by setting the parent anchor e.g. of \a startDir simply to \a start, + and then specify the desired pixel offset with QCPItemPosition::setCoords on \a startDir. +*/ - To disable drawing of a background brush, set \a brush to Qt::NoBrush. +/*! + Creates a curve item and sets default values. - \see setBackground(const QPixmap &pm) + The constructed item can be added to the plot with QCustomPlot::addItem. */ -void QCPAxisRect::setBackground(const QBrush &brush) +QCPItemCurve::QCPItemCurve(QCustomPlot *parentPlot) : + QCPAbstractItem(parentPlot), + start(createPosition("start")), + startDir(createPosition("startDir")), + endDir(createPosition("endDir")), + end(createPosition("end")) { - mBackgroundBrush = brush; -} - -/*! \overload + start->setCoords(0, 0); + startDir->setCoords(0.5, 0); + endDir->setCoords(0, 0.5); + end->setCoords(1, 1); - Allows setting the background pixmap of the axis rect, whether it shall be scaled and how it - shall be scaled in one call. + setPen(QPen(Qt::black)); + setSelectedPen(QPen(Qt::blue,2)); +} - \see setBackground(const QPixmap &pm), setBackgroundScaled, setBackgroundScaledMode -*/ -void QCPAxisRect::setBackground(const QPixmap &pm, bool scaled, Qt::AspectRatioMode mode) +QCPItemCurve::~QCPItemCurve() { - mBackgroundPixmap = pm; - mScaledBackgroundPixmap = QPixmap(); - mBackgroundScaled = scaled; - mBackgroundScaledMode = mode; } /*! - Sets whether the axis background pixmap shall be scaled to fit the axis rect or not. If \a scaled - is set to true, you may control whether and how the aspect ratio of the original pixmap is - preserved with \ref setBackgroundScaledMode. - - Note that the scaled version of the original pixmap is buffered, so there is no performance - penalty on replots. (Except when the axis rect dimensions are changed continuously.) + Sets the pen that will be used to draw the line - \see setBackground, setBackgroundScaledMode + \see setSelectedPen */ -void QCPAxisRect::setBackgroundScaled(bool scaled) +void QCPItemCurve::setPen(const QPen &pen) { - mBackgroundScaled = scaled; + mPen = pen; } /*! - If scaling of the axis background pixmap is enabled (\ref setBackgroundScaled), use this function to - define whether and how the aspect ratio of the original pixmap passed to \ref setBackground is preserved. - \see setBackground, setBackgroundScaled + Sets the pen that will be used to draw the line when selected + + \see setPen, setSelected */ -void QCPAxisRect::setBackgroundScaledMode(Qt::AspectRatioMode mode) +void QCPItemCurve::setSelectedPen(const QPen &pen) { - mBackgroundScaledMode = mode; + mSelectedPen = pen; } /*! - Returns the range drag axis of the \a orientation provided. + Sets the line ending style of the head. The head corresponds to the \a end position. - \see setRangeDragAxes + Note that due to the overloaded QCPLineEnding constructor, you may directly specify + a QCPLineEnding::EndingStyle here, e.g. \code setHead(QCPLineEnding::esSpikeArrow) \endcode + + \see setTail */ -QCPAxis *QCPAxisRect::rangeDragAxis(Qt::Orientation orientation) +void QCPItemCurve::setHead(const QCPLineEnding &head) { - return (orientation == Qt::Horizontal ? mRangeDragHorzAxis.data() : mRangeDragVertAxis.data()); + mHead = head; } /*! - Returns the range zoom axis of the \a orientation provided. + Sets the line ending style of the tail. The tail corresponds to the \a start position. - \see setRangeZoomAxes + Note that due to the overloaded QCPLineEnding constructor, you may directly specify + a QCPLineEnding::EndingStyle here, e.g. \code setTail(QCPLineEnding::esSpikeArrow) \endcode + + \see setHead */ -QCPAxis *QCPAxisRect::rangeZoomAxis(Qt::Orientation orientation) +void QCPItemCurve::setTail(const QCPLineEnding &tail) { - return (orientation == Qt::Horizontal ? mRangeZoomHorzAxis.data() : mRangeZoomVertAxis.data()); + mTail = tail; } -/*! - Returns the range zoom factor of the \a orientation provided. +/* inherits documentation from base class */ +double QCPItemCurve::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + Q_UNUSED(details) + if (onlySelectable && !mSelectable) + return -1; - \see setRangeZoomFactor -*/ -double QCPAxisRect::rangeZoomFactor(Qt::Orientation orientation) + QPointF startVec(start->pixelPoint()); + QPointF startDirVec(startDir->pixelPoint()); + QPointF endDirVec(endDir->pixelPoint()); + QPointF endVec(end->pixelPoint()); + + QPainterPath cubicPath(startVec); + cubicPath.cubicTo(startDirVec, endDirVec, endVec); + + QPolygonF polygon = cubicPath.toSubpathPolygons().first(); + double minDistSqr = std::numeric_limits::max(); + for (int i=1; ipixelPoint()); + QPointF startDirVec(startDir->pixelPoint()); + QPointF endDirVec(endDir->pixelPoint()); + QPointF endVec(end->pixelPoint()); + if (QVector2D(endVec-startVec).length() > 1e10f) // too large curves cause crash + return; + + QPainterPath cubicPath(startVec); + cubicPath.cubicTo(startDirVec, endDirVec, endVec); + + // paint visible segment, if existent: + QRect clip = clipRect().adjusted(-mainPen().widthF(), -mainPen().widthF(), mainPen().widthF(), mainPen().widthF()); + QRect cubicRect = cubicPath.controlPointRect().toRect(); + if (cubicRect.isEmpty()) // may happen when start and end exactly on same x or y position + cubicRect.adjust(0, 0, 1, 1); + if (clip.intersects(cubicRect)) + { + painter->setPen(mainPen()); + painter->drawPath(cubicPath); + painter->setBrush(Qt::SolidPattern); + if (mTail.style() != QCPLineEnding::esNone) + mTail.draw(painter, QVector2D(startVec), M_PI-cubicPath.angleAtPercent(0)/180.0*M_PI); + if (mHead.style() != QCPLineEnding::esNone) + mHead.draw(painter, QVector2D(endVec), -cubicPath.angleAtPercent(1)/180.0*M_PI); + } } -/*! - Sets which axis orientation may be range dragged by the user with mouse interaction. - What orientation corresponds to which specific axis can be set with - \ref setRangeDragAxes(QCPAxis *horizontal, QCPAxis *vertical). By - default, the horizontal axis is the bottom axis (xAxis) and the vertical axis - is the left axis (yAxis). - - To disable range dragging entirely, pass 0 as \a orientations or remove \ref QCP::iRangeDrag from \ref - QCustomPlot::setInteractions. To enable range dragging for both directions, pass Qt::Horizontal | - Qt::Vertical as \a orientations. - - In addition to setting \a orientations to a non-zero value, make sure \ref QCustomPlot::setInteractions - contains \ref QCP::iRangeDrag to enable the range dragging interaction. - - \see setRangeZoom, setRangeDragAxes, setNoAntialiasingOnDrag +/*! \internal + + Returns the pen that should be used for drawing lines. Returns mPen when the + item is not selected and mSelectedPen when it is. */ -void QCPAxisRect::setRangeDrag(Qt::Orientations orientations) +QPen QCPItemCurve::mainPen() const { - mRangeDrag = orientations; + return mSelected ? mSelectedPen : mPen; } -/*! - Sets which axis orientation may be zoomed by the user with the mouse wheel. What orientation - corresponds to which specific axis can be set with \ref setRangeZoomAxes(QCPAxis *horizontal, - QCPAxis *vertical). By default, the horizontal axis is the bottom axis (xAxis) and the vertical - axis is the left axis (yAxis). - To disable range zooming entirely, pass 0 as \a orientations or remove \ref QCP::iRangeZoom from \ref - QCustomPlot::setInteractions. To enable range zooming for both directions, pass Qt::Horizontal | - Qt::Vertical as \a orientations. - - In addition to setting \a orientations to a non-zero value, make sure \ref QCustomPlot::setInteractions - contains \ref QCP::iRangeZoom to enable the range zooming interaction. - - \see setRangeZoomFactor, setRangeZoomAxes, setRangeDrag +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPItemRect +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPItemRect + \brief A rectangle + + \image html QCPItemRect.png "Rectangle example. Blue dotted circles are anchors, solid blue discs are positions." + + It has two positions, \a topLeft and \a bottomRight, which define the rectangle. */ -void QCPAxisRect::setRangeZoom(Qt::Orientations orientations) -{ - mRangeZoom = orientations; -} /*! - Sets the axes whose range will be dragged when \ref setRangeDrag enables mouse range dragging - on the QCustomPlot widget. + Creates a rectangle item and sets default values. - \see setRangeZoomAxes + The constructed item can be added to the plot with QCustomPlot::addItem. */ -void QCPAxisRect::setRangeDragAxes(QCPAxis *horizontal, QCPAxis *vertical) +QCPItemRect::QCPItemRect(QCustomPlot *parentPlot) : + QCPAbstractItem(parentPlot), + topLeft(createPosition("topLeft")), + bottomRight(createPosition("bottomRight")), + top(createAnchor("top", aiTop)), + topRight(createAnchor("topRight", aiTopRight)), + right(createAnchor("right", aiRight)), + bottom(createAnchor("bottom", aiBottom)), + bottomLeft(createAnchor("bottomLeft", aiBottomLeft)), + left(createAnchor("left", aiLeft)) { - mRangeDragHorzAxis = horizontal; - mRangeDragVertAxis = vertical; + topLeft->setCoords(0, 1); + bottomRight->setCoords(1, 0); + + setPen(QPen(Qt::black)); + setSelectedPen(QPen(Qt::blue,2)); + setBrush(Qt::NoBrush); + setSelectedBrush(Qt::NoBrush); } -/*! - Sets the axes whose range will be zoomed when \ref setRangeZoom enables mouse wheel zooming on the - QCustomPlot widget. The two axes can be zoomed with different strengths, when different factors - are passed to \ref setRangeZoomFactor(double horizontalFactor, double verticalFactor). - - \see setRangeDragAxes -*/ -void QCPAxisRect::setRangeZoomAxes(QCPAxis *horizontal, QCPAxis *vertical) +QCPItemRect::~QCPItemRect() { - mRangeZoomHorzAxis = horizontal; - mRangeZoomVertAxis = vertical; } /*! - Sets how strong one rotation step of the mouse wheel zooms, when range zoom was activated with - \ref setRangeZoom. The two parameters \a horizontalFactor and \a verticalFactor provide a way to - let the horizontal axis zoom at different rates than the vertical axis. Which axis is horizontal - and which is vertical, can be set with \ref setRangeZoomAxes. - - When the zoom factor is greater than one, scrolling the mouse wheel backwards (towards the user) - will zoom in (make the currently visible range smaller). For zoom factors smaller than one, the - same scrolling direction will zoom out. + Sets the pen that will be used to draw the line of the rectangle + + \see setSelectedPen, setBrush */ -void QCPAxisRect::setRangeZoomFactor(double horizontalFactor, double verticalFactor) +void QCPItemRect::setPen(const QPen &pen) { - mRangeZoomFactorHorz = horizontalFactor; - mRangeZoomFactorVert = verticalFactor; + mPen = pen; } -/*! \overload +/*! + Sets the pen that will be used to draw the line of the rectangle when selected - Sets both the horizontal and vertical zoom \a factor. + \see setPen, setSelected */ -void QCPAxisRect::setRangeZoomFactor(double factor) +void QCPItemRect::setSelectedPen(const QPen &pen) { - mRangeZoomFactorHorz = factor; - mRangeZoomFactorVert = factor; + mSelectedPen = pen; } -/*! \internal - - Draws the background of this axis rect. It may consist of a background fill (a QBrush) and a - pixmap. - - If a brush was given via \ref setBackground(const QBrush &brush), this function first draws an - according filling inside the axis rect with the provided \a painter. - - Then, if a pixmap was provided via \ref setBackground, this function buffers the scaled version - depending on \ref setBackgroundScaled and \ref setBackgroundScaledMode and then draws it inside - the axis rect with the provided \a painter. The scaled version is buffered in - mScaledBackgroundPixmap to prevent expensive rescaling at every redraw. It is only updated, when - the axis rect has changed in a way that requires a rescale of the background pixmap (this is - dependant on the \ref setBackgroundScaledMode), or when a differend axis backgroud pixmap was - set. +/*! + Sets the brush that will be used to fill the rectangle. To disable filling, set \a brush to + Qt::NoBrush. - \see setBackground, setBackgroundScaled, setBackgroundScaledMode + \see setSelectedBrush, setPen */ -void QCPAxisRect::drawBackground(QCPPainter *painter) +void QCPItemRect::setBrush(const QBrush &brush) { - // draw background fill: - if (mBackgroundBrush != Qt::NoBrush) - painter->fillRect(mRect, mBackgroundBrush); - - // draw background pixmap (on top of fill, if brush specified): - if (!mBackgroundPixmap.isNull()) - { - if (mBackgroundScaled) - { - // check whether mScaledBackground needs to be updated: - QSize scaledSize(mBackgroundPixmap.size()); - scaledSize.scale(mRect.size(), mBackgroundScaledMode); - if (mScaledBackgroundPixmap.size() != scaledSize) - mScaledBackgroundPixmap = mBackgroundPixmap.scaled(mRect.size(), mBackgroundScaledMode, Qt::SmoothTransformation); - painter->drawPixmap(mRect.topLeft(), mScaledBackgroundPixmap, QRect(0, 0, mRect.width(), mRect.height()) & mScaledBackgroundPixmap.rect()); - } else - { - painter->drawPixmap(mRect.topLeft(), mBackgroundPixmap, QRect(0, 0, mRect.width(), mRect.height())); - } - } + mBrush = brush; } -/*! \internal - - This function makes sure multiple axes on the side specified with \a type don't collide, but are - distributed according to their respective space requirement (QCPAxis::calculateMargin). - - It does this by setting an appropriate offset (\ref QCPAxis::setOffset) on all axes except the - one with index zero. +/*! + Sets the brush that will be used to fill the rectangle when selected. To disable filling, set \a + brush to Qt::NoBrush. - This function is called by \ref calculateAutoMargin. + \see setBrush */ -void QCPAxisRect::updateAxesOffset(QCPAxis::AxisType type) +void QCPItemRect::setSelectedBrush(const QBrush &brush) { - const QList axesList = mAxes.value(type); - for (int i=1; isetOffset(axesList.at(i-1)->offset() + axesList.at(i-1)->calculateMargin() + axesList.at(i)->tickLengthIn()); + mSelectedBrush = brush; } /* inherits documentation from base class */ -int QCPAxisRect::calculateAutoMargin(QCP::MarginSide side) +double QCPItemRect::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { - if (!mAutoMargins.testFlag(side)) - qDebug() << Q_FUNC_INFO << "Called with side that isn't specified as auto margin"; - - updateAxesOffset(QCPAxis::marginSideToAxisType(side)); + Q_UNUSED(details) + if (onlySelectable && !mSelectable) + return -1; - // note: only need to look at the last (outer most) axis to determine the total margin, due to updateAxisOffset call - const QList axesList = mAxes.value(QCPAxis::marginSideToAxisType(side)); - if (axesList.size() > 0) - return axesList.last()->offset() + axesList.last()->calculateMargin(); - else - return 0; + QRectF rect = QRectF(topLeft->pixelPoint(), bottomRight->pixelPoint()).normalized(); + bool filledRect = mBrush.style() != Qt::NoBrush && mBrush.color().alpha() != 0; + return rectSelectTest(rect, pos, filledRect); } -/*! \internal - - Event handler for when a mouse button is pressed on the axis rect. If the left mouse button is - pressed, the range dragging interaction is initialized (the actual range manipulation happens in - the \ref mouseMoveEvent). - - The mDragging flag is set to true and some anchor points are set that are needed to determine the - distance the mouse was dragged in the mouse move/release events later. - - \see mouseMoveEvent, mouseReleaseEvent -*/ -void QCPAxisRect::mousePressEvent(QMouseEvent *event) +/* inherits documentation from base class */ +void QCPItemRect::draw(QCPPainter *painter) { - mDragStart = event->pos(); // need this even when not LeftButton is pressed, to determine in releaseEvent whether it was a full click (no position change between press and release) - if (event->buttons() & Qt::LeftButton) + QPointF p1 = topLeft->pixelPoint(); + QPointF p2 = bottomRight->pixelPoint(); + if (p1.toPoint() == p2.toPoint()) + return; + QRectF rect = QRectF(p1, p2).normalized(); + double clipPad = mainPen().widthF(); + QRectF boundingRect = rect.adjusted(-clipPad, -clipPad, clipPad, clipPad); + if (boundingRect.intersects(clipRect())) // only draw if bounding rect of rect item is visible in cliprect { - mDragging = true; - // initialize antialiasing backup in case we start dragging: - if (mParentPlot->noAntialiasingOnDrag()) - { - mAADragBackup = mParentPlot->antialiasedElements(); - mNotAADragBackup = mParentPlot->notAntialiasedElements(); - } - // Mouse range dragging interaction: - if (mParentPlot->interactions().testFlag(QCP::iRangeDrag)) - { - if (mRangeDragHorzAxis) - mDragStartHorzRange = mRangeDragHorzAxis.data()->range(); - if (mRangeDragVertAxis) - mDragStartVertRange = mRangeDragVertAxis.data()->range(); - } + painter->setPen(mainPen()); + painter->setBrush(mainBrush()); + painter->drawRect(rect); } } -/*! \internal - - Event handler for when the mouse is moved on the axis rect. If range dragging was activated in a - preceding \ref mousePressEvent, the range is moved accordingly. - - \see mousePressEvent, mouseReleaseEvent -*/ -void QCPAxisRect::mouseMoveEvent(QMouseEvent *event) +/* inherits documentation from base class */ +QPointF QCPItemRect::anchorPixelPoint(int anchorId) const { - // Mouse range dragging interaction: - if (mDragging && mParentPlot->interactions().testFlag(QCP::iRangeDrag)) + QRectF rect = QRectF(topLeft->pixelPoint(), bottomRight->pixelPoint()); + switch (anchorId) { - if (mRangeDrag.testFlag(Qt::Horizontal)) - { - if (QCPAxis *rangeDragHorzAxis = mRangeDragHorzAxis.data()) - { - if (rangeDragHorzAxis->mScaleType == QCPAxis::stLinear) - { - double diff = rangeDragHorzAxis->pixelToCoord(mDragStart.x()) - rangeDragHorzAxis->pixelToCoord(event->pos().x()); - rangeDragHorzAxis->setRange(mDragStartHorzRange.lower+diff, mDragStartHorzRange.upper+diff); - } else if (rangeDragHorzAxis->mScaleType == QCPAxis::stLogarithmic) - { - double diff = rangeDragHorzAxis->pixelToCoord(mDragStart.x()) / rangeDragHorzAxis->pixelToCoord(event->pos().x()); - rangeDragHorzAxis->setRange(mDragStartHorzRange.lower*diff, mDragStartHorzRange.upper*diff); - } - } - } - if (mRangeDrag.testFlag(Qt::Vertical)) - { - if (QCPAxis *rangeDragVertAxis = mRangeDragVertAxis.data()) - { - if (rangeDragVertAxis->mScaleType == QCPAxis::stLinear) - { - double diff = rangeDragVertAxis->pixelToCoord(mDragStart.y()) - rangeDragVertAxis->pixelToCoord(event->pos().y()); - rangeDragVertAxis->setRange(mDragStartVertRange.lower+diff, mDragStartVertRange.upper+diff); - } else if (rangeDragVertAxis->mScaleType == QCPAxis::stLogarithmic) - { - double diff = rangeDragVertAxis->pixelToCoord(mDragStart.y()) / rangeDragVertAxis->pixelToCoord(event->pos().y()); - rangeDragVertAxis->setRange(mDragStartVertRange.lower*diff, mDragStartVertRange.upper*diff); - } - } - } - if (mRangeDrag != 0) // if either vertical or horizontal drag was enabled, do a replot - { - if (mParentPlot->noAntialiasingOnDrag()) - mParentPlot->setNotAntialiasedElements(QCP::aeAll); - mParentPlot->replot(); - } + case aiTop: return (rect.topLeft()+rect.topRight())*0.5; + case aiTopRight: return rect.topRight(); + case aiRight: return (rect.topRight()+rect.bottomRight())*0.5; + case aiBottom: return (rect.bottomLeft()+rect.bottomRight())*0.5; + case aiBottomLeft: return rect.bottomLeft(); + case aiLeft: return (rect.topLeft()+rect.bottomLeft())*0.5; } + + qDebug() << Q_FUNC_INFO << "invalid anchorId" << anchorId; + return QPointF(); } -/* inherits documentation from base class */ -void QCPAxisRect::mouseReleaseEvent(QMouseEvent *event) +/*! \internal + + Returns the pen that should be used for drawing lines. Returns mPen when the item is not selected + and mSelectedPen when it is. +*/ +QPen QCPItemRect::mainPen() const { - Q_UNUSED(event) - mDragging = false; - if (mParentPlot->noAntialiasingOnDrag()) - { - mParentPlot->setAntialiasedElements(mAADragBackup); - mParentPlot->setNotAntialiasedElements(mNotAADragBackup); - } + return mSelected ? mSelectedPen : mPen; } /*! \internal - - Event handler for mouse wheel events. If rangeZoom is Qt::Horizontal, Qt::Vertical or both, the - ranges of the axes defined as rangeZoomHorzAxis and rangeZoomVertAxis are scaled. The center of - the scaling operation is the current cursor position inside the axis rect. The scaling factor is - dependant on the mouse wheel delta (which direction the wheel was rotated) to provide a natural - zooming feel. The Strength of the zoom can be controlled via \ref setRangeZoomFactor. - - Note, that event->delta() is usually +/-120 for single rotation steps. However, if the mouse - wheel is turned rapidly, many steps may bunch up to one event, so the event->delta() may then be - multiples of 120. This is taken into account here, by calculating \a wheelSteps and using it as - exponent of the range zoom factor. This takes care of the wheel direction automatically, by - inverting the factor, when the wheel step is negative (f^-1 = 1/f). + + Returns the brush that should be used for drawing fills of the item. Returns mBrush when the item + is not selected and mSelectedBrush when it is. */ -void QCPAxisRect::wheelEvent(QWheelEvent *event) +QBrush QCPItemRect::mainBrush() const { - // Mouse range zooming interaction: - if (mParentPlot->interactions().testFlag(QCP::iRangeZoom)) - { - if (mRangeZoom != 0) - { - double factor; - double wheelSteps = event->delta()/120.0; // a single step delta is +/-120 usually - if (mRangeZoom.testFlag(Qt::Horizontal)) - { - factor = pow(mRangeZoomFactorHorz, wheelSteps); - if (mRangeZoomHorzAxis.data()) - mRangeZoomHorzAxis.data()->scaleRange(factor, mRangeZoomHorzAxis.data()->pixelToCoord(event->pos().x())); - } - if (mRangeZoom.testFlag(Qt::Vertical)) - { - factor = pow(mRangeZoomFactorVert, wheelSteps); - if (mRangeZoomVertAxis.data()) - mRangeZoomVertAxis.data()->scaleRange(factor, mRangeZoomVertAxis.data()->pixelToCoord(event->pos().y())); - } - mParentPlot->replot(); - } - } + return mSelected ? mSelectedBrush : mBrush; } //////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////// QCPAbstractLegendItem +//////////////////// QCPItemText //////////////////////////////////////////////////////////////////////////////////////////////////// -/*! \class QCPAbstractLegendItem - \brief The abstract base class for all entries in a QCPLegend. +/*! \class QCPItemText + \brief A text label + + \image html QCPItemText.png "Text example. Blue dotted circles are anchors, solid blue discs are positions." + + Its position is defined by the member \a position and the setting of \ref setPositionAlignment. + The latter controls which part of the text rect shall be aligned with \a position. - It defines a very basic interface for entries in a QCPLegend. For representing plottables in the - legend, the subclass \ref QCPPlottableLegendItem is more suitable. + The text alignment itself (i.e. left, center, right) can be controlled with \ref + setTextAlignment. - Only derive directly from this class when you need absolute freedom (e.g. a custom legend entry - that's not even associated with a plottable). + The text may be rotated around the \a position point with \ref setRotation. +*/ - You must implement the following pure virtual functions: - \li \ref draw (from QCPLayerable) +/*! + Creates a text item and sets default values. - You inherit the following members you may use: - - - - - - - - -
                                                                  QCPLegend *\b mParentLegendA pointer to the parent QCPLegend.
                                                                  QFont \b mFontThe generic font of the item. You should use this font for all or at least the most prominent text of the item.
                                                                  + The constructed item can be added to the plot with QCustomPlot::addItem. */ +QCPItemText::QCPItemText(QCustomPlot *parentPlot) : + QCPAbstractItem(parentPlot), + position(createPosition("position")), + topLeft(createAnchor("topLeft", aiTopLeft)), + top(createAnchor("top", aiTop)), + topRight(createAnchor("topRight", aiTopRight)), + right(createAnchor("right", aiRight)), + bottomRight(createAnchor("bottomRight", aiBottomRight)), + bottom(createAnchor("bottom", aiBottom)), + bottomLeft(createAnchor("bottomLeft", aiBottomLeft)), + left(createAnchor("left", aiLeft)) +{ + position->setCoords(0, 0); + + setRotation(0); + setTextAlignment(Qt::AlignTop|Qt::AlignHCenter); + setPositionAlignment(Qt::AlignCenter); + setText("text"); + + setPen(Qt::NoPen); + setSelectedPen(Qt::NoPen); + setBrush(Qt::NoBrush); + setSelectedBrush(Qt::NoBrush); + setColor(Qt::black); + setSelectedColor(Qt::blue); +} -/* start of documentation of signals */ +QCPItemText::~QCPItemText() +{ +} -/*! \fn void QCPAbstractLegendItem::selectionChanged(bool selected) - - This signal is emitted when the selection state of this legend item has changed, either by user - interaction or by a direct call to \ref setSelected. +/*! + Sets the color of the text. +*/ +void QCPItemText::setColor(const QColor &color) +{ + mColor = color; +} + +/*! + Sets the color of the text that will be used when the item is selected. */ +void QCPItemText::setSelectedColor(const QColor &color) +{ + mSelectedColor = color; +} -/* end of documentation of signals */ +/*! + Sets the pen that will be used do draw a rectangular border around the text. To disable the + border, set \a pen to Qt::NoPen. + + \see setSelectedPen, setBrush, setPadding +*/ +void QCPItemText::setPen(const QPen &pen) +{ + mPen = pen; +} /*! - Constructs a QCPAbstractLegendItem and associates it with the QCPLegend \a parent. This does not - cause the item to be added to \a parent, so \ref QCPLegend::addItem must be called separately. + Sets the pen that will be used do draw a rectangular border around the text, when the item is + selected. To disable the border, set \a pen to Qt::NoPen. + + \see setPen */ -QCPAbstractLegendItem::QCPAbstractLegendItem(QCPLegend *parent) : - QCPLayoutElement(parent->parentPlot()), - mParentLegend(parent), - mFont(parent->font()), - mTextColor(parent->textColor()), - mSelectedFont(parent->selectedFont()), - mSelectedTextColor(parent->selectedTextColor()), - mSelectable(true), - mSelected(false) +void QCPItemText::setSelectedPen(const QPen &pen) { - setLayer("legend"); - setMargins(QMargins(8, 2, 8, 2)); + mSelectedPen = pen; } /*! - Sets the default font of this specific legend item to \a font. + Sets the brush that will be used do fill the background of the text. To disable the + background, set \a brush to Qt::NoBrush. - \see setTextColor, QCPLegend::setFont + \see setSelectedBrush, setPen, setPadding */ -void QCPAbstractLegendItem::setFont(const QFont &font) +void QCPItemText::setBrush(const QBrush &brush) { - mFont = font; + mBrush = brush; } /*! - Sets the default text color of this specific legend item to \a color. + Sets the brush that will be used do fill the background of the text, when the item is selected. To disable the + background, set \a brush to Qt::NoBrush. - \see setFont, QCPLegend::setTextColor + \see setBrush */ -void QCPAbstractLegendItem::setTextColor(const QColor &color) +void QCPItemText::setSelectedBrush(const QBrush &brush) { - mTextColor = color; + mSelectedBrush = brush; } /*! - When this legend item is selected, \a font is used to draw generic text, instead of the normal - font set with \ref setFont. + Sets the font of the text. - \see setFont, QCPLegend::setSelectedFont + \see setSelectedFont, setColor */ -void QCPAbstractLegendItem::setSelectedFont(const QFont &font) +void QCPItemText::setFont(const QFont &font) { - mSelectedFont = font; + mFont = font; } /*! - When this legend item is selected, \a color is used to draw generic text, instead of the normal - color set with \ref setTextColor. + Sets the font of the text that will be used when the item is selected. - \see setTextColor, QCPLegend::setSelectedTextColor + \see setFont */ -void QCPAbstractLegendItem::setSelectedTextColor(const QColor &color) +void QCPItemText::setSelectedFont(const QFont &font) { - mSelectedTextColor = color; + mSelectedFont = font; } /*! - Sets whether this specific legend item is selectable. + Sets the text that will be displayed. Multi-line texts are supported by inserting a line break + character, e.g. '\n'. - \see setSelectedParts, QCustomPlot::setInteractions + \see setFont, setColor, setTextAlignment */ -void QCPAbstractLegendItem::setSelectable(bool selectable) +void QCPItemText::setText(const QString &text) { - mSelectable = selectable; + mText = text; } /*! - Sets whether this specific legend item is selected. + Sets which point of the text rect shall be aligned with \a position. - It is possible to set the selection state of this item by calling this function directly, even if - setSelectable is set to false. + Examples: + \li If \a alignment is Qt::AlignHCenter | Qt::AlignTop, the text will be positioned such + that the top of the text rect will be horizontally centered on \a position. + \li If \a alignment is Qt::AlignLeft | Qt::AlignBottom, \a position will indicate the + bottom left corner of the text rect. - \see setSelectableParts, QCustomPlot::setInteractions + If you want to control the alignment of (multi-lined) text within the text rect, use \ref + setTextAlignment. */ -void QCPAbstractLegendItem::setSelected(bool selected) +void QCPItemText::setPositionAlignment(Qt::Alignment alignment) { - if (mSelected != selected) - { - mSelected = selected; - emit selectionChanged(mSelected); - } + mPositionAlignment = alignment; +} + +/*! + Controls how (multi-lined) text is aligned inside the text rect (typically Qt::AlignLeft, Qt::AlignCenter or Qt::AlignRight). +*/ +void QCPItemText::setTextAlignment(Qt::Alignment alignment) +{ + mTextAlignment = alignment; +} + +/*! + Sets the angle in degrees by which the text (and the text rectangle, if visible) will be rotated + around \a position. +*/ +void QCPItemText::setRotation(double degrees) +{ + mRotation = degrees; +} + +/*! + Sets the distance between the border of the text rectangle and the text. The appearance (and + visibility) of the text rectangle can be controlled with \ref setPen and \ref setBrush. +*/ +void QCPItemText::setPadding(const QMargins &padding) +{ + mPadding = padding; } /* inherits documentation from base class */ -double QCPAbstractLegendItem::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +double QCPItemText::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { Q_UNUSED(details) - if (!mParentPlot) return -1; - if (onlySelectable && (!mSelectable || !mParentLegend->selectableParts().testFlag(QCPLegend::spItems))) + if (onlySelectable && !mSelectable) return -1; - if (mRect.contains(pos.toPoint())) - return mParentPlot->selectionTolerance()*0.99; - else - return -1; -} - -/* inherits documentation from base class */ -void QCPAbstractLegendItem::applyDefaultAntialiasingHint(QCPPainter *painter) const -{ - applyAntialiasingHint(painter, mAntialiased, QCP::aeLegendItems); -} + // The rect may be rotated, so we transform the actual clicked pos to the rotated + // coordinate system, so we can use the normal rectSelectTest function for non-rotated rects: + QPointF positionPixels(position->pixelPoint()); + QTransform inputTransform; + inputTransform.translate(positionPixels.x(), positionPixels.y()); + inputTransform.rotate(-mRotation); + inputTransform.translate(-positionPixels.x(), -positionPixels.y()); + QPointF rotatedPos = inputTransform.map(pos); + QFontMetrics fontMetrics(mFont); + QRect textRect = fontMetrics.boundingRect(0, 0, 0, 0, Qt::TextDontClip|mTextAlignment, mText); + QRect textBoxRect = textRect.adjusted(-mPadding.left(), -mPadding.top(), mPadding.right(), mPadding.bottom()); + QPointF textPos = getTextDrawPoint(positionPixels, textBoxRect, mPositionAlignment); + textBoxRect.moveTopLeft(textPos.toPoint()); -/* inherits documentation from base class */ -QRect QCPAbstractLegendItem::clipRect() const -{ - return mOuterRect; + return rectSelectTest(textBoxRect, rotatedPos, true); } /* inherits documentation from base class */ -void QCPAbstractLegendItem::selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) +void QCPItemText::draw(QCPPainter *painter) { - Q_UNUSED(event) - Q_UNUSED(details) - if (mSelectable && mParentLegend->selectableParts().testFlag(QCPLegend::spItems)) + QPointF pos(position->pixelPoint()); + QTransform transform = painter->transform(); + transform.translate(pos.x(), pos.y()); + if (!qFuzzyIsNull(mRotation)) + transform.rotate(mRotation); + painter->setFont(mainFont()); + QRect textRect = painter->fontMetrics().boundingRect(0, 0, 0, 0, Qt::TextDontClip|mTextAlignment, mText); + QRect textBoxRect = textRect.adjusted(-mPadding.left(), -mPadding.top(), mPadding.right(), mPadding.bottom()); + QPointF textPos = getTextDrawPoint(QPointF(0, 0), textBoxRect, mPositionAlignment); // 0, 0 because the transform does the translation + textRect.moveTopLeft(textPos.toPoint()+QPoint(mPadding.left(), mPadding.top())); + textBoxRect.moveTopLeft(textPos.toPoint()); + double clipPad = mainPen().widthF(); + QRect boundingRect = textBoxRect.adjusted(-clipPad, -clipPad, clipPad, clipPad); + if (transform.mapRect(boundingRect).intersects(painter->transform().mapRect(clipRect()))) { - bool selBefore = mSelected; - setSelected(additive ? !mSelected : true); - if (selectionStateChanged) - *selectionStateChanged = mSelected != selBefore; + painter->setTransform(transform); + if ((mainBrush().style() != Qt::NoBrush && mainBrush().color().alpha() != 0) || + (mainPen().style() != Qt::NoPen && mainPen().color().alpha() != 0)) + { + painter->setPen(mainPen()); + painter->setBrush(mainBrush()); + painter->drawRect(textBoxRect); + } + painter->setBrush(Qt::NoBrush); + painter->setPen(QPen(mainColor())); + painter->drawText(textRect, Qt::TextDontClip|mTextAlignment, mText); } } /* inherits documentation from base class */ -void QCPAbstractLegendItem::deselectEvent(bool *selectionStateChanged) +QPointF QCPItemText::anchorPixelPoint(int anchorId) const { - if (mSelectable && mParentLegend->selectableParts().testFlag(QCPLegend::spItems)) + // get actual rect points (pretty much copied from draw function): + QPointF pos(position->pixelPoint()); + QTransform transform; + transform.translate(pos.x(), pos.y()); + if (!qFuzzyIsNull(mRotation)) + transform.rotate(mRotation); + QFontMetrics fontMetrics(mainFont()); + QRect textRect = fontMetrics.boundingRect(0, 0, 0, 0, Qt::TextDontClip|mTextAlignment, mText); + QRectF textBoxRect = textRect.adjusted(-mPadding.left(), -mPadding.top(), mPadding.right(), mPadding.bottom()); + QPointF textPos = getTextDrawPoint(QPointF(0, 0), textBoxRect, mPositionAlignment); // 0, 0 because the transform does the translation + textBoxRect.moveTopLeft(textPos.toPoint()); + QPolygonF rectPoly = transform.map(QPolygonF(textBoxRect)); + + switch (anchorId) { - bool selBefore = mSelected; - setSelected(false); - if (selectionStateChanged) - *selectionStateChanged = mSelected != selBefore; + case aiTopLeft: return rectPoly.at(0); + case aiTop: return (rectPoly.at(0)+rectPoly.at(1))*0.5; + case aiTopRight: return rectPoly.at(1); + case aiRight: return (rectPoly.at(1)+rectPoly.at(2))*0.5; + case aiBottomRight: return rectPoly.at(2); + case aiBottom: return (rectPoly.at(2)+rectPoly.at(3))*0.5; + case aiBottomLeft: return rectPoly.at(3); + case aiLeft: return (rectPoly.at(3)+rectPoly.at(0))*0.5; } -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////// QCPPlottableLegendItem -//////////////////////////////////////////////////////////////////////////////////////////////////// - -/*! \class QCPPlottableLegendItem - \brief A legend item representing a plottable with an icon and the plottable name. - - This is the standard legend item for plottables. It displays an icon of the plottable next to the - plottable name. The icon is drawn by the respective plottable itself (\ref - QCPAbstractPlottable::drawLegendIcon), and tries to give an intuitive symbol for the plottable. - For example, the QCPGraph draws a centered horizontal line and/or a single scatter point in the - middle. - - Legend items of this type are always associated with one plottable (retrievable via the - plottable() function and settable with the constructor). You may change the font of the plottable - name with \ref setFont. Icon padding and border pen is taken from the parent QCPLegend, see \ref - QCPLegend::setIconBorderPen and \ref QCPLegend::setIconTextPadding. - - The function \ref QCPAbstractPlottable::addToLegend/\ref QCPAbstractPlottable::removeFromLegend - creates/removes legend items of this type in the default implementation. However, these functions - may be reimplemented such that a different kind of legend item (e.g a direct subclass of - QCPAbstractLegendItem) is used for that plottable. - - Since QCPLegend is based on QCPLayoutGrid, a legend item itself is just a subclass of - QCPLayoutElement. While it could be added to a legend (or any other layout) via the normal layout - interface, QCPLegend has specialized functions for handling legend items conveniently, see the - documentation of \ref QCPLegend. -*/ - -/*! - Creates a new legend item associated with \a plottable. - - Once it's created, it can be added to the legend via \ref QCPLegend::addItem. - A more convenient way of adding/removing a plottable to/from the legend is via the functions \ref - QCPAbstractPlottable::addToLegend and \ref QCPAbstractPlottable::removeFromLegend. -*/ -QCPPlottableLegendItem::QCPPlottableLegendItem(QCPLegend *parent, QCPAbstractPlottable *plottable) : - QCPAbstractLegendItem(parent), - mPlottable(plottable) -{ + qDebug() << Q_FUNC_INFO << "invalid anchorId" << anchorId; + return QPointF(); } /*! \internal - Returns the pen that shall be used to draw the icon border, taking into account the selection - state of this item. + Returns the point that must be given to the QPainter::drawText function (which expects the top + left point of the text rect), according to the position \a pos, the text bounding box \a rect and + the requested \a positionAlignment. + + For example, if \a positionAlignment is Qt::AlignLeft | Qt::AlignBottom the returned point + will be shifted upward by the height of \a rect, starting from \a pos. So if the text is finally + drawn at that point, the lower left corner of the resulting text rect is at \a pos. */ -QPen QCPPlottableLegendItem::getIconBorderPen() const +QPointF QCPItemText::getTextDrawPoint(const QPointF &pos, const QRectF &rect, Qt::Alignment positionAlignment) const { - return mSelected ? mParentLegend->selectedIconBorderPen() : mParentLegend->iconBorderPen(); + if (positionAlignment == 0 || positionAlignment == (Qt::AlignLeft|Qt::AlignTop)) + return pos; + + QPointF result = pos; // start at top left + if (positionAlignment.testFlag(Qt::AlignHCenter)) + result.rx() -= rect.width()/2.0; + else if (positionAlignment.testFlag(Qt::AlignRight)) + result.rx() -= rect.width(); + if (positionAlignment.testFlag(Qt::AlignVCenter)) + result.ry() -= rect.height()/2.0; + else if (positionAlignment.testFlag(Qt::AlignBottom)) + result.ry() -= rect.height(); + return result; } /*! \internal - - Returns the text color that shall be used to draw text, taking into account the selection state - of this item. + + Returns the font that should be used for drawing text. Returns mFont when the item is not selected + and mSelectedFont when it is. */ -QColor QCPPlottableLegendItem::getTextColor() const +QFont QCPItemText::mainFont() const { - return mSelected ? mSelectedTextColor : mTextColor; + return mSelected ? mSelectedFont : mFont; } /*! \internal - - Returns the font that shall be used to draw text, taking into account the selection state of this - item. + + Returns the color that should be used for drawing text. Returns mColor when the item is not + selected and mSelectedColor when it is. */ -QFont QCPPlottableLegendItem::getFont() const +QColor QCPItemText::mainColor() const { - return mSelected ? mSelectedFont : mFont; + return mSelected ? mSelectedColor : mColor; } /*! \internal - - Draws the item with \a painter. The size and position of the drawn legend item is defined by the - parent layout (typically a \ref QCPLegend) and the \ref minimumSizeHint and \ref maximumSizeHint - of this legend item. + + Returns the pen that should be used for drawing lines. Returns mPen when the item is not selected + and mSelectedPen when it is. */ -void QCPPlottableLegendItem::draw(QCPPainter *painter) +QPen QCPItemText::mainPen() const { - if (!mPlottable) return; - painter->setFont(getFont()); - painter->setPen(QPen(getTextColor())); - QSizeF iconSize = mParentLegend->iconSize(); - QRectF textRect = painter->fontMetrics().boundingRect(0, 0, 0, iconSize.height(), Qt::TextDontClip, mPlottable->name()); - QRectF iconRect(mRect.topLeft(), iconSize); - int textHeight = qMax(textRect.height(), iconSize.height()); // if text has smaller height than icon, center text vertically in icon height, else align tops - painter->drawText(mRect.x()+iconSize.width()+mParentLegend->iconTextPadding(), mRect.y(), textRect.width(), textHeight, Qt::TextDontClip, mPlottable->name()); - // draw icon: - painter->save(); - painter->setClipRect(iconRect, Qt::IntersectClip); - mPlottable->drawLegendIcon(painter, iconRect); - painter->restore(); - // draw icon border: - if (getIconBorderPen().style() != Qt::NoPen) - { - painter->setPen(getIconBorderPen()); - painter->setBrush(Qt::NoBrush); - painter->drawRect(iconRect); - } + return mSelected ? mSelectedPen : mPen; } /*! \internal - - Calculates and returns the size of this item. This includes the icon, the text and the padding in - between. + + Returns the brush that should be used for drawing fills of the item. Returns mBrush when the item + is not selected and mSelectedBrush when it is. */ -QSize QCPPlottableLegendItem::minimumSizeHint() const +QBrush QCPItemText::mainBrush() const { - if (!mPlottable) return QSize(); - QSize result(0, 0); - QRect textRect; - QFontMetrics fontMetrics(getFont()); - QSize iconSize = mParentLegend->iconSize(); - textRect = fontMetrics.boundingRect(0, 0, 0, iconSize.height(), Qt::TextDontClip, mPlottable->name()); - result.setWidth(iconSize.width() + mParentLegend->iconTextPadding() + textRect.width() + mMargins.left() + mMargins.right()); - result.setHeight(qMax(textRect.height(), iconSize.height()) + mMargins.top() + mMargins.bottom()); - return result; + return mSelected ? mSelectedBrush : mBrush; } -//////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////// QCPLegend -//////////////////////////////////////////////////////////////////////////////////////////////////// - -/*! \class QCPLegend - \brief Manages a legend inside a QCustomPlot. - - A legend is a small box somewhere in the plot which lists plottables with their name and icon. - - Normally, the legend is populated by calling \ref QCPAbstractPlottable::addToLegend. The - respective legend item can be removed with \ref QCPAbstractPlottable::removeFromLegend. However, - QCPLegend also offers an interface to add and manipulate legend items directly: \ref item, \ref - itemWithPlottable, \ref itemCount, \ref addItem, \ref removeItem, etc. - - The QCPLegend derives from QCPLayoutGrid and as such can be placed in any position a - QCPLayoutElement may be positioned. The legend items are themselves QCPLayoutElements which are - placed in the grid layout of the legend. QCPLegend only adds an interface specialized for - handling child elements of type QCPAbstractLegendItem, as mentioned above. In principle, any - other layout elements may also be added to a legend via the normal \ref QCPLayoutGrid interface. - However, the QCPAbstractLegendItem-Interface will ignore those elements (e.g. \ref itemCount will - only return the number of items with QCPAbstractLegendItems type). - - By default, every QCustomPlot has one legend (QCustomPlot::legend) which is placed in the inset - layout of the main axis rect (\ref QCPAxisRect::insetLayout). To move the legend to another - position inside the axis rect, use the methods of the \ref QCPLayoutInset. To move the legend - outside of the axis rect, place it anywhere else with the QCPLayout/QCPLayoutElement interface. -*/ +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPItemEllipse +//////////////////////////////////////////////////////////////////////////////////////////////////// -/* start of documentation of signals */ +/*! \class QCPItemEllipse + \brief An ellipse -/*! \fn void QCPLegend::selectionChanged(QCPLegend::SelectableParts selection); + \image html QCPItemEllipse.png "Ellipse example. Blue dotted circles are anchors, solid blue discs are positions." - This signal is emitted when the selection state of this legend has changed. - - \see setSelectedParts, setSelectableParts + It has two positions, \a topLeft and \a bottomRight, which define the rect the ellipse will be drawn in. */ -/* end of documentation of signals */ - /*! - Constructs a new QCPLegend instance with \a parentPlot as the containing plot and default values. + Creates an ellipse item and sets default values. - Note that by default, QCustomPlot already contains a legend ready to be used as - QCustomPlot::legend + The constructed item can be added to the plot with QCustomPlot::addItem. */ -QCPLegend::QCPLegend() +QCPItemEllipse::QCPItemEllipse(QCustomPlot *parentPlot) : + QCPAbstractItem(parentPlot), + topLeft(createPosition("topLeft")), + bottomRight(createPosition("bottomRight")), + topLeftRim(createAnchor("topLeftRim", aiTopLeftRim)), + top(createAnchor("top", aiTop)), + topRightRim(createAnchor("topRightRim", aiTopRightRim)), + right(createAnchor("right", aiRight)), + bottomRightRim(createAnchor("bottomRightRim", aiBottomRightRim)), + bottom(createAnchor("bottom", aiBottom)), + bottomLeftRim(createAnchor("bottomLeftRim", aiBottomLeftRim)), + left(createAnchor("left", aiLeft)), + center(createAnchor("center", aiCenter)) { - setRowSpacing(0); - setColumnSpacing(10); - setMargins(QMargins(2, 3, 2, 2)); - setAntialiased(false); - setIconSize(32, 18); - - setIconTextPadding(7); - - setSelectableParts(spLegendBox | spItems); - setSelectedParts(spNone); + topLeft->setCoords(0, 1); + bottomRight->setCoords(1, 0); - setBorderPen(QPen(Qt::black)); - setSelectedBorderPen(QPen(Qt::blue, 2)); - setIconBorderPen(Qt::NoPen); - setSelectedIconBorderPen(QPen(Qt::blue, 2)); - setBrush(Qt::white); - setSelectedBrush(Qt::white); - setTextColor(Qt::black); - setSelectedTextColor(Qt::blue); + setPen(QPen(Qt::black)); + setSelectedPen(QPen(Qt::blue, 2)); + setBrush(Qt::NoBrush); + setSelectedBrush(Qt::NoBrush); } -QCPLegend::~QCPLegend() +QCPItemEllipse::~QCPItemEllipse() { - clearItems(); - if (mParentPlot) - mParentPlot->legendRemoved(this); } -/* no doc for getter, see setSelectedParts */ -QCPLegend::SelectableParts QCPLegend::selectedParts() const +/*! + Sets the pen that will be used to draw the line of the ellipse + + \see setSelectedPen, setBrush +*/ +void QCPItemEllipse::setPen(const QPen &pen) { - // check whether any legend elements selected, if yes, add spItems to return value - bool hasSelectedItems = false; - for (int i=0; iselected()) - { - hasSelectedItems = true; - break; - } - } - if (hasSelectedItems) - return mSelectedParts | spItems; - else - return mSelectedParts & ~spItems; + mPen = pen; } /*! - Sets the pen, the border of the entire legend is drawn with. + Sets the pen that will be used to draw the line of the ellipse when selected + + \see setPen, setSelected */ -void QCPLegend::setBorderPen(const QPen &pen) +void QCPItemEllipse::setSelectedPen(const QPen &pen) { - mBorderPen = pen; + mSelectedPen = pen; } /*! - Sets the brush of the legend background. + Sets the brush that will be used to fill the ellipse. To disable filling, set \a brush to + Qt::NoBrush. + + \see setSelectedBrush, setPen */ -void QCPLegend::setBrush(const QBrush &brush) +void QCPItemEllipse::setBrush(const QBrush &brush) { mBrush = brush; } /*! - Sets the default font of legend text. Legend items that draw text (e.g. the name of a graph) will - use this font by default. However, a different font can be specified on a per-item-basis by - accessing the specific legend item. - - This function will also set \a font on all already existing legend items. + Sets the brush that will be used to fill the ellipse when selected. To disable filling, set \a + brush to Qt::NoBrush. - \see QCPAbstractLegendItem::setFont + \see setBrush */ -void QCPLegend::setFont(const QFont &font) +void QCPItemEllipse::setSelectedBrush(const QBrush &brush) { - mFont = font; - for (int i=0; isetFont(mFont); - } + mSelectedBrush = brush; } -/*! - Sets the default color of legend text. Legend items that draw text (e.g. the name of a graph) - will use this color by default. However, a different colors can be specified on a per-item-basis - by accessing the specific legend item. +/* inherits documentation from base class */ +double QCPItemEllipse::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + Q_UNUSED(details) + if (onlySelectable && !mSelectable) + return -1; - This function will also set \a color on all already existing legend items. + double result = -1; + QPointF p1 = topLeft->pixelPoint(); + QPointF p2 = bottomRight->pixelPoint(); + QPointF center((p1+p2)/2.0); + double a = qAbs(p1.x()-p2.x())/2.0; + double b = qAbs(p1.y()-p2.y())/2.0; + double x = pos.x()-center.x(); + double y = pos.y()-center.y(); - \see QCPAbstractLegendItem::setTextColor -*/ -void QCPLegend::setTextColor(const QColor &color) -{ - mTextColor = color; - for (int i=0; i mParentPlot->selectionTolerance()*0.99 && mBrush.style() != Qt::NoBrush && mBrush.color().alpha() != 0) { - if (item(i)) - item(i)->setTextColor(color); + if (x*x/(a*a) + y*y/(b*b) <= 1) + result = mParentPlot->selectionTolerance()*0.99; } + return result; } -/*! - Sets the size of legend icons. Legend items that draw an icon (e.g. a visual - representation of the graph) will use this size by default. -*/ -void QCPLegend::setIconSize(const QSize &size) +/* inherits documentation from base class */ +void QCPItemEllipse::draw(QCPPainter *painter) { - mIconSize = size; + QPointF p1 = topLeft->pixelPoint(); + QPointF p2 = bottomRight->pixelPoint(); + if (p1.toPoint() == p2.toPoint()) + return; + QRectF ellipseRect = QRectF(p1, p2).normalized(); + QRect clip = clipRect().adjusted(-mainPen().widthF(), -mainPen().widthF(), mainPen().widthF(), mainPen().widthF()); + if (ellipseRect.intersects(clip)) // only draw if bounding rect of ellipse is visible in cliprect + { + painter->setPen(mainPen()); + painter->setBrush(mainBrush()); +#ifdef __EXCEPTIONS + try // drawEllipse sometimes throws exceptions if ellipse is too big + { +#endif + painter->drawEllipse(ellipseRect); +#ifdef __EXCEPTIONS + } catch (...) + { + qDebug() << Q_FUNC_INFO << "Item too large for memory, setting invisible"; + setVisible(false); + } +#endif + } } -/*! \overload -*/ -void QCPLegend::setIconSize(int width, int height) +/* inherits documentation from base class */ +QPointF QCPItemEllipse::anchorPixelPoint(int anchorId) const { - mIconSize.setWidth(width); - mIconSize.setHeight(height); + QRectF rect = QRectF(topLeft->pixelPoint(), bottomRight->pixelPoint()); + switch (anchorId) + { + case aiTopLeftRim: return rect.center()+(rect.topLeft()-rect.center())*1/qSqrt(2); + case aiTop: return (rect.topLeft()+rect.topRight())*0.5; + case aiTopRightRim: return rect.center()+(rect.topRight()-rect.center())*1/qSqrt(2); + case aiRight: return (rect.topRight()+rect.bottomRight())*0.5; + case aiBottomRightRim: return rect.center()+(rect.bottomRight()-rect.center())*1/qSqrt(2); + case aiBottom: return (rect.bottomLeft()+rect.bottomRight())*0.5; + case aiBottomLeftRim: return rect.center()+(rect.bottomLeft()-rect.center())*1/qSqrt(2); + case aiLeft: return (rect.topLeft()+rect.bottomLeft())*0.5; + case aiCenter: return (rect.topLeft()+rect.bottomRight())*0.5; + } + + qDebug() << Q_FUNC_INFO << "invalid anchorId" << anchorId; + return QPointF(); } -/*! - Sets the horizontal space in pixels between the legend icon and the text next to it. - Legend items that draw an icon (e.g. a visual representation of the graph) and text (e.g. the - name of the graph) will use this space by default. +/*! \internal + + Returns the pen that should be used for drawing lines. Returns mPen when the item is not selected + and mSelectedPen when it is. */ -void QCPLegend::setIconTextPadding(int padding) +QPen QCPItemEllipse::mainPen() const { - mIconTextPadding = padding; + return mSelected ? mSelectedPen : mPen; } -/*! - Sets the pen used to draw a border around each legend icon. Legend items that draw an - icon (e.g. a visual representation of the graph) will use this pen by default. - - If no border is wanted, set this to \a Qt::NoPen. +/*! \internal + + Returns the brush that should be used for drawing fills of the item. Returns mBrush when the item + is not selected and mSelectedBrush when it is. */ -void QCPLegend::setIconBorderPen(const QPen &pen) +QBrush QCPItemEllipse::mainBrush() const { - mIconBorderPen = pen; + return mSelected ? mSelectedBrush : mBrush; } -/*! - Sets whether the user can (de-)select the parts in \a selectable by clicking on the QCustomPlot surface. - (When \ref QCustomPlot::setInteractions contains iSelectLegend.) - - However, even when \a selectable is set to a value not allowing the selection of a specific part, - it is still possible to set the selection of this part manually, by calling \ref setSelectedParts - directly. + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPItemPixmap +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPItemPixmap + \brief An arbitrary pixmap + + \image html QCPItemPixmap.png "Pixmap example. Blue dotted circles are anchors, solid blue discs are positions." + + It has two positions, \a topLeft and \a bottomRight, which define the rectangle the pixmap will + be drawn in. Depending on the scale setting (\ref setScaled), the pixmap will be either scaled to + fit the rectangle or be drawn aligned to the topLeft position. - \see SelectablePart, setSelectedParts + If scaling is enabled and \a topLeft is further to the bottom/right than \a bottomRight (as shown + on the right side of the example image), the pixmap will be flipped in the respective + orientations. */ -void QCPLegend::setSelectableParts(const SelectableParts &selectable) -{ - mSelectableParts = selectable; -} /*! - Sets the selected state of the respective legend parts described by \ref SelectablePart. When a part - is selected, it uses a different pen/font and brush. If some legend items are selected and \a selected - doesn't contain \ref spItems, those items become deselected. - - The entire selection mechanism is handled automatically when \ref QCustomPlot::setInteractions - contains iSelectLegend. You only need to call this function when you wish to change the selection - state manually. - - This function can change the selection state of a part even when \ref setSelectableParts was set to a - value that actually excludes the part. - - emits the \ref selectionChanged signal when \a selected is different from the previous selection state. - - Note that it doesn't make sense to set the selected state \ref spItems here when it wasn't set - before, because there's no way to specify which exact items to newly select. Do this by calling - \ref QCPAbstractLegendItem::setSelected directly on the legend item you wish to select. + Creates a rectangle item and sets default values. - \see SelectablePart, setSelectableParts, selectTest, setSelectedBorderPen, setSelectedIconBorderPen, setSelectedBrush, - setSelectedFont + The constructed item can be added to the plot with QCustomPlot::addItem. */ -void QCPLegend::setSelectedParts(const SelectableParts &selected) +QCPItemPixmap::QCPItemPixmap(QCustomPlot *parentPlot) : + QCPAbstractItem(parentPlot), + topLeft(createPosition("topLeft")), + bottomRight(createPosition("bottomRight")), + top(createAnchor("top", aiTop)), + topRight(createAnchor("topRight", aiTopRight)), + right(createAnchor("right", aiRight)), + bottom(createAnchor("bottom", aiBottom)), + bottomLeft(createAnchor("bottomLeft", aiBottomLeft)), + left(createAnchor("left", aiLeft)) { - SelectableParts newSelected = selected; - mSelectedParts = this->selectedParts(); // update mSelectedParts in case item selection changed + topLeft->setCoords(0, 1); + bottomRight->setCoords(1, 0); + + setPen(Qt::NoPen); + setSelectedPen(QPen(Qt::blue)); + setScaled(false, Qt::KeepAspectRatio); +} - if (mSelectedParts != newSelected) - { - if (!mSelectedParts.testFlag(spItems) && newSelected.testFlag(spItems)) // attempt to set spItems flag (can't do that) - { - qDebug() << Q_FUNC_INFO << "spItems flag can not be set, it can only be unset with this function"; - newSelected &= ~spItems; - } - if (mSelectedParts.testFlag(spItems) && !newSelected.testFlag(spItems)) // spItems flag was unset, so clear item selection - { - for (int i=0; isetSelected(false); - } - } - mSelectedParts = newSelected; - emit selectionChanged(mSelectedParts); - } +QCPItemPixmap::~QCPItemPixmap() +{ } /*! - When the legend box is selected, this pen is used to draw the border instead of the normal pen - set via \ref setBorderPen. - - \see setSelectedParts, setSelectableParts, setSelectedBrush + Sets the pixmap that will be displayed. */ -void QCPLegend::setSelectedBorderPen(const QPen &pen) +void QCPItemPixmap::setPixmap(const QPixmap &pixmap) { - mSelectedBorderPen = pen; + mPixmap = pixmap; + if (mPixmap.isNull()) + qDebug() << Q_FUNC_INFO << "pixmap is null"; } /*! - Sets the pen legend items will use to draw their icon borders, when they are selected. - - \see setSelectedParts, setSelectableParts, setSelectedFont + Sets whether the pixmap will be scaled to fit the rectangle defined by the \a topLeft and \a + bottomRight positions. */ -void QCPLegend::setSelectedIconBorderPen(const QPen &pen) +void QCPItemPixmap::setScaled(bool scaled, Qt::AspectRatioMode aspectRatioMode) { - mSelectedIconBorderPen = pen; + mScaled = scaled; + mAspectRatioMode = aspectRatioMode; + updateScaledPixmap(); } /*! - When the legend box is selected, this brush is used to draw the legend background instead of the normal brush - set via \ref setBrush. - - \see setSelectedParts, setSelectableParts, setSelectedBorderPen + Sets the pen that will be used to draw a border around the pixmap. + + \see setSelectedPen, setBrush */ -void QCPLegend::setSelectedBrush(const QBrush &brush) +void QCPItemPixmap::setPen(const QPen &pen) { - mSelectedBrush = brush; + mPen = pen; } /*! - Sets the default font that is used by legend items when they are selected. + Sets the pen that will be used to draw a border around the pixmap when selected - This function will also set \a font on all already existing legend items. - - \see setFont, QCPAbstractLegendItem::setSelectedFont + \see setPen, setSelected */ -void QCPLegend::setSelectedFont(const QFont &font) +void QCPItemPixmap::setSelectedPen(const QPen &pen) { - mSelectedFont = font; - for (int i=0; isetSelectedFont(font); - } + mSelectedPen = pen; } -/*! - Sets the default text color that is used by legend items when they are selected. +/* inherits documentation from base class */ +double QCPItemPixmap::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + Q_UNUSED(details) + if (onlySelectable && !mSelectable) + return -1; - This function will also set \a color on all already existing legend items. + return rectSelectTest(getFinalRect(), pos, true); +} - \see setTextColor, QCPAbstractLegendItem::setSelectedTextColor -*/ -void QCPLegend::setSelectedTextColor(const QColor &color) +/* inherits documentation from base class */ +void QCPItemPixmap::draw(QCPPainter *painter) { - mSelectedTextColor = color; - for (int i=0; isetSelectedTextColor(color); + updateScaledPixmap(rect, flipHorz, flipVert); + painter->drawPixmap(rect.topLeft(), mScaled ? mScaledPixmap : mPixmap); + QPen pen = mainPen(); + if (pen.style() != Qt::NoPen) + { + painter->setPen(pen); + painter->setBrush(Qt::NoBrush); + painter->drawRect(rect); + } } } -/*! - Returns the item with index \a i. - - \see itemCount -*/ -QCPAbstractLegendItem *QCPLegend::item(int index) const +/* inherits documentation from base class */ +QPointF QCPItemPixmap::anchorPixelPoint(int anchorId) const { - return qobject_cast(elementAt(index)); + bool flipHorz; + bool flipVert; + QRect rect = getFinalRect(&flipHorz, &flipVert); + // we actually want denormal rects (negative width/height) here, so restore + // the flipped state: + if (flipHorz) + rect.adjust(rect.width(), 0, -rect.width(), 0); + if (flipVert) + rect.adjust(0, rect.height(), 0, -rect.height()); + + switch (anchorId) + { + case aiTop: return (rect.topLeft()+rect.topRight())*0.5; + case aiTopRight: return rect.topRight(); + case aiRight: return (rect.topRight()+rect.bottomRight())*0.5; + case aiBottom: return (rect.bottomLeft()+rect.bottomRight())*0.5; + case aiBottomLeft: return rect.bottomLeft(); + case aiLeft: return (rect.topLeft()+rect.bottomLeft())*0.5;; + } + + qDebug() << Q_FUNC_INFO << "invalid anchorId" << anchorId; + return QPointF(); } -/*! - Returns the QCPPlottableLegendItem which is associated with \a plottable (e.g. a \ref QCPGraph*). - If such an item isn't in the legend, returns 0. +/*! \internal - \see hasItemWithPlottable + Creates the buffered scaled image (\a mScaledPixmap) to fit the specified \a finalRect. The + parameters \a flipHorz and \a flipVert control whether the resulting image shall be flipped + horizontally or vertically. (This is used when \a topLeft is further to the bottom/right than \a + bottomRight.) + + This function only creates the scaled pixmap when the buffered pixmap has a different size than + the expected result, so calling this function repeatedly, e.g. in the \ref draw function, does + not cause expensive rescaling every time. + + If scaling is disabled, sets mScaledPixmap to a null QPixmap. */ -QCPPlottableLegendItem *QCPLegend::itemWithPlottable(const QCPAbstractPlottable *plottable) const +void QCPItemPixmap::updateScaledPixmap(QRect finalRect, bool flipHorz, bool flipVert) { - for (int i=0; i(item(i))) + if (finalRect.isNull()) + finalRect = getFinalRect(&flipHorz, &flipVert); + if (finalRect.size() != mScaledPixmap.size()) { - if (pli->plottable() == plottable) - return pli; + mScaledPixmap = mPixmap.scaled(finalRect.size(), mAspectRatioMode, Qt::SmoothTransformation); + if (flipHorz || flipVert) + mScaledPixmap = QPixmap::fromImage(mScaledPixmap.toImage().mirrored(flipHorz, flipVert)); } - } - return 0; -} - -/*! - Returns the number of items currently in the legend. - \see item -*/ -int QCPLegend::itemCount() const -{ - return elementCount(); + } else if (!mScaledPixmap.isNull()) + mScaledPixmap = QPixmap(); } -/*! - Returns whether the legend contains \a itm. +/*! \internal + + Returns the final (tight) rect the pixmap is drawn in, depending on the current item positions + and scaling settings. + + The output parameters \a flippedHorz and \a flippedVert return whether the pixmap should be drawn + flipped horizontally or vertically in the returned rect. (The returned rect itself is always + normalized, i.e. the top left corner of the rect is actually further to the top/left than the + bottom right corner). This is the case when the item position \a topLeft is further to the + bottom/right than \a bottomRight. + + If scaling is disabled, returns a rect with size of the original pixmap and the top left corner + aligned with the item position \a topLeft. The position \a bottomRight is ignored. */ -bool QCPLegend::hasItem(QCPAbstractLegendItem *item) const +QRect QCPItemPixmap::getFinalRect(bool *flippedHorz, bool *flippedVert) const { - for (int i=0; ipixelPoint().toPoint(); + QPoint p2 = bottomRight->pixelPoint().toPoint(); + if (p1 == p2) + return QRect(p1, QSize(0, 0)); + if (mScaled) + { + QSize newSize = QSize(p2.x()-p1.x(), p2.y()-p1.y()); + QPoint topLeft = p1; + if (newSize.width() < 0) + { + flipHorz = true; + newSize.rwidth() *= -1; + topLeft.setX(p2.x()); + } + if (newSize.height() < 0) + { + flipVert = true; + newSize.rheight() *= -1; + topLeft.setY(p2.y()); + } + QSize scaledSize = mPixmap.size(); + scaledSize.scale(newSize, mAspectRatioMode); + result = QRect(topLeft, scaledSize); + } else { - if (item == this->item(i)) - return true; + result = QRect(p1, mPixmap.size()); } - return false; + if (flippedHorz) + *flippedHorz = flipHorz; + if (flippedVert) + *flippedVert = flipVert; + return result; } -/*! - Returns whether the legend contains a QCPPlottableLegendItem which is associated with \a plottable (e.g. a \ref QCPGraph*). - If such an item isn't in the legend, returns false. - - \see itemWithPlottable +/*! \internal + + Returns the pen that should be used for drawing lines. Returns mPen when the item is not selected + and mSelectedPen when it is. */ -bool QCPLegend::hasItemWithPlottable(const QCPAbstractPlottable *plottable) const +QPen QCPItemPixmap::mainPen() const { - return itemWithPlottable(plottable); + return mSelected ? mSelectedPen : mPen; } -/*! - Adds \a item to the legend, if it's not present already. + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPItemTracer +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPItemTracer + \brief Item that sticks to QCPGraph data points + + \image html QCPItemTracer.png "Tracer example. Blue dotted circles are anchors, solid blue discs are positions." + + The tracer can be connected with a QCPGraph via \ref setGraph. Then it will automatically adopt + the coordinate axes of the graph and update its \a position to be on the graph's data. This means + the key stays controllable via \ref setGraphKey, but the value will follow the graph data. If a + QCPGraph is connected, note that setting the coordinates of the tracer item directly via \a + position will have no effect because they will be overriden in the next redraw (this is when the + coordinate update happens). - Returns true on sucess, i.e. if the item wasn't in the list already and has been successfuly added. + If the specified key in \ref setGraphKey is outside the key bounds of the graph, the tracer will + stay at the corresponding end of the graph. - The legend takes ownership of the item. + With \ref setInterpolating you may specify whether the tracer may only stay exactly on data + points or whether it interpolates data points linearly, if given a key that lies between two data + points of the graph. + + The tracer has different visual styles, see \ref setStyle. It is also possible to make the tracer + have no own visual appearance (set the style to \ref tsNone), and just connect other item + positions to the tracer \a position (used as an anchor) via \ref + QCPItemPosition::setParentAnchor. + + \note The tracer position is only automatically updated upon redraws. So when the data of the + graph changes and immediately afterwards (without a redraw) the a position coordinates of the + tracer are retrieved, they will not reflect the updated data of the graph. In this case \ref + updatePosition must be called manually, prior to reading the tracer coordinates. */ -bool QCPLegend::addItem(QCPAbstractLegendItem *item) -{ - if (!hasItem(item)) - { - return addElement(rowCount(), 0, item); - } else - return false; -} /*! - Removes the item with index \a index from the legend. - - Returns true, if successful. + Creates a tracer item and sets default values. - \see itemCount, clearItems + The constructed item can be added to the plot with QCustomPlot::addItem. */ -bool QCPLegend::removeItem(int index) +QCPItemTracer::QCPItemTracer(QCustomPlot *parentPlot) : + QCPAbstractItem(parentPlot), + position(createPosition("position")), + mGraph(0) { - if (QCPAbstractLegendItem *ali = item(index)) - { - bool success = remove(ali); - simplify(); - return success; - } else - return false; -} + position->setCoords(0, 0); -/*! \overload - - Removes \a item from the legend. + setBrush(Qt::NoBrush); + setSelectedBrush(Qt::NoBrush); + setPen(QPen(Qt::black)); + setSelectedPen(QPen(Qt::blue, 2)); + setStyle(tsCrosshair); + setSize(6); + setInterpolating(false); + setGraphKey(0); +} - Returns true, if successful. - - \see clearItems -*/ -bool QCPLegend::removeItem(QCPAbstractLegendItem *item) +QCPItemTracer::~QCPItemTracer() { - bool success = remove(item); - simplify(); - return success; } /*! - Removes all items from the legend. + Sets the pen that will be used to draw the line of the tracer + + \see setSelectedPen, setBrush */ -void QCPLegend::clearItems() +void QCPItemTracer::setPen(const QPen &pen) { - for (int i=itemCount()-1; i>=0; --i) - removeItem(i); + mPen = pen; } /*! - Returns the legend items that are currently selected. If no items are selected, - the list is empty. + Sets the pen that will be used to draw the line of the tracer when selected - \see QCPAbstractLegendItem::setSelected, setSelectable + \see setPen, setSelected */ -QList QCPLegend::selectedItems() const +void QCPItemTracer::setSelectedPen(const QPen &pen) { - QList result; - for (int i=0; iselected()) - result.append(ali); - } - } - return result; + mSelectedPen = pen; } -/*! \internal - - A convenience function to easily set the QPainter::Antialiased hint on the provided \a painter - before drawing main legend elements. - - This is the antialiasing state the painter passed to the \ref draw method is in by default. - - This function takes into account the local setting of the antialiasing flag as well as the - overrides set with \ref QCustomPlot::setAntialiasedElements and \ref - QCustomPlot::setNotAntialiasedElements. +/*! + Sets the brush that will be used to draw any fills of the tracer - \see setAntialiased + \see setSelectedBrush, setPen */ -void QCPLegend::applyDefaultAntialiasingHint(QCPPainter *painter) const +void QCPItemTracer::setBrush(const QBrush &brush) { - applyAntialiasingHint(painter, mAntialiased, QCP::aeLegend); + mBrush = brush; } -/*! \internal +/*! + Sets the brush that will be used to draw any fills of the tracer, when selected. - Returns the pen used to paint the border of the legend, taking into account the selection state - of the legend box. + \see setBrush, setSelected */ -QPen QCPLegend::getBorderPen() const +void QCPItemTracer::setSelectedBrush(const QBrush &brush) { - return mSelectedParts.testFlag(spLegendBox) ? mSelectedBorderPen : mBorderPen; + mSelectedBrush = brush; } -/*! \internal - - Returns the brush used to paint the background of the legend, taking into account the selection - state of the legend box. +/*! + Sets the size of the tracer in pixels, if the style supports setting a size (e.g. \ref tsSquare + does, \ref tsCrosshair does not). */ -QBrush QCPLegend::getBrush() const +void QCPItemTracer::setSize(double size) { - return mSelectedParts.testFlag(spLegendBox) ? mSelectedBrush : mBrush; + mSize = size; } -/*! \internal +/*! + Sets the style/visual appearance of the tracer. - Draws the legend box with the provided \a painter. The individual legend items are layerables - themselves, thus are drawn independently. + If you only want to use the tracer \a position as an anchor for other items, set \a style to + \ref tsNone. */ -void QCPLegend::draw(QCPPainter *painter) +void QCPItemTracer::setStyle(QCPItemTracer::TracerStyle style) { - // draw background rect: - painter->setBrush(getBrush()); - painter->setPen(getBorderPen()); - painter->drawRect(mOuterRect); + mStyle = style; } -/* inherits documentation from base class */ -double QCPLegend::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const -{ - if (!mParentPlot) return -1; - if (onlySelectable && !mSelectableParts.testFlag(spLegendBox)) - return -1; +/*! + Sets the QCPGraph this tracer sticks to. The tracer \a position will be set to type + QCPItemPosition::ptPlotCoords and the axes will be set to the axes of \a graph. - if (mOuterRect.contains(pos.toPoint())) - { - if (details) details->setValue(spLegendBox); - return mParentPlot->selectionTolerance()*0.99; - } - return -1; -} - -/* inherits documentation from base class */ -void QCPLegend::selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) + To free the tracer from any graph, set \a graph to 0. The tracer \a position can then be placed + freely like any other item position. This is the state the tracer will assume when its graph gets + deleted while still attached to it. + + \see setGraphKey +*/ +void QCPItemTracer::setGraph(QCPGraph *graph) { - Q_UNUSED(event) - mSelectedParts = selectedParts(); // in case item selection has changed - if (details.value() == spLegendBox && mSelectableParts.testFlag(spLegendBox)) + if (graph) { - SelectableParts selBefore = mSelectedParts; - setSelectedParts(additive ? mSelectedParts^spLegendBox : mSelectedParts|spLegendBox); // no need to unset spItems in !additive case, because they will be deselected by QCustomPlot (they're normal QCPLayerables with own deselectEvent) - if (selectionStateChanged) - *selectionStateChanged = mSelectedParts != selBefore; - } -} - -/* inherits documentation from base class */ -void QCPLegend::deselectEvent(bool *selectionStateChanged) -{ - mSelectedParts = selectedParts(); // in case item selection has changed - if (mSelectableParts.testFlag(spLegendBox)) + if (graph->parentPlot() == mParentPlot) + { + position->setType(QCPItemPosition::ptPlotCoords); + position->setAxes(graph->keyAxis(), graph->valueAxis()); + mGraph = graph; + updatePosition(); + } else + qDebug() << Q_FUNC_INFO << "graph isn't in same QCustomPlot instance as this item"; + } else { - SelectableParts selBefore = mSelectedParts; - setSelectedParts(selectedParts() & ~spLegendBox); - if (selectionStateChanged) - *selectionStateChanged = mSelectedParts != selBefore; + mGraph = 0; } } -/* inherits documentation from base class */ -QCP::Interaction QCPLegend::selectionCategory() const +/*! + Sets the key of the graph's data point the tracer will be positioned at. This is the only free + coordinate of a tracer when attached to a graph. + + Depending on \ref setInterpolating, the tracer will be either positioned on the data point + closest to \a key, or will stay exactly at \a key and interpolate the value linearly. + + \see setGraph, setInterpolating +*/ +void QCPItemTracer::setGraphKey(double key) { - return QCP::iSelectLegend; + mGraphKey = key; } -/* inherits documentation from base class */ -QCP::Interaction QCPAbstractLegendItem::selectionCategory() const +/*! + Sets whether the value of the graph's data points shall be interpolated, when positioning the + tracer. + + If \a enabled is set to false and a key is given with \ref setGraphKey, the tracer is placed on + the data point of the graph which is closest to the key, but which is not necessarily exactly + there. If \a enabled is true, the tracer will be positioned exactly at the specified key, and + the appropriate value will be interpolated from the graph's data points linearly. + + \see setGraph, setGraphKey +*/ +void QCPItemTracer::setInterpolating(bool enabled) { - return QCP::iSelectLegend; + mInterpolating = enabled; } /* inherits documentation from base class */ -void QCPLegend::parentPlotInitialized(QCustomPlot *parentPlot) +double QCPItemTracer::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { - Q_UNUSED(parentPlot) -} - + Q_UNUSED(details) + if (onlySelectable && !mSelectable) + return -1; -//////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////// QCPPlotTitle -//////////////////////////////////////////////////////////////////////////////////////////////////// + QPointF center(position->pixelPoint()); + double w = mSize/2.0; + QRect clip = clipRect(); + switch (mStyle) + { + case tsNone: return -1; + case tsPlus: + { + if (clipRect().intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect())) + return qSqrt(qMin(distSqrToLine(center+QPointF(-w, 0), center+QPointF(w, 0), pos), + distSqrToLine(center+QPointF(0, -w), center+QPointF(0, w), pos))); + break; + } + case tsCrosshair: + { + return qSqrt(qMin(distSqrToLine(QPointF(clip.left(), center.y()), QPointF(clip.right(), center.y()), pos), + distSqrToLine(QPointF(center.x(), clip.top()), QPointF(center.x(), clip.bottom()), pos))); + } + case tsCircle: + { + if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect())) + { + // distance to border: + double centerDist = QVector2D(center-pos).length(); + double circleLine = w; + double result = qAbs(centerDist-circleLine); + // filled ellipse, allow click inside to count as hit: + if (result > mParentPlot->selectionTolerance()*0.99 && mBrush.style() != Qt::NoBrush && mBrush.color().alpha() != 0) + { + if (centerDist <= circleLine) + result = mParentPlot->selectionTolerance()*0.99; + } + return result; + } + break; + } + case tsSquare: + { + if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect())) + { + QRectF rect = QRectF(center-QPointF(w, w), center+QPointF(w, w)); + bool filledRect = mBrush.style() != Qt::NoBrush && mBrush.color().alpha() != 0; + return rectSelectTest(rect, pos, filledRect); + } + break; + } + } + return -1; +} -/*! \class QCPPlotTitle - \brief A layout element displaying a plot title text - - The text may be specified with \ref setText, theformatting can be controlled with \ref setFont - and \ref setTextColor. - - A plot title can be added as follows: - \code - customPlot->plotLayout()->insertRow(0); // inserts an empty row above the default axis rect - customPlot->plotLayout()->addElement(0, 0, new QCPPlotTitle(customPlot, "Your Plot Title")); - \endcode - - Since a plot title is a common requirement, QCustomPlot offers specialized selection signals for - easy interaction with QCPPlotTitle. If a layout element of type QCPPlotTitle is clicked, the - signal \ref QCustomPlot::titleClick is emitted. A double click emits the \ref - QCustomPlot::titleDoubleClick signal. -*/ +/* inherits documentation from base class */ +void QCPItemTracer::draw(QCPPainter *painter) +{ + updatePosition(); + if (mStyle == tsNone) + return; -/* start documentation of signals */ + painter->setPen(mainPen()); + painter->setBrush(mainBrush()); + QPointF center(position->pixelPoint()); + double w = mSize/2.0; + QRect clip = clipRect(); + switch (mStyle) + { + case tsNone: return; + case tsPlus: + { + if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect())) + { + painter->drawLine(QLineF(center+QPointF(-w, 0), center+QPointF(w, 0))); + painter->drawLine(QLineF(center+QPointF(0, -w), center+QPointF(0, w))); + } + break; + } + case tsCrosshair: + { + if (center.y() > clip.top() && center.y() < clip.bottom()) + painter->drawLine(QLineF(clip.left(), center.y(), clip.right(), center.y())); + if (center.x() > clip.left() && center.x() < clip.right()) + painter->drawLine(QLineF(center.x(), clip.top(), center.x(), clip.bottom())); + break; + } + case tsCircle: + { + if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect())) + painter->drawEllipse(center, w, w); + break; + } + case tsSquare: + { + if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect())) + painter->drawRect(QRectF(center-QPointF(w, w), center+QPointF(w, w))); + break; + } + } +} -/*! \fn void QCPPlotTitle::selectionChanged(bool selected) +/*! + If the tracer is connected with a graph (\ref setGraph), this function updates the tracer's \a + position to reside on the graph data, depending on the configured key (\ref setGraphKey). - This signal is emitted when the selection state has changed to \a selected, either by user - interaction or by a direct call to \ref setSelected. + It is called automatically on every redraw and normally doesn't need to be called manually. One + exception is when you want to read the tracer coordinates via \a position and are not sure that + the graph's data (or the tracer key with \ref setGraphKey) hasn't changed since the last redraw. + In that situation, call this function before accessing \a position, to make sure you don't get + out-of-date coordinates. - \see setSelected, setSelectable + If there is no graph set on this tracer, this function does nothing. */ +void QCPItemTracer::updatePosition() +{ + if (mGraph) + { + if (mParentPlot->hasPlottable(mGraph)) + { + if (mGraph->data()->size() > 1) + { + QCPDataMap::const_iterator first = mGraph->data()->constBegin(); + QCPDataMap::const_iterator last = mGraph->data()->constEnd()-1; + if (mGraphKey < first.key()) + position->setCoords(first.key(), first.value().value); + else if (mGraphKey > last.key()) + position->setCoords(last.key(), last.value().value); + else + { + QCPDataMap::const_iterator it = mGraph->data()->lowerBound(mGraphKey); + if (it != first) // mGraphKey is somewhere between iterators + { + QCPDataMap::const_iterator prevIt = it-1; + if (mInterpolating) + { + // interpolate between iterators around mGraphKey: + double slope = 0; + if (!qFuzzyCompare((double)it.key(), (double)prevIt.key())) + slope = (it.value().value-prevIt.value().value)/(it.key()-prevIt.key()); + position->setCoords(mGraphKey, (mGraphKey-prevIt.key())*slope+prevIt.value().value); + } else + { + // find iterator with key closest to mGraphKey: + if (mGraphKey < (prevIt.key()+it.key())*0.5) + it = prevIt; + position->setCoords(it.key(), it.value().value); + } + } else // mGraphKey is exactly on first iterator + position->setCoords(it.key(), it.value().value); + } + } else if (mGraph->data()->size() == 1) + { + QCPDataMap::const_iterator it = mGraph->data()->constBegin(); + position->setCoords(it.key(), it.value().value); + } else + qDebug() << Q_FUNC_INFO << "graph has no data"; + } else + qDebug() << Q_FUNC_INFO << "graph not contained in QCustomPlot instance (anymore)"; + } +} -/* end documentation of signals */ +/*! \internal -/*! - Creates a new QCPPlotTitle instance and sets default values. The initial text is empty (\ref setText). - - To set the title text in the constructor, rather use \ref QCPPlotTitle(QCustomPlot *parentPlot, const QString &text). + Returns the pen that should be used for drawing lines. Returns mPen when the item is not selected + and mSelectedPen when it is. */ -QCPPlotTitle::QCPPlotTitle(QCustomPlot *parentPlot) : - QCPLayoutElement(parentPlot), - mFont(QFont("sans serif", 13*1.5, QFont::Bold)), - mTextColor(Qt::black), - mSelectedFont(QFont("sans serif", 13*1.6, QFont::Bold)), - mSelectedTextColor(Qt::blue), - mSelectable(false), - mSelected(false) +QPen QCPItemTracer::mainPen() const { - if (parentPlot) - { - setLayer(parentPlot->currentLayer()); - mFont = QFont(parentPlot->font().family(), parentPlot->font().pointSize()*1.5, QFont::Bold); - mSelectedFont = QFont(parentPlot->font().family(), parentPlot->font().pointSize()*1.6, QFont::Bold); - } - setMargins(QMargins(5, 5, 5, 0)); + return mSelected ? mSelectedPen : mPen; } -/*! \overload - - Creates a new QCPPlotTitle instance and sets default values. The initial text is set to \a text. +/*! \internal + + Returns the brush that should be used for drawing fills of the item. Returns mBrush when the item + is not selected and mSelectedBrush when it is. */ -QCPPlotTitle::QCPPlotTitle(QCustomPlot *parentPlot, const QString &text) : - QCPLayoutElement(parentPlot), - mText(text), - mFont(QFont(parentPlot->font().family(), parentPlot->font().pointSize()*1.5, QFont::Bold)), - mTextColor(Qt::black), - mSelectedFont(QFont(parentPlot->font().family(), parentPlot->font().pointSize()*1.6, QFont::Bold)), - mSelectedTextColor(Qt::blue), - mSelectable(false), - mSelected(false) +QBrush QCPItemTracer::mainBrush() const { - setLayer("axes"); - setMargins(QMargins(5, 5, 5, 0)); + return mSelected ? mSelectedBrush : mBrush; } -/*! - Sets the text that will be displayed to \a text. Multiple lines can be created by insertion of "\n". + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPItemBracket +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPItemBracket + \brief A bracket for referencing/highlighting certain parts in the plot. + + \image html QCPItemBracket.png "Bracket example. Blue dotted circles are anchors, solid blue discs are positions." + + It has two positions, \a left and \a right, which define the span of the bracket. If \a left is + actually farther to the left than \a right, the bracket is opened to the bottom, as shown in the + example image. - \see setFont, setTextColor + The bracket supports multiple styles via \ref setStyle. The length, i.e. how far the bracket + stretches away from the embraced span, can be controlled with \ref setLength. + + \image html QCPItemBracket-length.png +
                                                                  Demonstrating the effect of different values for \ref setLength, for styles \ref + bsCalligraphic and \ref bsSquare. Anchors and positions are displayed for reference.
                                                                  + + It provides an anchor \a center, to allow connection of other items, e.g. an arrow (QCPItemLine + or QCPItemCurve) or a text label (QCPItemText), to the bracket. */ -void QCPPlotTitle::setText(const QString &text) -{ - mText = text; -} /*! - Sets the \a font of the title text. + Creates a bracket item and sets default values. - \see setTextColor, setSelectedFont + The constructed item can be added to the plot with QCustomPlot::addItem. */ -void QCPPlotTitle::setFont(const QFont &font) +QCPItemBracket::QCPItemBracket(QCustomPlot *parentPlot) : + QCPAbstractItem(parentPlot), + left(createPosition("left")), + right(createPosition("right")), + center(createAnchor("center", aiCenter)) { - mFont = font; + left->setCoords(0, 0); + right->setCoords(1, 1); + + setPen(QPen(Qt::black)); + setSelectedPen(QPen(Qt::blue, 2)); + setLength(8); + setStyle(bsCalligraphic); } -/*! - Sets the \a color of the title text. - - \see setFont, setSelectedTextColor -*/ -void QCPPlotTitle::setTextColor(const QColor &color) +QCPItemBracket::~QCPItemBracket() { - mTextColor = color; } /*! - Sets the \a font of the title text that will be used if the plot title is selected (\ref setSelected). + Sets the pen that will be used to draw the bracket. - \see setFont + Note that when the style is \ref bsCalligraphic, only the color will be taken from the pen, the + stroke and width are ignored. To change the apparent stroke width of a calligraphic bracket, use + \ref setLength, which has a similar effect. + + \see setSelectedPen */ -void QCPPlotTitle::setSelectedFont(const QFont &font) +void QCPItemBracket::setPen(const QPen &pen) { - mSelectedFont = font; + mPen = pen; } /*! - Sets the \a color of the title text that will be used if the plot title is selected (\ref setSelected). + Sets the pen that will be used to draw the bracket when selected - \see setTextColor + \see setPen, setSelected */ -void QCPPlotTitle::setSelectedTextColor(const QColor &color) +void QCPItemBracket::setSelectedPen(const QPen &pen) { - mSelectedTextColor = color; + mSelectedPen = pen; } /*! - Sets whether the user may select this plot title to \a selectable. - - Note that even when \a selectable is set to false, the selection state may be changed - programmatically via \ref setSelected. + Sets the \a length in pixels how far the bracket extends in the direction towards the embraced + span of the bracket (i.e. perpendicular to the left-right-direction) + + \image html QCPItemBracket-length.png +
                                                                  Demonstrating the effect of different values for \ref setLength, for styles \ref + bsCalligraphic and \ref bsSquare. Anchors and positions are displayed for reference.
                                                                  */ -void QCPPlotTitle::setSelectable(bool selectable) +void QCPItemBracket::setLength(double length) { - mSelectable = selectable; + mLength = length; } /*! - Sets the selection state of this plot title to \a selected. If the selection has changed, \ref - selectionChanged is emitted. + Sets the style of the bracket, i.e. the shape/visual appearance. - Note that this function can change the selection state independently of the current \ref - setSelectable state. + \see setPen */ -void QCPPlotTitle::setSelected(bool selected) -{ - if (mSelected != selected) - { - mSelected = selected; - emit selectionChanged(mSelected); - } -} - -/* inherits documentation from base class */ -void QCPPlotTitle::applyDefaultAntialiasingHint(QCPPainter *painter) const -{ - applyAntialiasingHint(painter, mAntialiased, QCP::aeNone); -} - -/* inherits documentation from base class */ -void QCPPlotTitle::draw(QCPPainter *painter) +void QCPItemBracket::setStyle(QCPItemBracket::BracketStyle style) { - painter->setFont(mainFont()); - painter->setPen(QPen(mainTextColor())); - painter->drawText(mRect, Qt::AlignCenter, mText, &mTextBoundingRect); + mStyle = style; } /* inherits documentation from base class */ -QSize QCPPlotTitle::minimumSizeHint() const +double QCPItemBracket::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { - QFontMetrics metrics(mFont); - QSize result = metrics.boundingRect(0, 0, 0, 0, Qt::AlignCenter, mText).size(); - result.rwidth() += mMargins.left() + mMargins.right(); - result.rheight() += mMargins.top() + mMargins.bottom(); - return result; + Q_UNUSED(details) + if (onlySelectable && !mSelectable) + return -1; + + QVector2D leftVec(left->pixelPoint()); + QVector2D rightVec(right->pixelPoint()); + if (leftVec.toPoint() == rightVec.toPoint()) + return -1; + + QVector2D widthVec = (rightVec-leftVec)*0.5f; + QVector2D lengthVec(-widthVec.y(), widthVec.x()); + lengthVec = lengthVec.normalized()*mLength; + QVector2D centerVec = (rightVec+leftVec)*0.5f-lengthVec; + + return qSqrt(distSqrToLine((centerVec-widthVec).toPointF(), (centerVec+widthVec).toPointF(), pos)); } /* inherits documentation from base class */ -QSize QCPPlotTitle::maximumSizeHint() const +void QCPItemBracket::draw(QCPPainter *painter) { - QFontMetrics metrics(mFont); - QSize result = metrics.boundingRect(0, 0, 0, 0, Qt::AlignCenter, mText).size(); - result.rheight() += mMargins.top() + mMargins.bottom(); - result.setWidth(QWIDGETSIZE_MAX); - return result; -} + QVector2D leftVec(left->pixelPoint()); + QVector2D rightVec(right->pixelPoint()); + if (leftVec.toPoint() == rightVec.toPoint()) + return; + + QVector2D widthVec = (rightVec-leftVec)*0.5f; + QVector2D lengthVec(-widthVec.y(), widthVec.x()); + lengthVec = lengthVec.normalized()*mLength; + QVector2D centerVec = (rightVec+leftVec)*0.5f-lengthVec; -/* inherits documentation from base class */ -void QCPPlotTitle::selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) -{ - Q_UNUSED(event) - Q_UNUSED(details) - if (mSelectable) + QPolygon boundingPoly; + boundingPoly << leftVec.toPoint() << rightVec.toPoint() + << (rightVec-lengthVec).toPoint() << (leftVec-lengthVec).toPoint(); + QRect clip = clipRect().adjusted(-mainPen().widthF(), -mainPen().widthF(), mainPen().widthF(), mainPen().widthF()); + if (clip.intersects(boundingPoly.boundingRect())) { - bool selBefore = mSelected; - setSelected(additive ? !mSelected : true); - if (selectionStateChanged) - *selectionStateChanged = mSelected != selBefore; + painter->setPen(mainPen()); + switch (mStyle) + { + case bsSquare: + { + painter->drawLine((centerVec+widthVec).toPointF(), (centerVec-widthVec).toPointF()); + painter->drawLine((centerVec+widthVec).toPointF(), (centerVec+widthVec+lengthVec).toPointF()); + painter->drawLine((centerVec-widthVec).toPointF(), (centerVec-widthVec+lengthVec).toPointF()); + break; + } + case bsRound: + { + painter->setBrush(Qt::NoBrush); + QPainterPath path; + path.moveTo((centerVec+widthVec+lengthVec).toPointF()); + path.cubicTo((centerVec+widthVec).toPointF(), (centerVec+widthVec).toPointF(), centerVec.toPointF()); + path.cubicTo((centerVec-widthVec).toPointF(), (centerVec-widthVec).toPointF(), (centerVec-widthVec+lengthVec).toPointF()); + painter->drawPath(path); + break; + } + case bsCurly: + { + painter->setBrush(Qt::NoBrush); + QPainterPath path; + path.moveTo((centerVec+widthVec+lengthVec).toPointF()); + path.cubicTo((centerVec+widthVec-lengthVec*0.8f).toPointF(), (centerVec+0.4f*widthVec+lengthVec).toPointF(), centerVec.toPointF()); + path.cubicTo((centerVec-0.4f*widthVec+lengthVec).toPointF(), (centerVec-widthVec-lengthVec*0.8f).toPointF(), (centerVec-widthVec+lengthVec).toPointF()); + painter->drawPath(path); + break; + } + case bsCalligraphic: + { + painter->setPen(Qt::NoPen); + painter->setBrush(QBrush(mainPen().color())); + QPainterPath path; + path.moveTo((centerVec+widthVec+lengthVec).toPointF()); + + path.cubicTo((centerVec+widthVec-lengthVec*0.8f).toPointF(), (centerVec+0.4f*widthVec+0.8f*lengthVec).toPointF(), centerVec.toPointF()); + path.cubicTo((centerVec-0.4f*widthVec+0.8f*lengthVec).toPointF(), (centerVec-widthVec-lengthVec*0.8f).toPointF(), (centerVec-widthVec+lengthVec).toPointF()); + + path.cubicTo((centerVec-widthVec-lengthVec*0.5f).toPointF(), (centerVec-0.2f*widthVec+1.2f*lengthVec).toPointF(), (centerVec+lengthVec*0.2f).toPointF()); + path.cubicTo((centerVec+0.2f*widthVec+1.2f*lengthVec).toPointF(), (centerVec+widthVec-lengthVec*0.5f).toPointF(), (centerVec+widthVec+lengthVec).toPointF()); + + painter->drawPath(path); + break; + } + } } } /* inherits documentation from base class */ -void QCPPlotTitle::deselectEvent(bool *selectionStateChanged) +QPointF QCPItemBracket::anchorPixelPoint(int anchorId) const { - if (mSelectable) + QVector2D leftVec(left->pixelPoint()); + QVector2D rightVec(right->pixelPoint()); + if (leftVec.toPoint() == rightVec.toPoint()) + return leftVec.toPointF(); + + QVector2D widthVec = (rightVec-leftVec)*0.5f; + QVector2D lengthVec(-widthVec.y(), widthVec.x()); + lengthVec = lengthVec.normalized()*mLength; + QVector2D centerVec = (rightVec+leftVec)*0.5f-lengthVec; + + switch (anchorId) { - bool selBefore = mSelected; - setSelected(false); - if (selectionStateChanged) - *selectionStateChanged = mSelected != selBefore; + case aiCenter: + return centerVec.toPointF(); } -} - -/* inherits documentation from base class */ -double QCPPlotTitle::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const -{ - Q_UNUSED(details) - if (onlySelectable && !mSelectable) - return -1; - - if (mTextBoundingRect.contains(pos.toPoint())) - return mParentPlot->selectionTolerance()*0.99; - else - return -1; + qDebug() << Q_FUNC_INFO << "invalid anchorId" << anchorId; + return QPointF(); } /*! \internal - - Returns the main font to be used. This is mSelectedFont if \ref setSelected is set to - true, else mFont is returned. -*/ -QFont QCPPlotTitle::mainFont() const -{ - return mSelected ? mSelectedFont : mFont; -} -/*! \internal - - Returns the main color to be used. This is mSelectedTextColor if \ref setSelected is set to - true, else mTextColor is returned. + Returns the pen that should be used for drawing lines. Returns mPen when the + item is not selected and mSelectedPen when it is. */ -QColor QCPPlotTitle::mainTextColor() const +QPen QCPItemBracket::mainPen() const { - return mSelected ? mSelectedTextColor : mTextColor; + return mSelected ? mSelectedPen : mPen; } diff -Nru qcustomplot-1.1.0/qcustomplot.h qcustomplot-1.2.0/qcustomplot.h --- qcustomplot-1.1.0/qcustomplot.h 2013-11-04 22:19:27.000000000 +0000 +++ qcustomplot-1.2.0/qcustomplot.h 2014-03-14 21:11:10.000000000 +0000 @@ -1,7 +1,7 @@ /*************************************************************************** ** ** ** QCustomPlot, an easy to use, modern plotting widget for Qt ** -** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer ** +** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer ** ** ** ** 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 ** @@ -19,8 +19,8 @@ **************************************************************************** ** Author: Emanuel Eichhammer ** ** Website/Contact: http://www.qcustomplot.com/ ** -** Date: 04.11.13 ** -** Version: 1.1.0 ** +** Date: 14.03.14 ** +** Version: 1.2.0 ** ****************************************************************************/ #ifndef QCUSTOMPLOT_H @@ -48,6 +48,7 @@ #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) # include # include +# include #else # include # include @@ -60,6 +61,7 @@ class QCPLayout; class QCPAxis; class QCPAxisRect; +class QCPAxisPainterPrivate; class QCPAbstractPlottable; class QCPGraph; class QCPAbstractItem; @@ -68,6 +70,8 @@ class QCPPlotTitle; class QCPLegend; class QCPAbstractLegendItem; +class QCPColorMap; +class QCPColorScale; /*! \file */ @@ -134,8 +138,8 @@ enum PlottingHint { phNone = 0x000 ///< 0x000 No hints are set ,phFastPolylines = 0x001 ///< 0x001 Graph/Curve lines are drawn with a faster method. This reduces the quality ///< especially of the line segment joins. (Only relevant for solid line pens.) - ,phForceRepaint = 0x002 ///< 0x002 causes an immediate repaint() instead of a soft update() when QCustomPlot::replot() is called. This is set by default - ///< on Windows-Systems to prevent the plot from freezing on fast consecutive replots (e.g. user drags ranges with mouse). + ,phForceRepaint = 0x002 ///< 0x002 causes an immediate repaint() instead of a soft update() when QCustomPlot::replot() is called with parameter \ref QCustomPlot::rpHint. + ///< This is set by default to prevent the plot from freezing on fast consecutive replots (e.g. user drags ranges with mouse). ,phCacheLabels = 0x004 ///< 0x004 axis (tick) labels will be cached as pixmaps, increasing replot performance. }; Q_DECLARE_FLAGS(PlottingHints, PlottingHint) @@ -312,10 +316,10 @@ Defines special modes the painter can operate in. They disable or enable certain subsets of features/fixes/workarounds, depending on whether they are wanted on the respective output device. */ - enum PainterMode {pmDefault = 0x00 ///< 0x00 Default mode for painting on screen devices - ,pmVectorized = 0x01 ///< 0x01 Mode for vectorized painting (e.g. PDF export). For example, this prevents some antialiasing fixes. - ,pmNoCaching = 0x02 ///< 0x02 Mode for all sorts of exports (e.g. PNG, PDF,...). For example, this prevents using cached pixmap labels - ,pmNonCosmetic = 0x04 ///< 0x04 Turns pen widths 0 to 1, i.e. disables cosmetic pens. (A cosmetic pen is always drawn with width 1 pixel in the vector image/pdf viewer, independent of zoom.) + enum PainterMode { pmDefault = 0x00 ///< 0x00 Default mode for painting on screen devices + ,pmVectorized = 0x01 ///< 0x01 Mode for vectorized painting (e.g. PDF export). For example, this prevents some antialiasing fixes. + ,pmNoCaching = 0x02 ///< 0x02 Mode for all sorts of exports (e.g. PNG, PDF,...). For example, this prevents using cached pixmap labels + ,pmNonCosmetic = 0x04 ///< 0x04 Turns pen widths 0 to 1, i.e. disables cosmetic pens. (A cosmetic pen is always drawn with width 1 pixel in the vector image/pdf viewer, independent of zoom.) }; Q_FLAGS(PainterMode PainterModes) Q_DECLARE_FLAGS(PainterModes, PainterMode) @@ -365,6 +369,7 @@ Q_PROPERTY(QString name READ name) Q_PROPERTY(int index READ index) Q_PROPERTY(QList children READ children) + Q_PROPERTY(bool visible READ visible WRITE setVisible) /// \endcond public: QCPLayer(QCustomPlot* parentPlot, const QString &layerName); @@ -375,6 +380,10 @@ QString name() const { return mName; } int index() const { return mIndex; } QList children() const { return mChildren; } + bool visible() const { return mVisible; } + + // setters: + void setVisible(bool visible); protected: // property members: @@ -382,6 +391,7 @@ QString mName; int mIndex; QList mChildren; + bool mVisible; // non-virtual methods: void addChild(QCPLayerable *layerable, bool prepend); @@ -401,7 +411,7 @@ Q_PROPERTY(bool visible READ visible WRITE setVisible) Q_PROPERTY(QCustomPlot* parentPlot READ parentPlot) Q_PROPERTY(QCPLayerable* parentLayerable READ parentLayerable) - Q_PROPERTY(QCPLayer* layer READ layer WRITE setLayer) + Q_PROPERTY(QCPLayer* layer READ layer WRITE setLayer NOTIFY layerChanged) Q_PROPERTY(bool antialiased READ antialiased WRITE setAntialiased) /// \endcond public: @@ -417,7 +427,7 @@ // setters: void setVisible(bool on); - bool setLayer(QCPLayer *layer); + Q_SLOT bool setLayer(QCPLayer *layer); bool setLayer(const QString &layerName); void setAntialiased(bool enabled); @@ -427,6 +437,9 @@ // non-property methods: bool realVisibility() const; +signals: + void layerChanged(QCPLayer *newLayer); + protected: // property members: bool mVisible; @@ -467,6 +480,20 @@ QCPRange(); QCPRange(double lower, double upper); + bool operator==(const QCPRange& other) { return lower == other.lower && upper == other.upper; } + bool operator!=(const QCPRange& other) { return !(*this == other); } + + QCPRange &operator+=(const double& value) { lower+=value; upper+=value; return *this; } + QCPRange &operator-=(const double& value) { lower-=value; upper-=value; return *this; } + QCPRange &operator*=(const double& value) { lower*=value; upper*=value; return *this; } + QCPRange &operator/=(const double& value) { lower/=value; upper/=value; return *this; } + friend inline const QCPRange operator+(const QCPRange&, double); + friend inline const QCPRange operator+(double, const QCPRange&); + friend inline const QCPRange operator-(const QCPRange& range, double value); + friend inline const QCPRange operator*(const QCPRange& range, double value); + friend inline const QCPRange operator*(double value, const QCPRange& range); + friend inline const QCPRange operator/(const QCPRange& range, double value); + double size() const; double center() const; void normalize(); @@ -480,9 +507,94 @@ static bool validRange(const QCPRange &range); static const double minRange; //1e-280; static const double maxRange; //1e280; + }; Q_DECLARE_TYPEINFO(QCPRange, Q_MOVABLE_TYPE); +/* documentation of inline functions */ + +/*! \fn QCPRange &QCPRange::operator+=(const double& value) + + Adds \a value to both boundaries of the range. +*/ + +/*! \fn QCPRange &QCPRange::operator-=(const double& value) + + Subtracts \a value from both boundaries of the range. +*/ + +/*! \fn QCPRange &QCPRange::operator*=(const double& value) + + Multiplies both boundaries of the range by \a value. +*/ + +/*! \fn QCPRange &QCPRange::operator/=(const double& value) + + Divides both boundaries of the range by \a value. +*/ + +/* end documentation of inline functions */ + +/*! + Adds \a value to both boundaries of the range. +*/ +inline const QCPRange operator+(const QCPRange& range, double value) +{ + QCPRange result(range); + result += value; + return result; +} + +/*! + Adds \a value to both boundaries of the range. +*/ +inline const QCPRange operator+(double value, const QCPRange& range) +{ + QCPRange result(range); + result += value; + return result; +} + +/*! + Subtracts \a value from both boundaries of the range. +*/ +inline const QCPRange operator-(const QCPRange& range, double value) +{ + QCPRange result(range); + result -= value; + return result; +} + +/*! + Multiplies both boundaries of the range by \a value. +*/ +inline const QCPRange operator*(const QCPRange& range, double value) +{ + QCPRange result(range); + result *= value; + return result; +} + +/*! + Multiplies both boundaries of the range by \a value. +*/ +inline const QCPRange operator*(double value, const QCPRange& range) +{ + QCPRange result(range); + result *= value; + return result; +} + +/*! + Divides both boundaries of the range by \a value. +*/ +inline const QCPRange operator/(const QCPRange& range, double value) +{ + QCPRange result(range); + result /= value; + return result; +} + class QCP_LIB_DECL QCPMarginGroup : public QObject { @@ -526,6 +638,16 @@ Q_PROPERTY(QSize maximumSize READ maximumSize WRITE setMaximumSize) /// \endcond public: + /*! + Defines the phases of the update process, that happens just before a replot. At each phase, + \ref update is called with the according UpdatePhase value. + */ + enum UpdatePhase { upPreparation ///< Phase used for any type of preparation that needs to be done before margin calculation and layout + ,upMargins ///< Phase in which the margins are calculated and set + ,upLayout ///< Final phase in which the layout system places the rects of the elements + }; + Q_ENUMS(UpdatePhase) + explicit QCPLayoutElement(QCustomPlot *parentPlot=0); virtual ~QCPLayoutElement(); @@ -553,7 +675,7 @@ void setMarginGroup(QCP::MarginSides sides, QCPMarginGroup *group); // introduced virtual methods: - virtual void update(); + virtual void update(UpdatePhase phase); virtual QSize minimumSizeHint() const; virtual QSize maximumSizeHint() const; virtual QList elements(bool recursive) const; @@ -600,7 +722,7 @@ explicit QCPLayout(); // reimplemented virtual methods: - virtual void update(); + virtual void update(UpdatePhase phase); virtual QList elements(bool recursive) const; // introduced virtual methods: @@ -704,8 +826,8 @@ /*! Defines how the placement and sizing is handled for a certain element in a QCPLayoutInset. */ - enum InsetPlacement {ipFree ///< The element may be positioned/sized arbitrarily, see \ref setInsetRect - ,ipBorderAligned ///< The element is aligned to one of the layout sides, see \ref setInsetAlignment + enum InsetPlacement { ipFree ///< The element may be positioned/sized arbitrarily, see \ref setInsetRect + ,ipBorderAligned ///< The element is aligned to one of the layout sides, see \ref setInsetAlignment }; explicit QCPLayoutInset(); @@ -759,7 +881,7 @@ and \ref setLength. Some decorations like \ref esDisc, \ref esSquare, \ref esDiamond and \ref esBar only support a width, the length property is ignored. - \see QCPItemLine::setHead, QCPItemLine::setTail, QCPItemCurve::setHead, QCPItemCurve::setTail + \see QCPItemLine::setHead, QCPItemLine::setTail, QCPItemCurve::setHead, QCPItemCurve::setTail, QCPAxis::setLowerEnding, QCPAxis::setUpperEnding */ Q_ENUMS(EndingStyle) enum EndingStyle { esNone ///< No ending decoration @@ -770,7 +892,7 @@ ,esSquare ///< A filled square ,esDiamond ///< A filled diamond (45° rotated square) ,esBar ///< A bar perpendicular to the line - ,esHalfBar ///< A bar perpendicular to the line sticking out to one side + ,esHalfBar ///< A bar perpendicular to the line, pointing out to only one side (to which side can be changed with \ref setInverted) ,esSkewedBar ///< A bar that is skewed (skew controllable via \ref setLength) }; @@ -860,9 +982,9 @@ /// \cond INCLUDE_QPROPERTIES Q_PROPERTY(AxisType axisType READ axisType) Q_PROPERTY(QCPAxisRect* axisRect READ axisRect) - Q_PROPERTY(ScaleType scaleType READ scaleType WRITE setScaleType) + Q_PROPERTY(ScaleType scaleType READ scaleType WRITE setScaleType NOTIFY scaleTypeChanged) Q_PROPERTY(double scaleLogBase READ scaleLogBase WRITE setScaleLogBase) - Q_PROPERTY(QCPRange range READ range WRITE setRange) + Q_PROPERTY(QCPRange range READ range WRITE setRange NOTIFY rangeChanged) Q_PROPERTY(bool rangeReversed READ rangeReversed WRITE setRangeReversed) Q_PROPERTY(bool autoTicks READ autoTicks WRITE setAutoTicks) Q_PROPERTY(int autoTickCount READ autoTickCount WRITE setAutoTickCount) @@ -877,6 +999,7 @@ Q_PROPERTY(QColor tickLabelColor READ tickLabelColor WRITE setTickLabelColor) Q_PROPERTY(double tickLabelRotation READ tickLabelRotation WRITE setTickLabelRotation) Q_PROPERTY(QString dateTimeFormat READ dateTimeFormat WRITE setDateTimeFormat) + Q_PROPERTY(Qt::TimeSpec dateTimeSpec READ dateTimeSpec WRITE setDateTimeSpec) Q_PROPERTY(QString numberFormat READ numberFormat WRITE setNumberFormat) Q_PROPERTY(int numberPrecision READ numberPrecision WRITE setNumberPrecision) Q_PROPERTY(double tickStep READ tickStep WRITE setTickStep) @@ -896,8 +1019,8 @@ Q_PROPERTY(int labelPadding READ labelPadding WRITE setLabelPadding) Q_PROPERTY(int padding READ padding WRITE setPadding) Q_PROPERTY(int offset READ offset WRITE setOffset) - Q_PROPERTY(SelectableParts selectedParts READ selectedParts WRITE setSelectedParts) - Q_PROPERTY(SelectableParts selectableParts READ selectableParts WRITE setSelectableParts) + Q_PROPERTY(SelectableParts selectedParts READ selectedParts WRITE setSelectedParts NOTIFY selectionChanged) + Q_PROPERTY(SelectableParts selectableParts READ selectableParts WRITE setSelectableParts NOTIFY selectableChanged) Q_PROPERTY(QFont selectedTickLabelFont READ selectedTickLabelFont WRITE setSelectedTickLabelFont) Q_PROPERTY(QFont selectedLabelFont READ selectedLabelFont WRITE setSelectedLabelFont) Q_PROPERTY(QColor selectedTickLabelColor READ selectedTickLabelColor WRITE setSelectedTickLabelColor) @@ -952,7 +1075,8 @@ Q_DECLARE_FLAGS(SelectableParts, SelectablePart) explicit QCPAxis(QCPAxisRect *parent, AxisType type); - + virtual ~QCPAxis(); + // getters: AxisType axisType() const { return mAxisType; } QCPAxisRect *axisRect() const { return mAxisRect; } @@ -967,11 +1091,11 @@ bool autoSubTicks() const { return mAutoSubTicks; } bool ticks() const { return mTicks; } bool tickLabels() const { return mTickLabels; } - int tickLabelPadding() const { return mTickLabelPadding; } + int tickLabelPadding() const; LabelType tickLabelType() const { return mTickLabelType; } QFont tickLabelFont() const { return mTickLabelFont; } QColor tickLabelColor() const { return mTickLabelColor; } - double tickLabelRotation() const { return mTickLabelRotation; } + double tickLabelRotation() const; QString dateTimeFormat() const { return mDateTimeFormat; } Qt::TimeSpec dateTimeSpec() const { return mDateTimeSpec; } QString numberFormat() const; @@ -979,20 +1103,20 @@ double tickStep() const { return mTickStep; } QVector tickVector() const { return mTickVector; } QVector tickVectorLabels() const { return mTickVectorLabels; } - int tickLengthIn() const { return mTickLengthIn; } - int tickLengthOut() const { return mTickLengthOut; } + int tickLengthIn() const; + int tickLengthOut() const; int subTickCount() const { return mSubTickCount; } - int subTickLengthIn() const { return mSubTickLengthIn; } - int subTickLengthOut() const { return mSubTickLengthOut; } + int subTickLengthIn() const; + int subTickLengthOut() const; QPen basePen() const { return mBasePen; } QPen tickPen() const { return mTickPen; } QPen subTickPen() const { return mSubTickPen; } QFont labelFont() const { return mLabelFont; } QColor labelColor() const { return mLabelColor; } QString label() const { return mLabel; } - int labelPadding() const { return mLabelPadding; } + int labelPadding() const; int padding() const { return mPadding; } - int offset() const { return mOffset; } + int offset() const; SelectableParts selectedParts() const { return mSelectedParts; } SelectableParts selectableParts() const { return mSelectableParts; } QFont selectedTickLabelFont() const { return mSelectedTickLabelFont; } @@ -1002,12 +1126,12 @@ QPen selectedBasePen() const { return mSelectedBasePen; } QPen selectedTickPen() const { return mSelectedTickPen; } QPen selectedSubTickPen() const { return mSelectedSubTickPen; } - QCPLineEnding lowerEnding() const { return mLowerEnding; } - QCPLineEnding upperEnding() const { return mUpperEnding; } + QCPLineEnding lowerEnding() const; + QCPLineEnding upperEnding() const; QCPGrid *grid() const { return mGrid; } // setters: - void setScaleType(ScaleType type); + Q_SLOT void setScaleType(QCPAxis::ScaleType type); void setScaleLogBase(double base); Q_SLOT void setRange(const QCPRange &range); void setRange(double lower, double upper); @@ -1065,7 +1189,7 @@ // reimplemented virtual methods: virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; - // non-virtual methods: + // non-property methods: Qt::Orientation orientation() const { return mOrientation; } void moveRange(double diff); void scaleRange(double factor, double center); @@ -1079,44 +1203,37 @@ QList items() const; static AxisType marginSideToAxisType(QCP::MarginSide side); + static Qt::Orientation orientation(AxisType type) { return type==atBottom||type==atTop ? Qt::Horizontal : Qt::Vertical; } + static AxisType opposite(AxisType type); signals: void ticksRequest(); void rangeChanged(const QCPRange &newRange); void rangeChanged(const QCPRange &newRange, const QCPRange &oldRange); + void scaleTypeChanged(QCPAxis::ScaleType scaleType); void selectionChanged(const QCPAxis::SelectableParts &parts); + void selectableChanged(const QCPAxis::SelectableParts &parts); protected: - struct CachedLabel - { - QPointF offset; - QPixmap pixmap; - }; - struct TickLabelData - { - QString basePart, expPart; - QRect baseBounds, expBounds, totalBounds, rotatedTotalBounds; - QFont baseFont, expFont; - }; - // property members: // axis base: AxisType mAxisType; QCPAxisRect *mAxisRect; - int mOffset, mPadding; + //int mOffset; // in QCPAxisPainter + int mPadding; Qt::Orientation mOrientation; SelectableParts mSelectableParts, mSelectedParts; QPen mBasePen, mSelectedBasePen; - QCPLineEnding mLowerEnding, mUpperEnding; + //QCPLineEnding mLowerEnding, mUpperEnding; // in QCPAxisPainter // axis label: - int mLabelPadding; + //int mLabelPadding; // in QCPAxisPainter QString mLabel; QFont mLabelFont, mSelectedLabelFont; QColor mLabelColor, mSelectedLabelColor; // tick labels: - int mTickLabelPadding; + //int mTickLabelPadding; // in QCPAxisPainter bool mTickLabels, mAutoTickLabels; - double mTickLabelRotation; + //double mTickLabelRotation; // in QCPAxisPainter LabelType mTickLabelType; QFont mTickLabelFont, mSelectedTickLabelFont; QColor mTickLabelColor, mSelectedTickLabelColor; @@ -1125,13 +1242,13 @@ int mNumberPrecision; char mNumberFormatChar; bool mNumberBeautifulPowers; - bool mNumberMultiplyCross; + //bool mNumberMultiplyCross; // QCPAxisPainter // ticks and subticks: bool mTicks; double mTickStep; int mSubTickCount, mAutoTickCount; bool mAutoTicks, mAutoTickStep, mAutoSubTicks; - int mTickLengthIn, mTickLengthOut, mSubTickLengthIn, mSubTickLengthOut; + //int mTickLengthIn, mTickLengthOut, mSubTickLengthIn, mSubTickLengthOut; // QCPAxisPainter QPen mTickPen, mSelectedTickPen; QPen mSubTickPen, mSelectedSubTickPen; // scale and range: @@ -1142,13 +1259,11 @@ // non-property members: QCPGrid *mGrid; - QCache mLabelCache; + QCPAxisPainterPrivate *mAxisPainter; int mLowestVisibleTick, mHighestVisibleTick; - QChar mExponentialChar, mPositiveSignChar; QVector mTickVector; QVector mTickVectorLabels; QVector mSubTickVector; - QRect mAxisSelectionBox, mTickLabelsSelectionBox, mLabelSelectionBox; bool mCachedMarginValid; int mCachedMargin; @@ -1157,16 +1272,10 @@ virtual void generateAutoTicks(); virtual int calculateAutoSubTickCount(double tickStep) const; virtual int calculateMargin(); - // tick label drawing/caching: - virtual void placeTickLabel(QCPPainter *painter, double position, int distanceToAxis, const QString &text, QSize *tickLabelsSize); - virtual void drawTickLabel(QCPPainter *painter, double x, double y, const TickLabelData &labelData) const; - virtual TickLabelData getTickLabelData(const QFont &font, const QString &text) const; - virtual QPointF getTickLabelDrawOffset(const TickLabelData &labelData) const; - virtual void getMaxTickLabelSize(const QFont &font, const QString &text, QSize *tickLabelsSize) const; // reimplemented virtual methods: virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const; - virtual void draw(QCPPainter *painter); + virtual void draw(QCPPainter *painter); virtual QCP::Interaction selectionCategory() const; // events: virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged); @@ -1196,6 +1305,72 @@ Q_DECLARE_METATYPE(QCPAxis::SelectablePart) +class QCPAxisPainterPrivate +{ +public: + explicit QCPAxisPainterPrivate(QCustomPlot *parentPlot); + virtual ~QCPAxisPainterPrivate(); + + virtual void draw(QCPPainter *painter); + virtual int size() const; + void clearCache(); + + QRect axisSelectionBox() const { return mAxisSelectionBox; } + QRect tickLabelsSelectionBox() const { return mTickLabelsSelectionBox; } + QRect labelSelectionBox() const { return mLabelSelectionBox; } + + // public property members: + QCPAxis::AxisType type; + QPen basePen; + QCPLineEnding lowerEnding, upperEnding; // directly accessed by QCPAxis setters/getters + int labelPadding; // directly accessed by QCPAxis setters/getters + QFont labelFont; + QColor labelColor; + QString label; + int tickLabelPadding; // directly accessed by QCPAxis setters/getters + double tickLabelRotation; // directly accessed by QCPAxis setters/getters + bool substituteExponent; + bool numberMultiplyCross; // directly accessed by QCPAxis setters/getters + int tickLengthIn, tickLengthOut, subTickLengthIn, subTickLengthOut; // directly accessed by QCPAxis setters/getters + QPen tickPen, subTickPen; + QFont tickLabelFont; + QColor tickLabelColor; + QRect alignmentRect, viewportRect; + double offset; // directly accessed by QCPAxis setters/getters + bool abbreviateDecimalPowers; + bool reversedEndings; + + QVector subTickPositions; + QVector tickPositions; + QVector tickLabels; + +protected: + struct CachedLabel + { + QPointF offset; + QPixmap pixmap; + }; + struct TickLabelData + { + QString basePart, expPart; + QRect baseBounds, expBounds, totalBounds, rotatedTotalBounds; + QFont baseFont, expFont; + }; + QCustomPlot *mParentPlot; + QByteArray mLabelParameterHash; // to determine whether mLabelCache needs to be cleared due to changed parameters + QCache mLabelCache; + QRect mAxisSelectionBox, mTickLabelsSelectionBox, mLabelSelectionBox; + + virtual QByteArray generateLabelParameterHash() const; + + virtual void placeTickLabel(QCPPainter *painter, double position, int distanceToAxis, const QString &text, QSize *tickLabelsSize); + virtual void drawTickLabel(QCPPainter *painter, double x, double y, const TickLabelData &labelData) const; + virtual TickLabelData getTickLabelData(const QFont &font, const QString &text) const; + virtual QPointF getTickLabelDrawOffset(const TickLabelData &labelData) const; + virtual void getMaxTickLabelSize(const QFont &font, const QString &text, QSize *tickLabelsSize) const; +}; + + class QCP_LIB_DECL QCPAbstractPlottable : public QCPLayerable { Q_OBJECT @@ -1210,8 +1385,8 @@ Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush) Q_PROPERTY(QCPAxis* keyAxis READ keyAxis WRITE setKeyAxis) Q_PROPERTY(QCPAxis* valueAxis READ valueAxis WRITE setValueAxis) - Q_PROPERTY(bool selectable READ selectable WRITE setSelectable) - Q_PROPERTY(bool selected READ selected WRITE setSelected) + Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectableChanged) + Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectionChanged) /// \endcond public: QCPAbstractPlottable(QCPAxis *keyAxis, QCPAxis *valueAxis); @@ -1257,6 +1432,7 @@ signals: void selectionChanged(bool selected); + void selectableChanged(bool selectable); protected: /*! @@ -1286,8 +1462,8 @@ // introduced virtual methods: virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const = 0; - virtual QCPRange getKeyRange(bool &validRange, SignDomain inSignDomain=sdBoth) const = 0; - virtual QCPRange getValueRange(bool &validRange, SignDomain inSignDomain=sdBoth) const = 0; + virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const = 0; + virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const = 0; // non-virtual methods: void coordsToPixels(double key, double value, double &x, double &y) const; @@ -1355,8 +1531,12 @@ \see setType */ enum PositionType { ptAbsolute ///< Static positioning in pixels, starting from the top left corner of the viewport/widget. - ,ptViewportRatio ///< Static positioning given by a fraction of the viewport size. - ,ptAxisRectRatio ///< Static positioning given by a fraction of the axis rect size (see \ref setAxisRect). + ,ptViewportRatio ///< Static positioning given by a fraction of the viewport size. For example, if you call setCoords(0, 0), the position will be at the top + ///< left corner of the viewport/widget. setCoords(1, 1) will be at the bottom right corner, setCoords(0.5, 0) will be horizontally centered and + ///< vertically at the top of the viewport/widget, etc. + ,ptAxisRectRatio ///< Static positioning given by a fraction of the axis rect size (see \ref setAxisRect). For example, if you call setCoords(0, 0), the position will be at the top + ///< left corner of the axis rect. setCoords(1, 1) will be at the bottom right corner, setCoords(0.5, 0) will be horizontally centered and + ///< vertically at the top of the axis rect, etc. You can also go beyond the axis rect by providing negative coordinates or coordinates larger than 1. ,ptPlotCoords ///< Dynamic positioning at a plot coordinate defined by two axes (see \ref setAxes). }; @@ -1406,8 +1586,8 @@ /// \cond INCLUDE_QPROPERTIES Q_PROPERTY(bool clipToAxisRect READ clipToAxisRect WRITE setClipToAxisRect) Q_PROPERTY(QCPAxisRect* clipAxisRect READ clipAxisRect WRITE setClipAxisRect) - Q_PROPERTY(bool selectable READ selectable WRITE setSelectable) - Q_PROPERTY(bool selected READ selected WRITE setSelected) + Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectableChanged) + Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectionChanged) /// \endcond public: QCPAbstractItem(QCustomPlot *parentPlot); @@ -1422,8 +1602,8 @@ // setters: void setClipToAxisRect(bool clip); void setClipAxisRect(QCPAxisRect *rect); - void setSelectable(bool selectable); - void setSelected(bool selected); + Q_SLOT void setSelectable(bool selectable); + Q_SLOT void setSelected(bool selected); // reimplemented virtual methods: virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const = 0; @@ -1437,6 +1617,7 @@ signals: void selectionChanged(bool selected); + void selectableChanged(bool selectable); protected: // property members: @@ -1497,6 +1678,16 @@ }; Q_ENUMS(LayerInsertMode) + /*! + Defines with what timing the QCustomPlot surface is refreshed after a replot. + + \see replot + */ + enum RefreshPriority { rpImmediate ///< The QCustomPlot surface is immediately refreshed, by calling QWidget::repaint() after the replot + ,rpQueued ///< Queues the refresh such that it is performed at a slightly delayed point in time after the replot, by calling QWidget::update() after the replot + ,rpHint ///< Whether to use immediate repaint or queued update depends on whether the plotting hint \ref QCP::phForceRepaint is set, see \ref setPlottingHints. + }; + explicit QCustomPlot(QWidget *parent = 0); virtual ~QCustomPlot(); @@ -1592,14 +1783,14 @@ QList selectedLegends() const; Q_SLOT void deselectAll(); - bool savePdf(const QString &fileName, bool noCosmeticPen=false, int width=0, int height=0); + bool savePdf(const QString &fileName, bool noCosmeticPen=false, int width=0, int height=0, const QString &pdfCreator="", const QString &pdfTitle=""); bool savePng(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1); bool saveJpg(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1); bool saveBmp(const QString &fileName, int width=0, int height=0, double scale=1.0); bool saveRastered(const QString &fileName, int width, int height, double scale, const char *format, int quality=-1); QPixmap toPixmap(int width=0, int height=0, double scale=1.0); void toPainter(QCPPainter *painter, int width=0, int height=0); - Q_SLOT void replot(); + Q_SLOT void replot(QCustomPlot::RefreshPriority refreshPriority=QCustomPlot::rpHint); QCPAxis *xAxis, *yAxis, *xAxis2, *yAxis2; QCPLegend *legend; @@ -1651,7 +1842,7 @@ // non-property members: QPixmap mPaintBuffer; QPoint mMousePressPos; - QCPLayoutElement *mMouseEventElement; + QPointer mMouseEventElement; bool mReplotting; // reimplemented virtual methods: @@ -1682,179 +1873,748 @@ }; -/*! \file */ - - - -class QCP_LIB_DECL QCPData -{ -public: - QCPData(); - QCPData(double key, double value); - double key, value; - double keyErrorPlus, keyErrorMinus; - double valueErrorPlus, valueErrorMinus; -}; -Q_DECLARE_TYPEINFO(QCPData, Q_MOVABLE_TYPE); - -/*! \typedef QCPDataMap - Container for storing QCPData items in a sorted fashion. The key of the map - is the key member of the QCPData instance. - - This is the container in which QCPGraph holds its data. - \see QCPData, QCPGraph::setData -*/ -typedef QMap QCPDataMap; -typedef QMapIterator QCPDataMapIterator; -typedef QMutableMapIterator QCPDataMutableMapIterator; - - -class QCP_LIB_DECL QCPGraph : public QCPAbstractPlottable +class QCP_LIB_DECL QCPColorGradient { - Q_OBJECT - /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY(LineStyle lineStyle READ lineStyle WRITE setLineStyle) - Q_PROPERTY(QCPScatterStyle scatterStyle READ scatterStyle WRITE setScatterStyle) - Q_PROPERTY(ErrorType errorType READ errorType WRITE setErrorType) - Q_PROPERTY(QPen errorPen READ errorPen WRITE setErrorPen) - Q_PROPERTY(double errorBarSize READ errorBarSize WRITE setErrorBarSize) - Q_PROPERTY(bool errorBarSkipSymbol READ errorBarSkipSymbol WRITE setErrorBarSkipSymbol) - Q_PROPERTY(QCPGraph* channelFillGraph READ channelFillGraph WRITE setChannelFillGraph) - /// \endcond + Q_GADGET public: /*! - Defines how the graph's line is represented visually in the plot. The line is drawn with the - current pen of the graph (\ref setPen). - \see setLineStyle + Defines the color spaces in which color interpolation between gradient stops can be performed. + + \see setColorInterpolation */ - enum LineStyle { lsNone ///< data points are not connected with any lines (e.g. data only represented - ///< with symbols according to the scatter style, see \ref setScatterStyle) - ,lsLine ///< data points are connected by a straight line - ,lsStepLeft ///< line is drawn as steps where the step height is the value of the left data point - ,lsStepRight ///< line is drawn as steps where the step height is the value of the right data point - ,lsStepCenter ///< line is drawn as steps where the step is in between two data points - ,lsImpulse ///< each data point is represented by a line parallel to the value axis, which reaches from the data point to the zero-value-line - }; - Q_ENUMS(LineStyle) + enum ColorInterpolation { ciRGB ///< Color channels red, green and blue are linearly interpolated + ,ciHSV ///< Color channels hue, saturation and value are linearly interpolated (The hue is interpolated over the shortest angle distance) + }; + Q_ENUMS(ColorInterpolation) + /*! - Defines what kind of error bars are drawn for each data point + Defines the available presets that can be loaded with \ref loadPreset. See the documentation + there for an image of the presets. */ - enum ErrorType { etNone ///< No error bars are shown - ,etKey ///< Error bars for the key dimension of the data point are shown - ,etValue ///< Error bars for the value dimension of the data point are shown - ,etBoth ///< Error bars for both key and value dimensions of the data point are shown - }; - Q_ENUMS(ErrorType) + enum GradientPreset { gpGrayscale ///< Continuous lightness from black to white (suited for non-biased data representation) + ,gpHot ///< Continuous lightness from black over firey colors to white (suited for non-biased data representation) + ,gpCold ///< Continuous lightness from black over icey colors to white (suited for non-biased data representation) + ,gpNight ///< Continuous lightness from black over weak blueish colors to white (suited for non-biased data representation) + ,gpCandy ///< Blue over pink to white + ,gpGeography ///< Colors suitable to represent different elevations on geographical maps + ,gpIon ///< Half hue spectrum from black over purple to blue and finally green (creates banding illusion but allows more precise magnitude estimates) + ,gpThermal ///< Colors suitable for thermal imaging, ranging from dark blue over purple to orange, yellow and white + ,gpPolar ///< Colors suitable to emphasize polarity around the center, with blue for negative, black in the middle and red for positive values + ,gpSpectrum ///< An approximation of the visible light spectrum (creates banding illusion but allows more precise magnitude estimates) + ,gpJet ///< Hue variation similar to a spectrum, often used in numerical visualization (creates banding illusion but allows more precise magnitude estimates) + ,gpHues ///< Full hue cycle, with highest and lowest color red (suitable for periodic data, such as angles and phases, see \ref setPeriodic) + }; + Q_ENUMS(GradientPreset) - explicit QCPGraph(QCPAxis *keyAxis, QCPAxis *valueAxis); - virtual ~QCPGraph(); + QCPColorGradient(GradientPreset preset=gpCold); + bool operator==(const QCPColorGradient &other) const; + bool operator!=(const QCPColorGradient &other) const { return !(*this == other); } // getters: - const QCPDataMap *data() const { return mData; } - LineStyle lineStyle() const { return mLineStyle; } - QCPScatterStyle scatterStyle() const { return mScatterStyle; } - ErrorType errorType() const { return mErrorType; } - QPen errorPen() const { return mErrorPen; } - double errorBarSize() const { return mErrorBarSize; } - bool errorBarSkipSymbol() const { return mErrorBarSkipSymbol; } - QCPGraph *channelFillGraph() const { return mChannelFillGraph.data(); } + int levelCount() const { return mLevelCount; } + QMap colorStops() const { return mColorStops; } + ColorInterpolation colorInterpolation() const { return mColorInterpolation; } + bool periodic() const { return mPeriodic; } // setters: - void setData(QCPDataMap *data, bool copy=false); - void setData(const QVector &key, const QVector &value); - void setDataKeyError(const QVector &key, const QVector &value, const QVector &keyError); - void setDataKeyError(const QVector &key, const QVector &value, const QVector &keyErrorMinus, const QVector &keyErrorPlus); - void setDataValueError(const QVector &key, const QVector &value, const QVector &valueError); - void setDataValueError(const QVector &key, const QVector &value, const QVector &valueErrorMinus, const QVector &valueErrorPlus); - void setDataBothError(const QVector &key, const QVector &value, const QVector &keyError, const QVector &valueError); - void setDataBothError(const QVector &key, const QVector &value, const QVector &keyErrorMinus, const QVector &keyErrorPlus, const QVector &valueErrorMinus, const QVector &valueErrorPlus); - void setLineStyle(LineStyle ls); - void setScatterStyle(const QCPScatterStyle &style); - void setErrorType(ErrorType errorType); - void setErrorPen(const QPen &pen); - void setErrorBarSize(double size); - void setErrorBarSkipSymbol(bool enabled); - void setChannelFillGraph(QCPGraph *targetGraph); + void setLevelCount(int n); + void setColorStops(const QMap &colorStops); + void setColorStopAt(double position, const QColor &color); + void setColorInterpolation(ColorInterpolation interpolation); + void setPeriodic(bool enabled); // non-property methods: - void addData(const QCPDataMap &dataMap); - void addData(const QCPData &data); - void addData(double key, double value); - void addData(const QVector &keys, const QVector &values); - void removeDataBefore(double key); - void removeDataAfter(double key); - void removeData(double fromKey, double toKey); - void removeData(double key); - - // reimplemented virtual methods: - virtual void clearData(); - virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; - using QCPAbstractPlottable::rescaleAxes; - using QCPAbstractPlottable::rescaleKeyAxis; - using QCPAbstractPlottable::rescaleValueAxis; - void rescaleAxes(bool onlyEnlarge, bool includeErrorBars) const; // overloads base class interface - void rescaleKeyAxis(bool onlyEnlarge, bool includeErrorBars) const; // overloads base class interface - void rescaleValueAxis(bool onlyEnlarge, bool includeErrorBars) const; // overloads base class interface + void colorize(const double *data, const QCPRange &range, QRgb *scanLine, int n, int dataIndexFactor=1, bool logarithmic=false); + QRgb color(double position, const QCPRange &range, bool logarithmic=false); + void loadPreset(GradientPreset preset); + void clearColorStops(); + QCPColorGradient inverted() const; protected: - // property members: - QCPDataMap *mData; - QPen mErrorPen; - LineStyle mLineStyle; - QCPScatterStyle mScatterStyle; - ErrorType mErrorType; - double mErrorBarSize; - bool mErrorBarSkipSymbol; - QPointer mChannelFillGraph; - - // reimplemented virtual methods: - virtual void draw(QCPPainter *painter); - virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const; - virtual QCPRange getKeyRange(bool &validRange, SignDomain inSignDomain=sdBoth) const; - virtual QCPRange getValueRange(bool &validRange, SignDomain inSignDomain=sdBoth) const; - virtual QCPRange getKeyRange(bool &validRange, SignDomain inSignDomain, bool includeErrors) const; // overloads base class interface - virtual QCPRange getValueRange(bool &validRange, SignDomain inSignDomain, bool includeErrors) const; // overloads base class interface - - // introduced virtual methods: - virtual void drawFill(QCPPainter *painter, QVector *lineData) const; - virtual void drawScatterPlot(QCPPainter *painter, QVector *pointData) const; - virtual void drawLinePlot(QCPPainter *painter, QVector *lineData) const; - virtual void drawImpulsePlot(QCPPainter *painter, QVector *lineData) const; + void updateColorBuffer(); - // non-virtual methods: - void getPlotData(QVector *lineData, QVector *pointData) const; - void getScatterPlotData(QVector *pointData) const; - void getLinePlotData(QVector *lineData, QVector *pointData) const; - void getStepLeftPlotData(QVector *lineData, QVector *pointData) const; - void getStepRightPlotData(QVector *lineData, QVector *pointData) const; - void getStepCenterPlotData(QVector *lineData, QVector *pointData) const; - void getImpulsePlotData(QVector *lineData, QVector *pointData) const; - void drawError(QCPPainter *painter, double x, double y, const QCPData &data) const; - void getVisibleDataBounds(QCPDataMap::const_iterator &lower, QCPDataMap::const_iterator &upper, int &count) const; - void addFillBasePoints(QVector *lineData) const; - void removeFillBasePoints(QVector *lineData) const; - QPointF lowerFillBasePoint(double lowerKey) const; - QPointF upperFillBasePoint(double upperKey) const; - const QPolygonF getChannelFillPolygon(const QVector *lineData) const; - int findIndexBelowX(const QVector *data, double x) const; - int findIndexAboveX(const QVector *data, double x) const; - int findIndexBelowY(const QVector *data, double y) const; - int findIndexAboveY(const QVector *data, double y) const; - double pointDistance(const QPointF &pixelPoint) const; + // property members: + int mLevelCount; + QMap mColorStops; + ColorInterpolation mColorInterpolation; + bool mPeriodic; - friend class QCustomPlot; - friend class QCPLegend; + // non-property members: + QVector mColorBuffer; + bool mColorBufferInvalidated; }; -/*! \file */ - - - -class QCP_LIB_DECL QCPCurveData +class QCP_LIB_DECL QCPAxisRect : public QCPLayoutElement { -public: - QCPCurveData(); + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(QPixmap background READ background WRITE setBackground) + Q_PROPERTY(bool backgroundScaled READ backgroundScaled WRITE setBackgroundScaled) + Q_PROPERTY(Qt::AspectRatioMode backgroundScaledMode READ backgroundScaledMode WRITE setBackgroundScaledMode) + Q_PROPERTY(Qt::Orientations rangeDrag READ rangeDrag WRITE setRangeDrag) + Q_PROPERTY(Qt::Orientations rangeZoom READ rangeZoom WRITE setRangeZoom) + /// \endcond +public: + explicit QCPAxisRect(QCustomPlot *parentPlot, bool setupDefaultAxes=true); + virtual ~QCPAxisRect(); + + // getters: + QPixmap background() const { return mBackgroundPixmap; } + bool backgroundScaled() const { return mBackgroundScaled; } + Qt::AspectRatioMode backgroundScaledMode() const { return mBackgroundScaledMode; } + Qt::Orientations rangeDrag() const { return mRangeDrag; } + Qt::Orientations rangeZoom() const { return mRangeZoom; } + QCPAxis *rangeDragAxis(Qt::Orientation orientation); + QCPAxis *rangeZoomAxis(Qt::Orientation orientation); + double rangeZoomFactor(Qt::Orientation orientation); + + // setters: + void setBackground(const QPixmap &pm); + void setBackground(const QPixmap &pm, bool scaled, Qt::AspectRatioMode mode=Qt::KeepAspectRatioByExpanding); + void setBackground(const QBrush &brush); + void setBackgroundScaled(bool scaled); + void setBackgroundScaledMode(Qt::AspectRatioMode mode); + void setRangeDrag(Qt::Orientations orientations); + void setRangeZoom(Qt::Orientations orientations); + void setRangeDragAxes(QCPAxis *horizontal, QCPAxis *vertical); + void setRangeZoomAxes(QCPAxis *horizontal, QCPAxis *vertical); + void setRangeZoomFactor(double horizontalFactor, double verticalFactor); + void setRangeZoomFactor(double factor); + + // non-property methods: + int axisCount(QCPAxis::AxisType type) const; + QCPAxis *axis(QCPAxis::AxisType type, int index=0) const; + QList axes(QCPAxis::AxisTypes types) const; + QList axes() const; + QCPAxis *addAxis(QCPAxis::AxisType type); + QList addAxes(QCPAxis::AxisTypes types); + bool removeAxis(QCPAxis *axis); + QCPLayoutInset *insetLayout() const { return mInsetLayout; } + + void setupFullAxesBox(bool connectRanges=false); + QList plottables() const; + QList graphs() const; + QList items() const; + + // read-only interface imitating a QRect: + int left() const { return mRect.left(); } + int right() const { return mRect.right(); } + int top() const { return mRect.top(); } + int bottom() const { return mRect.bottom(); } + int width() const { return mRect.width(); } + int height() const { return mRect.height(); } + QSize size() const { return mRect.size(); } + QPoint topLeft() const { return mRect.topLeft(); } + QPoint topRight() const { return mRect.topRight(); } + QPoint bottomLeft() const { return mRect.bottomLeft(); } + QPoint bottomRight() const { return mRect.bottomRight(); } + QPoint center() const { return mRect.center(); } + + // reimplemented virtual methods: + virtual void update(UpdatePhase phase); + virtual QList elements(bool recursive) const; + +protected: + // property members: + QBrush mBackgroundBrush; + QPixmap mBackgroundPixmap; + QPixmap mScaledBackgroundPixmap; + bool mBackgroundScaled; + Qt::AspectRatioMode mBackgroundScaledMode; + QCPLayoutInset *mInsetLayout; + Qt::Orientations mRangeDrag, mRangeZoom; + QPointer mRangeDragHorzAxis, mRangeDragVertAxis, mRangeZoomHorzAxis, mRangeZoomVertAxis; + double mRangeZoomFactorHorz, mRangeZoomFactorVert; + // non-property members: + QCPRange mDragStartHorzRange, mDragStartVertRange; + QCP::AntialiasedElements mAADragBackup, mNotAADragBackup; + QPoint mDragStart; + bool mDragging; + QHash > mAxes; + + // reimplemented virtual methods: + virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const; + virtual void draw(QCPPainter *painter); + virtual int calculateAutoMargin(QCP::MarginSide side); + // events: + virtual void mousePressEvent(QMouseEvent *event); + virtual void mouseMoveEvent(QMouseEvent *event); + virtual void mouseReleaseEvent(QMouseEvent *event); + virtual void wheelEvent(QWheelEvent *event); + + // non-property methods: + void drawBackground(QCPPainter *painter); + void updateAxesOffset(QCPAxis::AxisType type); + +private: + Q_DISABLE_COPY(QCPAxisRect) + + friend class QCustomPlot; +}; + + +class QCP_LIB_DECL QCPAbstractLegendItem : public QCPLayoutElement +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(QCPLegend* parentLegend READ parentLegend) + Q_PROPERTY(QFont font READ font WRITE setFont) + Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor) + Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont) + Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor) + Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectionChanged) + Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectableChanged) + /// \endcond +public: + explicit QCPAbstractLegendItem(QCPLegend *parent); + + // getters: + QCPLegend *parentLegend() const { return mParentLegend; } + QFont font() const { return mFont; } + QColor textColor() const { return mTextColor; } + QFont selectedFont() const { return mSelectedFont; } + QColor selectedTextColor() const { return mSelectedTextColor; } + bool selectable() const { return mSelectable; } + bool selected() const { return mSelected; } + + // setters: + void setFont(const QFont &font); + void setTextColor(const QColor &color); + void setSelectedFont(const QFont &font); + void setSelectedTextColor(const QColor &color); + Q_SLOT void setSelectable(bool selectable); + Q_SLOT void setSelected(bool selected); + + // reimplemented virtual methods: + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; + +signals: + void selectionChanged(bool selected); + void selectableChanged(bool selectable); + +protected: + // property members: + QCPLegend *mParentLegend; + QFont mFont; + QColor mTextColor; + QFont mSelectedFont; + QColor mSelectedTextColor; + bool mSelectable, mSelected; + + // reimplemented virtual methods: + virtual QCP::Interaction selectionCategory() const; + virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const; + virtual QRect clipRect() const; + virtual void draw(QCPPainter *painter) = 0; + // events: + virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged); + virtual void deselectEvent(bool *selectionStateChanged); + +private: + Q_DISABLE_COPY(QCPAbstractLegendItem) + + friend class QCPLegend; +}; + + +class QCP_LIB_DECL QCPPlottableLegendItem : public QCPAbstractLegendItem +{ + Q_OBJECT +public: + QCPPlottableLegendItem(QCPLegend *parent, QCPAbstractPlottable *plottable); + + // getters: + QCPAbstractPlottable *plottable() { return mPlottable; } + +protected: + // property members: + QCPAbstractPlottable *mPlottable; + + // reimplemented virtual methods: + virtual void draw(QCPPainter *painter); + virtual QSize minimumSizeHint() const; + + // non-virtual methods: + QPen getIconBorderPen() const; + QColor getTextColor() const; + QFont getFont() const; +}; + + +class QCP_LIB_DECL QCPLegend : public QCPLayoutGrid +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(QPen borderPen READ borderPen WRITE setBorderPen) + Q_PROPERTY(QBrush brush READ brush WRITE setBrush) + Q_PROPERTY(QFont font READ font WRITE setFont) + Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor) + Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize) + Q_PROPERTY(int iconTextPadding READ iconTextPadding WRITE setIconTextPadding) + Q_PROPERTY(QPen iconBorderPen READ iconBorderPen WRITE setIconBorderPen) + Q_PROPERTY(SelectableParts selectableParts READ selectableParts WRITE setSelectableParts NOTIFY selectionChanged) + Q_PROPERTY(SelectableParts selectedParts READ selectedParts WRITE setSelectedParts NOTIFY selectableChanged) + Q_PROPERTY(QPen selectedBorderPen READ selectedBorderPen WRITE setSelectedBorderPen) + Q_PROPERTY(QPen selectedIconBorderPen READ selectedIconBorderPen WRITE setSelectedIconBorderPen) + Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush) + Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont) + Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor) + /// \endcond +public: + /*! + Defines the selectable parts of a legend + + \see setSelectedParts, setSelectableParts + */ + enum SelectablePart { spNone = 0x000 ///< 0x000 None + ,spLegendBox = 0x001 ///< 0x001 The legend box (frame) + ,spItems = 0x002 ///< 0x002 Legend items individually (see \ref selectedItems) + }; + Q_FLAGS(SelectablePart SelectableParts) + Q_DECLARE_FLAGS(SelectableParts, SelectablePart) + + explicit QCPLegend(); + virtual ~QCPLegend(); + + // getters: + QPen borderPen() const { return mBorderPen; } + QBrush brush() const { return mBrush; } + QFont font() const { return mFont; } + QColor textColor() const { return mTextColor; } + QSize iconSize() const { return mIconSize; } + int iconTextPadding() const { return mIconTextPadding; } + QPen iconBorderPen() const { return mIconBorderPen; } + SelectableParts selectableParts() const { return mSelectableParts; } + SelectableParts selectedParts() const; + QPen selectedBorderPen() const { return mSelectedBorderPen; } + QPen selectedIconBorderPen() const { return mSelectedIconBorderPen; } + QBrush selectedBrush() const { return mSelectedBrush; } + QFont selectedFont() const { return mSelectedFont; } + QColor selectedTextColor() const { return mSelectedTextColor; } + + // setters: + void setBorderPen(const QPen &pen); + void setBrush(const QBrush &brush); + void setFont(const QFont &font); + void setTextColor(const QColor &color); + void setIconSize(const QSize &size); + void setIconSize(int width, int height); + void setIconTextPadding(int padding); + void setIconBorderPen(const QPen &pen); + Q_SLOT void setSelectableParts(const SelectableParts &selectableParts); + Q_SLOT void setSelectedParts(const SelectableParts &selectedParts); + void setSelectedBorderPen(const QPen &pen); + void setSelectedIconBorderPen(const QPen &pen); + void setSelectedBrush(const QBrush &brush); + void setSelectedFont(const QFont &font); + void setSelectedTextColor(const QColor &color); + + // reimplemented virtual methods: + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; + + // non-virtual methods: + QCPAbstractLegendItem *item(int index) const; + QCPPlottableLegendItem *itemWithPlottable(const QCPAbstractPlottable *plottable) const; + int itemCount() const; + bool hasItem(QCPAbstractLegendItem *item) const; + bool hasItemWithPlottable(const QCPAbstractPlottable *plottable) const; + bool addItem(QCPAbstractLegendItem *item); + bool removeItem(int index); + bool removeItem(QCPAbstractLegendItem *item); + void clearItems(); + QList selectedItems() const; + +signals: + void selectionChanged(QCPLegend::SelectableParts parts); + void selectableChanged(QCPLegend::SelectableParts parts); + +protected: + // property members: + QPen mBorderPen, mIconBorderPen; + QBrush mBrush; + QFont mFont; + QColor mTextColor; + QSize mIconSize; + int mIconTextPadding; + SelectableParts mSelectedParts, mSelectableParts; + QPen mSelectedBorderPen, mSelectedIconBorderPen; + QBrush mSelectedBrush; + QFont mSelectedFont; + QColor mSelectedTextColor; + + // reimplemented virtual methods: + virtual void parentPlotInitialized(QCustomPlot *parentPlot); + virtual QCP::Interaction selectionCategory() const; + virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const; + virtual void draw(QCPPainter *painter); + // events: + virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged); + virtual void deselectEvent(bool *selectionStateChanged); + + // non-virtual methods: + QPen getBorderPen() const; + QBrush getBrush() const; + +private: + Q_DISABLE_COPY(QCPLegend) + + friend class QCustomPlot; + friend class QCPAbstractLegendItem; +}; +Q_DECLARE_OPERATORS_FOR_FLAGS(QCPLegend::SelectableParts) +Q_DECLARE_METATYPE(QCPLegend::SelectablePart) + + +class QCP_LIB_DECL QCPPlotTitle : public QCPLayoutElement +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(QString text READ text WRITE setText) + Q_PROPERTY(QFont font READ font WRITE setFont) + Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor) + Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont) + Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor) + Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectableChanged) + Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectionChanged) + /// \endcond +public: + explicit QCPPlotTitle(QCustomPlot *parentPlot); + explicit QCPPlotTitle(QCustomPlot *parentPlot, const QString &text); + + // getters: + QString text() const { return mText; } + QFont font() const { return mFont; } + QColor textColor() const { return mTextColor; } + QFont selectedFont() const { return mSelectedFont; } + QColor selectedTextColor() const { return mSelectedTextColor; } + bool selectable() const { return mSelectable; } + bool selected() const { return mSelected; } + + // setters: + void setText(const QString &text); + void setFont(const QFont &font); + void setTextColor(const QColor &color); + void setSelectedFont(const QFont &font); + void setSelectedTextColor(const QColor &color); + Q_SLOT void setSelectable(bool selectable); + Q_SLOT void setSelected(bool selected); + + // reimplemented virtual methods: + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; + +signals: + void selectionChanged(bool selected); + void selectableChanged(bool selectable); + +protected: + // property members: + QString mText; + QFont mFont; + QColor mTextColor; + QFont mSelectedFont; + QColor mSelectedTextColor; + QRect mTextBoundingRect; + bool mSelectable, mSelected; + + // reimplemented virtual methods: + virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const; + virtual void draw(QCPPainter *painter); + virtual QSize minimumSizeHint() const; + virtual QSize maximumSizeHint() const; + // events: + virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged); + virtual void deselectEvent(bool *selectionStateChanged); + + // non-virtual methods: + QFont mainFont() const; + QColor mainTextColor() const; + +private: + Q_DISABLE_COPY(QCPPlotTitle) +}; + + +class QCPColorScaleAxisRectPrivate : public QCPAxisRect +{ + Q_OBJECT +public: + explicit QCPColorScaleAxisRectPrivate(QCPColorScale *parentColorScale); +protected: + QCPColorScale *mParentColorScale; + QImage mGradientImage; + bool mGradientImageInvalidated; + // re-using some methods of QCPAxisRect to make them available to friend class QCPColorScale + using QCPAxisRect::calculateAutoMargin; + using QCPAxisRect::mousePressEvent; + using QCPAxisRect::mouseMoveEvent; + using QCPAxisRect::mouseReleaseEvent; + using QCPAxisRect::wheelEvent; + using QCPAxisRect::update; + virtual void draw(QCPPainter *painter); + void updateGradientImage(); + Q_SLOT void axisSelectionChanged(QCPAxis::SelectableParts selectedParts); + Q_SLOT void axisSelectableChanged(QCPAxis::SelectableParts selectableParts); + friend class QCPColorScale; +}; + + +class QCP_LIB_DECL QCPColorScale : public QCPLayoutElement +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(QCPAxis::AxisType type READ type WRITE setType) + Q_PROPERTY(QCPRange dataRange READ dataRange WRITE setDataRange NOTIFY dataRangeChanged) + Q_PROPERTY(QCPAxis::ScaleType dataScaleType READ dataScaleType WRITE setDataScaleType NOTIFY dataScaleTypeChanged) + Q_PROPERTY(QCPColorGradient gradient READ gradient WRITE setGradient NOTIFY gradientChanged) + Q_PROPERTY(QString label READ label WRITE setLabel) + Q_PROPERTY(int barWidth READ barWidth WRITE setBarWidth) + Q_PROPERTY(bool rangeDrag READ rangeDrag WRITE setRangeDrag) + Q_PROPERTY(bool rangeZoom READ rangeZoom WRITE setRangeZoom) + /// \endcond +public: + explicit QCPColorScale(QCustomPlot *parentPlot); + virtual ~QCPColorScale(); + + // getters: + QCPAxis *axis() const { return mColorAxis.data(); } + QCPAxis::AxisType type() const { return mType; } + QCPRange dataRange() const { return mDataRange; } + QCPAxis::ScaleType dataScaleType() const { return mDataScaleType; } + QCPColorGradient gradient() const { return mGradient; } + QString label() const; + int barWidth () const { return mBarWidth; } + bool rangeDrag() const; + bool rangeZoom() const; + + // setters: + void setType(QCPAxis::AxisType type); + Q_SLOT void setDataRange(const QCPRange &dataRange); + Q_SLOT void setDataScaleType(QCPAxis::ScaleType scaleType); + Q_SLOT void setGradient(const QCPColorGradient &gradient); + void setLabel(const QString &str); + void setBarWidth(int width); + void setRangeDrag(bool enabled); + void setRangeZoom(bool enabled); + + // non-property methods: + QList colorMaps() const; + void rescaleDataRange(bool onlyVisibleMaps); + + // reimplemented virtual methods: + virtual void update(UpdatePhase phase); + +signals: + void dataRangeChanged(QCPRange newRange); + void dataScaleTypeChanged(QCPAxis::ScaleType scaleType); + void gradientChanged(QCPColorGradient newGradient); + +protected: + // property members: + QCPAxis::AxisType mType; + QCPRange mDataRange; + QCPAxis::ScaleType mDataScaleType; + QCPColorGradient mGradient; + int mBarWidth; + + // non-property members: + QPointer mAxisRect; + QPointer mColorAxis; + + // reimplemented virtual methods: + virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const; + // events: + virtual void mousePressEvent(QMouseEvent *event); + virtual void mouseMoveEvent(QMouseEvent *event); + virtual void mouseReleaseEvent(QMouseEvent *event); + virtual void wheelEvent(QWheelEvent *event); + +private: + Q_DISABLE_COPY(QCPColorScale) + + friend class QCPColorScaleAxisRectPrivate; +}; + + +/*! \file */ + + + +class QCP_LIB_DECL QCPData +{ +public: + QCPData(); + QCPData(double key, double value); + double key, value; + double keyErrorPlus, keyErrorMinus; + double valueErrorPlus, valueErrorMinus; +}; +Q_DECLARE_TYPEINFO(QCPData, Q_MOVABLE_TYPE); + +/*! \typedef QCPDataMap + Container for storing QCPData items in a sorted fashion. The key of the map + is the key member of the QCPData instance. + + This is the container in which QCPGraph holds its data. + \see QCPData, QCPGraph::setData +*/ +typedef QMap QCPDataMap; +typedef QMapIterator QCPDataMapIterator; +typedef QMutableMapIterator QCPDataMutableMapIterator; + + +class QCP_LIB_DECL QCPGraph : public QCPAbstractPlottable +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(LineStyle lineStyle READ lineStyle WRITE setLineStyle) + Q_PROPERTY(QCPScatterStyle scatterStyle READ scatterStyle WRITE setScatterStyle) + Q_PROPERTY(ErrorType errorType READ errorType WRITE setErrorType) + Q_PROPERTY(QPen errorPen READ errorPen WRITE setErrorPen) + Q_PROPERTY(double errorBarSize READ errorBarSize WRITE setErrorBarSize) + Q_PROPERTY(bool errorBarSkipSymbol READ errorBarSkipSymbol WRITE setErrorBarSkipSymbol) + Q_PROPERTY(QCPGraph* channelFillGraph READ channelFillGraph WRITE setChannelFillGraph) + Q_PROPERTY(bool adaptiveSampling READ adaptiveSampling WRITE setAdaptiveSampling) + /// \endcond +public: + /*! + Defines how the graph's line is represented visually in the plot. The line is drawn with the + current pen of the graph (\ref setPen). + \see setLineStyle + */ + enum LineStyle { lsNone ///< data points are not connected with any lines (e.g. data only represented + ///< with symbols according to the scatter style, see \ref setScatterStyle) + ,lsLine ///< data points are connected by a straight line + ,lsStepLeft ///< line is drawn as steps where the step height is the value of the left data point + ,lsStepRight ///< line is drawn as steps where the step height is the value of the right data point + ,lsStepCenter ///< line is drawn as steps where the step is in between two data points + ,lsImpulse ///< each data point is represented by a line parallel to the value axis, which reaches from the data point to the zero-value-line + }; + Q_ENUMS(LineStyle) + /*! + Defines what kind of error bars are drawn for each data point + */ + enum ErrorType { etNone ///< No error bars are shown + ,etKey ///< Error bars for the key dimension of the data point are shown + ,etValue ///< Error bars for the value dimension of the data point are shown + ,etBoth ///< Error bars for both key and value dimensions of the data point are shown + }; + Q_ENUMS(ErrorType) + + explicit QCPGraph(QCPAxis *keyAxis, QCPAxis *valueAxis); + virtual ~QCPGraph(); + + // getters: + QCPDataMap *data() const { return mData; } + LineStyle lineStyle() const { return mLineStyle; } + QCPScatterStyle scatterStyle() const { return mScatterStyle; } + ErrorType errorType() const { return mErrorType; } + QPen errorPen() const { return mErrorPen; } + double errorBarSize() const { return mErrorBarSize; } + bool errorBarSkipSymbol() const { return mErrorBarSkipSymbol; } + QCPGraph *channelFillGraph() const { return mChannelFillGraph.data(); } + bool adaptiveSampling() const { return mAdaptiveSampling; } + + // setters: + void setData(QCPDataMap *data, bool copy=false); + void setData(const QVector &key, const QVector &value); + void setDataKeyError(const QVector &key, const QVector &value, const QVector &keyError); + void setDataKeyError(const QVector &key, const QVector &value, const QVector &keyErrorMinus, const QVector &keyErrorPlus); + void setDataValueError(const QVector &key, const QVector &value, const QVector &valueError); + void setDataValueError(const QVector &key, const QVector &value, const QVector &valueErrorMinus, const QVector &valueErrorPlus); + void setDataBothError(const QVector &key, const QVector &value, const QVector &keyError, const QVector &valueError); + void setDataBothError(const QVector &key, const QVector &value, const QVector &keyErrorMinus, const QVector &keyErrorPlus, const QVector &valueErrorMinus, const QVector &valueErrorPlus); + void setLineStyle(LineStyle ls); + void setScatterStyle(const QCPScatterStyle &style); + void setErrorType(ErrorType errorType); + void setErrorPen(const QPen &pen); + void setErrorBarSize(double size); + void setErrorBarSkipSymbol(bool enabled); + void setChannelFillGraph(QCPGraph *targetGraph); + void setAdaptiveSampling(bool enabled); + + // non-property methods: + void addData(const QCPDataMap &dataMap); + void addData(const QCPData &data); + void addData(double key, double value); + void addData(const QVector &keys, const QVector &values); + void removeDataBefore(double key); + void removeDataAfter(double key); + void removeData(double fromKey, double toKey); + void removeData(double key); + + // reimplemented virtual methods: + virtual void clearData(); + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; + using QCPAbstractPlottable::rescaleAxes; + using QCPAbstractPlottable::rescaleKeyAxis; + using QCPAbstractPlottable::rescaleValueAxis; + void rescaleAxes(bool onlyEnlarge, bool includeErrorBars) const; // overloads base class interface + void rescaleKeyAxis(bool onlyEnlarge, bool includeErrorBars) const; // overloads base class interface + void rescaleValueAxis(bool onlyEnlarge, bool includeErrorBars) const; // overloads base class interface + +protected: + // property members: + QCPDataMap *mData; + QPen mErrorPen; + LineStyle mLineStyle; + QCPScatterStyle mScatterStyle; + ErrorType mErrorType; + double mErrorBarSize; + bool mErrorBarSkipSymbol; + QPointer mChannelFillGraph; + bool mAdaptiveSampling; + + // reimplemented virtual methods: + virtual void draw(QCPPainter *painter); + virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const; + virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const; + virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const; + virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain, bool includeErrors) const; // overloads base class interface + virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain, bool includeErrors) const; // overloads base class interface + + // introduced virtual methods: + virtual void drawFill(QCPPainter *painter, QVector *lineData) const; + virtual void drawScatterPlot(QCPPainter *painter, QVector *scatterData) const; + virtual void drawLinePlot(QCPPainter *painter, QVector *lineData) const; + virtual void drawImpulsePlot(QCPPainter *painter, QVector *lineData) const; + + // non-virtual methods: + void getPreparedData(QVector *lineData, QVector *scatterData) const; + void getPlotData(QVector *lineData, QVector *scatterData) const; + void getScatterPlotData(QVector *scatterData) const; + void getLinePlotData(QVector *linePixelData, QVector *scatterData) const; + void getStepLeftPlotData(QVector *linePixelData, QVector *scatterData) const; + void getStepRightPlotData(QVector *linePixelData, QVector *scatterData) const; + void getStepCenterPlotData(QVector *linePixelData, QVector *scatterData) const; + void getImpulsePlotData(QVector *linePixelData, QVector *scatterData) const; + void drawError(QCPPainter *painter, double x, double y, const QCPData &data) const; + void getVisibleDataBounds(QCPDataMap::const_iterator &lower, QCPDataMap::const_iterator &upper) const; + int countDataInBounds(const QCPDataMap::const_iterator &lower, const QCPDataMap::const_iterator &upper, int maxCount) const; + void addFillBasePoints(QVector *lineData) const; + void removeFillBasePoints(QVector *lineData) const; + QPointF lowerFillBasePoint(double lowerKey) const; + QPointF upperFillBasePoint(double upperKey) const; + const QPolygonF getChannelFillPolygon(const QVector *lineData) const; + int findIndexBelowX(const QVector *data, double x) const; + int findIndexAboveX(const QVector *data, double x) const; + int findIndexBelowY(const QVector *data, double y) const; + int findIndexAboveY(const QVector *data, double y) const; + double pointDistance(const QPointF &pixelPoint) const; + + friend class QCustomPlot; + friend class QCPLegend; +}; + + +/*! \file */ + + + +class QCP_LIB_DECL QCPCurveData +{ +public: + QCPCurveData(); QCPCurveData(double t, double key, double value); double t, key, value; }; @@ -1886,8 +2646,8 @@ current pen of the curve (\ref setPen). \see setLineStyle */ - enum LineStyle { lsNone, ///< No line is drawn between data points (e.g. only scatters) - lsLine ///< Data points are connected with a straight line + enum LineStyle { lsNone ///< No line is drawn between data points (e.g. only scatters) + ,lsLine ///< Data points are connected with a straight line }; explicit QCPCurve(QCPAxis *keyAxis, QCPAxis *valueAxis); virtual ~QCPCurve(); @@ -1928,8 +2688,8 @@ // reimplemented virtual methods: virtual void draw(QCPPainter *painter); virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const; - virtual QCPRange getKeyRange(bool &validRange, SignDomain inSignDomain=sdBoth) const; - virtual QCPRange getValueRange(bool &validRange, SignDomain inSignDomain=sdBoth) const; + virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const; + virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const; // introduced virtual methods: virtual void drawScatterPlot(QCPPainter *painter, const QVector *pointData) const; @@ -2017,8 +2777,8 @@ // reimplemented virtual methods: virtual void draw(QCPPainter *painter); virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const; - virtual QCPRange getKeyRange(bool &validRange, SignDomain inSignDomain=sdBoth) const; - virtual QCPRange getValueRange(bool &validRange, SignDomain inSignDomain=sdBoth) const; + virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const; + virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const; // non-virtual methods: QPolygonF getBarPolygon(double key, double value) const; @@ -2102,8 +2862,8 @@ // reimplemented virtual methods: virtual void draw(QCPPainter *painter); virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const; - virtual QCPRange getKeyRange(bool &validRange, SignDomain inSignDomain=sdBoth) const; - virtual QCPRange getValueRange(bool &validRange, SignDomain inSignDomain=sdBoth) const; + virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const; + virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const; // introduced virtual methods: virtual void drawQuartileBox(QCPPainter *painter, QRectF *quartileBox=0) const; @@ -2116,523 +2876,302 @@ }; -class QCP_LIB_DECL QCPItemStraightLine : public QCPAbstractItem -{ - Q_OBJECT - /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY(QPen pen READ pen WRITE setPen) - Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) - /// \endcond -public: - QCPItemStraightLine(QCustomPlot *parentPlot); - virtual ~QCPItemStraightLine(); - - // getters: - QPen pen() const { return mPen; } - QPen selectedPen() const { return mSelectedPen; } - - // setters; - void setPen(const QPen &pen); - void setSelectedPen(const QPen &pen); - - // reimplemented virtual methods: - virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; - - QCPItemPosition * const point1; - QCPItemPosition * const point2; - -protected: - // property members: - QPen mPen, mSelectedPen; - - // reimplemented virtual methods: - virtual void draw(QCPPainter *painter); - - // non-virtual methods: - double distToStraightLine(const QVector2D &point1, const QVector2D &vec, const QVector2D &point) const; - QLineF getRectClippedStraightLine(const QVector2D &point1, const QVector2D &vec, const QRect &rect) const; - QPen mainPen() const; -}; - - -class QCP_LIB_DECL QCPItemLine : public QCPAbstractItem -{ - Q_OBJECT - /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY(QPen pen READ pen WRITE setPen) - Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) - Q_PROPERTY(QCPLineEnding head READ head WRITE setHead) - Q_PROPERTY(QCPLineEnding tail READ tail WRITE setTail) - /// \endcond -public: - QCPItemLine(QCustomPlot *parentPlot); - virtual ~QCPItemLine(); - - // getters: - QPen pen() const { return mPen; } - QPen selectedPen() const { return mSelectedPen; } - QCPLineEnding head() const { return mHead; } - QCPLineEnding tail() const { return mTail; } - - // setters; - void setPen(const QPen &pen); - void setSelectedPen(const QPen &pen); - void setHead(const QCPLineEnding &head); - void setTail(const QCPLineEnding &tail); - - // reimplemented virtual methods: - virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; - - QCPItemPosition * const start; - QCPItemPosition * const end; - -protected: - // property members: - QPen mPen, mSelectedPen; - QCPLineEnding mHead, mTail; - - // reimplemented virtual methods: - virtual void draw(QCPPainter *painter); - - // non-virtual methods: - QLineF getRectClippedLine(const QVector2D &start, const QVector2D &end, const QRect &rect) const; - QPen mainPen() const; -}; - - -class QCP_LIB_DECL QCPItemCurve : public QCPAbstractItem -{ - Q_OBJECT - /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY(QPen pen READ pen WRITE setPen) - Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) - Q_PROPERTY(QCPLineEnding head READ head WRITE setHead) - Q_PROPERTY(QCPLineEnding tail READ tail WRITE setTail) - /// \endcond -public: - QCPItemCurve(QCustomPlot *parentPlot); - virtual ~QCPItemCurve(); - - // getters: - QPen pen() const { return mPen; } - QPen selectedPen() const { return mSelectedPen; } - QCPLineEnding head() const { return mHead; } - QCPLineEnding tail() const { return mTail; } - - // setters; - void setPen(const QPen &pen); - void setSelectedPen(const QPen &pen); - void setHead(const QCPLineEnding &head); - void setTail(const QCPLineEnding &tail); - - // reimplemented virtual methods: - virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; - - QCPItemPosition * const start; - QCPItemPosition * const startDir; - QCPItemPosition * const endDir; - QCPItemPosition * const end; - -protected: - // property members: - QPen mPen, mSelectedPen; - QCPLineEnding mHead, mTail; - - // reimplemented virtual methods: - virtual void draw(QCPPainter *painter); - - // non-virtual methods: - QPen mainPen() const; -}; - - -class QCP_LIB_DECL QCPItemRect : public QCPAbstractItem +class QCP_LIB_DECL QCPColorMapData { - Q_OBJECT - /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY(QPen pen READ pen WRITE setPen) - Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) - Q_PROPERTY(QBrush brush READ brush WRITE setBrush) - Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush) - /// \endcond public: - QCPItemRect(QCustomPlot *parentPlot); - virtual ~QCPItemRect(); - - // getters: - QPen pen() const { return mPen; } - QPen selectedPen() const { return mSelectedPen; } - QBrush brush() const { return mBrush; } - QBrush selectedBrush() const { return mSelectedBrush; } - - // setters; - void setPen(const QPen &pen); - void setSelectedPen(const QPen &pen); - void setBrush(const QBrush &brush); - void setSelectedBrush(const QBrush &brush); - - // reimplemented virtual methods: - virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; - - QCPItemPosition * const topLeft; - QCPItemPosition * const bottomRight; - QCPItemAnchor * const top; - QCPItemAnchor * const topRight; - QCPItemAnchor * const right; - QCPItemAnchor * const bottom; - QCPItemAnchor * const bottomLeft; - QCPItemAnchor * const left; - -protected: - enum AnchorIndex {aiTop, aiTopRight, aiRight, aiBottom, aiBottomLeft, aiLeft}; + QCPColorMapData(int keySize, int valueSize, const QCPRange &keyRange, const QCPRange &valueRange); + ~QCPColorMapData(); + QCPColorMapData(const QCPColorMapData &other); + QCPColorMapData &operator=(const QCPColorMapData &other); + + // getters: + int keySize() const { return mKeySize; } + int valueSize() const { return mValueSize; } + QCPRange keyRange() const { return mKeyRange; } + QCPRange valueRange() const { return mValueRange; } + QCPRange dataBounds() const { return mDataBounds; } + double data(double key, double value); + double cell(int keyIndex, int valueIndex); + + // setters: + void setSize(int keySize, int valueSize); + void setKeySize(int keySize); + void setValueSize(int valueSize); + void setRange(const QCPRange &keyRange, const QCPRange &valueRange); + void setKeyRange(const QCPRange &keyRange); + void setValueRange(const QCPRange &valueRange); + void setData(double key, double value, double z); + void setCell(int keyIndex, int valueIndex, double z); - // property members: - QPen mPen, mSelectedPen; - QBrush mBrush, mSelectedBrush; - - // reimplemented virtual methods: - virtual void draw(QCPPainter *painter); - virtual QPointF anchorPixelPoint(int anchorId) const; - - // non-virtual methods: - QPen mainPen() const; - QBrush mainBrush() const; -}; - - -class QCP_LIB_DECL QCPItemText : public QCPAbstractItem -{ - Q_OBJECT - /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(QColor selectedColor READ selectedColor WRITE setSelectedColor) - Q_PROPERTY(QPen pen READ pen WRITE setPen) - Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) - Q_PROPERTY(QBrush brush READ brush WRITE setBrush) - Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush) - Q_PROPERTY(QFont font READ font WRITE setFont) - Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont) - Q_PROPERTY(QString text READ text WRITE setText) - Q_PROPERTY(Qt::Alignment positionAlignment READ positionAlignment WRITE setPositionAlignment) - Q_PROPERTY(Qt::Alignment textAlignment READ textAlignment WRITE setTextAlignment) - Q_PROPERTY(double rotation READ rotation WRITE setRotation) - Q_PROPERTY(QMargins padding READ padding WRITE setPadding) + // non-property methods: + void recalculateDataBounds(); + void clear(); + void fill(double z); + bool isEmpty() const { return mIsEmpty; } + void coordToCell(double key, double value, int *keyIndex, int *valueIndex) const; + void cellToCoord(int keyIndex, int valueIndex, double *key, double *value) const; + +protected: + // property members: + int mKeySize, mValueSize; + QCPRange mKeyRange, mValueRange; + bool mIsEmpty; + // non-property members: + double *mData; + QCPRange mDataBounds; + bool mDataModified; + + friend class QCPColorMap; +}; + + +class QCP_LIB_DECL QCPColorMap : public QCPAbstractPlottable +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(QCPRange dataRange READ dataRange WRITE setDataRange NOTIFY dataRangeChanged) + Q_PROPERTY(QCPAxis::ScaleType dataScaleType READ dataScaleType WRITE setDataScaleType NOTIFY dataScaleTypeChanged) + Q_PROPERTY(QCPColorGradient gradient READ gradient WRITE setGradient NOTIFY gradientChanged) + Q_PROPERTY(bool interpolate READ interpolate WRITE setInterpolate) + Q_PROPERTY(bool tightBoundary READ tightBoundary WRITE setTightBoundary) + Q_PROPERTY(QCPColorScale* colorScale READ colorScale WRITE setColorScale) /// \endcond public: - QCPItemText(QCustomPlot *parentPlot); - virtual ~QCPItemText(); + explicit QCPColorMap(QCPAxis *keyAxis, QCPAxis *valueAxis); + virtual ~QCPColorMap(); // getters: - QColor color() const { return mColor; } - QColor selectedColor() const { return mSelectedColor; } - QPen pen() const { return mPen; } - QPen selectedPen() const { return mSelectedPen; } - QBrush brush() const { return mBrush; } - QBrush selectedBrush() const { return mSelectedBrush; } - QFont font() const { return mFont; } - QFont selectedFont() const { return mSelectedFont; } - QString text() const { return mText; } - Qt::Alignment positionAlignment() const { return mPositionAlignment; } - Qt::Alignment textAlignment() const { return mTextAlignment; } - double rotation() const { return mRotation; } - QMargins padding() const { return mPadding; } + QCPColorMapData *data() const { return mMapData; } + QCPRange dataRange() const { return mDataRange; } + QCPAxis::ScaleType dataScaleType() const { return mDataScaleType; } + bool interpolate() const { return mInterpolate; } + bool tightBoundary() const { return mTightBoundary; } + QCPColorGradient gradient() const { return mGradient; } + QCPColorScale *colorScale() const { return mColorScale.data(); } - // setters; - void setColor(const QColor &color); - void setSelectedColor(const QColor &color); - void setPen(const QPen &pen); - void setSelectedPen(const QPen &pen); - void setBrush(const QBrush &brush); - void setSelectedBrush(const QBrush &brush); - void setFont(const QFont &font); - void setSelectedFont(const QFont &font); - void setText(const QString &text); - void setPositionAlignment(Qt::Alignment alignment); - void setTextAlignment(Qt::Alignment alignment); - void setRotation(double degrees); - void setPadding(const QMargins &padding); + // setters: + void setData(QCPColorMapData *data, bool copy=false); + Q_SLOT void setDataRange(const QCPRange &dataRange); + Q_SLOT void setDataScaleType(QCPAxis::ScaleType scaleType); + Q_SLOT void setGradient(const QCPColorGradient &gradient); + void setInterpolate(bool enabled); + void setTightBoundary(bool enabled); + void setColorScale(QCPColorScale *colorScale); + + // non-property methods: + void rescaleDataRange(bool recalculateDataBounds=false); + Q_SLOT void updateLegendIcon(Qt::TransformationMode transformMode=Qt::SmoothTransformation, const QSize &thumbSize=QSize(32, 18)); // reimplemented virtual methods: + virtual void clearData(); virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; - QCPItemPosition * const position; - QCPItemAnchor * const topLeft; - QCPItemAnchor * const top; - QCPItemAnchor * const topRight; - QCPItemAnchor * const right; - QCPItemAnchor * const bottomRight; - QCPItemAnchor * const bottom; - QCPItemAnchor * const bottomLeft; - QCPItemAnchor * const left; +signals: + void dataRangeChanged(QCPRange newRange); + void dataScaleTypeChanged(QCPAxis::ScaleType scaleType); + void gradientChanged(QCPColorGradient newGradient); protected: - enum AnchorIndex {aiTopLeft, aiTop, aiTopRight, aiRight, aiBottomRight, aiBottom, aiBottomLeft, aiLeft}; - // property members: - QColor mColor, mSelectedColor; - QPen mPen, mSelectedPen; - QBrush mBrush, mSelectedBrush; - QFont mFont, mSelectedFont; - QString mText; - Qt::Alignment mPositionAlignment; - Qt::Alignment mTextAlignment; - double mRotation; - QMargins mPadding; + QCPRange mDataRange; + QCPAxis::ScaleType mDataScaleType; + QCPColorMapData *mMapData; + QCPColorGradient mGradient; + bool mInterpolate; + bool mTightBoundary; + QPointer mColorScale; + // non-property members: + QImage mMapImage; + QPixmap mLegendIcon; + bool mMapImageInvalidated; + + // introduced virtual methods: + virtual void updateMapImage(); // reimplemented virtual methods: virtual void draw(QCPPainter *painter); - virtual QPointF anchorPixelPoint(int anchorId) const; + virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const; + virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const; + virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const; - // non-virtual methods: - QPointF getTextDrawPoint(const QPointF &pos, const QRectF &rect, Qt::Alignment positionAlignment) const; - QFont mainFont() const; - QColor mainColor() const; - QPen mainPen() const; - QBrush mainBrush() const; + friend class QCustomPlot; + friend class QCPLegend; }; -class QCP_LIB_DECL QCPItemEllipse : public QCPAbstractItem +class QCP_LIB_DECL QCPItemStraightLine : public QCPAbstractItem { Q_OBJECT /// \cond INCLUDE_QPROPERTIES Q_PROPERTY(QPen pen READ pen WRITE setPen) Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) - Q_PROPERTY(QBrush brush READ brush WRITE setBrush) - Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush) /// \endcond public: - QCPItemEllipse(QCustomPlot *parentPlot); - virtual ~QCPItemEllipse(); + QCPItemStraightLine(QCustomPlot *parentPlot); + virtual ~QCPItemStraightLine(); // getters: QPen pen() const { return mPen; } QPen selectedPen() const { return mSelectedPen; } - QBrush brush() const { return mBrush; } - QBrush selectedBrush() const { return mSelectedBrush; } // setters; void setPen(const QPen &pen); void setSelectedPen(const QPen &pen); - void setBrush(const QBrush &brush); - void setSelectedBrush(const QBrush &brush); // reimplemented virtual methods: virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; - QCPItemPosition * const topLeft; - QCPItemPosition * const bottomRight; - QCPItemAnchor * const topLeftRim; - QCPItemAnchor * const top; - QCPItemAnchor * const topRightRim; - QCPItemAnchor * const right; - QCPItemAnchor * const bottomRightRim; - QCPItemAnchor * const bottom; - QCPItemAnchor * const bottomLeftRim; - QCPItemAnchor * const left; - QCPItemAnchor * const center; + QCPItemPosition * const point1; + QCPItemPosition * const point2; protected: - enum AnchorIndex {aiTopLeftRim, aiTop, aiTopRightRim, aiRight, aiBottomRightRim, aiBottom, aiBottomLeftRim, aiLeft, aiCenter}; - // property members: QPen mPen, mSelectedPen; - QBrush mBrush, mSelectedBrush; // reimplemented virtual methods: virtual void draw(QCPPainter *painter); - virtual QPointF anchorPixelPoint(int anchorId) const; // non-virtual methods: + double distToStraightLine(const QVector2D &point1, const QVector2D &vec, const QVector2D &point) const; + QLineF getRectClippedStraightLine(const QVector2D &point1, const QVector2D &vec, const QRect &rect) const; QPen mainPen() const; - QBrush mainBrush() const; }; -class QCP_LIB_DECL QCPItemPixmap : public QCPAbstractItem +class QCP_LIB_DECL QCPItemLine : public QCPAbstractItem { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap) - Q_PROPERTY(bool scaled READ scaled WRITE setScaled) - Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode) Q_PROPERTY(QPen pen READ pen WRITE setPen) Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) + Q_PROPERTY(QCPLineEnding head READ head WRITE setHead) + Q_PROPERTY(QCPLineEnding tail READ tail WRITE setTail) /// \endcond public: - QCPItemPixmap(QCustomPlot *parentPlot); - virtual ~QCPItemPixmap(); + QCPItemLine(QCustomPlot *parentPlot); + virtual ~QCPItemLine(); // getters: - QPixmap pixmap() const { return mPixmap; } - bool scaled() const { return mScaled; } - Qt::AspectRatioMode aspectRatioMode() const { return mAspectRatioMode; } QPen pen() const { return mPen; } QPen selectedPen() const { return mSelectedPen; } + QCPLineEnding head() const { return mHead; } + QCPLineEnding tail() const { return mTail; } // setters; - void setPixmap(const QPixmap &pixmap); - void setScaled(bool scaled, Qt::AspectRatioMode aspectRatioMode=Qt::KeepAspectRatio); void setPen(const QPen &pen); void setSelectedPen(const QPen &pen); + void setHead(const QCPLineEnding &head); + void setTail(const QCPLineEnding &tail); // reimplemented virtual methods: virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; - QCPItemPosition * const topLeft; - QCPItemPosition * const bottomRight; - QCPItemAnchor * const top; - QCPItemAnchor * const topRight; - QCPItemAnchor * const right; - QCPItemAnchor * const bottom; - QCPItemAnchor * const bottomLeft; - QCPItemAnchor * const left; + QCPItemPosition * const start; + QCPItemPosition * const end; protected: - enum AnchorIndex {aiTop, aiTopRight, aiRight, aiBottom, aiBottomLeft, aiLeft}; - // property members: - QPixmap mPixmap; - QPixmap mScaledPixmap; - bool mScaled; - Qt::AspectRatioMode mAspectRatioMode; QPen mPen, mSelectedPen; + QCPLineEnding mHead, mTail; // reimplemented virtual methods: virtual void draw(QCPPainter *painter); - virtual QPointF anchorPixelPoint(int anchorId) const; // non-virtual methods: - void updateScaledPixmap(QRect finalRect=QRect(), bool flipHorz=false, bool flipVert=false); - QRect getFinalRect(bool *flippedHorz=0, bool *flippedVert=0) const; + QLineF getRectClippedLine(const QVector2D &start, const QVector2D &end, const QRect &rect) const; QPen mainPen() const; }; -class QCP_LIB_DECL QCPItemTracer : public QCPAbstractItem +class QCP_LIB_DECL QCPItemCurve : public QCPAbstractItem { Q_OBJECT /// \cond INCLUDE_QPROPERTIES Q_PROPERTY(QPen pen READ pen WRITE setPen) Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) - Q_PROPERTY(QBrush brush READ brush WRITE setBrush) - Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush) - Q_PROPERTY(double size READ size WRITE setSize) - Q_PROPERTY(TracerStyle style READ style WRITE setStyle) - Q_PROPERTY(QCPGraph* graph READ graph WRITE setGraph) - Q_PROPERTY(double graphKey READ graphKey WRITE setGraphKey) - Q_PROPERTY(bool interpolating READ interpolating WRITE setInterpolating) + Q_PROPERTY(QCPLineEnding head READ head WRITE setHead) + Q_PROPERTY(QCPLineEnding tail READ tail WRITE setTail) /// \endcond public: - /*! - The different visual appearances a tracer item can have. Some styles size may be controlled with \ref setSize. - - \see setStyle - */ - enum TracerStyle { tsNone ///< The tracer is not visible - ,tsPlus ///< A plus shaped crosshair with limited size - ,tsCrosshair ///< A plus shaped crosshair which spans the complete axis rect - ,tsCircle ///< A circle - ,tsSquare ///< A square - }; - Q_ENUMS(TracerStyle) - - QCPItemTracer(QCustomPlot *parentPlot); - virtual ~QCPItemTracer(); - + QCPItemCurve(QCustomPlot *parentPlot); + virtual ~QCPItemCurve(); + // getters: QPen pen() const { return mPen; } QPen selectedPen() const { return mSelectedPen; } - QBrush brush() const { return mBrush; } - QBrush selectedBrush() const { return mSelectedBrush; } - double size() const { return mSize; } - TracerStyle style() const { return mStyle; } - QCPGraph *graph() const { return mGraph; } - double graphKey() const { return mGraphKey; } - bool interpolating() const { return mInterpolating; } - + QCPLineEnding head() const { return mHead; } + QCPLineEnding tail() const { return mTail; } + // setters; void setPen(const QPen &pen); void setSelectedPen(const QPen &pen); - void setBrush(const QBrush &brush); - void setSelectedBrush(const QBrush &brush); - void setSize(double size); - void setStyle(TracerStyle style); - void setGraph(QCPGraph *graph); - void setGraphKey(double key); - void setInterpolating(bool enabled); - + void setHead(const QCPLineEnding &head); + void setTail(const QCPLineEnding &tail); + // reimplemented virtual methods: virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; - // non-virtual methods: - void updatePosition(); - - QCPItemPosition * const position; - + QCPItemPosition * const start; + QCPItemPosition * const startDir; + QCPItemPosition * const endDir; + QCPItemPosition * const end; + protected: // property members: QPen mPen, mSelectedPen; - QBrush mBrush, mSelectedBrush; - double mSize; - TracerStyle mStyle; - QCPGraph *mGraph; - double mGraphKey; - bool mInterpolating; - + QCPLineEnding mHead, mTail; + // reimplemented virtual methods: virtual void draw(QCPPainter *painter); - + // non-virtual methods: QPen mainPen() const; - QBrush mainBrush() const; }; -class QCP_LIB_DECL QCPItemBracket : public QCPAbstractItem +class QCP_LIB_DECL QCPItemRect : public QCPAbstractItem { Q_OBJECT /// \cond INCLUDE_QPROPERTIES Q_PROPERTY(QPen pen READ pen WRITE setPen) Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) - Q_PROPERTY(double length READ length WRITE setLength) - Q_PROPERTY(BracketStyle style READ style WRITE setStyle) + Q_PROPERTY(QBrush brush READ brush WRITE setBrush) + Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush) /// \endcond public: - enum BracketStyle { bsSquare ///< A brace with angled edges - ,bsRound ///< A brace with round edges - ,bsCurly ///< A curly brace - ,bsCalligraphic ///< A curly brace with varying stroke width giving a calligraphic impression - }; - - QCPItemBracket(QCustomPlot *parentPlot); - virtual ~QCPItemBracket(); + QCPItemRect(QCustomPlot *parentPlot); + virtual ~QCPItemRect(); // getters: QPen pen() const { return mPen; } QPen selectedPen() const { return mSelectedPen; } - double length() const { return mLength; } - BracketStyle style() const { return mStyle; } + QBrush brush() const { return mBrush; } + QBrush selectedBrush() const { return mSelectedBrush; } // setters; void setPen(const QPen &pen); void setSelectedPen(const QPen &pen); - void setLength(double length); - void setStyle(BracketStyle style); + void setBrush(const QBrush &brush); + void setSelectedBrush(const QBrush &brush); // reimplemented virtual methods: virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; - QCPItemPosition * const left; - QCPItemPosition * const right; - QCPItemAnchor * const center; + QCPItemPosition * const topLeft; + QCPItemPosition * const bottomRight; + QCPItemAnchor * const top; + QCPItemAnchor * const topRight; + QCPItemAnchor * const right; + QCPItemAnchor * const bottom; + QCPItemAnchor * const bottomLeft; + QCPItemAnchor * const left; protected: + enum AnchorIndex {aiTop, aiTopRight, aiRight, aiBottom, aiBottomLeft, aiLeft}; + // property members: - enum AnchorIndex {aiCenter}; QPen mPen, mSelectedPen; - double mLength; - BracketStyle mStyle; + QBrush mBrush, mSelectedBrush; // reimplemented virtual methods: virtual void draw(QCPPainter *painter); @@ -2640,393 +3179,350 @@ // non-virtual methods: QPen mainPen() const; + QBrush mainBrush() const; }; -class QCP_LIB_DECL QCPAxisRect : public QCPLayoutElement +class QCP_LIB_DECL QCPItemText : public QCPAbstractItem { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY(QPixmap background READ background WRITE setBackground) - Q_PROPERTY(bool backgroundScaled READ backgroundScaled WRITE setBackgroundScaled) - Q_PROPERTY(Qt::AspectRatioMode backgroundScaledMode READ backgroundScaledMode WRITE setBackgroundScaledMode) - Q_PROPERTY(Qt::Orientations rangeDrag READ rangeDrag WRITE setRangeDrag) - Q_PROPERTY(Qt::Orientations rangeZoom READ rangeZoom WRITE setRangeZoom) + Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(QColor selectedColor READ selectedColor WRITE setSelectedColor) + Q_PROPERTY(QPen pen READ pen WRITE setPen) + Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) + Q_PROPERTY(QBrush brush READ brush WRITE setBrush) + Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush) + Q_PROPERTY(QFont font READ font WRITE setFont) + Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont) + Q_PROPERTY(QString text READ text WRITE setText) + Q_PROPERTY(Qt::Alignment positionAlignment READ positionAlignment WRITE setPositionAlignment) + Q_PROPERTY(Qt::Alignment textAlignment READ textAlignment WRITE setTextAlignment) + Q_PROPERTY(double rotation READ rotation WRITE setRotation) + Q_PROPERTY(QMargins padding READ padding WRITE setPadding) /// \endcond public: - explicit QCPAxisRect(QCustomPlot *parentPlot, bool setupDefaultAxes=true); - virtual ~QCPAxisRect(); + QCPItemText(QCustomPlot *parentPlot); + virtual ~QCPItemText(); // getters: - QPixmap background() const { return mBackgroundPixmap; } - bool backgroundScaled() const { return mBackgroundScaled; } - Qt::AspectRatioMode backgroundScaledMode() const { return mBackgroundScaledMode; } - Qt::Orientations rangeDrag() const { return mRangeDrag; } - Qt::Orientations rangeZoom() const { return mRangeZoom; } - QCPAxis *rangeDragAxis(Qt::Orientation orientation); - QCPAxis *rangeZoomAxis(Qt::Orientation orientation); - double rangeZoomFactor(Qt::Orientation orientation); - - // setters: - void setBackground(const QPixmap &pm); - void setBackground(const QPixmap &pm, bool scaled, Qt::AspectRatioMode mode=Qt::KeepAspectRatioByExpanding); - void setBackground(const QBrush &brush); - void setBackgroundScaled(bool scaled); - void setBackgroundScaledMode(Qt::AspectRatioMode mode); - void setRangeDrag(Qt::Orientations orientations); - void setRangeZoom(Qt::Orientations orientations); - void setRangeDragAxes(QCPAxis *horizontal, QCPAxis *vertical); - void setRangeZoomAxes(QCPAxis *horizontal, QCPAxis *vertical); - void setRangeZoomFactor(double horizontalFactor, double verticalFactor); - void setRangeZoomFactor(double factor); + QColor color() const { return mColor; } + QColor selectedColor() const { return mSelectedColor; } + QPen pen() const { return mPen; } + QPen selectedPen() const { return mSelectedPen; } + QBrush brush() const { return mBrush; } + QBrush selectedBrush() const { return mSelectedBrush; } + QFont font() const { return mFont; } + QFont selectedFont() const { return mSelectedFont; } + QString text() const { return mText; } + Qt::Alignment positionAlignment() const { return mPositionAlignment; } + Qt::Alignment textAlignment() const { return mTextAlignment; } + double rotation() const { return mRotation; } + QMargins padding() const { return mPadding; } - // non-property methods: - int axisCount(QCPAxis::AxisType type) const; - QCPAxis *axis(QCPAxis::AxisType type, int index=0) const; - QList axes(QCPAxis::AxisTypes types) const; - QList axes() const; - QCPAxis *addAxis(QCPAxis::AxisType type); - QList addAxes(QCPAxis::AxisTypes types); - bool removeAxis(QCPAxis *axis); - QCPLayoutInset *insetLayout() const { return mInsetLayout; } + // setters; + void setColor(const QColor &color); + void setSelectedColor(const QColor &color); + void setPen(const QPen &pen); + void setSelectedPen(const QPen &pen); + void setBrush(const QBrush &brush); + void setSelectedBrush(const QBrush &brush); + void setFont(const QFont &font); + void setSelectedFont(const QFont &font); + void setText(const QString &text); + void setPositionAlignment(Qt::Alignment alignment); + void setTextAlignment(Qt::Alignment alignment); + void setRotation(double degrees); + void setPadding(const QMargins &padding); - void setupFullAxesBox(bool connectRanges=false); - QList plottables() const; - QList graphs() const; - QList items() const; + // reimplemented virtual methods: + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; - // read-only interface imitating a QRect: - int left() const { return mRect.left(); } - int right() const { return mRect.right(); } - int top() const { return mRect.top(); } - int bottom() const { return mRect.bottom(); } - int width() const { return mRect.width(); } - int height() const { return mRect.height(); } - QSize size() const { return mRect.size(); } - QPoint topLeft() const { return mRect.topLeft(); } - QPoint topRight() const { return mRect.topRight(); } - QPoint bottomLeft() const { return mRect.bottomLeft(); } - QPoint bottomRight() const { return mRect.bottomRight(); } - QPoint center() const { return mRect.center(); } + QCPItemPosition * const position; + QCPItemAnchor * const topLeft; + QCPItemAnchor * const top; + QCPItemAnchor * const topRight; + QCPItemAnchor * const right; + QCPItemAnchor * const bottomRight; + QCPItemAnchor * const bottom; + QCPItemAnchor * const bottomLeft; + QCPItemAnchor * const left; - // reimplemented virtual methods: - virtual void update(); - virtual QList elements(bool recursive) const; - protected: + enum AnchorIndex {aiTopLeft, aiTop, aiTopRight, aiRight, aiBottomRight, aiBottom, aiBottomLeft, aiLeft}; + // property members: - QBrush mBackgroundBrush; - QPixmap mBackgroundPixmap; - QPixmap mScaledBackgroundPixmap; - bool mBackgroundScaled; - Qt::AspectRatioMode mBackgroundScaledMode; - QCPLayoutInset *mInsetLayout; - Qt::Orientations mRangeDrag, mRangeZoom; - QPointer mRangeDragHorzAxis, mRangeDragVertAxis, mRangeZoomHorzAxis, mRangeZoomVertAxis; - double mRangeZoomFactorHorz, mRangeZoomFactorVert; - // non-property members: - QCPRange mDragStartHorzRange, mDragStartVertRange; - QCP::AntialiasedElements mAADragBackup, mNotAADragBackup; - QPoint mDragStart; - bool mDragging; - QHash > mAxes; + QColor mColor, mSelectedColor; + QPen mPen, mSelectedPen; + QBrush mBrush, mSelectedBrush; + QFont mFont, mSelectedFont; + QString mText; + Qt::Alignment mPositionAlignment; + Qt::Alignment mTextAlignment; + double mRotation; + QMargins mPadding; // reimplemented virtual methods: - virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const; virtual void draw(QCPPainter *painter); - virtual int calculateAutoMargin(QCP::MarginSide side); - // events: - virtual void mousePressEvent(QMouseEvent *event); - virtual void mouseMoveEvent(QMouseEvent *event); - virtual void mouseReleaseEvent(QMouseEvent *event); - virtual void wheelEvent(QWheelEvent *event); - - // non-property methods: - void drawBackground(QCPPainter *painter); - void updateAxesOffset(QCPAxis::AxisType type); - -private: - Q_DISABLE_COPY(QCPAxisRect) + virtual QPointF anchorPixelPoint(int anchorId) const; - friend class QCustomPlot; + // non-virtual methods: + QPointF getTextDrawPoint(const QPointF &pos, const QRectF &rect, Qt::Alignment positionAlignment) const; + QFont mainFont() const; + QColor mainColor() const; + QPen mainPen() const; + QBrush mainBrush() const; }; -class QCP_LIB_DECL QCPAbstractLegendItem : public QCPLayoutElement +class QCP_LIB_DECL QCPItemEllipse : public QCPAbstractItem { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY(QCPLegend* parentLegend READ parentLegend) - Q_PROPERTY(QFont font READ font WRITE setFont) - Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor) - Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont) - Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor) - Q_PROPERTY(bool selectable READ selectable WRITE setSelectable) - Q_PROPERTY(bool selected READ selected WRITE setSelected) + Q_PROPERTY(QPen pen READ pen WRITE setPen) + Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) + Q_PROPERTY(QBrush brush READ brush WRITE setBrush) + Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush) /// \endcond public: - explicit QCPAbstractLegendItem(QCPLegend *parent); + QCPItemEllipse(QCustomPlot *parentPlot); + virtual ~QCPItemEllipse(); // getters: - QCPLegend *parentLegend() const { return mParentLegend; } - QFont font() const { return mFont; } - QColor textColor() const { return mTextColor; } - QFont selectedFont() const { return mSelectedFont; } - QColor selectedTextColor() const { return mSelectedTextColor; } - bool selectable() const { return mSelectable; } - bool selected() const { return mSelected; } + QPen pen() const { return mPen; } + QPen selectedPen() const { return mSelectedPen; } + QBrush brush() const { return mBrush; } + QBrush selectedBrush() const { return mSelectedBrush; } - // setters: - void setFont(const QFont &font); - void setTextColor(const QColor &color); - void setSelectedFont(const QFont &font); - void setSelectedTextColor(const QColor &color); - void setSelectable(bool selectable); - void setSelected(bool selected); + // setters; + void setPen(const QPen &pen); + void setSelectedPen(const QPen &pen); + void setBrush(const QBrush &brush); + void setSelectedBrush(const QBrush &brush); // reimplemented virtual methods: virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; -signals: - void selectionChanged(bool selected); + QCPItemPosition * const topLeft; + QCPItemPosition * const bottomRight; + QCPItemAnchor * const topLeftRim; + QCPItemAnchor * const top; + QCPItemAnchor * const topRightRim; + QCPItemAnchor * const right; + QCPItemAnchor * const bottomRightRim; + QCPItemAnchor * const bottom; + QCPItemAnchor * const bottomLeftRim; + QCPItemAnchor * const left; + QCPItemAnchor * const center; protected: + enum AnchorIndex {aiTopLeftRim, aiTop, aiTopRightRim, aiRight, aiBottomRightRim, aiBottom, aiBottomLeftRim, aiLeft, aiCenter}; + // property members: - QCPLegend *mParentLegend; - QFont mFont; - QColor mTextColor; - QFont mSelectedFont; - QColor mSelectedTextColor; - bool mSelectable, mSelected; + QPen mPen, mSelectedPen; + QBrush mBrush, mSelectedBrush; // reimplemented virtual methods: - virtual QCP::Interaction selectionCategory() const; - virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const; - virtual QRect clipRect() const; - virtual void draw(QCPPainter *painter) = 0; - // events: - virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged); - virtual void deselectEvent(bool *selectionStateChanged); - -private: - Q_DISABLE_COPY(QCPAbstractLegendItem) + virtual void draw(QCPPainter *painter); + virtual QPointF anchorPixelPoint(int anchorId) const; - friend class QCPLegend; + // non-virtual methods: + QPen mainPen() const; + QBrush mainBrush() const; }; -class QCP_LIB_DECL QCPPlottableLegendItem : public QCPAbstractLegendItem +class QCP_LIB_DECL QCPItemPixmap : public QCPAbstractItem { Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap) + Q_PROPERTY(bool scaled READ scaled WRITE setScaled) + Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode) + Q_PROPERTY(QPen pen READ pen WRITE setPen) + Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) + /// \endcond public: - QCPPlottableLegendItem(QCPLegend *parent, QCPAbstractPlottable *plottable); + QCPItemPixmap(QCustomPlot *parentPlot); + virtual ~QCPItemPixmap(); // getters: - QCPAbstractPlottable *plottable() { return mPlottable; } + QPixmap pixmap() const { return mPixmap; } + bool scaled() const { return mScaled; } + Qt::AspectRatioMode aspectRatioMode() const { return mAspectRatioMode; } + QPen pen() const { return mPen; } + QPen selectedPen() const { return mSelectedPen; } + + // setters; + void setPixmap(const QPixmap &pixmap); + void setScaled(bool scaled, Qt::AspectRatioMode aspectRatioMode=Qt::KeepAspectRatio); + void setPen(const QPen &pen); + void setSelectedPen(const QPen &pen); + + // reimplemented virtual methods: + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; + + QCPItemPosition * const topLeft; + QCPItemPosition * const bottomRight; + QCPItemAnchor * const top; + QCPItemAnchor * const topRight; + QCPItemAnchor * const right; + QCPItemAnchor * const bottom; + QCPItemAnchor * const bottomLeft; + QCPItemAnchor * const left; protected: + enum AnchorIndex {aiTop, aiTopRight, aiRight, aiBottom, aiBottomLeft, aiLeft}; + // property members: - QCPAbstractPlottable *mPlottable; + QPixmap mPixmap; + QPixmap mScaledPixmap; + bool mScaled; + Qt::AspectRatioMode mAspectRatioMode; + QPen mPen, mSelectedPen; // reimplemented virtual methods: virtual void draw(QCPPainter *painter); - virtual QSize minimumSizeHint() const; + virtual QPointF anchorPixelPoint(int anchorId) const; // non-virtual methods: - QPen getIconBorderPen() const; - QColor getTextColor() const; - QFont getFont() const; + void updateScaledPixmap(QRect finalRect=QRect(), bool flipHorz=false, bool flipVert=false); + QRect getFinalRect(bool *flippedHorz=0, bool *flippedVert=0) const; + QPen mainPen() const; }; -class QCP_LIB_DECL QCPLegend : public QCPLayoutGrid +class QCP_LIB_DECL QCPItemTracer : public QCPAbstractItem { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY(QPen borderPen READ borderPen WRITE setBorderPen) + Q_PROPERTY(QPen pen READ pen WRITE setPen) + Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) Q_PROPERTY(QBrush brush READ brush WRITE setBrush) - Q_PROPERTY(QFont font READ font WRITE setFont) - Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor) - Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize) - Q_PROPERTY(int iconTextPadding READ iconTextPadding WRITE setIconTextPadding) - Q_PROPERTY(QPen iconBorderPen READ iconBorderPen WRITE setIconBorderPen) - Q_PROPERTY(SelectableParts selectableParts READ selectableParts WRITE setSelectableParts) - Q_PROPERTY(SelectableParts selectedParts READ selectedParts WRITE setSelectedParts) - Q_PROPERTY(QPen selectedBorderPen READ selectedBorderPen WRITE setSelectedBorderPen) - Q_PROPERTY(QPen selectedIconBorderPen READ selectedIconBorderPen WRITE setSelectedIconBorderPen) Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush) - Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont) - Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor) + Q_PROPERTY(double size READ size WRITE setSize) + Q_PROPERTY(TracerStyle style READ style WRITE setStyle) + Q_PROPERTY(QCPGraph* graph READ graph WRITE setGraph) + Q_PROPERTY(double graphKey READ graphKey WRITE setGraphKey) + Q_PROPERTY(bool interpolating READ interpolating WRITE setInterpolating) /// \endcond public: /*! - Defines the selectable parts of a legend + The different visual appearances a tracer item can have. Some styles size may be controlled with \ref setSize. - \see setSelectedParts, setSelectableParts + \see setStyle */ - enum SelectablePart { spNone = 0x000 ///< 0x000 None - ,spLegendBox = 0x001 ///< 0x001 The legend box (frame) - ,spItems = 0x002 ///< 0x002 Legend items individually (see \ref selectedItems) - }; - Q_FLAGS(SelectablePart SelectableParts) - Q_DECLARE_FLAGS(SelectableParts, SelectablePart) - - explicit QCPLegend(); - virtual ~QCPLegend(); - + enum TracerStyle { tsNone ///< The tracer is not visible + ,tsPlus ///< A plus shaped crosshair with limited size + ,tsCrosshair ///< A plus shaped crosshair which spans the complete axis rect + ,tsCircle ///< A circle + ,tsSquare ///< A square + }; + Q_ENUMS(TracerStyle) + + QCPItemTracer(QCustomPlot *parentPlot); + virtual ~QCPItemTracer(); + // getters: - QPen borderPen() const { return mBorderPen; } + QPen pen() const { return mPen; } + QPen selectedPen() const { return mSelectedPen; } QBrush brush() const { return mBrush; } - QFont font() const { return mFont; } - QColor textColor() const { return mTextColor; } - QSize iconSize() const { return mIconSize; } - int iconTextPadding() const { return mIconTextPadding; } - QPen iconBorderPen() const { return mIconBorderPen; } - SelectableParts selectableParts() const { return mSelectableParts; } - SelectableParts selectedParts() const; - QPen selectedBorderPen() const { return mSelectedBorderPen; } - QPen selectedIconBorderPen() const { return mSelectedIconBorderPen; } QBrush selectedBrush() const { return mSelectedBrush; } - QFont selectedFont() const { return mSelectedFont; } - QColor selectedTextColor() const { return mSelectedTextColor; } - - // setters: - void setBorderPen(const QPen &pen); + double size() const { return mSize; } + TracerStyle style() const { return mStyle; } + QCPGraph *graph() const { return mGraph; } + double graphKey() const { return mGraphKey; } + bool interpolating() const { return mInterpolating; } + + // setters; + void setPen(const QPen &pen); + void setSelectedPen(const QPen &pen); void setBrush(const QBrush &brush); - void setFont(const QFont &font); - void setTextColor(const QColor &color); - void setIconSize(const QSize &size); - void setIconSize(int width, int height); - void setIconTextPadding(int padding); - void setIconBorderPen(const QPen &pen); - void setSelectableParts(const SelectableParts &selectableParts); - void setSelectedParts(const SelectableParts &selectedParts); - void setSelectedBorderPen(const QPen &pen); - void setSelectedIconBorderPen(const QPen &pen); void setSelectedBrush(const QBrush &brush); - void setSelectedFont(const QFont &font); - void setSelectedTextColor(const QColor &color); - + void setSize(double size); + void setStyle(TracerStyle style); + void setGraph(QCPGraph *graph); + void setGraphKey(double key); + void setInterpolating(bool enabled); + // reimplemented virtual methods: virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; // non-virtual methods: - QCPAbstractLegendItem *item(int index) const; - QCPPlottableLegendItem *itemWithPlottable(const QCPAbstractPlottable *plottable) const; - int itemCount() const; - bool hasItem(QCPAbstractLegendItem *item) const; - bool hasItemWithPlottable(const QCPAbstractPlottable *plottable) const; - bool addItem(QCPAbstractLegendItem *item); - bool removeItem(int index); - bool removeItem(QCPAbstractLegendItem *item); - void clearItems(); - QList selectedItems() const; - -signals: - void selectionChanged(QCPLegend::SelectableParts selection); - + void updatePosition(); + + QCPItemPosition * const position; + protected: // property members: - QPen mBorderPen, mIconBorderPen; - QBrush mBrush; - QFont mFont; - QColor mTextColor; - QSize mIconSize; - int mIconTextPadding; - SelectableParts mSelectedParts, mSelectableParts; - QPen mSelectedBorderPen, mSelectedIconBorderPen; - QBrush mSelectedBrush; - QFont mSelectedFont; - QColor mSelectedTextColor; - + QPen mPen, mSelectedPen; + QBrush mBrush, mSelectedBrush; + double mSize; + TracerStyle mStyle; + QCPGraph *mGraph; + double mGraphKey; + bool mInterpolating; + // reimplemented virtual methods: - virtual void parentPlotInitialized(QCustomPlot *parentPlot); - virtual QCP::Interaction selectionCategory() const; - virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const; virtual void draw(QCPPainter *painter); - // events: - virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged); - virtual void deselectEvent(bool *selectionStateChanged); - + // non-virtual methods: - QPen getBorderPen() const; - QBrush getBrush() const; - -private: - Q_DISABLE_COPY(QCPLegend) - - friend class QCustomPlot; - friend class QCPAbstractLegendItem; + QPen mainPen() const; + QBrush mainBrush() const; }; -Q_DECLARE_OPERATORS_FOR_FLAGS(QCPLegend::SelectableParts) -Q_DECLARE_METATYPE(QCPLegend::SelectablePart) -class QCP_LIB_DECL QCPPlotTitle : public QCPLayoutElement +class QCP_LIB_DECL QCPItemBracket : public QCPAbstractItem { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY(QString text READ text WRITE setText) - Q_PROPERTY(QFont font READ font WRITE setFont) - Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor) - Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont) - Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor) - Q_PROPERTY(bool selectable READ selectable WRITE setSelectable) - Q_PROPERTY(bool selected READ selected WRITE setSelected) + Q_PROPERTY(QPen pen READ pen WRITE setPen) + Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) + Q_PROPERTY(double length READ length WRITE setLength) + Q_PROPERTY(BracketStyle style READ style WRITE setStyle) /// \endcond public: - explicit QCPPlotTitle(QCustomPlot *parentPlot); - explicit QCPPlotTitle(QCustomPlot *parentPlot, const QString &text); + enum BracketStyle { bsSquare ///< A brace with angled edges + ,bsRound ///< A brace with round edges + ,bsCurly ///< A curly brace + ,bsCalligraphic ///< A curly brace with varying stroke width giving a calligraphic impression + }; + + QCPItemBracket(QCustomPlot *parentPlot); + virtual ~QCPItemBracket(); // getters: - QString text() const { return mText; } - QFont font() const { return mFont; } - QColor textColor() const { return mTextColor; } - QFont selectedFont() const { return mSelectedFont; } - QColor selectedTextColor() const { return mSelectedTextColor; } - bool selectable() const { return mSelectable; } - bool selected() const { return mSelected; } + QPen pen() const { return mPen; } + QPen selectedPen() const { return mSelectedPen; } + double length() const { return mLength; } + BracketStyle style() const { return mStyle; } - // setters: - void setText(const QString &text); - void setFont(const QFont &font); - void setTextColor(const QColor &color); - void setSelectedFont(const QFont &font); - void setSelectedTextColor(const QColor &color); - void setSelectable(bool selectable); - void setSelected(bool selected); + // setters; + void setPen(const QPen &pen); + void setSelectedPen(const QPen &pen); + void setLength(double length); + void setStyle(BracketStyle style); // reimplemented virtual methods: virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; -signals: - void selectionChanged(bool selected); + QCPItemPosition * const left; + QCPItemPosition * const right; + QCPItemAnchor * const center; protected: // property members: - QString mText; - QFont mFont; - QColor mTextColor; - QFont mSelectedFont; - QColor mSelectedTextColor; - QRect mTextBoundingRect; - bool mSelectable, mSelected; + enum AnchorIndex {aiCenter}; + QPen mPen, mSelectedPen; + double mLength; + BracketStyle mStyle; // reimplemented virtual methods: - virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const; virtual void draw(QCPPainter *painter); - virtual QSize minimumSizeHint() const; - virtual QSize maximumSizeHint() const; - // events: - virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged); - virtual void deselectEvent(bool *selectionStateChanged); + virtual QPointF anchorPixelPoint(int anchorId) const; // non-virtual methods: - QFont mainFont() const; - QColor mainTextColor() const; - -private: - Q_DISABLE_COPY(QCPPlotTitle) + QPen mainPen() const; }; #endif // QCUSTOMPLOT_H