diff --git a/src/core.cpp b/src/core.cpp index f346f37aa8675fb98d6dad8b6ebc63fdebd0810c..18524b9f8463ec95f195fe06ada884674334419b 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -42,10 +42,10 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// /*! \class QCustomPlot - + \brief The central class of the library. This is the QWidget which displays the plot and interacts with the user. - + For tutorials on how to use QCustomPlot, see the website\n http://www.qcustomplot.com/ */ @@ -53,15 +53,15 @@ /* start of documentation of inline functions */ /*! \fn QCPSelectionRect *QCustomPlot::selectionRect() const - + Allows access to the currently used QCPSelectionRect instance (or subclass thereof), that is used to handle and draw selection rect interactions (see \ref setSelectionRectMode). - + \see setSelectionRect */ /*! \fn QCPLayoutGrid *QCustomPlot::plotLayout() const - + Returns the top level layout of this QCustomPlot instance. It is a \ref QCPLayoutGrid, initially containing just one cell with the main QCPAxisRect inside. */ @@ -77,7 +77,7 @@ /*! \fn void QCustomPlot::mousePress(QMouseEvent *event) This signal is emitted when the QCustomPlot receives a mouse press event. - + It is emitted before QCustomPlot handles any other mechanism like range dragging. So a slot connected to this signal can still influence the behaviour e.g. with \ref QCPAxisRect::setRangeDrag or \ref QCPAxisRect::setRangeDragAxes. @@ -86,11 +86,11 @@ /*! \fn void QCustomPlot::mouseMove(QMouseEvent *event) This signal is emitted when the QCustomPlot receives a mouse move event. - + It is emitted before QCustomPlot handles any other mechanism like range dragging. So a slot connected to this signal can still influence the behaviour e.g. with \ref QCPAxisRect::setRangeDrag or \ref QCPAxisRect::setRangeDragAxes. - + \warning It is discouraged to change the drag-axes with \ref QCPAxisRect::setRangeDragAxes here, because the dragging starting point was saved the moment the mouse was pressed. Thus it only has a meaning for the range drag axes that were set at that moment. If you want to change the drag @@ -100,7 +100,7 @@ /*! \fn void QCustomPlot::mouseRelease(QMouseEvent *event) This signal is emitted when the QCustomPlot receives a mouse release event. - + It is emitted before QCustomPlot handles any other mechanisms like object selection. So a slot connected to this signal can still influence the behaviour e.g. with \ref setInteractions or \ref QCPAbstractPlottable::setSelectable. @@ -109,7 +109,7 @@ /*! \fn void QCustomPlot::mouseWheel(QMouseEvent *event) This signal is emitted when the QCustomPlot receives a mouse wheel event. - + It is emitted before QCustomPlot handles any other mechanisms like range zooming. So a slot connected to this signal can still influence the behaviour e.g. with \ref QCPAxisRect::setRangeZoom, \ref QCPAxisRect::setRangeZoomAxes or \ref QCPAxisRect::setRangeZoomFactor. @@ -138,104 +138,104 @@ */ /*! \fn void QCustomPlot::itemClick(QCPAbstractItem *item, QMouseEvent *event) - + This signal is emitted when an item is clicked. \a event is the mouse event that caused the click and \a item is the item that received the click. - + \see itemDoubleClick */ /*! \fn void QCustomPlot::itemDoubleClick(QCPAbstractItem *item, QMouseEvent *event) - + This signal is emitted when an item is double clicked. - + \a event is the mouse event that caused the click and \a item is the item that received the click. - + \see itemClick */ /*! \fn void QCustomPlot::axisClick(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event) - + This signal is emitted when an axis is clicked. - + \a event is the mouse event that caused the click, \a axis is the axis that received the click and \a part indicates the part of the axis that was clicked. - + \see axisDoubleClick */ /*! \fn void QCustomPlot::axisDoubleClick(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event) This signal is emitted when an axis is double clicked. - + \a event is the mouse event that caused the click, \a axis is the axis that received the click and \a part indicates the part of the axis that was clicked. - + \see axisClick */ /*! \fn void QCustomPlot::legendClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event) This signal is emitted when a legend (item) is clicked. - + \a event is the mouse event that caused the click, \a legend is the legend that received the click and \a item is the legend item that received the click. If only the legend and no item is clicked, \a item is 0. This happens for a click inside the legend padding or the space between two items. - + \see legendDoubleClick */ /*! \fn void QCustomPlot::legendDoubleClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event) This signal is emitted when a legend (item) is double clicked. - + \a event is the mouse event that caused the click, \a legend is the legend that received the click and \a item is the legend item that received the click. If only the legend and no item is clicked, \a item is 0. This happens for a click inside the legend padding or the space between two items. - + \see legendClick */ /*! \fn void QCustomPlot::selectionChangedByUser() - + This signal is emitted after the user has changed the selection in the QCustomPlot, e.g. by clicking. It is not emitted when the selection state of an object has changed programmatically by a direct call to setSelected()/setSelection() on an object or by calling \ref deselectAll. - + In addition to this signal, selectable objects also provide individual signals, for example \ref QCPAxis::selectionChanged or \ref QCPAbstractPlottable::selectionChanged. Note that those signals are emitted even if the selection state is changed programmatically. - + See the documentation of \ref setInteractions for details about the selection mechanism. - + \see selectedPlottables, selectedGraphs, selectedItems, selectedAxes, selectedLegends */ /*! \fn void QCustomPlot::beforeReplot() - + This signal is emitted immediately before a replot takes place (caused by a call to the slot \ref 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 replot, afterReplot */ /*! \fn void QCustomPlot::afterReplot() - + This signal is emitted immediately after a replot has taken place (caused by a call to the slot \ref 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 replot, beforeReplot */ @@ -245,7 +245,7 @@ /*! \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 @@ -253,7 +253,7 @@ 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. - + If an axis convenience pointer is currently zero and a new axis rect or a corresponding axis is added in the place of the main axis rect, QCustomPlot resets the convenience pointers to the according new axes. Similarly the \ref legend convenience pointer will be reset if a legend is @@ -263,7 +263,7 @@ /*! \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 @@ -271,7 +271,7 @@ 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. - + If an axis convenience pointer is currently zero and a new axis rect or a corresponding axis is added in the place of the main axis rect, QCustomPlot resets the convenience pointers to the according new axes. Similarly the \ref legend convenience pointer will be reset if a legend is @@ -283,7 +283,7 @@ 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 @@ -291,7 +291,7 @@ 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. - + If an axis convenience pointer is currently zero and a new axis rect or a corresponding axis is added in the place of the main axis rect, QCustomPlot resets the convenience pointers to the according new axes. Similarly the \ref legend convenience pointer will be reset if a legend is @@ -303,7 +303,7 @@ 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 @@ -311,7 +311,7 @@ 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. - + If an axis convenience pointer is currently zero and a new axis rect or a corresponding axis is added in the place of the main axis rect, QCustomPlot resets the convenience pointers to the according new axes. Similarly the \ref legend convenience pointer will be reset if a legend is @@ -322,7 +322,7 @@ 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 @@ -331,7 +331,7 @@ 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. - + If an axis convenience pointer is currently zero and a new axis rect or a corresponding axis is added in the place of the main axis rect, QCustomPlot resets the convenience pointers to the according new axes. Similarly the \ref legend convenience pointer will be reset if a legend is @@ -367,6 +367,7 @@ QCustomPlot::QCustomPlot(QWidget *parent) : mSelectionRectMode(QCP::srmNone), mSelectionRect(0), mOpenGl(false), + mRepaintAll(true), mMouseHasMoved(false), mMouseEventLayerable(0), mMouseSignalLayerable(0), @@ -390,7 +391,7 @@ QCustomPlot::QCustomPlot(QWidget *parent) : setBufferDevicePixelRatio(QWidget::devicePixelRatio()); # endif #endif - + mOpenGlAntialiasedElementsBackup = mAntialiasedElements; mOpenGlCacheLabelsBackup = mPlottingHints.testFlag(QCP::phCacheLabels); // create initial layers: @@ -403,7 +404,7 @@ QCustomPlot::QCustomPlot(QWidget *parent) : updateLayerIndices(); setCurrentLayer(QLatin1String("main")); layer(QLatin1String("overlay"))->setMode(QCPLayer::lmBuffered); - + // create initial layout, axis rect and legend: mPlotLayout = new QCPLayoutGrid; mPlotLayout->initializeParentPlot(this); @@ -419,7 +420,7 @@ QCustomPlot::QCustomPlot(QWidget *parent) : legend->setVisible(false); defaultAxisRect->insetLayout()->addElement(legend, Qt::AlignRight|Qt::AlignTop); defaultAxisRect->insetLayout()->setMargins(QMargins(12, 12, 12, 12)); - + defaultAxisRect->setLayer(QLatin1String("background")); xAxis->setLayer(QLatin1String("axes")); yAxis->setLayer(QLatin1String("axes")); @@ -430,13 +431,13 @@ QCustomPlot::QCustomPlot(QWidget *parent) : xAxis2->grid()->setLayer(QLatin1String("grid")); yAxis2->grid()->setLayer(QLatin1String("grid")); legend->setLayer(QLatin1String("legend")); - + // create selection rect instance: mSelectionRect = new QCPSelectionRect(this); mSelectionRect->setLayer(QLatin1String("overlay")); - + setViewport(rect()); // needs to be called after mPlotLayout has been created - + replot(rpQueuedReplot); } @@ -450,7 +451,7 @@ QCustomPlot::~QCustomPlot() delete mPlotLayout; mPlotLayout = 0; } - + mCurrentLayer = 0; qDeleteAll(mLayers); // don't use removeLayer, because it would prevent the last layer to be removed mLayers.clear(); @@ -458,25 +459,25 @@ QCustomPlot::~QCustomPlot() /*! Sets which elements are forcibly drawn antialiased as an \a or combination of QCP::AntialiasedElement. - + This overrides the antialiasing settings for whole element groups, normally controlled with the \a setAntialiasing function on the individual elements. If an element is neither specified in \ref setAntialiasedElements nor in \ref setNotAntialiasedElements, the antialiasing setting on each individual element instance is used. - + For example, if \a antialiasedElements contains \ref QCP::aePlottables, all plottables will be drawn antialiased, no matter what the specific QCPAbstractPlottable::setAntialiased value was set to. - + if an element in \a antialiasedElements is already set in \ref setNotAntialiasedElements, it is removed from there. - + \see setNotAntialiasedElements */ void QCustomPlot::setAntialiasedElements(const QCP::AntialiasedElements &antialiasedElements) { mAntialiasedElements = antialiasedElements; - + // make sure elements aren't in mNotAntialiasedElements and mAntialiasedElements simultaneously: if ((mNotAntialiasedElements & mAntialiasedElements) != 0) mNotAntialiasedElements |= ~mAntialiasedElements; @@ -484,9 +485,9 @@ void QCustomPlot::setAntialiasedElements(const QCP::AntialiasedElements &antiali /*! Sets whether the specified \a antialiasedElement is forcibly drawn antialiased. - + See \ref setAntialiasedElements for details. - + \see setNotAntialiasedElement */ void QCustomPlot::setAntialiasedElement(QCP::AntialiasedElement antialiasedElement, bool enabled) @@ -495,7 +496,7 @@ void QCustomPlot::setAntialiasedElement(QCP::AntialiasedElement antialiasedEleme mAntialiasedElements &= ~antialiasedElement; else if (enabled && !mAntialiasedElements.testFlag(antialiasedElement)) mAntialiasedElements |= antialiasedElement; - + // make sure elements aren't in mNotAntialiasedElements and mAntialiasedElements simultaneously: if ((mNotAntialiasedElements & mAntialiasedElements) != 0) mNotAntialiasedElements |= ~mAntialiasedElements; @@ -504,25 +505,25 @@ void QCustomPlot::setAntialiasedElement(QCP::AntialiasedElement antialiasedEleme /*! Sets which elements are forcibly drawn not antialiased as an \a or combination of QCP::AntialiasedElement. - + This overrides the antialiasing settings for whole element groups, normally controlled with the \a setAntialiasing function on the individual elements. If an element is neither specified in \ref setAntialiasedElements nor in \ref setNotAntialiasedElements, the antialiasing setting on each individual element instance is used. - + For example, if \a notAntialiasedElements contains \ref QCP::aePlottables, no plottables will be drawn antialiased, no matter what the specific QCPAbstractPlottable::setAntialiased value was set to. - + if an element in \a notAntialiasedElements is already set in \ref setAntialiasedElements, it is removed from there. - + \see setAntialiasedElements */ void QCustomPlot::setNotAntialiasedElements(const QCP::AntialiasedElements ¬AntialiasedElements) { mNotAntialiasedElements = notAntialiasedElements; - + // make sure elements aren't in mNotAntialiasedElements and mAntialiasedElements simultaneously: if ((mNotAntialiasedElements & mAntialiasedElements) != 0) mAntialiasedElements |= ~mNotAntialiasedElements; @@ -530,9 +531,9 @@ void QCustomPlot::setNotAntialiasedElements(const QCP::AntialiasedElements ¬A /*! Sets whether the specified \a notAntialiasedElement is forcibly drawn not antialiased. - + See \ref setNotAntialiasedElements for details. - + \see setAntialiasedElement */ void QCustomPlot::setNotAntialiasedElement(QCP::AntialiasedElement notAntialiasedElement, bool enabled) @@ -541,7 +542,7 @@ void QCustomPlot::setNotAntialiasedElement(QCP::AntialiasedElement notAntialiase mNotAntialiasedElements &= ~notAntialiasedElement; else if (enabled && !mNotAntialiasedElements.testFlag(notAntialiasedElement)) mNotAntialiasedElements |= notAntialiasedElement; - + // make sure elements aren't in mNotAntialiasedElements and mAntialiasedElements simultaneously: if ((mNotAntialiasedElements & mAntialiasedElements) != 0) mAntialiasedElements |= ~mNotAntialiasedElements; @@ -550,7 +551,7 @@ void QCustomPlot::setNotAntialiasedElement(QCP::AntialiasedElement notAntialiase /*! 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 addGraph, QCPLegend::addItem */ void QCustomPlot::setAutoAddPlottableToLegend(bool on) @@ -561,13 +562,13 @@ void QCustomPlot::setAutoAddPlottableToLegend(bool on) /*! Sets the possible interactions of this QCustomPlot as an or-combination of \ref QCP::Interaction enums. There are the following types of interactions: - + Axis range manipulation is controlled via \ref QCP::iRangeDrag and \ref QCP::iRangeZoom. When the respective interaction is enabled, the user may drag axes ranges and zoom with the mouse wheel. For details how to control which axes the user may drag/zoom and in what orientations, see \ref QCPAxisRect::setRangeDrag, \ref QCPAxisRect::setRangeZoom, \ref QCPAxisRect::setRangeDragAxes, \ref QCPAxisRect::setRangeZoomAxes. - + Plottable data selection is controlled by \ref QCP::iSelectPlottables. If \ref QCP::iSelectPlottables is set, the user may select plottables (graphs, curves, bars,...) and their data by clicking on them or in their vicinity (\ref setSelectionTolerance). Whether the @@ -576,40 +577,40 @@ void QCustomPlot::setAutoAddPlottableToLegend(bool on) special page about the \ref dataselection "data selection mechanism". To retrieve a list of all currently selected plottables, call \ref selectedPlottables. If you're only interested in QCPGraphs, you may use the convenience function \ref selectedGraphs. - + Item selection is controlled by \ref QCP::iSelectItems. If \ref QCP::iSelectItems is set, the user may select items (QCPItemLine, QCPItemText,...) by clicking on them or in their vicinity. To find out whether a specific item is selected, call QCPAbstractItem::selected(). To retrieve a list of all currently selected items, call \ref selectedItems. - + Axis selection is controlled with \ref QCP::iSelectAxes. If \ref QCP::iSelectAxes is set, the user may select parts of the axes by clicking on them. What parts exactly (e.g. Axis base line, tick labels, axis label) are selectable can be controlled via \ref QCPAxis::setSelectableParts for each axis. To retrieve a list of all axes that currently contain selected parts, call \ref selectedAxes. Which parts of an axis are selected, can be retrieved with QCPAxis::selectedParts(). - + Legend selection is controlled with \ref QCP::iSelectLegend. If this is set, the user may select the legend itself or individual items by clicking on them. What parts exactly are selectable can be controlled via \ref QCPLegend::setSelectableParts. To find out whether the legend or any of its child items are selected, check the value of QCPLegend::selectedParts. To find out which child items are selected, call \ref QCPLegend::selectedItems. - + All other selectable elements The selection of all other selectable objects (e.g. QCPTextElement, or your own layerable subclasses) is controlled with \ref QCP::iSelectOther. If set, the user may select those objects by clicking on them. To find out which are currently selected, you need to check their selected state explicitly. - + If the selection state has changed by user interaction, the \ref selectionChangedByUser signal is emitted. Each selectable object additionally emits an individual selectionChanged signal whenever their selection state has changed, i.e. not only by user interaction. - + To allow multiple objects to be selected by holding the selection modifier (\ref setMultiSelectModifier), set the flag \ref QCP::iMultiSelect. - + \note In addition to the selection mechanism presented here, QCustomPlot always emits corresponding signals, when an object is clicked or double clicked. see \ref plottableClick and \ref plottableDoubleClick for example. - + \see setInteraction, setSelectionTolerance */ void QCustomPlot::setInteractions(const QCP::Interactions &interactions) @@ -619,9 +620,9 @@ void QCustomPlot::setInteractions(const QCP::Interactions &interactions) /*! Sets the single \a interaction of this QCustomPlot to \a enabled. - + For details about the interaction system, see \ref setInteractions. - + \see setInteractions */ void QCustomPlot::setInteraction(const QCP::Interaction &interaction, bool enabled) @@ -635,14 +636,14 @@ void QCustomPlot::setInteraction(const QCP::Interaction &interaction, bool enabl /*! Sets the tolerance that is used to decide whether a click selects an object (e.g. a plottable) or not. - + If the user clicks in the vicinity of the line of e.g. a QCPGraph, it's only regarded as a potential selection when the minimum distance between the click position and the graph line is smaller than \a pixels. Objects that are defined by an area (e.g. QCPBars) only react to clicks directly inside the area and ignore this selection tolerance. In other words, it only has meaning for parts of objects that are too thin to exactly hit with a click and thus need such a tolerance. - + \see setInteractions, QCPLayerable::selectTest */ void QCustomPlot::setSelectionTolerance(int pixels) @@ -656,7 +657,7 @@ void QCustomPlot::setSelectionTolerance(int pixels) performance during dragging. Thus it creates a more responsive user experience. As soon as the user stops dragging, the last replot is done with normal antialiasing, to restore high image quality. - + \see setAntialiasedElements, setNotAntialiasedElements */ void QCustomPlot::setNoAntialiasingOnDrag(bool enabled) @@ -666,7 +667,7 @@ void QCustomPlot::setNoAntialiasingOnDrag(bool enabled) /*! Sets the plotting hints for this QCustomPlot instance as an \a or combination of QCP::PlottingHint. - + \see setPlottingHint */ void QCustomPlot::setPlottingHints(const QCP::PlottingHints &hints) @@ -676,7 +677,7 @@ void QCustomPlot::setPlottingHints(const QCP::PlottingHints &hints) /*! Sets the specified plotting \a hint to \a enabled. - + \see setPlottingHints */ void QCustomPlot::setPlottingHint(QCP::PlottingHint hint, bool enabled) @@ -686,19 +687,19 @@ void QCustomPlot::setPlottingHint(QCP::PlottingHint hint, bool enabled) newHints &= ~hint; else newHints |= hint; - + if (newHints != mPlottingHints) setPlottingHints(newHints); } /*! Sets the keyboard modifier that will be recognized as multi-select-modifier. - + If \ref QCP::iMultiSelect is specified in \ref setInteractions, the user may select multiple objects (or data points) by clicking on them one after the other while holding down \a modifier. - + By default the multi-select-modifier is set to Qt::ControlModifier. - + \see setInteractions */ void QCustomPlot::setMultiSelectModifier(Qt::KeyboardModifier modifier) @@ -713,17 +714,17 @@ void QCustomPlot::setMultiSelectModifier(Qt::KeyboardModifier modifier) example, QCPAxisRect may process a mouse drag by dragging axis ranges, see \ref QCPAxisRect::setRangeDrag. If \a mode is not \ref QCP::srmNone, the current selection rect (\ref selectionRect) becomes activated and allows e.g. rect zooming and data point selection. - + If you wish to provide your user both with axis range dragging and data selection/range zooming, use this method to switch between the modes just before the interaction is processed, e.g. in reaction to the \ref mousePress or \ref mouseMove signals. For example you could check whether the user is holding a certain keyboard modifier, and then decide which \a mode shall be set. - + If a selection rect interaction is currently active, and \a mode is set to \ref QCP::srmNone, the interaction is canceled (\ref QCPSelectionRect::cancel). Switching between any of the other modes will keep the selection rect active. Upon completion of the interaction, the behaviour is as defined by the currently set \a mode, not the mode that was set when the interaction started. - + \see setInteractions, setSelectionRect, QCPSelectionRect */ void QCustomPlot::setSelectionRectMode(QCP::SelectionRectMode mode) @@ -732,20 +733,20 @@ void QCustomPlot::setSelectionRectMode(QCP::SelectionRectMode mode) { if (mode == QCP::srmNone) mSelectionRect->cancel(); // when switching to none, we immediately want to abort a potentially active selection rect - + // disconnect old connections: if (mSelectionRectMode == QCP::srmSelect) disconnect(mSelectionRect, SIGNAL(accepted(QRect,QMouseEvent*)), this, SLOT(processRectSelection(QRect,QMouseEvent*))); else if (mSelectionRectMode == QCP::srmZoom) disconnect(mSelectionRect, SIGNAL(accepted(QRect,QMouseEvent*)), this, SLOT(processRectZoom(QRect,QMouseEvent*))); - + // establish new ones: if (mode == QCP::srmSelect) connect(mSelectionRect, SIGNAL(accepted(QRect,QMouseEvent*)), this, SLOT(processRectSelection(QRect,QMouseEvent*))); else if (mode == QCP::srmZoom) connect(mSelectionRect, SIGNAL(accepted(QRect,QMouseEvent*)), this, SLOT(processRectZoom(QRect,QMouseEvent*))); } - + mSelectionRectMode = mode; } @@ -753,19 +754,19 @@ void QCustomPlot::setSelectionRectMode(QCP::SelectionRectMode mode) Sets the \ref QCPSelectionRect instance that QCustomPlot will use if \a mode is not \ref QCP::srmNone and the user performs a click-and-drag interaction. QCustomPlot takes ownership of the passed \a selectionRect. It can be accessed later via \ref selectionRect. - + This method is useful if you wish to replace the default QCPSelectionRect instance with an instance of a QCPSelectionRect subclass, to introduce custom behaviour of the selection rect. - + \see setSelectionRectMode */ void QCustomPlot::setSelectionRect(QCPSelectionRect *selectionRect) { if (mSelectionRect) delete mSelectionRect; - + mSelectionRect = selectionRect; - + if (mSelectionRect) { // establish connections with new selection rect: @@ -780,7 +781,7 @@ void QCustomPlot::setSelectionRect(QCPSelectionRect *selectionRect) \warning This is still an experimental feature and its performance depends on the system that it runs on. Having multiple QCustomPlot widgets in one application with enabled OpenGL rendering might cause context conflicts on some systems. - + This method allows to enable OpenGL plot rendering, for increased plotting performance of graphically demanding plots (thick lines, translucent fills, etc.). @@ -850,6 +851,11 @@ void QCustomPlot::setOpenGl(bool enabled, int multisampling) #endif } +void QCustomPlot::setRepaintAll(bool repaint) +{ + mRepaintAll = repaint; +} + /*! Sets the viewport of this QCustomPlot. Usually users of QCustomPlot don't need to change the viewport manually. @@ -908,7 +914,7 @@ void QCustomPlot::setBufferDevicePixelRatio(double ratio) enabled with \ref setBackgroundScaled and the scaling mode (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. - + If a background brush was set with \ref setBackground(const QBrush &brush), the viewport will first be filled with that brush, before drawing the background pixmap. This can be useful for background pixmaps with translucent areas. @@ -928,7 +934,7 @@ void QCustomPlot::setBackground(const QPixmap &pm) was set with \ref setBackground(const QPixmap &pm), this brush will be used to fill the viewport before the background pixmap is drawn. This can be useful for background pixmaps with translucent areas. - + Set \a brush to Qt::NoBrush or Qt::Transparent to leave background transparent. This can be useful for exporting to image formats which support transparency, e.g. \ref savePng. @@ -940,7 +946,7 @@ void QCustomPlot::setBackground(const QBrush &brush) } /*! \overload - + Allows setting the background pixmap of the viewport, whether it shall be scaled and how it shall be scaled in one call. @@ -958,10 +964,10 @@ void QCustomPlot::setBackground(const QPixmap &pm, bool scaled, Qt::AspectRatioM Sets whether the viewport background pixmap shall be scaled to fit the viewport. If \a scaled is set to true, 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 viewport dimensions are changed continuously.) - + \see setBackground, setBackgroundScaledMode */ void QCustomPlot::setBackgroundScaled(bool scaled) @@ -972,7 +978,7 @@ void QCustomPlot::setBackgroundScaled(bool scaled) /*! If scaling of the viewport background pixmap is enabled (\ref setBackgroundScaled), use this function to define whether and how the aspect ratio of the original pixmap is preserved. - + \see setBackground, setBackgroundScaled */ void QCustomPlot::setBackgroundScaledMode(Qt::AspectRatioMode mode) @@ -982,10 +988,10 @@ void QCustomPlot::setBackgroundScaledMode(Qt::AspectRatioMode mode) /*! Returns the plottable with \a index. If the index is invalid, returns 0. - + There is an overloaded version of this function with no parameter which returns the last added plottable, see QCustomPlot::plottable() - + \see plottableCount */ QCPAbstractPlottable *QCustomPlot::plottable(int index) @@ -1001,10 +1007,10 @@ QCPAbstractPlottable *QCustomPlot::plottable(int index) } /*! \overload - + Returns the last plottable that was added to the plot. If there are no plottables in the plot, returns 0. - + \see plottableCount */ QCPAbstractPlottable *QCustomPlot::plottable() @@ -1019,9 +1025,9 @@ QCPAbstractPlottable *QCustomPlot::plottable() /*! Removes the specified plottable from the plot and deletes it. If necessary, the corresponding legend item is also removed from the default legend (QCustomPlot::legend). - + Returns true on success. - + \see clearPlottables */ bool QCustomPlot::removePlottable(QCPAbstractPlottable *plottable) @@ -1031,7 +1037,7 @@ bool QCustomPlot::removePlottable(QCPAbstractPlottable *plottable) qDebug() << Q_FUNC_INFO << "plottable not in list:" << reinterpret_cast(plottable); return false; } - + // remove plottable from legend: plottable->removeFromLegend(); // special handling for QCPGraphs to maintain the simple graph interface: @@ -1044,7 +1050,7 @@ bool QCustomPlot::removePlottable(QCPAbstractPlottable *plottable) } /*! \overload - + Removes and deletes the plottable by its \a index. */ bool QCustomPlot::removePlottable(int index) @@ -1061,9 +1067,9 @@ bool QCustomPlot::removePlottable(int index) /*! Removes all plottables from the plot and deletes them. Corresponding legend items are also removed from the default legend (QCustomPlot::legend). - + Returns the number of plottables removed. - + \see removePlottable */ int QCustomPlot::clearPlottables() @@ -1076,7 +1082,7 @@ int QCustomPlot::clearPlottables() /*! Returns the number of currently existing plottables in the plot - + \see plottable */ int QCustomPlot::plottableCount() const @@ -1086,9 +1092,9 @@ int QCustomPlot::plottableCount() const /*! Returns a list of the selected plottables. If no plottables are currently selected, the list is empty. - + There is a convenience function if you're only interested in selected graphs, see \ref selectedGraphs. - + \see setInteractions, QCPAbstractPlottable::setSelectable, QCPAbstractPlottable::setSelection */ QList QCustomPlot::selectedPlottables() const @@ -1106,19 +1112,19 @@ QList QCustomPlot::selectedPlottables() const Returns the plottable at the pixel position \a pos. Plottables that only consist of single lines (like graphs) have a tolerance band around them, see \ref setSelectionTolerance. If multiple plottables come into consideration, the one closest to \a pos is returned. - + If \a onlySelectable is true, only plottables that are selectable (QCPAbstractPlottable::setSelectable) are considered. - + If there is no plottable at \a pos, the return value is 0. - + \see itemAt, layoutElementAt */ QCPAbstractPlottable *QCustomPlot::plottableAt(const QPointF &pos, bool onlySelectable) const { QCPAbstractPlottable *resultPlottable = 0; double resultDistance = mSelectionTolerance; // only regard clicks with distances smaller than mSelectionTolerance as selections, so initialize with that value - + foreach (QCPAbstractPlottable *plottable, mPlottables) { 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 @@ -1133,7 +1139,7 @@ QCPAbstractPlottable *QCustomPlot::plottableAt(const QPointF &pos, bool onlySele } } } - + return resultPlottable; } @@ -1147,10 +1153,10 @@ bool QCustomPlot::hasPlottable(QCPAbstractPlottable *plottable) const /*! Returns the graph with \a index. If the index is invalid, returns 0. - + There is an overloaded version of this function with no parameter which returns the last created graph, see QCustomPlot::graph() - + \see graphCount, addGraph */ QCPGraph *QCustomPlot::graph(int index) const @@ -1166,10 +1172,10 @@ QCPGraph *QCustomPlot::graph(int index) const } /*! \overload - + Returns the last graph, that was created with \ref addGraph. If there are no graphs in the plot, returns 0. - + \see graphCount, addGraph */ QCPGraph *QCustomPlot::graph() const @@ -1185,12 +1191,12 @@ QCPGraph *QCustomPlot::graph() const Creates a new graph inside the plot. If \a keyAxis and \a valueAxis are left unspecified (0), the bottom (xAxis) is used as key and the left (yAxis) is used as value axis. If specified, \a keyAxis and \a valueAxis must reside in this QCustomPlot. - + \a keyAxis will be used as key axis (typically "x") and \a valueAxis as value axis (typically "y") for the graph. - + Returns a pointer to the newly created graph, or 0 if adding the graph failed. - + \see graph, graphCount, removeGraph, clearGraphs */ QCPGraph *QCustomPlot::addGraph(QCPAxis *keyAxis, QCPAxis *valueAxis) @@ -1207,7 +1213,7 @@ QCPGraph *QCustomPlot::addGraph(QCPAxis *keyAxis, QCPAxis *valueAxis) qDebug() << Q_FUNC_INFO << "passed keyAxis or valueAxis doesn't have this QCustomPlot as parent"; return 0; } - + QCPGraph *newGraph = new QCPGraph(keyAxis, valueAxis); newGraph->setName(QLatin1String("Graph ")+QString::number(mGraphs.size())); return newGraph; @@ -1218,9 +1224,9 @@ QCPGraph *QCustomPlot::addGraph(QCPAxis *keyAxis, QCPAxis *valueAxis) legend item is also removed from the default legend (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 clearGraphs */ bool QCustomPlot::removeGraph(QCPGraph *graph) @@ -1229,7 +1235,7 @@ bool QCustomPlot::removeGraph(QCPGraph *graph) } /*! \overload - + Removes and deletes the graph by its \a index. */ bool QCustomPlot::removeGraph(int index) @@ -1245,7 +1251,7 @@ bool QCustomPlot::removeGraph(int index) from the default legend (QCustomPlot::legend). Returns the number of graphs removed. - + \see removeGraph */ int QCustomPlot::clearGraphs() @@ -1258,7 +1264,7 @@ int QCustomPlot::clearGraphs() /*! Returns the number of currently existing graphs in the plot - + \see graph, addGraph */ int QCustomPlot::graphCount() const @@ -1268,10 +1274,10 @@ int QCustomPlot::graphCount() const /*! Returns a list of the selected graphs. If no graphs are currently selected, the list is empty. - + If you are not only interested in selected graphs but other plottables like QCPCurve, QCPBars, etc., use \ref selectedPlottables. - + \see setInteractions, selectedPlottables, QCPAbstractPlottable::setSelectable, QCPAbstractPlottable::setSelection */ QList QCustomPlot::selectedGraphs() const @@ -1287,10 +1293,10 @@ QList QCustomPlot::selectedGraphs() const /*! Returns the item with \a index. If the index is invalid, returns 0. - + There is an overloaded version of this function with no parameter which returns the last added item, see QCustomPlot::item() - + \see itemCount */ QCPAbstractItem *QCustomPlot::item(int index) const @@ -1306,10 +1312,10 @@ QCPAbstractItem *QCustomPlot::item(int index) const } /*! \overload - + Returns the last item that was added to this plot. If there are no items in the plot, returns 0. - + \see itemCount */ QCPAbstractItem *QCustomPlot::item() const @@ -1323,9 +1329,9 @@ QCPAbstractItem *QCustomPlot::item() const /*! Removes the specified item from the plot and deletes it. - + Returns true on success. - + \see clearItems */ bool QCustomPlot::removeItem(QCPAbstractItem *item) @@ -1343,7 +1349,7 @@ bool QCustomPlot::removeItem(QCPAbstractItem *item) } /*! \overload - + Removes and deletes the item by its \a index. */ bool QCustomPlot::removeItem(int index) @@ -1359,9 +1365,9 @@ bool QCustomPlot::removeItem(int index) /*! Removes all items from the plot and deletes them. - + Returns the number of items removed. - + \see removeItem */ int QCustomPlot::clearItems() @@ -1374,7 +1380,7 @@ int QCustomPlot::clearItems() /*! Returns the number of currently existing items in the plot - + \see item */ int QCustomPlot::itemCount() const @@ -1384,7 +1390,7 @@ int QCustomPlot::itemCount() const /*! Returns a list of the selected items. If no items are currently selected, the list is empty. - + \see setInteractions, QCPAbstractItem::setSelectable, QCPAbstractItem::setSelected */ QList QCustomPlot::selectedItems() const @@ -1403,19 +1409,19 @@ QList QCustomPlot::selectedItems() const QCPItemLine or \ref QCPItemCurve) have a tolerance band around them, see \ref setSelectionTolerance. If multiple items come into consideration, the one closest to \a pos is returned. - + If \a onlySelectable is true, only items that are selectable (QCPAbstractItem::setSelectable) are considered. - + If there is no item at \a pos, the return value is 0. - + \see plottableAt, layoutElementAt */ QCPAbstractItem *QCustomPlot::itemAt(const QPointF &pos, bool onlySelectable) const { QCPAbstractItem *resultItem = 0; double resultDistance = mSelectionTolerance; // only regard clicks with distances smaller than mSelectionTolerance as selections, so initialize with that value - + foreach (QCPAbstractItem *item, mItems) { 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 @@ -1430,13 +1436,13 @@ QCPAbstractItem *QCustomPlot::itemAt(const QPointF &pos, bool onlySelectable) co } } } - + return resultItem; } /*! Returns whether this QCustomPlot contains the \a item. - + \see item */ bool QCustomPlot::hasItem(QCPAbstractItem *item) const @@ -1447,9 +1453,9 @@ bool QCustomPlot::hasItem(QCPAbstractItem *item) const /*! Returns the layer with the specified \a name. If there is no layer with the specified name, 0 is returned. - + Layer names are case-sensitive. - + \see addLayer, moveLayer, removeLayer */ QCPLayer *QCustomPlot::layer(const QString &name) const @@ -1463,9 +1469,9 @@ QCPLayer *QCustomPlot::layer(const QString &name) const } /*! \overload - + Returns the layer by \a index. If the index is invalid, 0 is returned. - + \see addLayer, moveLayer, removeLayer */ QCPLayer *QCustomPlot::layer(int index) const @@ -1491,11 +1497,11 @@ QCPLayer *QCustomPlot::currentLayer() const /*! Sets the layer with the specified \a name to be the current layer. All layerables (\ref QCPLayerable), e.g. plottables and items, are created on the current layer. - + Returns true on success, i.e. if there is a layer with the specified \a name in the QCustomPlot. - + Layer names are case-sensitive. - + \see addLayer, moveLayer, removeLayer, QCPLayerable::setLayer */ bool QCustomPlot::setCurrentLayer(const QString &name) @@ -1511,11 +1517,11 @@ bool QCustomPlot::setCurrentLayer(const QString &name) } /*! \overload - + Sets the provided \a layer to be the current layer. - + Returns true on success, i.e. when \a layer is a valid layer in the QCustomPlot. - + \see addLayer, moveLayer, removeLayer */ bool QCustomPlot::setCurrentLayer(QCPLayer *layer) @@ -1525,14 +1531,14 @@ bool QCustomPlot::setCurrentLayer(QCPLayer *layer) qDebug() << Q_FUNC_INFO << "layer not a layer of this QCustomPlot:" << reinterpret_cast(layer); return false; } - + mCurrentLayer = layer; return true; } /*! Returns the number of currently existing layers in the plot - + \see layer, addLayer */ int QCustomPlot::layerCount() const @@ -1543,14 +1549,14 @@ int QCustomPlot::layerCount() const /*! Adds a new layer to this QCustomPlot instance. The new layer will have the name \a name, which must be unique. Depending on \a insertMode, it is positioned either below or above \a otherLayer. - + Returns true on success, i.e. if there is no other layer named \a name and \a otherLayer is a valid layer inside this QCustomPlot. - + If \a otherLayer is 0, the highest layer in the QCustomPlot will be used. - + For an explanation of what layers are in QCustomPlot, see the documentation of \ref QCPLayer. - + \see layer, moveLayer, removeLayer */ bool QCustomPlot::addLayer(const QString &name, QCPLayer *otherLayer, QCustomPlot::LayerInsertMode insertMode) @@ -1567,7 +1573,7 @@ bool QCustomPlot::addLayer(const QString &name, QCPLayer *otherLayer, QCustomPlo qDebug() << Q_FUNC_INFO << "A layer exists already with the name" << name; return false; } - + QCPLayer *newLayer = new QCPLayer(this, name); mLayers.insert(otherLayer->index() + (insertMode==limAbove ? 1:0), newLayer); updateLayerIndices(); @@ -1577,16 +1583,16 @@ bool QCustomPlot::addLayer(const QString &name, QCPLayer *otherLayer, QCustomPlo /*! Removes the specified \a layer and returns true on success. - + All layerables (e.g. plottables and items) on the removed layer will be moved to the layer below \a layer. If \a layer is the bottom layer, the layerables are moved to the layer above. In both cases, the total rendering order of all layerables in the QCustomPlot is preserved. - + If \a layer is the current layer (\ref setCurrentLayer), the layer below (or above, if bottom layer) becomes the new current layer. - + It is not possible to remove the last layer of the plot. - + \see layer, addLayer, moveLayer */ bool QCustomPlot::removeLayer(QCPLayer *layer) @@ -1601,7 +1607,7 @@ bool QCustomPlot::removeLayer(QCPLayer *layer) qDebug() << Q_FUNC_INFO << "can't remove last layer"; return false; } - + // append all children of this layer to layer below (if this is lowest layer, prepend to layer above) int removedIndex = layer->index(); bool isFirstLayer = removedIndex==0; @@ -1632,10 +1638,10 @@ bool QCustomPlot::removeLayer(QCPLayer *layer) /*! Moves the specified \a layer either above or below \a otherLayer. Whether it's placed above or below is controlled with \a insertMode. - + Returns true on success, i.e. when both \a layer and \a otherLayer are valid layers in the QCustomPlot. - + \see layer, addLayer, moveLayer */ bool QCustomPlot::moveLayer(QCPLayer *layer, QCPLayer *otherLayer, QCustomPlot::LayerInsertMode insertMode) @@ -1650,29 +1656,29 @@ bool QCustomPlot::moveLayer(QCPLayer *layer, QCPLayer *otherLayer, QCustomPlot:: qDebug() << Q_FUNC_INFO << "otherLayer not a layer of this QCustomPlot:" << reinterpret_cast(otherLayer); return false; } - + if (layer->index() > otherLayer->index()) mLayers.move(layer->index(), otherLayer->index() + (insertMode==limAbove ? 1:0)); else if (layer->index() < otherLayer->index()) mLayers.move(layer->index(), otherLayer->index() + (insertMode==limAbove ? 0:-1)); - + // invalidate the paint buffers that are responsible for the layers: if (!layer->mPaintBuffer.isNull()) layer->mPaintBuffer.data()->setInvalidated(); if (!otherLayer->mPaintBuffer.isNull()) otherLayer->mPaintBuffer.data()->setInvalidated(); - + updateLayerIndices(); return true; } /*! Returns the number of axis rects in the plot. - + All axis rects can be accessed via QCustomPlot::axisRect(). - + Initially, only one axis rect exists in the plot. - + \see axisRect, axisRects */ int QCustomPlot::axisRectCount() const @@ -1682,11 +1688,11 @@ int QCustomPlot::axisRectCount() const /*! Returns the axis rect with \a index. - + Initially, only one axis rect (with index 0) exists in the plot. If multiple axis rects were added, all of them may be accessed with this function in a linear fashion (even when they are nested in a layout hierarchy or inside other axis rects via QCPAxisRect::insetLayout). - + \see axisRectCount, axisRects */ QCPAxisRect *QCustomPlot::axisRect(int index) const @@ -1704,7 +1710,7 @@ QCPAxisRect *QCustomPlot::axisRect(int index) const /*! Returns all axis rects in the plot. - + \see axisRectCount, axisRect */ QList QCustomPlot::axisRects() const @@ -1713,7 +1719,7 @@ QList QCustomPlot::axisRects() const QStack elementStack; if (mPlotLayout) elementStack.push(mPlotLayout); - + while (!elementStack.isEmpty()) { foreach (QCPLayoutElement *element, elementStack.pop()->elements(false)) @@ -1726,17 +1732,17 @@ QList QCustomPlot::axisRects() const } } } - + return result; } /*! Returns the layout element at pixel position \a pos. If there is no element at that position, returns 0. - + Only visible elements are used. If \ref QCPLayoutElement::setVisible on the element itself or on any of its parent elements is set to false, it will not be considered. - + \see itemAt, plottableAt */ QCPLayoutElement *QCustomPlot::layoutElementAt(const QPointF &pos) const @@ -1795,7 +1801,7 @@ QCPAxisRect *QCustomPlot::axisRectAt(const QPointF &pos) const /*! Returns the axes that currently have selected parts, i.e. whose selection state is not \ref QCPAxis::spNone. - + \see selectedPlottables, selectedLegends, setInteractions, QCPAxis::setSelectedParts, QCPAxis::setSelectableParts */ @@ -1804,31 +1810,31 @@ QList QCustomPlot::selectedAxes() const QList result, allAxes; foreach (QCPAxisRect *rect, axisRects()) allAxes << rect->axes(); - + foreach (QCPAxis *axis, allAxes) { if (axis->selectedParts() != QCPAxis::spNone) result.append(axis); } - + return result; } /*! Returns the legends that currently have selected parts, i.e. whose selection state is not \ref QCPLegend::spNone. - + \see selectedPlottables, selectedAxes, setInteractions, QCPLegend::setSelectedParts, QCPLegend::setSelectableParts, QCPLegend::selectedItems */ QList QCustomPlot::selectedLegends() const { QList result; - + QStack elementStack; if (mPlotLayout) elementStack.push(mPlotLayout); - + while (!elementStack.isEmpty()) { foreach (QCPLayoutElement *subElement, elementStack.pop()->elements(false)) @@ -1844,17 +1850,17 @@ QList QCustomPlot::selectedLegends() const } } } - + return result; } /*! Deselects all layerables (plottables, items, axes, legends,...) of the QCustomPlot. - + Since calling this function is not a user interaction, this does not emit the \ref selectionChangedByUser signal. The individual selectionChanged signals are emitted though, if the objects were previously selected. - + \see setInteractions, selectedPlottables, selectedItems, selectedAxes, selectedLegends */ void QCustomPlot::deselectAll() @@ -1902,36 +1908,40 @@ void QCustomPlot::replot(QCustomPlot::RefreshPriority refreshPriority) } return; } - + if (mReplotting) // incase signals loop back to replot slot return; mReplotting = true; mReplotQueued = false; emit beforeReplot(); - + updateLayout(); // draw all layered objects (grid, axes, plottables, items, legend,...) into their buffers: setupPaintBuffers(); foreach (QCPLayer *layer, mLayers) - layer->drawToPaintBuffer(); + { + // Repaint only the main layer unless mRepaintAll + if ((layer->name() == "main") || mRepaintAll) + layer->drawToPaintBuffer(); + } for (int i=0; isetInvalidated(false); - + if ((refreshPriority == rpRefreshHint && mPlottingHints.testFlag(QCP::phImmediateRefresh)) || refreshPriority==rpImmediateRefresh) repaint(); else update(); - + emit afterReplot(); mReplotting = false; } /*! Rescales the axes such that all plottables (like graphs) in the plot are fully visible. - + if \a onlyVisiblePlottables is set to true, only the plottables that have their visibility set to true (QCPLayerable::setVisible), will be used to rescale the axes. - + \see QCPAbstractPlottable::rescaleAxes, QCPAxis::rescale */ void QCustomPlot::rescaleAxes(bool onlyVisiblePlottables) @@ -1939,7 +1949,7 @@ void QCustomPlot::rescaleAxes(bool onlyVisiblePlottables) QList allAxes; foreach (QCPAxisRect *rect, axisRects()) allAxes << rect->axes(); - + foreach (QCPAxis *axis, allAxes) axis->rescale(onlyVisiblePlottables); } @@ -2003,7 +2013,7 @@ bool QCustomPlot::savePdf(const QString &fileName, int width, int height, QCP::E newWidth = width; newHeight = height; } - + QPrinter printer(QPrinter::ScreenResolution); printer.setOutputFileName(fileName); printer.setOutputFormat(QPrinter::PdfFormat); @@ -2186,7 +2196,7 @@ bool QCustomPlot::saveBmp(const QString &fileName, int width, int height, double } /*! \internal - + Returns a minimum size hint that corresponds to the minimum size of the top level layout (\ref plotLayout). To prevent QCustomPlot from being collapsed to size/width zero, set a minimum size (setMinimumSize) either on the whole QCustomPlot or on any layout elements inside the plot. @@ -2199,9 +2209,9 @@ QSize QCustomPlot::minimumSizeHint() const } /*! \internal - + Returns a size hint that is the same as \ref minimumSizeHint. - + */ QSize QCustomPlot::sizeHint() const { @@ -2209,7 +2219,7 @@ QSize QCustomPlot::sizeHint() const } /*! \internal - + Event handler for when the QCustomPlot widget needs repainting. This does not cause a \ref replot, but draws the internal buffer on the widget surface. */ @@ -2229,7 +2239,7 @@ void QCustomPlot::paintEvent(QPaintEvent *event) } /*! \internal - + Event handler for a resize of the QCustomPlot widget. The viewport (which becomes the outer rect of mPlotLayout) is resized appropriately. Finally a \ref replot is performed. */ @@ -2242,12 +2252,12 @@ void QCustomPlot::resizeEvent(QResizeEvent *event) } /*! \internal - + Event handler for when a double click occurs. Emits the \ref mouseDoubleClick signal, then determines the layerable under the cursor and forwards the event to it. Finally, emits the specialized signals when certain objecs are clicked (e.g. \ref plottableDoubleClick, \ref axisDoubleClick, etc.). - + \see mousePressEvent, mouseReleaseEvent */ void QCustomPlot::mouseDoubleClickEvent(QMouseEvent *event) @@ -2255,7 +2265,7 @@ void QCustomPlot::mouseDoubleClickEvent(QMouseEvent *event) emit mouseDoubleClick(event); mMouseHasMoved = false; mMousePressPos = event->pos(); - + // determine layerable under the cursor (this event is called instead of the second press event in a double-click): QList details; QList candidates = layerableListAt(mMousePressPos, false, &details); @@ -2270,7 +2280,7 @@ void QCustomPlot::mouseDoubleClickEvent(QMouseEvent *event) break; } } - + // emit specialized object double click signals: if (!candidates.isEmpty()) { @@ -2289,17 +2299,17 @@ void QCustomPlot::mouseDoubleClickEvent(QMouseEvent *event) else if (QCPAbstractLegendItem *li = qobject_cast(candidates.first())) emit legendDoubleClick(li->parentLegend(), li, event); } - + event->accept(); // in case QCPLayerable reimplementation manipulates event accepted state. In QWidget event system, QCustomPlot wants to accept the event. } /*! \internal - + Event handler for when a mouse button is pressed. Emits the mousePress signal. If the current \ref setSelectionRectMode is not \ref QCP::srmNone, passes the event to the selection rect. Otherwise determines the layerable under the cursor and forwards the event to it. - + \see mouseMoveEvent, mouseReleaseEvent */ void QCustomPlot::mousePressEvent(QMouseEvent *event) @@ -2308,7 +2318,7 @@ void QCustomPlot::mousePressEvent(QMouseEvent *event) // save some state to tell in releaseEvent whether it was a click: mMouseHasMoved = false; mMousePressPos = event->pos(); - + if (mSelectionRect && mSelectionRectMode != QCP::srmNone) { if (mSelectionRectMode != QCP::srmZoom || qobject_cast(axisRectAt(mMousePressPos))) // in zoom mode only activate selection rect if on an axis rect @@ -2336,34 +2346,34 @@ void QCustomPlot::mousePressEvent(QMouseEvent *event) } } } - + event->accept(); // in case QCPLayerable reimplementation manipulates event accepted state. In QWidget event system, QCustomPlot wants to accept the event. } /*! \internal - + Event handler for when the cursor is moved. Emits the \ref mouseMove signal. If the selection rect (\ref setSelectionRect) is currently active, the event is forwarded to it in order to update the rect geometry. - + Otherwise, if a layout element has mouse capture focus (a mousePressEvent happened on top of the layout element before), the mouseMoveEvent is forwarded to that element. - + \see mousePressEvent, mouseReleaseEvent */ void QCustomPlot::mouseMoveEvent(QMouseEvent *event) { emit mouseMove(event); - + if (!mMouseHasMoved && (mMousePressPos-event->pos()).manhattanLength() > 3) mMouseHasMoved = true; // moved too far from mouse press position, don't handle as click on mouse release - + if (mSelectionRect && mSelectionRect->isActive()) mSelectionRect->moveSelection(event); else if (mMouseEventLayerable) // call event of affected layerable: mMouseEventLayerable->mouseMoveEvent(event, mMousePressPos); - + event->accept(); // in case QCPLayerable reimplementation manipulates event accepted state. In QWidget event system, QCustomPlot wants to accept the event. } @@ -2384,14 +2394,14 @@ void QCustomPlot::mouseMoveEvent(QMouseEvent *event) void QCustomPlot::mouseReleaseEvent(QMouseEvent *event) { emit mouseRelease(event); - + if (!mMouseHasMoved) // mouse hasn't moved (much) between press and release, so handle as click { if (mSelectionRect && mSelectionRect->isActive()) // a simple click shouldn't successfully finish a selection rect, so cancel it here mSelectionRect->cancel(); if (event->button() == Qt::LeftButton) processPointSelection(event); - + // emit specialized click signals of QCustomPlot instance: if (QCPAbstractPlottable *ap = qobject_cast(mMouseSignalLayerable)) { @@ -2409,7 +2419,7 @@ void QCustomPlot::mouseReleaseEvent(QMouseEvent *event) emit legendClick(li->parentLegend(), li, event); mMouseSignalLayerable = 0; } - + if (mSelectionRect && mSelectionRect->isActive()) // Note: if a click was detected above, the selection rect is canceled there { // finish selection rect, the appropriate action will be taken via signal-slot connection: @@ -2423,10 +2433,10 @@ void QCustomPlot::mouseReleaseEvent(QMouseEvent *event) mMouseEventLayerable = 0; } } - + if (noAntialiasingOnDrag()) replot(rpQueuedReplot); - + event->accept(); // in case QCPLayerable reimplementation manipulates event accepted state. In QWidget event system, QCustomPlot wants to accept the event. } @@ -2451,7 +2461,7 @@ void QCustomPlot::wheelEvent(QWheelEvent *event) } /*! \internal - + This function draws the entire plot, including background pixmap, with the specified \a painter. It does not make use of the paint buffers like \ref replot, so this is the function typically used by saving/exporting methods such as \ref savePdf or \ref toPainter. @@ -2463,14 +2473,14 @@ void QCustomPlot::wheelEvent(QWheelEvent *event) void QCustomPlot::draw(QCPPainter *painter) { updateLayout(); - + // draw viewport background pixmap: drawBackground(painter); // draw all layered objects (grid, axes, plottables, items, legend,...): foreach (QCPLayer *layer, mLayers) layer->draw(painter); - + /* Debug code to draw all layout element rects foreach (QCPLayoutElement* el, findChildren()) { @@ -2500,9 +2510,9 @@ void QCustomPlot::updateLayout() } /*! \internal - + Draws the viewport background pixmap of the plot. - + 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 viewport with the provided \a painter. The scaled version is buffered in @@ -2510,10 +2520,10 @@ void QCustomPlot::updateLayout() the axis rect has changed in a way that requires a rescale of the background pixmap (this is 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 QBrush &brush)) beneath the pixmap. - + \see setBackground, setBackgroundScaled, setBackgroundScaledMode */ void QCustomPlot::drawBackground(QCPPainter *painter) @@ -2562,7 +2572,7 @@ void QCustomPlot::setupPaintBuffers() int bufferIndex = 0; if (mPaintBuffers.isEmpty()) mPaintBuffers.append(QSharedPointer(createPaintBuffer())); - + for (int layerIndex = 0; layerIndex < mLayers.size(); ++layerIndex) { QCPLayer *layer = mLayers.at(layerIndex); @@ -2590,7 +2600,8 @@ void QCustomPlot::setupPaintBuffers() for (int i=0; isetSize(viewport().size()); // won't do anything if already correct size - mPaintBuffers.at(i)->clear(Qt::transparent); + if (mRepaintAll) + mPaintBuffers.at(i)->clear(Qt::transparent); mPaintBuffers.at(i)->setInvalidated(); } } @@ -2721,7 +2732,7 @@ void QCustomPlot::freeOpenGl() } /*! \internal - + This method is used by \ref QCPAxisRect::removeAxis to report removed axes to the QCustomPlot so it may clear its QCustomPlot::xAxis, yAxis, xAxis2 and yAxis2 members accordingly. */ @@ -2735,12 +2746,12 @@ void QCustomPlot::axisRemoved(QCPAxis *axis) yAxis = 0; if (yAxis2 == axis) yAxis2 = 0; - + // Note: No need to take care of range drag axes and range zoom axes, because they are stored in smart pointers } /*! \internal - + This method is used by the QCPLegend destructor to report legend removal to the QCustomPlot so it may clear its QCustomPlot::legend member accordingly. */ @@ -2751,7 +2762,7 @@ void QCustomPlot::legendRemoved(QCPLegend *legend) } /*! \internal - + This slot is connected to the selection rect's \ref QCPSelectionRect::accepted signal when \ref setSelectionRectMode is set to \ref QCP::srmSelect. @@ -2759,18 +2770,18 @@ void QCustomPlot::legendRemoved(QCPLegend *legend) point of the selection. Then it goes through the plottables (\ref QCPAbstractPlottable1D to be precise) associated with that axis rect and finds the data points that are in \a rect. It does this by querying their \ref QCPAbstractPlottable1D::selectTestRect method. - + Then, the actual selection is done by calling the plottables' \ref QCPAbstractPlottable::selectEvent, placing the found selected data points in the \a details parameter as QVariant(\ref QCPDataSelection). All plottables that weren't touched by \a rect receive a \ref QCPAbstractPlottable::deselectEvent. - + \see processRectZoom */ void QCustomPlot::processRectSelection(QRect rect, QMouseEvent *event) { bool selectionStateChanged = false; - + if (mInteractions.testFlag(QCP::iSelectPlottables)) { QMap > potentialSelections; // map key is number of selected data points, so we have selections sorted by size @@ -2787,7 +2798,7 @@ void QCustomPlot::processRectSelection(QRect rect, QMouseEvent *event) potentialSelections.insertMulti(dataSel.dataPointCount(), QPair(plottable, dataSel)); } } - + if (!mInteractions.testFlag(QCP::iMultiSelect)) { // only leave plottable with most selected points in map, since we will only select a single plottable: @@ -2798,7 +2809,7 @@ void QCustomPlot::processRectSelection(QRect rect, QMouseEvent *event) it = potentialSelections.erase(it); } } - + bool additive = event->modifiers().testFlag(mMultiSelectModifier); // deselect all other layerables if not additive selection: if (!additive) @@ -2817,7 +2828,7 @@ void QCustomPlot::processRectSelection(QRect rect, QMouseEvent *event) } } } - + // go through selections in reverse (largest selection first) and emit select events: QMap >::const_iterator it = potentialSelections.constEnd(); while (it != potentialSelections.constBegin()) @@ -2832,7 +2843,7 @@ void QCustomPlot::processRectSelection(QRect rect, QMouseEvent *event) } } } - + if (selectionStateChanged) { emit selectionChangedByUser(); @@ -2842,14 +2853,14 @@ void QCustomPlot::processRectSelection(QRect rect, QMouseEvent *event) } /*! \internal - + This slot is connected to the selection rect's \ref QCPSelectionRect::accepted signal when \ref setSelectionRectMode is set to \ref QCP::srmZoom. It determines which axis rect was the origin of the selection rect judging by the starting point of the selection, and then zooms the axes defined via \ref QCPAxisRect::setRangeZoomAxes to the provided \a rect (see \ref QCPAxisRect::zoom). - + \see processRectSelection */ void QCustomPlot::processRectZoom(QRect rect, QMouseEvent *event) @@ -2918,14 +2929,14 @@ void QCustomPlot::processPointSelection(QMouseEvent *event) } /*! \internal - + Registers the specified plottable with this QCustomPlot and, if \ref setAutoAddPlottableToLegend is enabled, adds it to the legend (QCustomPlot::legend). QCustomPlot takes ownership of the plottable. - + Returns true on success, i.e. when \a plottable isn't already in this plot and the parent plot of \a plottable is this QCustomPlot. - + This method is called automatically in the QCPAbstractPlottable base class constructor. */ bool QCustomPlot::registerPlottable(QCPAbstractPlottable *plottable) @@ -2940,7 +2951,7 @@ bool QCustomPlot::registerPlottable(QCPAbstractPlottable *plottable) qDebug() << Q_FUNC_INFO << "plottable not created with this QCustomPlot as parent:" << reinterpret_cast(plottable); return false; } - + mPlottables.append(plottable); // possibly add plottable to legend: if (mAutoAddPlottableToLegend) @@ -2951,11 +2962,11 @@ bool QCustomPlot::registerPlottable(QCPAbstractPlottable *plottable) } /*! \internal - + In order to maintain the simplified graph interface of QCustomPlot, this method is called by the QCPGraph constructor to register itself with this QCustomPlot's internal graph list. Returns true on success, i.e. if \a graph is valid and wasn't already registered with this QCustomPlot. - + This graph specific registration happens in addition to the call to \ref registerPlottable by the QCPAbstractPlottable base class. */ @@ -2971,7 +2982,7 @@ bool QCustomPlot::registerGraph(QCPGraph *graph) qDebug() << Q_FUNC_INFO << "graph already registered with this QCustomPlot"; return false; } - + mGraphs.append(graph); return true; } @@ -2980,10 +2991,10 @@ bool QCustomPlot::registerGraph(QCPGraph *graph) /*! \internal Registers the specified item with this QCustomPlot. QCustomPlot takes ownership of the item. - + Returns true on success, i.e. when \a item wasn't already in the plot and the parent plot of \a item is this QCustomPlot. - + This method is called automatically in the QCPAbstractItem base class constructor. */ bool QCustomPlot::registerItem(QCPAbstractItem *item) @@ -2998,7 +3009,7 @@ bool QCustomPlot::registerItem(QCPAbstractItem *item) qDebug() << Q_FUNC_INFO << "item not created with this QCustomPlot as parent:" << reinterpret_cast(item); return false; } - + mItems.append(item); if (!item->layer()) // usually the layer is already set in the constructor of the item (via QCPLayerable constructor) item->setLayer(currentLayer()); @@ -3006,7 +3017,7 @@ bool QCustomPlot::registerItem(QCPAbstractItem *item) } /*! \internal - + Assigns all layers their index (QCPLayer::mIndex) in the mLayers list. This method is thus called after every operation that changes the layer indices, like layer removal, layer creation, layer moving. @@ -3029,7 +3040,7 @@ void QCustomPlot::updateLayerIndices() const information about which part of the layerable was hit, in multi-part layerables (e.g. QCPAxis::SelectablePart). If the layerable is a plottable, \a selectionDetails contains a \ref QCPDataSelection instance with the single data point which is closest to \a pos. - + \see layerableListAt, layoutElementAt, axisRectAt */ QCPLayerable *QCustomPlot::layerableAt(const QPointF &pos, bool onlySelectable, QVariant *selectionDetails) const @@ -3059,7 +3070,7 @@ QCPLayerable *QCustomPlot::layerableAt(const QPointF &pos, bool onlySelectable, information about which part of the layerable was hit, in multi-part layerables (e.g. QCPAxis::SelectablePart). If the layerable is a plottable, \a selectionDetails contains a \ref QCPDataSelection instance with the single data point which is closest to \a pos. - + \see layerableAt, layoutElementAt, axisRectAt */ QList QCustomPlot::layerableListAt(const QPointF &pos, bool onlySelectable, QList *selectionDetails) const @@ -3106,7 +3117,7 @@ QList QCustomPlot::layerableListAt(const QPointF &pos, bool onlyS bool QCustomPlot::saveRastered(const QString &fileName, int width, int height, double scale, const char *format, int quality, int resolution, QCP::ResolutionUnit resolutionUnit) { QImage buffer = toPixmap(width, height, scale).toImage(); - + int dotsPerMeter = 0; switch (resolutionUnit) { @@ -3124,10 +3135,10 @@ bool QCustomPlot::saveRastered(const QString &fileName, int width, int height, d /*! Renders the plot to a pixmap and returns it. - + The plot is sized to \a width and \a height in pixels and scaled with \a scale. (width 100 and scale 2.0 lead to a full resolution pixmap with width 200.) - + \see toPainter, saveRastered, saveBmp, savePng, saveJpg, savePdf */ QPixmap QCustomPlot::toPixmap(int width, int height, double scale) @@ -3176,14 +3187,14 @@ QPixmap QCustomPlot::toPixmap(int width, int height, double scale) /*! Renders the plot using the passed \a painter. - + The plot is sized to \a width and \a height in pixels. If the \a painter's scale is not 1.0, the resulting plot will appear scaled accordingly. - + \note If you are restricted to using a QPainter (instead of QCPPainter), create a temporary QPicture and open a QCPPainter on it. Then call \ref toPainter with this QCPPainter. After ending the paint operation on the picture, draw it with the QPainter. This will reproduce the painter actions the QCPPainter took, with a QPainter. - + \see toPixmap */ void QCustomPlot::toPainter(QCPPainter *painter, int width, int height) diff --git a/src/core.h b/src/core.h index 137e97e3ee7ef53a2a7a7ca8b51042d989c95a2d..6f20b8ddbd7c3cb0d0f884f5b7307afd3e753fc2 100644 --- a/src/core.h +++ b/src/core.h @@ -54,6 +54,7 @@ class QCP_LIB_DECL QCustomPlot : public QWidget Q_PROPERTY(bool noAntialiasingOnDrag READ noAntialiasingOnDrag WRITE setNoAntialiasingOnDrag) Q_PROPERTY(Qt::KeyboardModifier multiSelectModifier READ multiSelectModifier WRITE setMultiSelectModifier) Q_PROPERTY(bool openGl READ openGl WRITE setOpenGl) + Q_PROPERTY(bool repaintAll READ repaintAll WRITE setRepaintAll) /// \endcond public: /*! @@ -65,7 +66,7 @@ public: ,limAbove ///< Layer is inserted above other layer }; Q_ENUMS(LayerInsertMode) - + /*! Defines with what timing the QCustomPlot surface is refreshed after a replot. @@ -77,10 +78,10 @@ public: ,rpQueuedReplot ///< Queues the entire replot for the next event loop iteration. This way multiple redundant replots can be avoided. The actual replot is then done with \ref rpRefreshHint priority. }; Q_ENUMS(RefreshPriority) - + explicit QCustomPlot(QWidget *parent = 0); virtual ~QCustomPlot(); - + // getters: QRect viewport() const { return mViewport; } double bufferDevicePixelRatio() const { return mBufferDevicePixelRatio; } @@ -99,7 +100,8 @@ public: QCP::SelectionRectMode selectionRectMode() const { return mSelectionRectMode; } QCPSelectionRect *selectionRect() const { return mSelectionRect; } bool openGl() const { return mOpenGl; } - + bool repaintAll() const { return mRepaintAll; } + // setters: void setViewport(const QRect &rect); void setBufferDevicePixelRatio(double ratio); @@ -123,7 +125,8 @@ public: void setSelectionRectMode(QCP::SelectionRectMode mode); void setSelectionRect(QCPSelectionRect *selectionRect); void setOpenGl(bool enabled, int multisampling=16); - + void setRepaintAll(bool repaint); + // non-property methods: // plottable interface: QCPAbstractPlottable *plottable(int index); @@ -135,7 +138,7 @@ public: QList selectedPlottables() const; QCPAbstractPlottable *plottableAt(const QPointF &pos, bool onlySelectable=false) const; bool hasPlottable(QCPAbstractPlottable *plottable) const; - + // specialized interface for QCPGraph: QCPGraph *graph(int index) const; QCPGraph *graph() const; @@ -156,7 +159,7 @@ public: QList selectedItems() const; QCPAbstractItem *itemAt(const QPointF &pos, bool onlySelectable=false) const; bool hasItem(QCPAbstractItem *item) const; - + // layer interface: QCPLayer *layer(const QString &name) const; QCPLayer *layer(int index) const; @@ -167,7 +170,7 @@ public: bool addLayer(const QString &name, QCPLayer *otherLayer=0, LayerInsertMode insertMode=limAbove); bool removeLayer(QCPLayer *layer); bool moveLayer(QCPLayer *layer, QCPLayer *otherLayer, LayerInsertMode insertMode=limAbove); - + // axis rect/layout interface: int axisRectCount() const; QCPAxisRect* axisRect(int index=0) const; @@ -175,11 +178,11 @@ public: QCPLayoutElement* layoutElementAt(const QPointF &pos) const; QCPAxisRect* axisRectAt(const QPointF &pos) const; Q_SLOT void rescaleAxes(bool onlyVisiblePlottables=false); - + QList selectedAxes() const; QList selectedLegends() const; Q_SLOT void deselectAll(); - + bool savePdf(const QString &fileName, int width=0, int height=0, QCP::ExportPen exportPen=QCP::epAllowCosmetic, const QString &pdfCreator=QString(), const QString &pdfTitle=QString()); bool savePng(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch); bool saveJpg(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch); @@ -188,17 +191,17 @@ public: 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(QCustomPlot::RefreshPriority refreshPriority=QCustomPlot::rpRefreshHint); - + QCPAxis *xAxis, *yAxis, *xAxis2, *yAxis2; QCPLegend *legend; - + signals: void mouseDoubleClick(QMouseEvent *event); void mousePress(QMouseEvent *event); void mouseMove(QMouseEvent *event); void mouseRelease(QMouseEvent *event); void mouseWheel(QWheelEvent *event); - + void plottableClick(QCPAbstractPlottable *plottable, int dataIndex, QMouseEvent *event); void plottableDoubleClick(QCPAbstractPlottable *plottable, int dataIndex, QMouseEvent *event); void itemClick(QCPAbstractItem *item, QMouseEvent *event); @@ -207,11 +210,11 @@ signals: 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 selectionChangedByUser(); void beforeReplot(); void afterReplot(); - + protected: // property members: QRect mViewport; @@ -237,7 +240,8 @@ protected: QCP::SelectionRectMode mSelectionRectMode; QCPSelectionRect *mSelectionRect; bool mOpenGl; - + bool mRepaintAll; + // non-property members: QList > mPaintBuffers; QPoint mMousePressPos; @@ -256,7 +260,7 @@ protected: QSharedPointer mGlSurface; QSharedPointer mGlPaintDevice; #endif - + // reimplemented virtual methods: virtual QSize minimumSizeHint() const Q_DECL_OVERRIDE; virtual QSize sizeHint() const Q_DECL_OVERRIDE; @@ -267,7 +271,7 @@ protected: virtual void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; virtual void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE; - + // introduced virtual methods: virtual void draw(QCPPainter *painter); virtual void updateLayout(); @@ -276,7 +280,7 @@ protected: Q_SLOT virtual void processRectSelection(QRect rect, QMouseEvent *event); Q_SLOT virtual void processRectZoom(QRect rect, QMouseEvent *event); Q_SLOT virtual void processPointSelection(QMouseEvent *event); - + // non-virtual methods: bool registerPlottable(QCPAbstractPlottable *plottable); bool registerGraph(QCPGraph *graph); @@ -290,7 +294,7 @@ protected: bool hasInvalidatedPaintBuffers(); bool setupOpenGl(); void freeOpenGl(); - + friend class QCPLegend; friend class QCPAxis; friend class QCPLayer;