From dbd9c134fafed03d108d6a572cf5b4ccef108b7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Mayer?= Date: Tue, 3 Dec 2013 21:49:28 +0000 Subject: [PATCH] - Fix lots of "C:\wireshark\trunk\ui\qt\qcustomplot.cpp(16589) : warning C4305: 'argument' : truncation from 'double' to 'float'" - Remove trailing whitespace svn path=/trunk/; revision=53768 --- ui/qt/qcustomplot.cpp | 3096 ++++++++++++++++++++--------------------- 1 file changed, 1548 insertions(+), 1548 deletions(-) diff --git a/ui/qt/qcustomplot.cpp b/ui/qt/qcustomplot.cpp index 8cbd6a3cc1..1585755c9b 100644 --- a/ui/qt/qcustomplot.cpp +++ b/ui/qt/qcustomplot.cpp @@ -37,11 +37,11 @@ /*! \class QCPPainter \brief 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. - + \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 @@ -63,7 +63,7 @@ QCPPainter::QCPPainter() : /*! Creates a new QCPPainter instance on the specified paint \a device and sets default values. Just like the analogous QPainter constructor, begins painting on \a device immediately. - + Like \ref begin, this method sets QPainter::NonCosmeticDefaultPen in Qt versions before Qt5. */ QCPPainter::QCPPainter(QPaintDevice *device) : @@ -84,7 +84,7 @@ QCPPainter::~QCPPainter() /*! Sets the pen of the painter and applies certain fixes to it, depending on the mode of this QCPPainter. - + \note this function hides the non-virtual base class implementation. */ void QCPPainter::setPen(const QPen &pen) @@ -95,10 +95,10 @@ void QCPPainter::setPen(const QPen &pen) } /*! \overload - + Sets the pen (by color) of the painter and applies certain fixes to it, depending on the mode of this QCPPainter. - + \note this function hides the non-virtual base class implementation. */ void QCPPainter::setPen(const QColor &color) @@ -109,10 +109,10 @@ void QCPPainter::setPen(const QColor &color) } /*! \overload - + Sets the pen (by style) of the painter and applies certain fixes to it, depending on the mode of this QCPPainter. - + \note this function hides the non-virtual base class implementation. */ void QCPPainter::setPen(Qt::PenStyle penStyle) @@ -123,11 +123,11 @@ void QCPPainter::setPen(Qt::PenStyle penStyle) } /*! \overload - + Works around a Qt bug introduced with Qt 4.8 which makes drawing QLineF unpredictable when antialiasing is disabled. Thus when antialiasing is disabled, it rounds the \a line to integer coordinates and then passes it to the original drawLine. - + \note this function hides the non-virtual base class implementation. */ void QCPPainter::drawLine(const QLineF &line) @@ -138,7 +138,7 @@ void QCPPainter::drawLine(const QLineF &line) 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 @@ -174,10 +174,10 @@ void QCPPainter::setModes(QCPPainter::PainterModes modes) device. This is necessary to get cosmetic pen consistency across Qt versions, because since Qt5, all pens are non-cosmetic by default, and in Qt4 this render hint must be set to get that behaviour. - + The Constructor \ref QCPPainter(QPaintDevice *device) which directly starts painting also sets the render hint as appropriate. - + \note this function hides the non-virtual base class implementation. */ bool QCPPainter::begin(QPaintDevice *device) @@ -191,7 +191,7 @@ bool QCPPainter::begin(QPaintDevice *device) } /*! \overload - + Sets the mode of the painter. This controls whether the painter shall adjust its fixes/workarounds optimized for certain output devices. */ @@ -206,9 +206,9 @@ void QCPPainter::setMode(QCPPainter::PainterMode mode, bool enabled) /*! Saves the painter (see QPainter::save). Since QCPPainter adds some new internal state to QPainter, the save/restore functions are reimplemented to also save/restore those members. - + \note this function hides the non-virtual base class implementation. - + \see restore */ void QCPPainter::save() @@ -220,9 +220,9 @@ void QCPPainter::save() /*! Restores the painter (see QPainter::restore). Since QCPPainter adds some new internal state to QPainter, the save/restore functions are reimplemented to also save/restore those members. - + \note this function hides the non-virtual base class implementation. - + \see save */ void QCPPainter::restore() @@ -255,17 +255,17 @@ void QCPPainter::makeNonCosmetic() /*! \class QCPScatterStyle \brief Represents the visual appearance of scatter points - + This class holds information about shape, color and size of scatter points. In plottables like QCPGraph it is used to store how scatter points shall be drawn. For example, \ref QCPGraph::setScatterStyle takes a QCPScatterStyle instance. - + A scatter style consists of a shape (\ref setShape), a line color (\ref setPen) and possibly a fill (\ref setBrush), if the shape provides a fillable area. Further, the size of the shape can be controlled with \ref setSize. \section QCPScatterStyle-defining Specifying a scatter style - + You can set all these configurations either by calling the respective functions on an instance: \code QCPScatterStyle myScatter; @@ -275,22 +275,22 @@ void QCPPainter::makeNonCosmetic() myScatter.setSize(5); customPlot->graph(0)->setScatterStyle(myScatter); \endcode - + Or you can use one of the various constructors that take different parameter combinations, making it easy to specify a scatter style in a single call, like so: \code customPlot->graph(0)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, Qt::blue, Qt::white, 5)); \endcode - + \section QCPScatterStyle-undefinedpen Leaving the color/pen up to the plottable - + There are two constructors which leave the pen undefined: \ref QCPScatterStyle() and \ref QCPScatterStyle(ScatterShape shape, double size). If those constructors are used, a call to \ref isPenDefined will return false. It leads to scatter points that inherit the pen from the plottable that uses the scatter style. Thus, if such a scatter style is passed to QCPGraph, the line color of the graph (\ref QCPGraph::setPen) will be used by the scatter points. This makes it very convenient to set up typical scatter settings: - + \code customPlot->graph(0)->setScatterStyle(QCPScatterStyle::ssPlus); \endcode @@ -300,15 +300,15 @@ void QCPPainter::makeNonCosmetic() into a QCPScatterStyle instance (that's the \ref QCPScatterStyle(ScatterShape shape, double size) constructor with a default for \a size). In those cases, C++ allows directly supplying a \ref ScatterShape, where actually a QCPScatterStyle is expected. - + \section QCPScatterStyle-custompath-and-pixmap Custom shapes and pixmaps - + QCPScatterStyle supports drawing custom shapes and arbitrary pixmaps as scatter points. For custom shapes, you can provide a QPainterPath with the desired shape to the \ref setCustomPath function or call the constructor that takes a painter path. The scatter shape will automatically be set to \ref ssCustom. - + For pixmaps, you call \ref setPixmap with the desired QPixmap. Alternatively you can use the constructor that takes a QPixmap. The scatter shape will automatically be set to \ref ssPixmap. Note that \ref setSize does not influence the appearance of the pixmap. @@ -317,21 +317,21 @@ void QCPPainter::makeNonCosmetic() /* start documentation of inline functions */ /*! \fn bool QCPScatterStyle::isNone() const - + Returns whether the scatter shape is \ref ssNone. - + \see setShape */ /*! \fn bool QCPScatterStyle::isPenDefined() const - + Returns whether a pen has been defined for this scatter style. - + The pen is undefined if a constructor is called that does not carry \a pen as parameter. Those are \ref QCPScatterStyle() and \ref QCPScatterStyle(ScatterShape shape, double size). If the pen is left undefined, the scatter color will be inherited from the plottable that uses this scatter style. - + \see setPen */ @@ -339,7 +339,7 @@ void QCPPainter::makeNonCosmetic() /*! Creates a new QCPScatterStyle instance with size set to 6. No shape, pen or brush is defined. - + Since the pen is undefined (\ref isPenDefined returns false), the scatter color will be inherited from the plottable that uses this scatter style. */ @@ -355,7 +355,7 @@ QCPScatterStyle::QCPScatterStyle() : /*! Creates a new QCPScatterStyle instance with shape set to \a shape and size to \a size. No pen or brush is defined. - + Since the pen is undefined (\ref isPenDefined returns false), the scatter color will be inherited from the plottable that uses this scatter style. */ @@ -397,7 +397,7 @@ QCPScatterStyle::QCPScatterStyle(ScatterShape shape, const QColor &color, const /*! Creates a new QCPScatterStyle instance with shape set to \a shape, the pen set to \a pen, the brush to \a brush, and size to \a size. - + \warning In some cases it might be tempting to directly use a pen style like Qt::NoPen as \a pen and a color like Qt::blue as \a brush. Notice however, that the corresponding call\n QCPScatterStyle(QCPScatterShape::ssCircle, Qt::NoPen, Qt::blue, 5)\n @@ -435,7 +435,7 @@ QCPScatterStyle::QCPScatterStyle(const QPixmap &pixmap) : /*! Creates a new QCPScatterStyle instance with a custom shape that is defined via \a customPath. The scatter shape is set to \ref ssCustom. - + The custom shape line will be drawn with \a pen and filled with \a brush. The size has a slightly different meaning than for built-in scatter points: The custom path will be drawn scaled by a factor of \a size/6.0. Since the default \a size is 6, the custom path will appear at a its @@ -453,7 +453,7 @@ QCPScatterStyle::QCPScatterStyle(const QPainterPath &customPath, const QPen &pen /*! Sets the size (pixel diameter) of the drawn scatter points to \a size. - + \see setShape */ void QCPScatterStyle::setSize(double size) @@ -463,10 +463,10 @@ void QCPScatterStyle::setSize(double size) /*! Sets the shape to \a shape. - + Note that the calls \ref setPixmap and \ref setCustomPath automatically set the shape to \ref ssPixmap and \ref ssCustom, respectively. - + \see setSize */ void QCPScatterStyle::setShape(QCPScatterStyle::ScatterShape shape) @@ -476,10 +476,10 @@ void QCPScatterStyle::setShape(QCPScatterStyle::ScatterShape shape) /*! Sets the pen that will be used to draw scatter points to \a pen. - + If the pen was previously undefined (see \ref isPenDefined), the pen is considered defined after a call to this function, even if \a pen is Qt::NoPen. - + \see setBrush */ void QCPScatterStyle::setPen(const QPen &pen) @@ -491,7 +491,7 @@ void QCPScatterStyle::setPen(const QPen &pen) /*! Sets the brush that will be used to fill scatter points to \a brush. Note that not all scatter shapes have fillable areas. For example, \ref ssPlus does not while \ref ssCircle does. - + \see setPen */ void QCPScatterStyle::setBrush(const QBrush &brush) @@ -501,9 +501,9 @@ void QCPScatterStyle::setBrush(const QBrush &brush) /*! Sets the pixmap that will be drawn as scatter point to \a pixmap. - + Note that \ref setSize does not influence the appearance of the pixmap. - + The scatter shape is automatically set to \ref ssPixmap. */ void QCPScatterStyle::setPixmap(const QPixmap &pixmap) @@ -514,7 +514,7 @@ void QCPScatterStyle::setPixmap(const QPixmap &pixmap) /*! Sets the custom shape that will be drawn as scatter point to \a customPath. - + The scatter shape is automatically set to \ref ssCustom. */ void QCPScatterStyle::setCustomPath(const QPainterPath &customPath) @@ -526,10 +526,10 @@ void QCPScatterStyle::setCustomPath(const QPainterPath &customPath) /*! Applies the pen and the brush of this scatter style to \a painter. If this scatter style has an undefined pen (\ref isPenDefined), sets the pen of \a painter to \a defaultPen instead. - + This function is used by plottables (or any class that wants to draw scatters) just before a number of scatters with this style shall be drawn with the \a painter. - + \see drawShape */ void QCPScatterStyle::applyTo(QCPPainter *painter, const QPen &defaultPen) const @@ -540,10 +540,10 @@ void QCPScatterStyle::applyTo(QCPPainter *painter, const QPen &defaultPen) const /*! Draws the scatter shape with \a painter at position \a pos. - + This function does not modify the pen or the brush on the painter, as \ref applyTo is meant to be called before scatter points are drawn with \ref drawShape. - + \see applyTo */ void QCPScatterStyle::drawShape(QCPPainter *painter, QPointF pos) const @@ -685,18 +685,18 @@ void QCPScatterStyle::drawShape(QCPPainter *painter, double x, double y) const /*! \class QCPLayer \brief A layer that may contain objects, to control the rendering order - + The Layering system of QCustomPlot is the mechanism to control the rendering order of the elements inside the plot. - + It is based on the two classes QCPLayer and QCPLayerable. QCustomPlot holds an ordered list of one or more instances of QCPLayer (see QCustomPlot::addLayer, QCustomPlot::layer, QCustomPlot::moveLayer, etc.). When replotting, QCustomPlot goes through the list of layers bottom to top and successively draws the layerables of the layers. - + A QCPLayer contains an ordered list of QCPLayerable instances. QCPLayerable is an abstract base class from which almost all visible objects derive, like axes, grids, graphs, items, etc. - + Initially, QCustomPlot has five layers: "background", "grid", "main", "axes" and "legend" (in that order). The top two layers "axes" and "legend" contain the default axes and legend, so they will be drawn on top. In the middle, there is the "main" layer. It is initially empty and set as @@ -706,21 +706,21 @@ void QCPScatterStyle::drawShape(QCPPainter *painter, double x, double y) const shall be drawn behind everything else, thus the default QCPAxisRect instance is placed on the "background" layer. Of course, the layer affiliation of the individual objects can be changed as required (\ref QCPLayerable::setLayer). - + Controlling the ordering of objects is easy: Create a new layer in the position you want it to be, e.g. above "main", with QCustomPlot::addLayer. Then set the current layer with QCustomPlot::setCurrentLayer to that new layer and finally create the objects normally. They will be placed on the new layer automatically, due to the current layer setting. Alternatively you could have also ignored the current layer setting and just moved the objects with QCPLayerable::setLayer to the desired layer after creating them. - + It is also possible to move whole layers. For example, If you want the grid to be shown in front of all plottables/items on the "main" layer, just move it above "main" with QCustomPlot::moveLayer. - + The rendering order within one layer is simply by order of creation or insertion. The item created last (or added last to the layer), is drawn on top of all other objects on that layer. - + When a layer is deleted, the objects on it are not deleted with it, but fall on the layer below the deleted layer, see QCustomPlot::removeLayer. */ @@ -728,16 +728,16 @@ void QCPScatterStyle::drawShape(QCPPainter *painter, double x, double y) const /* start documentation of inline functions */ /*! \fn QList QCPLayer::children() const - + Returns a list of all layerables on this layer. The order corresponds to the rendering order: layerables with higher indices are drawn above layerables with lower indices. */ /*! \fn int QCPLayer::index() const - + Returns the index this layer has in the QCustomPlot. The index is the integer number by which this layer can be accessed via \ref QCustomPlot::layer. - + Layers with higher indices will be drawn above layers with lower indices. */ @@ -745,9 +745,9 @@ void QCPScatterStyle::drawShape(QCPPainter *painter, double x, double y) const /*! Creates a new QCPLayer instance. - + Normally you shouldn't directly instantiate layers, use \ref QCustomPlot::addLayer instead. - + \warning It is not checked that \a layerName is actually a unique layer name in \a parentPlot. This check is only performed by \ref QCustomPlot::addLayer. */ @@ -767,22 +767,22 @@ QCPLayer::~QCPLayer() // then invalid layer once they get deleted/moved themselves. This only happens when layers are deleted // directly, like in the QCustomPlot destructor. (The regular layer removal procedure for the user is to // call QCustomPlot::removeLayer, which moves all layerables off this layer before deleting it.) - + while (!mChildren.isEmpty()) mChildren.last()->setLayer(0); // removes itself from mChildren via removeChild() - + if (mParentPlot->currentLayer() == this) 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."; } /*! \internal - + Adds the \a layerable to the list of this layer. If \a prepend is set to true, the layerable will be prepended to the list, i.e. be drawn beneath the other layerables already in the list. - + This function does not change the \a mLayer member of \a layerable to this layer. (Use QCPLayerable::setLayer to change the layer of an object, not this function.) - + \see removeChild */ void QCPLayer::addChild(QCPLayerable *layerable, bool prepend) @@ -798,12 +798,12 @@ void QCPLayer::addChild(QCPLayerable *layerable, bool prepend) } /*! \internal - + Removes the \a layerable from the list of this layer. - + This function does not change the \a mLayer member of \a layerable. (Use QCPLayerable::setLayer to change the layer of an object, not this function.) - + \see addChild */ void QCPLayer::removeChild(QCPLayerable *layerable) @@ -819,27 +819,27 @@ void QCPLayer::removeChild(QCPLayerable *layerable) /*! \class QCPLayerable \brief Base class for all drawable objects - + This is the abstract base class most visible objects derive from, e.g. plottables, axes, grid etc. Every layerable is on a layer (QCPLayer) which allows controlling the rendering order by stacking the layers accordingly. - + For details about the layering mechanism, see the QCPLayer documentation. */ /* start documentation of inline functions */ /*! \fn QCPLayerable *QCPLayerable::parentLayerable() const - + Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method \ref 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. */ @@ -849,7 +849,7 @@ void QCPLayer::removeChild(QCPLayerable *layerable) /*! \fn virtual void QCPLayerable::applyDefaultAntialiasingHint(QCPPainter *painter) const = 0 \internal - + This function applies the default antialiasing setting to the specified \a painter, using the function \ref applyAntialiasingHint. It is the antialiasing state the painter is put in, when \ref draw is called on the layerable. If the layerable has multiple entities whose antialiasing @@ -857,7 +857,7 @@ void QCPLayer::removeChild(QCPLayerable *layerable) most prominent entity. In this case however, the \ref 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 @@ -865,7 +865,7 @@ void QCPLayer::removeChild(QCPLayerable *layerable) 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 @@ -878,10 +878,10 @@ void QCPLayer::removeChild(QCPLayerable *layerable) /*! \fn virtual void QCPLayerable::draw(QCPPainter *painter) const = 0 \internal - + This function draws the layerable with the specified \a painter. It is only called by QCustomPlot, if the layerable is visible (\ref setVisible). - + Before this function is called, the painter's antialiasing state is set via \ref applyDefaultAntialiasingHint, see the documentation there. Further, the clipping rectangle was set to \ref clipRect. @@ -891,17 +891,17 @@ void QCPLayer::removeChild(QCPLayerable *layerable) /*! Creates a new QCPLayerable instance. - + Since QCPLayerable is an abstract base class, it can't be instantiated directly. Use one of the derived classes. - + If \a plot is provided, it automatically places itself on the layer named \a targetLayer. If \a targetLayer is an empty string, it places itself on the current layer of the plot (see \ref QCustomPlot::setCurrentLayer). - + It is possible to provide 0 as \a plot. In that case, you should assign a parent plot at a later time with \ref initializeParentPlot. - + The layerable's parent layerable is set to \a parentLayerable, if provided. Direct layerable parents are mainly used to control visibility in a hierarchy of layerables. This means a layerable is only drawn, if all its ancestor layerables are also visible. Note that \a parentLayerable does @@ -946,7 +946,7 @@ void QCPLayerable::setVisible(bool on) /*! Sets the \a layer of this layerable object. The object will be placed on top of the other objects already on \a layer. - + Returns true on success, i.e. if \a layer is a valid layer. */ bool QCPLayerable::setLayer(QCPLayer *layer) @@ -956,7 +956,7 @@ bool QCPLayerable::setLayer(QCPLayer *layer) /*! \overload Sets the layer of this layerable object by name - + Returns true on success, i.e. if \a layerName is a valid layer name. */ bool QCPLayerable::setLayer(const QString &layerName) @@ -978,7 +978,7 @@ bool QCPLayerable::setLayer(const QString &layerName) /*! Sets whether this object will be drawn antialiased or not. - + Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. */ @@ -991,12 +991,12 @@ void QCPLayerable::setAntialiased(bool enabled) 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 \ref realVisibility returns true. - + If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility. */ @@ -1017,15 +1017,15 @@ bool QCPLayerable::realVisibility() const 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. - + \a details is an optional output parameter. Every layerable subclass may place any information in \a details. This information will be passed to \ref selectEvent when the parent QCustomPlot decides on the basis of this selectTest call, that the object was successfully selected. The @@ -1034,9 +1034,9 @@ bool QCPLayerable::realVisibility() const is only done once in \ref selectTest. The result (i.e. the actually clicked part) can then be placed in \a details. So in the subsequent \ref 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 \a details to indicate that you are not interested in those selection details. - + \see selectEvent, deselectEvent, QCustomPlot::setInteractions */ double QCPLayerable::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const @@ -1048,18 +1048,18 @@ double QCPLayerable::selectTest(const QPointF &pos, bool onlySelectable, QVarian } /*! \internal - + 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 \a parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(\a parentPlot) in addition to this function. - + Further, you will probably want to set a layer (\ref 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 \ref parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does). @@ -1071,23 +1071,23 @@ void QCPLayerable::initializeParentPlot(QCustomPlot *parentPlot) qDebug() << Q_FUNC_INFO << "called with mParentPlot already initialized"; return; } - + if (!parentPlot) qDebug() << Q_FUNC_INFO << "called with parentPlot zero"; - + mParentPlot = parentPlot; parentPlotInitialized(mParentPlot); } /*! \internal - + Sets the parent layerable of this layerable to \a parentLayerable. Note that \a parentLayerable does not become the QObject-parent (for memory management) of this layerable. - + The parent layerable has influence on the return value of the \ref realVisibility method. Only layerables with a fully visible parent tree will return true for \ref realVisibility, and thus be drawn. - + \see realVisibility */ void QCPLayerable::setParentLayerable(QCPLayerable *parentLayerable) @@ -1096,11 +1096,11 @@ void QCPLayerable::setParentLayerable(QCPLayerable *parentLayerable) } /*! \internal - + Moves this layerable object to \a layer. If \a 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 \a layer is a valid layer. */ bool QCPLayerable::moveToLayer(QCPLayer *layer, bool prepend) @@ -1115,7 +1115,7 @@ bool QCPLayerable::moveToLayer(QCPLayer *layer, bool prepend) qDebug() << Q_FUNC_INFO << "layer" << layer->name() << "is not in same QCustomPlot as this layerable"; return false; } - + if (mLayer) mLayer->removeChild(this); mLayer = layer; @@ -1146,15 +1146,15 @@ void QCPLayerable::applyAntialiasingHint(QCPPainter *painter, bool localAntialia This function is called by \ref 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 \ref 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 initializeParentPlot */ void QCPLayerable::parentPlotInitialized(QCustomPlot *parentPlot) @@ -1167,10 +1167,10 @@ void QCPLayerable::parentPlotInitialized(QCustomPlot *parentPlot) Returns the selection category this layerable shall belong to. The selection category is used in conjunction with \ref QCustomPlot::setInteractions to control which objects are selectable and which aren't. - + Subclasses that don't fit any of the normal \ref QCP::Interaction values can use \ref QCP::iSelectOther. This is what the default implementation returns. - + \see QCustomPlot::setInteractions */ QCP::Interaction QCPLayerable::selectionCategory() const @@ -1179,11 +1179,11 @@ QCP::Interaction QCPLayerable::selectionCategory() const } /*! \internal - + 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. */ @@ -1196,16 +1196,16 @@ QRect QCPLayerable::clipRect() const } /*! \internal - + 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. - + \a event is the mouse event that caused the selection. \a additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see \ref QCustomPlot::setMultiSelectModifier). if \a 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 \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 @@ -1213,14 +1213,14 @@ QRect QCPLayerable::clipRect() const 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 to do the calculation again to find out which part was actually clicked. - + \a 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 \a additive is true, \a selectionStateChanged must also be set to true, because the selection toggles. If \a additive is false, \a selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state. - + \see selectTest, deselectEvent */ void QCPLayerable::selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) @@ -1232,15 +1232,15 @@ void QCPLayerable::selectEvent(QMouseEvent *event, bool additive, const QVariant } /*! \internal - + This event is called when the layerable shall be deselected, either as consequence of a user interaction or a call to \ref QCustomPlot::deselectAll. Subclasses should react to it by unsetting their selection appropriately. - + just as in \ref selectEvent, the output parameter \a selectionStateChanged (if non-null), must return true or false when the selection state of this layerable has changed or not changed, respectively. - + \see selectTest, selectEvent */ void QCPLayerable::deselectEvent(bool *selectionStateChanged) @@ -1254,14 +1254,14 @@ void QCPLayerable::deselectEvent(bool *selectionStateChanged) //////////////////////////////////////////////////////////////////////////////////////////////////// /*! \class QCPRange \brief Represents the range an axis is encompassing. - + contains a \a lower and \a upper double value and provides convenience input, output and modification functions. - + \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. @@ -1269,7 +1269,7 @@ void QCPLayerable::deselectEvent(bool *selectionStateChanged) */ 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. @@ -1279,7 +1279,7 @@ const double QCPRange::minRange = 1e-280; */ const double QCPRange::maxRange = 1e250; -/*! +/*! Constructs a range with \a lower and \a upper set to zero. */ QCPRange::QCPRange() : @@ -1298,7 +1298,7 @@ QCPRange::QCPRange(double lower, double upper) : normalize(); } -/*! +/*! Returns the size of the range, i.e. \a upper-\a lower */ double QCPRange::size() const @@ -1306,7 +1306,7 @@ double QCPRange::size() const return upper-lower; } -/*! +/*! Returns the center of the range, i.e. (\a upper+\a lower)*0.5 */ double QCPRange::center() const @@ -1314,7 +1314,7 @@ double QCPRange::center() const 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. */ @@ -1324,11 +1324,11 @@ void QCPRange::normalize() qSwap(lower, upper); } -/*! +/*! 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. - + If the original range does span positive and negative sign domains or contains zero, the returned range will try to approximate the original range as good as possible. If the positive interval of the original range is wider than the negative interval, the @@ -1381,7 +1381,7 @@ QCPRange QCPRange::sanitizedForLogScale() const 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. */ @@ -1392,7 +1392,7 @@ QCPRange QCPRange::sanitizedForLinScale() const return sanitizedRange; } -/*! +/*! Returns true when \a value lies within or exactly on the borders of the range. */ bool QCPRange::contains(double value) const @@ -1400,7 +1400,7 @@ bool QCPRange::contains(double value) const 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: @@ -1423,7 +1423,7 @@ bool QCPRange::validRange(double lower, double upper) qAbs(lower-upper) < maxRange); } -/*! +/*! \overload Checks, whether the specified range is within valid bounds, which are defined as QCPRange::maxRange and QCPRange::minRange. @@ -1450,21 +1450,21 @@ bool QCPRange::validRange(const QCPRange &range) /*! \page thelayoutsystem The Layout System - + The layout system is responsible for positioning and scaling layout elements such as axis rects, legends and plot titles in a QCustomPlot. \section layoutsystem-classesandmechanisms Classes and mechanisms - + The layout system is based on the abstract base class \ref QCPLayoutElement. All objects that take part in the layout system derive from this class, either directly or indirectly. - + Since QCPLayoutElement itself derives from \ref QCPLayerable, a layout element may draw its own content. However, it is perfectly possible for a layout element to only serve as a structuring and/or positioning element, not drawing anything on its own. - + \subsection layoutsystem-rects Rects of a layout element - + A layout element is a rectangular object described by two rects: the inner rect (\ref QCPLayoutElement::rect) and the outer rect (\ref QCPLayoutElement::setOuterRect). The inner rect is calculated automatically by applying the margin (\ref QCPLayoutElement::setMargins) inward @@ -1472,9 +1472,9 @@ bool QCPRange::validRange(const QCPRange &range) left blank or serve for displaying peripheral graphics. For example, \ref QCPAxisRect positions the four main axes at the sides of the inner rect, so graphs end up inside it and the axis labels and tick labels are in the margin area. - + \subsection layoutsystem-margins Margins - + Each layout element may provide a mechanism to automatically determine its margins. Internally, this is realized with the \ref QCPLayoutElement::calculateAutoMargin function which takes a \ref QCP::MarginSide and returns an integer value which represents the ideal margin for the specified @@ -1485,15 +1485,15 @@ bool QCPRange::validRange(const QCPRange &range) margins smaller than desired for a specific situation. If automatic margin calculation is unset for a specific side, the margin of that side can be controlled directy via \ref QCPLayoutElement::setMargins. - + If multiple layout ements are arranged next to or beneath each other, it may be desirable to align their inner rects on certain sides. Since they all might have different automatic margins, this usually isn't the case. The class \ref QCPMarginGroup and \ref QCPLayoutElement::setMarginGroup fix this by allowing to synchronize multiple margins. See the documentation there for details. - + \subsection layoutsystem-layout 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 \ref QCPLayout specializes on. It is a QCPLayoutElement itself but has no visual @@ -1501,10 +1501,10 @@ bool QCPRange::validRange(const QCPRange &range) QCPLayout isn't a usable layout though, it's an abstract base class that concrete layouts derive from, like \ref QCPLayoutGrid which arranges its child elements in a grid and \ref 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. - +
@@ -1516,16 +1516,16 @@ bool QCPRange::validRange(const QCPRange &range) (0, 1).
- + \subsection layoutsystem-plotlayout The top level plot layout - + Every QCustomPlot has one top level layout of type \ref QCPLayoutGrid. It is accessible via \ref 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. - + \subsection layoutsystem-examples Examples - + Adding a plot title is a typical and simple case to demonstrate basic workings of the layout system. \code // first we create and prepare a plot title layout element: @@ -1553,7 +1553,7 @@ bool QCPRange::validRange(const QCPRange &range) subLayout->setColumnStretchFactor(1, 2); // right one only 40% (3:2 = 60:40) \endcode \image html layoutsystem-multipleaxisrects.png - + */ @@ -1563,29 +1563,29 @@ bool QCPRange::validRange(const QCPRange &range) /*! \class QCPMarginGroup \brief A margin group allows synchronization of margin sides if working with multiple layout elements. - + QCPMarginGroup allows you to tie a margin side of two or more layout elements together, such that they will all have the same size, based on the largest required margin in the group. - + \n \image html QCPMarginGroup.png "Demonstration of QCPMarginGroup" \n - + In certain situations it is desirable that margins at specific sides are synchronized across layout elements. For example, if one QCPAxisRect is below another one in a grid layout, it will provide a cleaner look to the user if the left and right margins of the two axis rects are of the same size. The left axis of the top axis rect will then be at the same horizontal position as the left axis of the lower axis rect, making them appear aligned. The same applies for the right axes. This is what QCPMarginGroup makes possible. - + To add/remove a specific side of a layout element to/from a margin group, use the \ref QCPLayoutElement::setMarginGroup method. To completely break apart the margin group, either call \ref clear, or just delete the margin group. - + \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: @@ -1600,7 +1600,7 @@ bool QCPRange::validRange(const QCPRange &range) /* start documentation of inline functions */ /*! \fn QList QCPMarginGroup::elements(QCP::MarginSide side) const - + Returns a list of all layout elements that have their margin \a side associated with this margin group. */ @@ -1659,10 +1659,10 @@ void QCPMarginGroup::clear() } /*! \internal - + Returns the synchronized common margin for \a side. This is the margin value that will be used by the layout element on the respective side, if it is part of this margin group. - + The common margin is calculated by requesting the automatic margin (\ref QCPLayoutElement::calculateAutoMargin) of each element associated with \a side in this margin group, and choosing the largest returned value. (QCPLayoutElement::minimumMargins is taken into @@ -1685,9 +1685,9 @@ int QCPMarginGroup::commonMargin(QCP::MarginSide side) const } /*! \internal - + Adds \a element to the internal list of child elements, for the margin \a side. - + This function does not modify the margin group property of \a element. */ void QCPMarginGroup::addChild(QCP::MarginSide side, QCPLayoutElement *element) @@ -1699,9 +1699,9 @@ void QCPMarginGroup::addChild(QCP::MarginSide side, QCPLayoutElement *element) } /*! \internal - + Removes \a element from the internal list of child elements, for the margin \a side. - + This function does not modify the margin group property of \a element. */ void QCPMarginGroup::removeChild(QCP::MarginSide side, QCPLayoutElement *element) @@ -1717,20 +1717,20 @@ void QCPMarginGroup::removeChild(QCP::MarginSide side, QCPLayoutElement *element /*! \class QCPLayoutElement \brief The abstract base class for all objects that form \ref thelayoutsystem "the layout system". - + This is an abstract base class. As such, it can't be instantiated directly, rather use one of its subclasses. - + A Layout element is a rectangular object which can be placed in layouts. It has an outer rect (QCPLayoutElement::outerRect) and an inner rect (\ref QCPLayoutElement::rect). The difference between outer and inner rect is called its margin. The margin can either be set to automatic or manual (\ref setAutoMargins) on a per-side basis. If a side is set to manual, that margin can be set explicitly with \ref setMargins and will stay fixed at that value. If it's set to automatic, the layout element subclass will control the value itself (via \ref calculateAutoMargin). - + Layout elements can be placed in layouts (base class QCPLayout) like QCPLayoutGrid. The top level layout is reachable via \ref QCustomPlot::plotLayout, and is a \ref QCPLayoutGrid. Since \ref QCPLayout itself derives from \ref 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 @@ -1744,15 +1744,15 @@ void QCPMarginGroup::removeChild(QCP::MarginSide side, QCPLayoutElement *element /* start documentation of inline functions */ /*! \fn QCPLayout *QCPLayoutElement::layout() const - + Returns the parent layout of this layout element. */ /*! \fn QRect QCPLayoutElement::rect() const - + Returns the inner rect of this layout element. The inner rect is the outer rect (\ref setOuterRect) shrinked by the margins (\ref setMargins, \ref 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 @@ -1762,30 +1762,30 @@ void QCPMarginGroup::removeChild(QCP::MarginSide side, QCPLayoutElement *element */ /*! \fn virtual void QCPLayoutElement::mousePressEvent(QMouseEvent *event) - + This event is called, if the mouse was pressed while being inside the outer rect of this layout element. */ /*! \fn virtual void QCPLayoutElement::mouseMoveEvent(QMouseEvent *event) - + This event is called, if the mouse is moved inside the outer rect of this layout element. */ /*! \fn virtual void QCPLayoutElement::mouseReleaseEvent(QMouseEvent *event) - + This event is called, if the mouse was previously pressed inside the outer rect of this layout element and is now released. */ /*! \fn virtual void QCPLayoutElement::mouseDoubleClickEvent(QMouseEvent *event) - + This event is called, if the mouse is double-clicked inside the outer rect of this layout element. */ /*! \fn virtual void QCPLayoutElement::wheelEvent(QWheelEvent *event) - + This event is called, if the mouse wheel is scrolled while the cursor is inside the rect of this layout element. */ @@ -1820,12 +1820,12 @@ QCPLayoutElement::~QCPLayoutElement() /*! 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 \ref rect by applying the margins inward to the outer rect. - + \see rect */ void QCPLayoutElement::setOuterRect(const QRect &rect) @@ -1841,11 +1841,11 @@ void QCPLayoutElement::setOuterRect(const QRect &rect) Sets the margins of this layout element. If \ref 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 \a margins. - + The margin is the distance between the outer rect (controlled by the parent layout via \ref setOuterRect) and the inner \ref rect (which usually contains the main content of this layout element). - + \see setAutoMargins */ void QCPLayoutElement::setMargins(const QMargins &margins) @@ -1860,10 +1860,10 @@ void QCPLayoutElement::setMargins(const QMargins &margins) /*! If \ref 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 \ref setAutoMargins. - + \see setAutoMargins */ void QCPLayoutElement::setMinimumMargins(const QMargins &margins) @@ -1878,10 +1878,10 @@ void QCPLayoutElement::setMinimumMargins(const QMargins &margins) Sets on which sides the margin shall be calculated automatically. If a side is calculated automatically, a minimum margin value may be provided with \ref setMinimumMargins. If a side is set to be controlled manually, the value may be specified with \ref setMargins. - + Margin sides that are under automatic control may participate in a \ref QCPMarginGroup (see \ref setMarginGroup), to synchronize (align) it with other layout elements in the plot. - + \see setMinimumMargins, setMargins */ void QCPLayoutElement::setAutoMargins(QCP::MarginSides sides) @@ -1892,7 +1892,7 @@ void QCPLayoutElement::setAutoMargins(QCP::MarginSides sides) /*! Sets the minimum size for the inner \ref rect of this layout element. A parent layout tries to respect the \a 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 \a size. QCustomPlot propagates the layout's size constraints to the outside by setting its own minimum QWidget size @@ -1909,7 +1909,7 @@ void QCPLayoutElement::setMinimumSize(const QSize &size) } /*! \overload - + Sets the minimum size for the inner \ref rect of this layout element. */ void QCPLayoutElement::setMinimumSize(int width, int height) @@ -1932,7 +1932,7 @@ void QCPLayoutElement::setMaximumSize(const QSize &size) } /*! \overload - + Sets the maximum size for the inner \ref rect of this layout element. */ void QCPLayoutElement::setMaximumSize(int width, int height) @@ -1942,12 +1942,12 @@ void QCPLayoutElement::setMaximumSize(int width, int height) /*! Sets the margin \a group of the specified margin \a sides. - + Margin groups allow synchronizing specified margins across layout elements, see the documentation of \ref QCPMarginGroup. - + To unset the margin group of \a sides, set \a group to 0. - + Note that margin groups only work for margin sides that are set to automatic (\ref setAutoMargins). */ @@ -1958,7 +1958,7 @@ void QCPLayoutElement::setMarginGroup(QCP::MarginSides sides, QCPMarginGroup *gr if (sides.testFlag(QCP::msRight)) sideVector.append(QCP::msRight); if (sides.testFlag(QCP::msTop)) sideVector.append(QCP::msTop); if (sides.testFlag(QCP::msBottom)) sideVector.append(QCP::msBottom); - + for (int i=0; iremoveChild(side, this); - + if (!group) // if setting to 0, remove hash entry. Else set hash entry to new group and register there { mMarginGroups.remove(side); @@ -1983,10 +1983,10 @@ void QCPLayoutElement::setMarginGroup(QCP::MarginSides sides, QCPMarginGroup *gr /*! 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 \ref 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. */ @@ -2002,9 +2002,9 @@ void QCPLayoutElement::update() QCP::MarginSide side = marginSides.at(i); if (mAutoMargins.testFlag(side)) // this side's margin shall be calculated automatically { - if (mMarginGroups.contains(side)) + 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 + 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)) @@ -2017,7 +2017,7 @@ void QCPLayoutElement::update() /*! Returns the minimum size this layout element (the inner \ref rect) may be compressed to. - + if a minimum size (\ref 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.) @@ -2029,7 +2029,7 @@ QSize QCPLayoutElement::minimumSizeHint() const /*! Returns the maximum size this layout element (the inner \ref rect) may be expanded to. - + if a maximum size (\ref 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.) @@ -2042,7 +2042,7 @@ QSize QCPLayoutElement::maximumSizeHint() const /*! 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 empty cells which yield 0 at the respective index.) */ @@ -2057,19 +2057,19 @@ QList QCPLayoutElement::elements(bool recursive) const 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 \ref onlySelectable is true, -1.0 is returned. - + See \ref QCPLayerable::selectTest for a general explanation of this virtual method. - + QCPLayoutElement subclasses may reimplement this method to provide more specific selection test behaviour. */ double QCPLayoutElement::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { Q_UNUSED(details) - + if (onlySelectable) return -1; - + if (QRectF(mOuterRect).contains(pos)) { if (mParentPlot) @@ -2083,8 +2083,8 @@ double QCPLayoutElement::selectTest(const QPointF &pos, bool onlySelectable, QVa return -1; } -/*! \internal - +/*! \internal + propagates the parent plot initialization to all child elements, by calling \ref QCPLayerable::initializeParentPlot on them. */ @@ -2098,12 +2098,12 @@ void QCPLayoutElement::parentPlotInitialized(QCustomPlot *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 returned value will not be smaller than the specified minimum margin. - + The default implementation just returns the respective manual margin (\ref setMargins) or the minimum margin, whichever is larger. */ @@ -2118,23 +2118,23 @@ int QCPLayoutElement::calculateAutoMargin(QCP::MarginSide side) /*! \class QCPLayout \brief The abstract base class for layouts - + This is an abstract base class for layout elements whose main purpose is to define the position and size of other child layout elements. In most cases, layouts don't draw anything themselves (but there are exceptions to this, e.g. QCPLegend). - + QCPLayout derives from QCPLayoutElement, and thus can itself be nested in other layouts. - + QCPLayout introduces a common interface for accessing and manipulating the child elements. Those functions are most notably \ref elementCount, \ref elementAt, \ref takeAt, \ref take, \ref simplify, \ref removeAt, \ref remove and \ref clear. Individual subclasses may add more functions to this interface which are more specialized to the form of the layout. For example, \ref QCPLayoutGrid adds functions that take row and column indices to access cells of the layout grid more conveniently. - + Since this is an abstract base class, you can't instantiate it directly. Rather use one of its subclasses like QCPLayoutGrid or QCPLayoutInset. - + For a general introduction to the layout system, see the dedicated documentation page \ref thelayoutsystem "The Layout System". */ @@ -2142,44 +2142,44 @@ int QCPLayoutElement::calculateAutoMargin(QCP::MarginSide side) /* start documentation of pure virtual functions */ /*! \fn virtual int QCPLayout::elementCount() const = 0 - + Returns the number of elements/cells in the layout. - + \see elements, elementAt */ /*! \fn virtual QCPLayoutElement* QCPLayout::elementAt(int index) const = 0 - + Returns the element in the cell with the given \a index. If \a index is invalid, returns 0. - + Note that even if \a 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 elements, elementCount, takeAt */ /*! \fn virtual QCPLayoutElement* QCPLayout::takeAt(int index) = 0 - + Removes the element with the given \a index from the layout and returns it. - + If the \a 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 \ref simplify. - + \see elementAt, take */ /*! \fn virtual bool QCPLayout::take(QCPLayoutElement* element) = 0 - + Removes the specified \a element from the layout and returns true on success. - + If the \a 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 \ref simplify. - + \see takeAt */ @@ -2196,18 +2196,18 @@ QCPLayout::QCPLayout() /*! First calls the QCPLayoutElement::update base class implementation to update the margins on this layout. - + Then calls \ref updateLayout which subclasses reimplement to reposition and resize their cells. - + Finally, \ref update is called on all child elements. */ void QCPLayout::update() { QCPLayoutElement::update(); // recalculates (auto-)margins - + // set child element rects according to layout: updateLayout(); - + // propagate update call to child elements: for (int i=0; i QCPLayout::elements(bool recursive) const /*! Simplifies the layout by collapsing empty cells. The exact behavior depends on subclasses, the default implementation does nothing. - + Not all layouts need simplification. For example, QCPLayoutInset doesn't use explicit simplification while QCPLayoutGrid does. */ @@ -2251,10 +2251,10 @@ void QCPLayout::simplify() /*! Removes and deletes the element at the provided \a index. Returns true on success. If \a index is invalid or points to an empty cell, returns false. - + This function internally uses \ref takeAt to remove the element from the layout and then deletes the returned element. - + \see remove, takeAt */ bool QCPLayout::removeAt(int index) @@ -2270,10 +2270,10 @@ bool QCPLayout::removeAt(int index) /*! Removes and deletes the provided \a element. Returns true on success. If \a element is not in the layout, returns false. - + This function internally uses \ref takeAt to remove the element from the layout and then deletes the element. - + \see removeAt, take */ bool QCPLayout::remove(QCPLayoutElement *element) @@ -2288,7 +2288,7 @@ bool QCPLayout::remove(QCPLayoutElement *element) /*! Removes and deletes all layout elements in this layout. - + \see remove, removeAt */ void QCPLayout::clear() @@ -2303,7 +2303,7 @@ void QCPLayout::clear() /*! 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 \ref sizeConstraintsChanged. If the parent is a QWidget (i.e. is the \ref QCustomPlot::plotLayout of QCustomPlot), calls QWidget::updateGeometry, so if the QCustomPlot widget is inside a Qt QLayout, @@ -2318,15 +2318,15 @@ void QCPLayout::sizeConstraintsChanged() const } /*! \internal - + Subclasses reimplement this method to update the position and sizes of the child elements/cells via calling their \ref QCPLayoutElement::setOuterRect. The default implementation does nothing. - + The geometry used as a reference is the inner \ref rect of this layout. Child elements should stay within that rect. - + \ref getSectionSizes may help with the reimplementation of this function. - + \see update */ void QCPLayout::updateLayout() @@ -2335,13 +2335,13 @@ void QCPLayout::updateLayout() /*! \internal - + Associates \a el with this layout. This is done by setting the \ref QCPLayoutElement::layout, the \ref QCPLayerable::parentLayerable and the QObject parent to this layout. - + Further, if \a el didn't previously have a parent plot, calls \ref QCPLayerable::initializeParentPlot on \a 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 \a el. The removal from the old layout and the insertion into the new layout must be done additionally. @@ -2360,11 +2360,11 @@ void QCPLayout::adoptElement(QCPLayoutElement *el) } /*! \internal - + Disassociates \a el from this layout. This is done by setting the \ref QCPLayoutElement::layout and the \ref 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. \ref take or \ref takeAt). Note that this method only changes properties in \a el. The removal from the old layout must be done additionally. @@ -2382,32 +2382,32 @@ void QCPLayout::releaseElement(QCPLayoutElement *el) } /*! \internal - + This is a helper function for the implementation of \ref 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. - + \a 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. - + \a 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 \a minSizes entries add up to a value greater than \a 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.) - + \a 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 \a stretchFactors to double the value of the other individual values (e.g. {2, 1, 1, 1}). - + \a 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. */ QVector QCPLayout::getSectionSizes(QVector maxSizes, QVector minSizes, QVector stretchFactors, int totalSize) const @@ -2434,13 +2434,13 @@ QVector QCPLayout::getSectionSizes(QVector maxSizes, QVector minS minSizes[i] = 0; } } - + QList minimumLockedSections; QList unfinishedSections; for (int i=0; i QCPLayout::getSectionSizes(QVector maxSizes, QVector minS } if (innerIterations == sectionCount*2) qDebug() << Q_FUNC_INFO << "Exceeded maximum expected inner iteration count, layouting aborted. Input was:" << maxSizes << minSizes << stretchFactors << totalSize; - + // now check whether the resulting section sizes violate minimum restrictions: bool foundMinimumViolation = false; for (int i=0; i QCPLayout::getSectionSizes(QVector maxSizes, QVector minS } if (outerIterations == sectionCount*2) qDebug() << Q_FUNC_INFO << "Exceeded maximum expected outer iteration count, layouting aborted. Input was:" << maxSizes << minSizes << stretchFactors << totalSize; - + QVector result(sectionCount); for (int i=0; i QCPLayout::getSectionSizes(QVector maxSizes, QVector minS /*! \class QCPLayoutGrid \brief A layout that arranges child elements in a grid - + Elements are laid out in a grid with configurable stretch factors (\ref setColumnStretchFactor, \ref setRowStretchFactor) and spacing (\ref setColumnSpacing, \ref setRowSpacing). - + Elements can be added to cells via \ref addElement. The grid is expanded if the specified row or column doesn't exist yet. Whether a cell contains a valid layout element can be checked with \ref hasElement, that element can be retrieved with \ref element. If rows and columns that only have empty cells shall be removed, call \ref simplify. Removal of elements is either done by just adding the element to a different layout or by using the QCPLayout interface \ref take or \ref remove. - + Row and column insertion can be performed with \ref insertRow and \ref insertColumn. */ @@ -2562,10 +2562,10 @@ QCPLayoutGrid::~QCPLayoutGrid() /*! Returns the element in the cell in \a row and \a 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 \ref hasElement. - + \see addElement, hasElement */ QCPLayoutElement *QCPLayoutGrid::element(int row, int column) const @@ -2587,7 +2587,7 @@ QCPLayoutElement *QCPLayoutGrid::element(int row, int column) const /*! Returns the number of rows in the layout. - + \see columnCount */ int QCPLayoutGrid::rowCount() const @@ -2597,7 +2597,7 @@ int QCPLayoutGrid::rowCount() const /*! Returns the number of columns in the layout. - + \see rowCount */ int QCPLayoutGrid::columnCount() const @@ -2612,10 +2612,10 @@ int QCPLayoutGrid::columnCount() const Adds the \a element to cell with \a row and \a column. If \a element is already in a layout, it is first removed from there. If \a row or \a column don't exist yet, the layout is expanded accordingly. - + Returns true if the element was added successfully, i.e. if the cell at \a row and \a column didn't already have an element. - + \see element, hasElement, take, remove */ bool QCPLayoutGrid::addElement(int row, int column, QCPLayoutElement *element) @@ -2631,7 +2631,7 @@ bool QCPLayoutGrid::addElement(int row, int column, QCPLayoutElement *element) 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; @@ -2640,7 +2640,7 @@ bool QCPLayoutGrid::addElement(int row, int column, QCPLayoutElement *element) /*! Returns whether the cell at \a row and \a column exists and contains a valid element, i.e. isn't empty. - + \see element */ bool QCPLayoutGrid::hasElement(int row, int column) @@ -2653,13 +2653,13 @@ bool QCPLayoutGrid::hasElement(int row, int column) /*! Sets the stretch \a factor of \a column. - + Stretch factors control the relative sizes of rows and columns. Cells will not be resized beyond their minimum and maximum widths/heights (\ref QCPLayoutElement::setMinimumSize, \ref QCPLayoutElement::setMaximumSize), regardless of the stretch factor. - + The default stretch factor of newly created rows/columns is 1. - + \see setColumnStretchFactors, setRowStretchFactor */ void QCPLayoutGrid::setColumnStretchFactor(int column, double factor) @@ -2676,13 +2676,13 @@ void QCPLayoutGrid::setColumnStretchFactor(int column, double factor) /*! Sets the stretch \a factors of all columns. \a factors must have the size \ref columnCount. - + Stretch factors control the relative sizes of rows and columns. Cells will not be resized beyond their minimum and maximum widths/heights (\ref QCPLayoutElement::setMinimumSize, \ref QCPLayoutElement::setMaximumSize), regardless of the stretch factor. - + The default stretch factor of newly created rows/columns is 1. - + \see setColumnStretchFactor, setRowStretchFactors */ void QCPLayoutGrid::setColumnStretchFactors(const QList &factors) @@ -2704,13 +2704,13 @@ void QCPLayoutGrid::setColumnStretchFactors(const QList &factors) /*! Sets the stretch \a factor of \a row. - + Stretch factors control the relative sizes of rows and columns. Cells will not be resized beyond their minimum and maximum widths/heights (\ref QCPLayoutElement::setMinimumSize, \ref QCPLayoutElement::setMaximumSize), regardless of the stretch factor. - + The default stretch factor of newly created rows/columns is 1. - + \see setColumnStretchFactors, setRowStretchFactor */ void QCPLayoutGrid::setRowStretchFactor(int row, double factor) @@ -2727,13 +2727,13 @@ void QCPLayoutGrid::setRowStretchFactor(int row, double factor) /*! Sets the stretch \a factors of all rows. \a factors must have the size \ref rowCount. - + Stretch factors control the relative sizes of rows and columns. Cells will not be resized beyond their minimum and maximum widths/heights (\ref QCPLayoutElement::setMinimumSize, \ref QCPLayoutElement::setMaximumSize), regardless of the stretch factor. - + The default stretch factor of newly created rows/columns is 1. - + \see setRowStretchFactor, setColumnStretchFactors */ void QCPLayoutGrid::setRowStretchFactors(const QList &factors) @@ -2755,7 +2755,7 @@ void QCPLayoutGrid::setRowStretchFactors(const QList &factors) /*! Sets the gap that is left blank between columns to \a pixels. - + \see setRowSpacing */ void QCPLayoutGrid::setColumnSpacing(int pixels) @@ -2765,7 +2765,7 @@ void QCPLayoutGrid::setColumnSpacing(int pixels) /*! Sets the gap that is left blank between rows to \a pixels. - + \see setColumnSpacing */ void QCPLayoutGrid::setRowSpacing(int pixels) @@ -2776,15 +2776,15 @@ void QCPLayoutGrid::setRowSpacing(int pixels) /*! Expands the layout to have \a newRowCount rows and \a newColumnCount columns. So the last valid row index will be \a newRowCount-1, the last valid column index will be \a newColumnCount-1. - + If the current column/row count is already larger or equal to \a newColumnCount/\a 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 \ref addElement, the layout is expanded automatically to contain the specified row and column, using this function. - + \see simplify */ void QCPLayoutGrid::expandTo(int newRowCount, int newColumnCount) @@ -2809,7 +2809,7 @@ void QCPLayoutGrid::expandTo(int newRowCount, int newColumnCount) /*! Inserts a new row with empty cells at the row index \a newIndex. Valid values for \a newIndex range from 0 (inserts a row at the top) to \a rowCount (appends a row at the bottom). - + \see insertColumn */ void QCPLayoutGrid::insertRow(int newIndex) @@ -2819,12 +2819,12 @@ void QCPLayoutGrid::insertRow(int newIndex) expandTo(1, 1); return; } - + if (newIndex < 0) newIndex = 0; if (newIndex > rowCount()) newIndex = rowCount(); - + mRowStretchFactors.insert(newIndex, 1); QList newRow; for (int col=0; col columnCount()) newIndex = columnCount(); - + mColumnStretchFactors.insert(newIndex, 1); for (int row=0; row minColWidths, minRowHeights, maxColWidths, maxRowHeights; getMinimumRowColSizes(&minColWidths, &minRowHeights); getMaximumRowColSizes(&maxColWidths, &maxRowHeights); - + int totalRowSpacing = (rowCount()-1) * mRowSpacing; int totalColSpacing = (columnCount()-1) * mColumnSpacing; QVector colWidths = getSectionSizes(maxColWidths, minColWidths, mColumnStretchFactors.toVector(), mRect.width()-totalColSpacing); QVector rowHeights = getSectionSizes(maxRowHeights, minRowHeights, mRowStretchFactors.toVector(), mRect.height()-totalRowSpacing); - + // go through cells and set rects accordingly: int yOffset = mRect.top(); for (int row=0; row=0; --col) { @@ -3029,7 +3029,7 @@ QSize QCPLayoutGrid::maximumSizeHint() const { QVector maxColWidths, maxRowHeights; getMaximumRowColSizes(&maxColWidths, &maxRowHeights); - + QSize result(0, 0); for (int i=0; i *minColWidths, QVector *minRowHeights) const @@ -3075,15 +3075,15 @@ void QCPLayoutGrid::getMinimumRowColSizes(QVector *minColWidths, QVector *maxColWidths, QVector *maxRowHeights) const @@ -3114,7 +3114,7 @@ void QCPLayoutGrid::getMaximumRowColSizes(QVector *maxColWidths, QVector *maxColWidths, QVectorsetHead(QCPLineEnding::esSpikeArrow) \endcode @@ -3475,7 +3475,7 @@ void QCPLineEnding::setStyle(QCPLineEnding::EndingStyle style) /*! Sets the width of the ending decoration, if the style supports it. On arrows, for example, the width defines the size perpendicular to the arrow's pointing direction. - + \see setLength */ void QCPLineEnding::setWidth(double width) @@ -3486,7 +3486,7 @@ void QCPLineEnding::setWidth(double width) /*! Sets the length of the ending decoration, if the style supports it. On arrows, for example, the length defines the size in pointing direction. - + \see setWidth */ void QCPLineEnding::setLength(double length) @@ -3508,10 +3508,10 @@ void QCPLineEnding::setInverted(bool inverted) } /*! \internal - + Returns the maximum pixel radius the ending decoration might cover, starting from the position the decoration is drawn at (typically a line ending/\ref QCPItemPosition of an item). - + This is relevant for clipping. Only omit painting of the decoration when the position where the decoration is supposed to be drawn is farther away from the clipping rect than the returned distance. @@ -3522,13 +3522,13 @@ double QCPLineEnding::boundingDistance() const { case esNone: return 0; - + case esFlatArrow: case esSpikeArrow: case esLineArrow: case esSkewedBar: return qSqrt(mWidth*mWidth+mLength*mLength); // items that have width and length - + case esDisc: case esSquare: case esDiamond: @@ -3543,11 +3543,11 @@ double QCPLineEnding::boundingDistance() const /*! Starting from the origin of this line ending (which is style specific), returns the length covered by the line ending symbol, in backward direction. - + For example, the \ref esSpikeArrow has a shorter real length than a \ref esFlatArrow, even if both have the same \ref setLength value, because the spike arrow has an inward curved back, which reduces the length along its center axis (the drawing origin for arrows is at the tip). - + This function is used for precise, style specific placement of line endings, for example in QCPAxes. */ @@ -3561,15 +3561,15 @@ double QCPLineEnding::realLength() const case esBar: case esHalfBar: return 0; - + case esFlatArrow: return mLength; - + case esDisc: case esSquare: case esDiamond: return mWidth*0.5; - + case esSpikeArrow: return mLength*0.8; } @@ -3577,7 +3577,7 @@ double QCPLineEnding::realLength() const } /*! \internal - + Draws the line ending with the specified \a painter at the position \a pos. The direction of the line ending is controlled with \a dir. */ @@ -3585,14 +3585,14 @@ void QCPLineEnding::draw(QCPPainter *painter, const QVector2D &pos, const QVecto { if (mStyle == esNone) return; - + QVector2D lengthVec(dir.normalized()); 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); - + QPen penBackup = painter->pen(); QBrush brushBackup = painter->brush(); QPen miterPen = penBackup; @@ -3618,7 +3618,7 @@ void QCPLineEnding::draw(QCPPainter *painter, const QVector2D &pos, const QVecto { 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); @@ -3691,13 +3691,13 @@ void QCPLineEnding::draw(QCPPainter *painter, const QVector2D &pos, const QVecto 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.0, (double)painter->pen().widthF())*0.5).toPointF(), + (pos-widthVec-lengthVec*0.2f*(mInverted?-1:1)+dir.normalized()*qMax(1.0, (double)painter->pen().widthF())*0.5).toPointF()); } break; } @@ -3706,7 +3706,7 @@ void QCPLineEnding::draw(QCPPainter *painter, const QVector2D &pos, const QVecto /*! \internal \overload - + Draws the line ending. The direction is controlled with the \a angle parameter in radians. */ void QCPLineEnding::draw(QCPPainter *painter, const QVector2D &pos, double angle) const @@ -3721,11 +3721,11 @@ void QCPLineEnding::draw(QCPPainter *painter, const QVector2D &pos, double angle /*! \class QCPGrid \brief Responsible for drawing the grid of a QCPAxis. - + This class is tightly bound to QCPAxis. Every axis owns a grid instance and uses it to draw the grid lines, sub grid lines and zero-line. You can interact with the grid of an axis via \ref QCPAxis::grid. Normally, you don't need to create an instance of QCPGrid yourself. - + The axis and grid drawing was split into two classes to allow them to be placed on different layers (both QCPAxis and QCPGrid inherit from QCPLayerable). Thus it is possible to have the grid in the background and the axes in the foreground, and any plottables/items in between. This @@ -3734,7 +3734,7 @@ void QCPLineEnding::draw(QCPPainter *painter, const QVector2D &pos, double angle /*! Creates a QCPGrid instance and sets default values. - + You shouldn't instantiate grids on their own, since every QCPAxis brings its own QCPGrid. */ QCPGrid::QCPGrid(QCPAxis *parentAxis) : @@ -3754,7 +3754,7 @@ QCPGrid::QCPGrid(QCPAxis *parentAxis) : /*! Sets whether grid lines at sub tick marks are drawn. - + \see setSubGridPen */ void QCPGrid::setSubGridVisible(bool visible) @@ -3796,7 +3796,7 @@ void QCPGrid::setSubGridPen(const QPen &pen) /*! Sets the pen with which zero lines are drawn. - + Zero lines are lines at value coordinate 0 which may be drawn with a different pen than other grid lines. To disable zero lines and just draw normal grid lines at zero, set \a pen to Qt::NoPen. */ @@ -3811,11 +3811,11 @@ void QCPGrid::setZeroLinePen(const QPen &pen) before drawing the major grid 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 QCPGrid::applyDefaultAntialiasingHint(QCPPainter *painter) const @@ -3824,29 +3824,29 @@ void QCPGrid::applyDefaultAntialiasingHint(QCPPainter *painter) const } /*! \internal - + Draws grid lines and sub grid lines at the positions of (sub) ticks of the parent axis, spanning over the complete axis rect. Also draws the zero line, if appropriate (\ref setZeroLinePen). */ void QCPGrid::draw(QCPPainter *painter) { if (!mParentAxis) { qDebug() << Q_FUNC_INFO << "invalid parent axis"; return; } - + if (mSubGridVisible) drawSubGridLines(painter); drawGridLines(painter); } /*! \internal - + Draws the main grid lines and possibly a zero line with the specified painter. - + This is a helper function called by \ref draw. */ void QCPGrid::drawGridLines(QCPPainter *painter) const { if (!mParentAxis) { qDebug() << Q_FUNC_INFO << "invalid parent axis"; return; } - + int lowTick = mParentAxis->mLowestVisibleTick; int highTick = mParentAxis->mHighestVisibleTick; double t; // helper variable, result of coordinate-to-pixel transforms @@ -3912,15 +3912,15 @@ void QCPGrid::drawGridLines(QCPPainter *painter) const } /*! \internal - + Draws the sub grid lines with the specified painter. - + This is a helper function called by \ref draw. */ void QCPGrid::drawSubGridLines(QCPPainter *painter) const { if (!mParentAxis) { qDebug() << Q_FUNC_INFO << "invalid parent axis"; return; } - + applyAntialiasingHint(painter, mAntialiasedSubGrid, QCP::aeSubGrid); double t; // helper variable, result of coordinate-to-pixel transforms painter->setPen(mSubGridPen); @@ -3952,12 +3952,12 @@ void QCPGrid::drawSubGridLines(QCPPainter *painter) const 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. \image html AxisNamesOverview.png
Naming convention of axis parts
\n - + \image html AxisRectSpacingOverview.png
Overview of the spacings and paddings that define the geometry of an axis. The dashed gray line on the left represents the QCustomPlot widget border.
@@ -3967,13 +3967,13 @@ void QCPGrid::drawSubGridLines(QCPPainter *painter) const /* start of documentation of inline functions */ /*! \fn Qt::Orientation QCPAxis::orientation() const - + Returns the orientation of the axis. The axis orientation (horizontal or vertical) is deduced from the axis type (left, top, right or bottom). */ /*! \fn QCPGrid *QCPAxis::grid() const - + Returns the \ref QCPGrid instance belonging to this axis. Access it to set details about the way the grid is displayed. */ @@ -3982,14 +3982,14 @@ void QCPGrid::drawSubGridLines(QCPPainter *painter) const /* start of documentation of signals */ /*! \fn void QCPAxis::ticksRequest() - + This signal is emitted when \ref setAutoTicks is false and the axis is about to generate tick labels for a replot. - + Modifying the tick positions can be done with \ref setTickVector. If you also want to control the tick labels, set \ref setAutoTickLabels to false and also provide the labels with \ref 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 @@ -4004,7 +4004,7 @@ void QCPGrid::drawSubGridLines(QCPPainter *painter) const */ /*! \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. */ @@ -4086,7 +4086,7 @@ QCPAxis::QCPAxis(QCPAxisRect *parent, AxisType type) : mGrid->setVisible(false); setAntialiased(false); setLayer(mParentPlot->currentLayer()); // it's actually on that layer already, but we want it in front of the grid, so we place it on there again - + if (type == atTop) { setTickLabelPadding(3); @@ -4126,7 +4126,7 @@ QString QCPAxis::numberFormat() const scaling, major tick marks appear at all powers of the logarithm base. Properties like tick step (\ref setTickStep) don't apply in logarithmic scaling. If you wish a decimal base but less major ticks, consider choosing a logarithm base of 100, 1000 or even higher. - + If \a type is \ref stLogarithmic and the number format (\ref setNumberFormat) 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]" @@ -4147,7 +4147,7 @@ void QCPAxis::setScaleType(ScaleType type) /*! If \ref setScaleType is set to \ref stLogarithmic, \a base will be the logarithm base of the scaling. In logarithmic axis scaling, major tick marks appear at all powers of \a base. - + Properties like tick step (\ref setTickStep) don't apply in logarithmic scaling. If you wish a decimal base but less major ticks, consider choosing \a base 100, 1000 or even higher. */ @@ -4164,17 +4164,17 @@ void QCPAxis::setScaleLogBase(double base) /*! Sets the range of the axis. - + This slot may be connected with the \ref rangeChanged signal of another axis so this axis is always synchronized with the other axis range, when it changes. - + To invert the direction of an axis, use \ref setRangeReversed. */ void QCPAxis::setRange(const QCPRange &range) { if (range.lower == mRange.lower && range.upper == mRange.upper) return; - + if (!QCPRange::validRange(range)) return; if (mScaleType == stLogarithmic) { @@ -4190,11 +4190,11 @@ void QCPAxis::setRange(const QCPRange &range) /*! Sets whether the user can (de-)select the parts in \a selectable by clicking on the QCustomPlot surface. (When \ref QCustomPlot::setInteractions contains iSelectAxes.) - + 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. - + \see SelectablePart, setSelectedParts */ void QCPAxis::setSelectableParts(const SelectableParts &selectable) @@ -4205,15 +4205,15 @@ void QCPAxis::setSelectableParts(const SelectableParts &selectable) /*! Sets the selected state of the respective axis parts described by \ref SelectablePart. When a part is selected, it uses a different pen/font. - + The entire selection mechanism for axes is handled automatically when \ref QCustomPlot::setInteractions contains iSelectAxes. 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, independent of the \ref setSelectableParts setting. - + emits the \ref selectionChanged signal when \a selected is different from the previous selection state. - + \see SelectablePart, setSelectableParts, selectTest, setSelectedBasePen, setSelectedTickPen, setSelectedSubTickPen, setSelectedTickLabelFont, setSelectedLabelFont, setSelectedTickLabelColor, setSelectedLabelColor */ @@ -4230,18 +4230,18 @@ void QCPAxis::setSelectedParts(const SelectableParts &selected) /*! \overload - + Sets the lower and upper bound of the axis range. - + To invert the direction of an axis, use \ref setRangeReversed. - + There is also a slot to set a range, see \ref setRange(const QCPRange &range). */ void QCPAxis::setRange(double lower, double upper) { if (lower == mRange.lower && upper == mRange.upper) return; - + if (!QCPRange::validRange(lower, upper)) return; mRange.lower = lower; mRange.upper = upper; @@ -4258,9 +4258,9 @@ void QCPAxis::setRange(double lower, double upper) /*! \overload - + Sets the range of the axis. - + The \a position coordinate indicates together with the \a alignment parameter, where the new range will be positioned. \a size defines the size of the new axis range. \a alignment may be Qt::AlignLeft, Qt::AlignRight or Qt::AlignCenter. This will cause the left border, right border, @@ -4285,7 +4285,7 @@ void QCPAxis::setRangeLower(double lower) { if (mRange.lower == lower) return; - + mRange.lower = lower; if (mScaleType == stLogarithmic) { @@ -4306,7 +4306,7 @@ void QCPAxis::setRangeUpper(double upper) { if (mRange.upper == upper) return; - + mRange.upper = upper; if (mScaleType == stLogarithmic) { @@ -4340,13 +4340,13 @@ void QCPAxis::setRangeReversed(bool reversed) /*! Sets whether the tick positions should be calculated automatically (either from an automatically generated tick step or a tick step provided manually via \ref setTickStep, see \ref setAutoTickStep). - + If \a on is set to false, you must provide the tick positions manually via \ref setTickVector. For these manual ticks you may let QCPAxis generate the appropriate labels automatically by leaving \ref setAutoTickLabels set to true. If you also wish to control the displayed labels manually, set \ref setAutoTickLabels to false and provide the label strings with \ref setTickVectorLabels. - + If you need dynamically calculated tick vectors (and possibly tick label vectors), set the vectors in a slot connected to the \ref ticksRequest signal. */ @@ -4362,10 +4362,10 @@ void QCPAxis::setAutoTicks(bool on) /*! When \ref setAutoTickStep is true, \a 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 \a approximateCount. */ void QCPAxis::setAutoTickCount(int approximateCount) @@ -4385,12 +4385,12 @@ void QCPAxis::setAutoTickCount(int approximateCount) Sets whether the tick labels are generated automatically. Depending on the tick label type (\ref ltNumber or \ref ltDateTime), the labels will either show the coordinate as floating point number (\ref setNumberFormat), or a date/time formatted according to \ref setDateTimeFormat. - + If \a on is set to false, you should provide the tick labels via \ref setTickVectorLabels. This is usually used in a combination with \ref 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 \ref ticksRequest signal. */ @@ -4406,11 +4406,11 @@ void QCPAxis::setAutoTickLabels(bool on) /*! 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 setAutoTickCount. - + If \a on is set to false, you may set the tick step manually with \ref setTickStep. */ void QCPAxis::setAutoTickStep(bool on) @@ -4426,7 +4426,7 @@ void QCPAxis::setAutoTickStep(bool on) 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 \ref setAutoTickStep is enabled, this is always the case. - + When \a on is set to false, you may set the sub tick count with \ref setSubTickCount manually. */ void QCPAxis::setAutoSubTicks(bool on) @@ -4480,23 +4480,23 @@ void QCPAxis::setTickLabelPadding(int padding) /*! Sets whether the tick labels display numbers or dates/times. - + If \a type is set to \ref ltNumber, the format specifications of \ref setNumberFormat apply. - + If \a type is set to \ref ltDateTime, the format specifications of \ref setDateTimeFormat apply. - + In QCustomPlot, date/time coordinates are double numbers representing the seconds since 1970-01-01T00:00:00 UTC. This format can be retrieved from QDateTime objects with the QDateTime::toTime_t() function. Since this only gives a resolution of one second, there is also the QDateTime::toMSecsSinceEpoch() function which returns the timespan described above in milliseconds. Divide its return value by 1000.0 to get a value with the format needed for date/time plotting, with a resolution of one millisecond. - + Using the toMSecsSinceEpoch function allows dates that go back to 2nd January 4713 B.C. (represented by a negative number), unlike the toTime_t function, which works with unsigned integers and thus only goes back to 1st January 1970. So both for range and accuracy, use of toMSecsSinceEpoch()/1000.0 should be preferred as key coordinate for date/time axes. - + \see setTickLabels */ void QCPAxis::setTickLabelType(LabelType type) @@ -4510,7 +4510,7 @@ void QCPAxis::setTickLabelType(LabelType type) /*! Sets the font of the tick labels. - + \see setTickLabels, setTickLabelColor */ void QCPAxis::setTickLabelFont(const QFont &font) @@ -4525,7 +4525,7 @@ void QCPAxis::setTickLabelFont(const QFont &font) /*! Sets the color of the tick labels. - + \see setTickLabels, setTickLabelFont */ void QCPAxis::setTickLabelColor(const QColor &color) @@ -4542,7 +4542,7 @@ void QCPAxis::setTickLabelColor(const QColor &color) Sets the rotation of the tick labels. If \a degrees is zero, the labels are drawn normally. Else, the tick labels are drawn rotated by \a degrees clockwise. The specified angle is bound to values from -90 to 90 degrees. - + If \a degrees is exactly -90, 0 or 90, the tick labels are centered on the tick coordinate. For other angles, the label is drawn with an offset such that it seems to point toward or away from the tick mark. @@ -4560,7 +4560,7 @@ void QCPAxis::setTickLabelRotation(double degrees) /*! Sets the format in which dates and times are displayed as tick labels, if \ref setTickLabelType is \ref ltDateTime. for details about the \a format string, see the documentation of QDateTime::toString(). - + Newlines can be inserted with "\n". */ void QCPAxis::setDateTimeFormat(const QString &format) @@ -4581,7 +4581,7 @@ void QCPAxis::setDateTimeFormat(const QString &format) or three characters. The first character is identical to the normal format code used by Qt. In short, this means: 'e'/'E' scientific format, 'f' fixed format, 'g'/'G' scientific or fixed, whichever is shorter. - + The second and third characters are optional and specific to QCustomPlot:\n 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 \a formatCode is set to 'b' (for @@ -4590,13 +4590,13 @@ void QCPAxis::setDateTimeFormat(const QString &format) If instead a cross should be shown (as is usual in the USA), the third char of \a 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 (\ref setScaleType) is \ref stLogarithmic and the \a 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 \ref setNumberPrecision. - + Examples for \a formatCode: \li \c g normal format code behaviour. If number is small, fixed format is used, if number is large, normal scientific format is used @@ -4618,7 +4618,7 @@ void QCPAxis::setNumberFormat(const QString &formatCode) } mLabelCache.clear(); mCachedMarginValid = false; - + // interpret first char as number format char: QString allowedFormatChars = "eEfgG"; if (allowedFormatChars.contains(formatCode.at(0))) @@ -4635,7 +4635,7 @@ void QCPAxis::setNumberFormat(const QString &formatCode) mNumberMultiplyCross = false; return; } - + // interpret second char as indicator for beautiful decimal powers: if (formatCode.at(1) == 'b' && (mNumberFormatChar == 'e' || mNumberFormatChar == 'g')) { @@ -4650,7 +4650,7 @@ void QCPAxis::setNumberFormat(const QString &formatCode) mNumberMultiplyCross = false; return; } - + // interpret third char as indicator for dot or cross multiplication symbol: if (formatCode.at(2) == 'c') { @@ -4705,9 +4705,9 @@ void QCPAxis::setTickStep(double step) the provided tick vector will be overwritten with automatically generated tick coordinates upon replot. The labels of the ticks can be generated automatically when \ref setAutoTickLabels is left enabled. If it is disabled, you can set the labels manually with \ref setTickVectorLabels. - + \a vec is a vector containing the positions of the ticks, in plot coordinates. - + \warning \a vec must be sorted in ascending order, no additional checks are made to ensure this. \see setTickVectorLabels @@ -4724,10 +4724,10 @@ void QCPAxis::setTickVector(const QVector &vec) number of QStrings that will be displayed at the tick positions which you need to provide with \ref setTickVector. These two vectors should have the same size. (Note that you need to disable \ref setAutoTicks and \ref setAutoTickLabels first.) - + \a vec is a vector containing the labels of the ticks. The entries correspond to the respective indices in the tick vector, passed via \ref setTickVector. - + \see setTickVector */ void QCPAxis::setTickVectorLabels(const QVector &vec) @@ -4742,7 +4742,7 @@ void QCPAxis::setTickVectorLabels(const QVector &vec) 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 setSubTickLength */ void QCPAxis::setTickLength(int inside, int outside) @@ -4761,7 +4761,7 @@ void QCPAxis::setTickLength(int inside, int 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 */ void QCPAxis::setTickLengthIn(int inside) @@ -4776,7 +4776,7 @@ void QCPAxis::setTickLengthIn(int inside) Sets the length of the outward ticks in pixels. \a outside is the length the ticks 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 setTickLengthIn, setSubTickLength */ void QCPAxis::setTickLengthOut(int outside) @@ -4791,7 +4791,7 @@ void QCPAxis::setTickLengthOut(int outside) /*! Sets the number of sub ticks in one (major) tick step. A sub tick count of three for example, divides the tick intervals in four sub intervals. - + By default, the number of sub ticks is chosen automatically in a reasonable manner as long as the mantissa of the tick step is a multiple of 0.5. When \ref setAutoTickStep is enabled, this is always the case. @@ -4826,7 +4826,7 @@ void QCPAxis::setSubTickLength(int inside, int 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 */ void QCPAxis::setSubTickLengthIn(int inside) @@ -4841,7 +4841,7 @@ void QCPAxis::setSubTickLengthIn(int inside) Sets the length of the outward subticks in pixels. \a outside is the length the subticks will reach 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 */ void QCPAxis::setSubTickLengthOut(int outside) @@ -4855,7 +4855,7 @@ void QCPAxis::setSubTickLengthOut(int outside) /*! Sets the pen, the axis base line is drawn with. - + \see setTickPen, setSubTickPen */ void QCPAxis::setBasePen(const QPen &pen) @@ -4865,7 +4865,7 @@ void QCPAxis::setBasePen(const QPen &pen) /*! Sets the pen, tick marks will be drawn with. - + \see setTickLength, setBasePen */ void QCPAxis::setTickPen(const QPen &pen) @@ -4875,7 +4875,7 @@ void QCPAxis::setTickPen(const QPen &pen) /*! Sets the pen, subtick marks will be drawn with. - + \see setSubTickCount, setSubTickLength, setBasePen */ void QCPAxis::setSubTickPen(const QPen &pen) @@ -4885,7 +4885,7 @@ void QCPAxis::setSubTickPen(const QPen &pen) /*! Sets the font of the axis label. - + \see setLabelColor */ void QCPAxis::setLabelFont(const QFont &font) @@ -4899,7 +4899,7 @@ void QCPAxis::setLabelFont(const QFont &font) /*! Sets the color of the axis label. - + \see setLabelFont */ void QCPAxis::setLabelColor(const QColor &color) @@ -4922,7 +4922,7 @@ void QCPAxis::setLabel(const QString &str) /*! Sets the distance between the tick labels and the axis label. - + \see setTickLabelPadding, setPadding */ void QCPAxis::setLabelPadding(int padding) @@ -4939,9 +4939,9 @@ void QCPAxis::setLabelPadding(int padding) When \ref QCPAxisRect::setAutoMargins is enabled, the padding is the additional outer most space, that is left blank. - + The axis padding has no meaning if \ref QCPAxisRect::setAutoMargins is disabled. - + \see setLabelPadding, setTickLabelPadding */ void QCPAxis::setPadding(int padding) @@ -4955,7 +4955,7 @@ void QCPAxis::setPadding(int padding) /*! 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. */ @@ -4966,7 +4966,7 @@ void QCPAxis::setOffset(int offset) /*! Sets the font that is used for tick labels when they are selected. - + \see setTickLabelFont, setSelectableParts, setSelectedParts, QCustomPlot::setInteractions */ void QCPAxis::setSelectedTickLabelFont(const QFont &font) @@ -4981,7 +4981,7 @@ void QCPAxis::setSelectedTickLabelFont(const QFont &font) /*! Sets the font that is used for the axis label when it is selected. - + \see setLabelFont, setSelectableParts, setSelectedParts, QCustomPlot::setInteractions */ void QCPAxis::setSelectedLabelFont(const QFont &font) @@ -4992,7 +4992,7 @@ void QCPAxis::setSelectedLabelFont(const QFont &font) /*! Sets the color that is used for tick labels when they are selected. - + \see setTickLabelColor, setSelectableParts, setSelectedParts, QCustomPlot::setInteractions */ void QCPAxis::setSelectedTickLabelColor(const QColor &color) @@ -5006,7 +5006,7 @@ void QCPAxis::setSelectedTickLabelColor(const QColor &color) /*! Sets the color that is used for the axis label when it is selected. - + \see setLabelColor, setSelectableParts, setSelectedParts, QCustomPlot::setInteractions */ void QCPAxis::setSelectedLabelColor(const QColor &color) @@ -5016,7 +5016,7 @@ void QCPAxis::setSelectedLabelColor(const QColor &color) /*! Sets the pen that is used to draw the axis base line when selected. - + \see setBasePen, setSelectableParts, setSelectedParts, QCustomPlot::setInteractions */ void QCPAxis::setSelectedBasePen(const QPen &pen) @@ -5026,7 +5026,7 @@ void QCPAxis::setSelectedBasePen(const QPen &pen) /*! Sets the pen that is used to draw the (major) ticks when selected. - + \see setTickPen, setSelectableParts, setSelectedParts, QCustomPlot::setInteractions */ void QCPAxis::setSelectedTickPen(const QPen &pen) @@ -5036,7 +5036,7 @@ void QCPAxis::setSelectedTickPen(const QPen &pen) /*! Sets the pen that is used to draw the subticks when selected. - + \see setSubTickPen, setSelectableParts, setSelectedParts, QCustomPlot::setInteractions */ void QCPAxis::setSelectedSubTickPen(const QPen &pen) @@ -5047,11 +5047,11 @@ void QCPAxis::setSelectedSubTickPen(const QPen &pen) /*! Sets the style for the lower axis ending. See the documentation of QCPLineEnding for available styles. - + For horizontal axes, this method refers to the left ending, for vertical axes the bottom ending. Note that this meaning does not change when the axis range is reversed with \ref setRangeReversed. - + \see setUpperEnding */ void QCPAxis::setLowerEnding(const QCPLineEnding &ending) @@ -5062,11 +5062,11 @@ void QCPAxis::setLowerEnding(const QCPLineEnding &ending) /*! Sets the style for the upper axis ending. See the documentation of QCPLineEnding for available styles. - + For horizontal axes, this method refers to the right ending, for vertical axes the top ending. Note that this meaning does not change when the axis range is reversed with \ref setRangeReversed. - + \see setLowerEnding */ void QCPAxis::setUpperEnding(const QCPLineEnding &ending) @@ -5077,7 +5077,7 @@ void QCPAxis::setUpperEnding(const QCPLineEnding &ending) /*! If the scale type (\ref setScaleType) is \ref stLinear, \a diff is added to the lower and upper bounds of the range. The range is simply moved by \a diff. - + If the scale type is \ref stLogarithmic, the range bounds are multiplied by \a diff. This corresponds to an apparent "linear" move in logarithmic scaling by a distance of log(diff). */ @@ -5143,17 +5143,17 @@ void QCPAxis::scaleRange(double factor, double center) void QCPAxis::setScaleRatio(const QCPAxis *otherAxis, double ratio) { int otherPixelSize, ownPixelSize; - + if (otherAxis->orientation() == Qt::Horizontal) otherPixelSize = otherAxis->axisRect()->width(); else otherPixelSize = otherAxis->axisRect()->height(); - + if (orientation() == Qt::Horizontal) ownPixelSize = axisRect()->width(); else ownPixelSize = axisRect()->height(); - + double newRangeSize = ratio*otherAxis->range().size()*ownPixelSize/(double)otherPixelSize; setRange(range().center(), newRangeSize, Qt::AlignCenter); } @@ -5232,7 +5232,7 @@ double QCPAxis::coordToPixel(double value) const 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 @@ -5252,16 +5252,16 @@ double QCPAxis::coordToPixel(double value) const Returns the part of the axis that is hit by \a pos (in pixels). The return value of this function is independent of the user-selectable parts defined with \ref setSelectableParts. Further, this function does not change the current selection state of the axis. - + If the axis is not visible (\ref setVisible), this function always returns \ref spNone. - + \see setSelectedParts, setSelectableParts, QCustomPlot::setInteractions */ QCPAxis::SelectablePart QCPAxis::getPartAt(const QPointF &pos) const { if (!mVisible) return spNone; - + if (mAxisSelectionBox.contains(pos.toPoint())) return spAxis; else if (mTickLabelsSelectionBox.contains(pos.toPoint())) @@ -5279,7 +5279,7 @@ double QCPAxis::selectTest(const QPointF &pos, bool onlySelectable, QVariant *de SelectablePart part = getPartAt(pos); if ((onlySelectable && !mSelectableParts.testFlag(part)) || part == spNone) return -1; - + if (details) details->setValue(part); return mParentPlot->selectionTolerance()*0.99; @@ -5287,16 +5287,16 @@ double QCPAxis::selectTest(const QPointF &pos, bool onlySelectable, QVariant *de /*! Returns a list of all the plottables that have this axis as key or value axis. - + If you are only interested in plottables of type QCPGraph, see \ref graphs. - + \see graphs, items */ QList QCPAxis::plottables() const { QList result; if (!mParentPlot) return result; - + for (int i=0; imPlottables.size(); ++i) { if (mParentPlot->mPlottables.at(i)->keyAxis() == this ||mParentPlot->mPlottables.at(i)->valueAxis() == this) @@ -5307,14 +5307,14 @@ QList QCPAxis::plottables() const /*! Returns a list of all the graphs that have this axis as key or value axis. - + \see plottables, items */ QList QCPAxis::graphs() const { QList result; if (!mParentPlot) return result; - + for (int i=0; imGraphs.size(); ++i) { if (mParentPlot->mGraphs.at(i)->keyAxis() == this || mParentPlot->mGraphs.at(i)->valueAxis() == this) @@ -5326,14 +5326,14 @@ QList QCPAxis::graphs() const /*! Returns a list of all the items that are associated with this axis. An item is considered associated with an axis if at least one of its positions uses the axis as key or value axis. - + \see plottables, graphs */ QList QCPAxis::items() const { QList result; if (!mParentPlot) return result; - + for (int itemId=0; itemIdmItems.size(); ++itemId) { QList positions = mParentPlot->mItems.at(itemId)->positions(); @@ -5368,7 +5368,7 @@ QCPAxis::AxisType QCPAxis::marginSideToAxisType(QCP::MarginSide side) } /*! \internal - + This function is called to prepare the tick vector, sub tick vector and tick label vector. If \ref setAutoTicks is set to true, appropriate tick values are determined automatically via \ref generateAutoTicks. If it's set to false, the signal ticksRequest is emitted, which can be used to @@ -5378,7 +5378,7 @@ void QCPAxis::setupTickVectors() { if (!mParentPlot) return; if ((!mTicks && !mTickLabels && !mGrid->visible()) || mRange.size() <= 0) return; - + // fill tick vectors, either by auto generating or by notifying user to fill the vectors himself if (mAutoTicks) { @@ -5387,14 +5387,14 @@ void QCPAxis::setupTickVectors() { emit ticksRequest(); } - + visibleTickBounds(mLowestVisibleTick, mHighestVisibleTick); if (mTickVector.isEmpty()) { mSubTickVector.clear(); return; } - + // generate subticks between ticks: mSubTickVector.resize((mTickVector.size()-1)*mSubTickCount); if (mSubTickCount > 0) @@ -5461,11 +5461,11 @@ void QCPAxis::setupTickVectors() } /*! \internal - + If \ref setAutoTicks is set to true, this function is called by \ref setupTickVectors to generate reasonable tick positions (and subtick count). The algorithm tries to create approximately mAutoTickCount ticks (set via \ref setAutoTickCount). - + If the scale is logarithmic, \ref setAutoTickCount is ignored, and one tick is generated at every power of the current logarithm base, set via \ref setScaleLogBase. */ @@ -5533,13 +5533,13 @@ void QCPAxis::generateAutoTicks() } /*! \internal - + Called by generateAutoTicks when \ref setAutoSubTicks is set to true. Depending on the \a tickStep between two major ticks on the axis, a different number of sub ticks is appropriate. For Example taking 4 sub ticks for a \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 (\ref setSubTickCount) is @@ -5548,18 +5548,18 @@ void QCPAxis::generateAutoTicks() int QCPAxis::calculateAutoSubTickCount(double tickStep) const { int result = mSubTickCount; // default to current setting, if no proper value can be found - + // get mantissa of tickstep: double magnitudeFactor = qPow(10.0, qFloor(qLn(tickStep)/qLn(10.0))); // get magnitude factor e.g. 0.01, 1, 10, 1000 etc. double tickStepMantissa = tickStep/magnitudeFactor; - + // separate integer and fractional part of mantissa: double epsilon = 0.01; double intPartf; int intPart; double fracPart = modf(tickStepMantissa, &intPartf); intPart = intPartf; - + // handle cases with (almost) integer mantissa: if (fracPart < epsilon || 1.0-fracPart < epsilon) { @@ -5597,14 +5597,14 @@ int QCPAxis::calculateAutoSubTickCount(double tickStep) const } // if mantissa fraction isnt 0.0 or 0.5, don't bother finding good sub tick marks, leave default } - + return result; } /*! \internal - + Draws the axis with the specified \a painter. - + The selection boxes (mAxisSelectionBox, mTickLabelsSelectionBox, mLabelSelectionBox) are set here, too. */ @@ -5620,7 +5620,7 @@ void QCPAxis::draw(QCPPainter *painter) 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) { @@ -5628,7 +5628,7 @@ void QCPAxis::draw(QCPPainter *painter) case atRight: xCor = 1; break; default: break; } - + int margin = 0; int lowTick = mLowestVisibleTick; int highTick = mHighestVisibleTick; @@ -5644,7 +5644,7 @@ void QCPAxis::draw(QCPPainter *painter) if (mRangeReversed) 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 (mTicks) { @@ -5667,7 +5667,7 @@ void QCPAxis::draw(QCPPainter *painter) } } } - + // draw subticks: if (mTicks && mSubTickCount > 0) { @@ -5691,7 +5691,7 @@ void QCPAxis::draw(QCPPainter *painter) } } 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 @@ -5702,7 +5702,7 @@ void QCPAxis::draw(QCPPainter *painter) 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) @@ -5750,7 +5750,7 @@ void QCPAxis::draw(QCPPainter *painter) else if (mAxisType == atBottom) painter->drawText(origin.x(), origin.y()+margin, mAxisRect->width(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter, mLabel); } - + // set selection boxes: int selAxisOutSize = qMax(qMax(mTickLengthOut, mSubTickLengthOut), mParentPlot->selectionTolerance()); int selAxisInSize = mParentPlot->selectionTolerance(); @@ -5785,20 +5785,20 @@ void QCPAxis::draw(QCPPainter *painter) } /*! \internal - + Draws a single tick label with the provided \a 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 \a distanceToAxis in pixels. The pixel position in the axis direction is passed in the \a position parameter. Hence for the bottom axis, \a 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 \a tickLabelsSize to the \ref drawTickLabel calls during the process of drawing all tick labels of one axis. In every call, \a tickLabelsSize is expanded, if the drawn label exceeds the value \a tickLabelsSize currently holds. - + The label is drawn with the font and pen that are currently set on the \a painter. To draw superscripted powers, the font is temporarily made smaller by a fixed factor (see \ref getTickLabelData). @@ -5867,18 +5867,18 @@ void QCPAxis::placeTickLabel(QCPPainter *painter, double position, int distanceT drawTickLabel(painter, finalPosition.x(), finalPosition.y(), labelData); finalSize = labelData.rotatedTotalBounds.size(); } - + // 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()); } /*! \internal - + This is a \ref placeTickLabel helper function. - + Draws the tick label specified in \a labelData with \a painter at the pixel positions \a x and \a y. This function is used by \ref 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 @@ -5889,12 +5889,12 @@ void QCPAxis::drawTickLabel(QCPPainter *painter, double x, double y, const QCPAx // backup painter settings that we're about to change: QTransform oldTransform = painter->transform(); QFont oldFont = painter->font(); - + // transform painter to position/rotation: painter->translate(x, y); if (!qFuzzyIsNull(mTickLabelRotation)) painter->rotate(mTickLabelRotation); - + // draw text: if (!labelData.expPart.isEmpty()) // indicator that beautiful powers must be used { @@ -5907,16 +5907,16 @@ void QCPAxis::drawTickLabel(QCPPainter *painter, double x, double y, const QCPAx painter->setFont(labelData.baseFont); painter->drawText(0, 0, labelData.totalBounds.width(), labelData.totalBounds.height(), Qt::TextDontClip | Qt::AlignHCenter, labelData.basePart); } - + // reset painter settings to what it was before: painter->setTransform(oldTransform); painter->setFont(oldFont); } /*! \internal - + This is a \ref placeTickLabel helper function. - + 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. @@ -5924,7 +5924,7 @@ void QCPAxis::drawTickLabel(QCPPainter *painter, double x, double y, const QCPAx QCPAxis::TickLabelData QCPAxis::getTickLabelData(const QFont &font, const QString &text) const { TickLabelData result; - + // determine whether beautiful decimal powers should be used bool useBeautifulPowers = false; int ePos = -1; @@ -5934,10 +5934,10 @@ QCPAxis::TickLabelData QCPAxis::getTickLabelData(const QFont &font, const QStrin if (ePos > -1) useBeautifulPowers = true; } - + // 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 + 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: @@ -5966,7 +5966,7 @@ QCPAxis::TickLabelData QCPAxis::getTickLabelData(const QFont &font, const QStrin result.totalBounds = QFontMetrics(result.baseFont).boundingRect(0, 0, 0, 0, Qt::TextDontClip | Qt::AlignHCenter, result.basePart); } result.totalBounds.moveTopLeft(QPoint(0, 0)); // want bounding box aligned top left at origin, independent of how it was created, to make further processing simpler - + // calculate possibly different bounding rect after rotation: result.rotatedTotalBounds = result.totalBounds; if (!qFuzzyIsNull(mTickLabelRotation)) @@ -5975,17 +5975,17 @@ QCPAxis::TickLabelData QCPAxis::getTickLabelData(const QFont &font, const QStrin transform.rotate(mTickLabelRotation); result.rotatedTotalBounds = transform.mapRect(result.rotatedTotalBounds); } - + return result; } /*! \internal - + This is a \ref 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. */ @@ -6078,12 +6078,12 @@ QPointF QCPAxis::getTickLabelDrawOffset(const QCPAxis::TickLabelData &labelData) y = 0; } } - + return QPointF(x, y); } /*! \internal - + Simulates the steps done by \ref 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 \a tickLabelsSize is only expanded, if it's currently set to a @@ -6102,9 +6102,9 @@ void QCPAxis::getMaxTickLabelSize(const QFont &font, const QString &text, QSize TickLabelData labelData = getTickLabelData(font, text); finalSize = labelData.rotatedTotalBounds.size(); } - + // 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()); @@ -6139,11 +6139,11 @@ void QCPAxis::deselectEvent(bool *selectionStateChanged) 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 @@ -6152,15 +6152,15 @@ void QCPAxis::applyDefaultAntialiasingHint(QCPPainter *painter) const } /*! \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 @@ -6173,7 +6173,7 @@ void QCPAxis::visibleTickBounds(int &lowIndex, int &highIndex) const bool highFound = false; lowIndex = 0; highIndex = -1; - + for (int i=0; i < mTickVector.size(); ++i) { if (mTickVector.at(i) >= mRange.lower) @@ -6192,7 +6192,7 @@ void QCPAxis::visibleTickBounds(int &lowIndex, int &highIndex) const break; } } - + if (!lowFound && highFound) lowIndex = highIndex+1; else if (lowFound && !highFound) @@ -6200,11 +6200,11 @@ void QCPAxis::visibleTickBounds(int &lowIndex, int &highIndex) const } /*! \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 @@ -6213,10 +6213,10 @@ double QCPAxis::baseLog(double value) const } /*! \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 @@ -6225,7 +6225,7 @@ double QCPAxis::basePow(double value) const } /*! \internal - + Returns the pen that is used to draw the axis base line. Depending on the selection state, this is either mSelectedBasePen or mBasePen. */ @@ -6235,7 +6235,7 @@ QPen QCPAxis::getBasePen() const } /*! \internal - + Returns the pen that is used to draw the (major) ticks. Depending on the selection state, this is either mSelectedTickPen or mTickPen. */ @@ -6245,7 +6245,7 @@ QPen QCPAxis::getTickPen() const } /*! \internal - + Returns the pen that is used to draw the subticks. Depending on the selection state, this is either mSelectedSubTickPen or mSubTickPen. */ @@ -6255,7 +6255,7 @@ QPen QCPAxis::getSubTickPen() const } /*! \internal - + Returns the font that is used to draw the tick labels. Depending on the selection state, this is either mSelectedTickLabelFont or mTickLabelFont. */ @@ -6265,7 +6265,7 @@ QFont QCPAxis::getTickLabelFont() const } /*! \internal - + Returns the font that is used to draw the axis label. Depending on the selection state, this is either mSelectedLabelFont or mLabelFont. */ @@ -6275,7 +6275,7 @@ QFont QCPAxis::getLabelFont() const } /*! \internal - + Returns the color that is used to draw the tick labels. Depending on the selection state, this is either mSelectedTickLabelColor or mTickLabelColor. */ @@ -6285,7 +6285,7 @@ QColor QCPAxis::getTickLabelColor() const } /*! \internal - + Returns the color that is used to draw the axis label. Depending on the selection state, this is either mSelectedLabelColor or mLabelColor. */ @@ -6295,16 +6295,16 @@ QColor QCPAxis::getLabelColor() const } /*! \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. */ @@ -6312,10 +6312,10 @@ 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; @@ -6365,16 +6365,16 @@ QCP::Interaction QCPAxis::selectionCategory() const It defines a very basic interface like name, pen, brush, visibility etc. Since this class is abstract, it can't be instantiated. Use one of the subclasses or create a subclass yourself to create new ways of displaying data (see "Creating own plottables" below). - + All further specifics are in the subclasses, for example: \li A normal graph with possibly a line, scatter points and error bars is displayed by \ref QCPGraph (typically created with \ref QCustomPlot::addGraph). \li A parametric curve can be displayed with \ref QCPCurve. \li A stackable bar chart can be achieved with \ref QCPBars. \li A box of a statistical box plot is created with \ref QCPStatisticalBox. - + \section plottables-subclassing Creating own plottables - + To create an own plottable, you implement a subclass of QCPAbstractPlottable. These are the pure virtual functions, you must implement: \li \ref clearData @@ -6383,9 +6383,9 @@ QCP::Interaction QCPAxis::selectionCategory() const \li \ref drawLegendIcon \li \ref getKeyRange \li \ref getValueRange - + See the documentation of those functions for what they need to do. - + For drawing your plot, you can use the \ref 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 @@ -6393,7 +6393,7 @@ QCP::Interaction QCPAxis::selectionCategory() const to translate many points in a loop like QCPGraph), you can directly use \ref QCPAxis::coordToPixel. However, you must then take care about the orientation of the axis yourself. - + Here are some important members you inherit from QCPAbstractPlottable: @@ -6433,14 +6433,14 @@ QCP::Interaction QCPAxis::selectionCategory() const /*! \fn void QCPAbstractPlottable::drawLegendIcon(QCPPainter *painter, const QRect &rect) const = 0 \internal - + called by QCPLegend::draw (via QCPPlottableLegendItem::draw) to create a graphical representation of this plottable inside \a rect, next to the plottable name. */ /*! \fn QCPRange QCPAbstractPlottable::getKeyRange(bool &validRange, 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 @@ -6448,13 +6448,13 @@ QCP::Interaction QCPAxis::selectionCategory() const 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). - + \see rescaleAxes, getValueRange */ /*! \fn QCPRange QCPAbstractPlottable::getValueRange(bool &validRange, 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 @@ -6462,7 +6462,7 @@ QCP::Interaction QCPAxis::selectionCategory() const 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). - + \see rescaleAxes, getKeyRange */ @@ -6470,7 +6470,7 @@ QCP::Interaction QCPAxis::selectionCategory() const /* start of documentation of signals */ /*! \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. */ @@ -6482,10 +6482,10 @@ QCP::Interaction QCPAxis::selectionCategory() const its value axis ("y"). \a keyAxis and \a valueAxis must reside in the same QCustomPlot instance and have perpendicular orientations. If either of these restrictions is violated, a corresponding message is printed to the debug output (qDebug), the construction is not aborted, though. - + Since QCPAbstractPlottable is an abstract class that defines the basic interface to plottables, it can't be directly instantiated. - + You probably want one of the subclasses like \ref QCPGraph or \ref QCPCurve instead. */ QCPAbstractPlottable::QCPAbstractPlottable(QCPAxis *keyAxis, QCPAxis *valueAxis) : @@ -6520,7 +6520,7 @@ void QCPAbstractPlottable::setName(const QString &name) /*! Sets whether fills of this plottable is drawn antialiased or not. - + Note that this setting may be overridden by \ref QCustomPlot::setAntialiasedElements and \ref QCustomPlot::setNotAntialiasedElements. */ @@ -6531,7 +6531,7 @@ void QCPAbstractPlottable::setAntialiasedFill(bool enabled) /*! Sets whether the scatter symbols of this plottable are drawn antialiased or not. - + Note that this setting may be overridden by \ref QCustomPlot::setAntialiasedElements and \ref QCustomPlot::setNotAntialiasedElements. */ @@ -6542,7 +6542,7 @@ void QCPAbstractPlottable::setAntialiasedScatters(bool enabled) /*! Sets whether the error bars of this plottable are drawn antialiased or not. - + Note that this setting may be overridden by \ref QCustomPlot::setAntialiasedElements and \ref QCustomPlot::setNotAntialiasedElements. */ @@ -6555,7 +6555,7 @@ void QCPAbstractPlottable::setAntialiasedErrorBars(bool enabled) /*! The pen is used to draw basic lines that make up the plottable representation in the plot. - + For example, the \ref QCPGraph subclass draws its graph lines and scatter points with this pen. @@ -6580,7 +6580,7 @@ void QCPAbstractPlottable::setSelectedPen(const QPen &pen) /*! 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 \ref QCPGraph subclass draws the fill under the graph with this brush, when it's not set to Qt::NoBrush. @@ -6607,7 +6607,7 @@ void QCPAbstractPlottable::setSelectedBrush(const QBrush &brush) 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 \ref QCustomPlot::addGraph when working with QCPGraphs through the dedicated graph interface). @@ -6626,7 +6626,7 @@ void QCPAbstractPlottable::setKeyAxis(QCPAxis *axis) Normally, the key and value axes are set in the constructor of the plottable (or \ref QCustomPlot::addGraph when working with QCPGraphs through the dedicated graph interface). - + \see setKeyAxis */ void QCPAbstractPlottable::setValueAxis(QCPAxis *axis) @@ -6637,10 +6637,10 @@ void QCPAbstractPlottable::setValueAxis(QCPAxis *axis) /*! Sets whether the user can (de-)select this plottable by clicking on the QCustomPlot surface. (When \ref QCustomPlot::setInteractions contains iSelectPlottables.) - + However, even when \a selectable was set to false, it is possible to set the selection manually, by calling \ref setSelected directly. - + \see setSelected */ void QCPAbstractPlottable::setSelectable(bool selectable) @@ -6655,11 +6655,11 @@ void QCPAbstractPlottable::setSelectable(bool selectable) The entire selection mechanism for plottables is handled automatically when \ref 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 \ref setSelectable was set to false. - + emits the \ref selectionChanged signal when \a selected is different from the previous selection state. - + \see setSelectable, selectTest */ void QCPAbstractPlottable::setSelected(bool selected) @@ -6677,11 +6677,11 @@ void QCPAbstractPlottable::setSelected(bool selected) 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. - + \a 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 \a onlyEnlarge set to false (the default), and all subsequent set to true. - + \see rescaleKeyAxis, rescaleValueAxis, QCustomPlot::rescaleAxes */ void QCPAbstractPlottable::rescaleAxes(bool onlyEnlarge) const @@ -6692,18 +6692,18 @@ void QCPAbstractPlottable::rescaleAxes(bool onlyEnlarge) const /*! Rescales the key axis of the plottable so the whole plottable is visible. - + See \ref rescaleAxes for detailed behaviour. */ void QCPAbstractPlottable::rescaleKeyAxis(bool onlyEnlarge) const { 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); if (validRange) @@ -6721,21 +6721,21 @@ void QCPAbstractPlottable::rescaleKeyAxis(bool onlyEnlarge) const /*! Rescales the value axis of the plottable so the whole plottable is visible. - + See \ref rescaleAxes for detailed behaviour. */ void QCPAbstractPlottable::rescaleValueAxis(bool onlyEnlarge) const { 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 validRange; QCPRange newRange = getValueRange(validRange, signDomain); - + if (validRange) { if (onlyEnlarge) @@ -6751,21 +6751,21 @@ void QCPAbstractPlottable::rescaleValueAxis(bool onlyEnlarge) const /*! 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 removeFromLegend, QCPLegend::addItem */ bool QCPAbstractPlottable::addToLegend() { if (!mParentPlot || !mParentPlot->legend) return false; - + if (!mParentPlot->legend->hasItemWithPlottable(this)) { mParentPlot->legend->addItem(new QCPPlottableLegendItem(mParentPlot->legend, this)); @@ -6774,21 +6774,21 @@ bool QCPAbstractPlottable::addToLegend() 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. - + Returns true on success, i.e. if the legend exists and a legend item associated with this plottable was found and removed. - + \see addToLegend, QCPLegend::removeItem */ bool QCPAbstractPlottable::removeFromLegend() const { if (!mParentPlot->legend) return false; - + if (QCPPlottableLegendItem *lip = mParentPlot->legend->itemWithPlottable(this)) return mParentPlot->legend->removeItem(lip); else @@ -6811,13 +6811,13 @@ QCP::Interaction QCPAbstractPlottable::selectionCategory() const } /*! \internal - + 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). - + \a key and \a value are transformed to the coodinates in pixels and are written to \a x and \a y. - + \see pixelsToCoords, QCPAxis::coordToPixel */ void QCPAbstractPlottable::coordsToPixels(double key, double value, double &x, double &y) const @@ -6825,7 +6825,7 @@ void QCPAbstractPlottable::coordsToPixels(double key, double value, double &x, d QCPAxis *keyAxis = mKeyAxis.data(); QCPAxis *valueAxis = mValueAxis.data(); if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } - + if (keyAxis->orientation() == Qt::Horizontal) { x = keyAxis->coordToPixel(key); @@ -6837,9 +6837,9 @@ void QCPAbstractPlottable::coordsToPixels(double key, double value, double &x, d } } -/*! \internal +/*! \internal \overload - + Returns the input as pixel coordinates in a QPointF. */ const QPointF QCPAbstractPlottable::coordsToPixels(double key, double value) const @@ -6847,7 +6847,7 @@ const QPointF QCPAbstractPlottable::coordsToPixels(double key, double value) con QCPAxis *keyAxis = mKeyAxis.data(); QCPAxis *valueAxis = mValueAxis.data(); if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return QPointF(); } - + if (keyAxis->orientation() == Qt::Horizontal) return QPointF(keyAxis->coordToPixel(key), valueAxis->coordToPixel(value)); else @@ -6855,13 +6855,13 @@ const QPointF QCPAbstractPlottable::coordsToPixels(double key, double value) con } /*! \internal - + 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). - + \a x and \a y are transformed to the plot coodinates and are written to \a key and \a value. - + \see coordsToPixels, QCPAxis::coordToPixel */ void QCPAbstractPlottable::pixelsToCoords(double x, double y, double &key, double &value) const @@ -6869,7 +6869,7 @@ void QCPAbstractPlottable::pixelsToCoords(double x, double y, double &key, doubl QCPAxis *keyAxis = mKeyAxis.data(); QCPAxis *valueAxis = mValueAxis.data(); if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } - + if (keyAxis->orientation() == Qt::Horizontal) { key = keyAxis->pixelToCoord(x); @@ -6917,11 +6917,11 @@ QBrush QCPAbstractPlottable::mainBrush() const before drawing plottable 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, applyFillAntialiasingHint, applyScattersAntialiasingHint, applyErrorBarsAntialiasingHint */ void QCPAbstractPlottable::applyDefaultAntialiasingHint(QCPPainter *painter) const @@ -6933,11 +6933,11 @@ void QCPAbstractPlottable::applyDefaultAntialiasingHint(QCPPainter *painter) con A convenience function to easily set the QPainter::Antialiased hint on the provided \a painter before drawing plottable fills. - + 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, applyDefaultAntialiasingHint, applyScattersAntialiasingHint, applyErrorBarsAntialiasingHint */ void QCPAbstractPlottable::applyFillAntialiasingHint(QCPPainter *painter) const @@ -6949,11 +6949,11 @@ void QCPAbstractPlottable::applyFillAntialiasingHint(QCPPainter *painter) const A convenience function to easily set the QPainter::Antialiased hint on the provided \a 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 \ref QCustomPlot::setAntialiasedElements and \ref QCustomPlot::setNotAntialiasedElements. - + \see setAntialiased, applyFillAntialiasingHint, applyDefaultAntialiasingHint, applyErrorBarsAntialiasingHint */ void QCPAbstractPlottable::applyScattersAntialiasingHint(QCPPainter *painter) const @@ -6965,11 +6965,11 @@ void QCPAbstractPlottable::applyScattersAntialiasingHint(QCPPainter *painter) co A convenience function to easily set the QPainter::Antialiased hint on the provided \a 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 \ref QCustomPlot::setAntialiasedElements and \ref QCustomPlot::setNotAntialiasedElements. - + \see setAntialiased, applyFillAntialiasingHint, applyScattersAntialiasingHint, applyDefaultAntialiasingHint */ void QCPAbstractPlottable::applyErrorBarsAntialiasingHint(QCPPainter *painter) const @@ -6981,10 +6981,10 @@ void QCPAbstractPlottable::applyErrorBarsAntialiasingHint(QCPPainter *painter) c Finds the shortest squared distance of \a point to the line segment defined by \a start and \a end. - + This function may be used to help with the implementation of the \ref selectTest function for specific plottables. - + \note This function is identical to QCPAbstractItem::distSqrToLine */ double QCPAbstractPlottable::distSqrToLine(const QPointF &start, const QPointF &end, const QPointF &point) const @@ -6993,7 +6993,7 @@ double QCPAbstractPlottable::distSqrToLine(const QPointF &start, const QPointF & QVector2D b(end); QVector2D p(point); QVector2D v(b-a); - + double vLengthSqr = v.lengthSquared(); if (!qFuzzyIsNull(vLengthSqr)) { @@ -7041,7 +7041,7 @@ void QCPAbstractPlottable::deselectEvent(bool *selectionStateChanged) /*! \class QCPItemAnchor \brief An anchor of an item to which positions can be attached to. - + An item (QCPAbstractItem) may have one or more anchors. Unlike QCPItemPosition, an anchor doesn't control anything on its item, but provides a way to tie other items via their positions to the anchor. @@ -7052,10 +7052,10 @@ void QCPAbstractPlottable::deselectEvent(bool *selectionStateChanged) calling QCPItemPosition::setParentAnchor on \a start, passing the wanted anchor of the QCPItemRect. This way the start of the line will now always follow the respective anchor location on the rect item. - + Note that QCPItemPosition derives from QCPItemAnchor, so every position can also serve as an anchor to other positions. - + To learn how to provide anchors in your own item subclasses, see the subclassing section of the QCPAbstractItem documentation. */ @@ -7083,7 +7083,7 @@ QCPItemAnchor::~QCPItemAnchor() /*! Returns the final absolute pixel position of the QCPItemAnchor on the QCustomPlot surface. - + The pixel information is internally retrieved via QCPAbstractItem::anchorPixelPosition of the parent item, QCPItemAnchor is just an intermediary. */ @@ -7110,7 +7110,7 @@ QPointF QCPItemAnchor::pixelPoint() const Adds \a 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 \a pos. */ void QCPItemAnchor::addChild(QCPItemPosition *pos) @@ -7124,7 +7124,7 @@ void QCPItemAnchor::addChild(QCPItemPosition *pos) /*! \internal Removes \a pos from the child list of this anchor. - + Note that this function does not change the parent setting in \a pos. */ void QCPItemAnchor::removeChild(QCPItemPosition *pos) @@ -7140,7 +7140,7 @@ void QCPItemAnchor::removeChild(QCPItemPosition *pos) /*! \class QCPItemPosition \brief Manages the position of an item. - + Every item has at least one public QCPItemPosition member pointer which provides ways to position the item on the QCustomPlot surface. Some items have multiple positions, for example QCPItemRect has two: \a topLeft and \a bottomRight. @@ -7194,22 +7194,22 @@ QCPItemPosition::~QCPItemPosition() /*! Sets the type of the position. The type defines how the coordinates passed to \ref setCoords should be handled and how the QCPItemPosition should behave in the plot. - + The possible values for \a type can be separated in two main categories: \li The position is regarded as a point in plot coordinates. This corresponds to \ref ptPlotCoords and requires two axes that define the plot coordinate system. They can be specified with \ref setAxes. By default, the QCustomPlot's x- and yAxis are used. - + \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 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 has no parent anchor (\ref 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 \ref setCoords may change in the process. */ @@ -7224,13 +7224,13 @@ void QCPItemPosition::setType(QCPItemPosition::PositionType type) recoverPixelPosition = false; if ((mPositionType == ptAxisRectRatio || type == ptAxisRectRatio) && (!mAxisRect)) recoverPixelPosition = false; - + QPointF pixelP; if (recoverPixelPosition) pixelP = pixelPoint(); - + mPositionType = type; - + if (recoverPixelPosition) setPixelPoint(pixelP); } @@ -7241,13 +7241,13 @@ void QCPItemPosition::setType(QCPItemPosition::PositionType type) follow any position changes of the anchor. The local coordinate system of positions with a parent anchor always is absolute with (0, 0) being exactly on top of the parent anchor. (Hence the type shouldn't be \ref ptPlotCoords for positions with parent anchors.) - + if \a keepPixelPosition is true, the current pixel position of the QCPItemPosition is preserved during reparenting. If it's set to false, the coordinates are set to (0, 0), i.e. the position will be exactly on top of the parent anchor. - + To remove this QCPItemPosition from any parent anchor, set \a parentAnchor to 0. - + If the QCPItemPosition previously had no parent and the type is \ref ptPlotCoords, the type is set to \ref ptAbsolute, to keep the position in a valid state. */ @@ -7285,11 +7285,11 @@ bool QCPItemPosition::setParentAnchor(QCPItemAnchor *parentAnchor, bool keepPixe break; } } - + // if previously no parent set and PosType is still ptPlotCoords, set to ptAbsolute: if (!mParentAnchor && mPositionType == ptPlotCoords) setType(ptAbsolute); - + // save pixel position: QPointF pixelP; if (keepPixelPosition) @@ -7312,7 +7312,7 @@ bool QCPItemPosition::setParentAnchor(QCPItemAnchor *parentAnchor, bool keepPixe /*! Sets the coordinates of this QCPItemPosition. What the coordinates mean, is defined by the type (\ref setType). - + For example, if the type is \ref ptAbsolute, \a key and \a value mean the x and y pixel position on the QCustomPlot surface. In that case the origin (0, 0) is in the top left corner of the QCustomPlot viewport. If the type is \ref ptPlotCoords, \a key and \a value mean a point in the @@ -7355,7 +7355,7 @@ QPointF QCPItemPosition::pixelPoint() const else return QPointF(mKey, mValue); } - + case ptViewportRatio: { if (mParentAnchor) @@ -7368,7 +7368,7 @@ QPointF QCPItemPosition::pixelPoint() const mValue*mParentPlot->viewport().height()) + mParentPlot->viewport().topLeft(); } } - + case ptAxisRectRatio: { if (mAxisRect) @@ -7388,7 +7388,7 @@ QPointF QCPItemPosition::pixelPoint() const return QPointF(mKey, mValue); } } - + case ptPlotCoords: { double x, y; @@ -7484,7 +7484,7 @@ void QCPItemPosition::setPixelPoint(const QPointF &pixelPoint) setCoords(pixelPoint); break; } - + case ptViewportRatio: { if (mParentAnchor) @@ -7502,7 +7502,7 @@ void QCPItemPosition::setPixelPoint(const QPointF &pixelPoint) } break; } - + case ptAxisRectRatio: { if (mAxisRect) @@ -7527,7 +7527,7 @@ void QCPItemPosition::setPixelPoint(const QPointF &pixelPoint) } break; } - + case ptPlotCoords: { double newKey, newValue; @@ -7587,18 +7587,18 @@ void QCPItemPosition::setPixelPoint(const QPointF &pixelPoint) /*! \class QCPAbstractItem \brief The abstract base class for all items in a plot. - + In QCustomPlot, items are supplemental graphical elements that are neither plottables (QCPAbstractPlottable) nor axes (QCPAxis). While plottables are always tied to two axes and thus plot coordinates, items can also be placed in absolute coordinates independent of any axes. Each specific item has at least one QCPItemPosition member which controls the positioning. Some items are defined by more than one coordinate and thus have two or more QCPItemPosition members (For example, QCPItemRect has \a topLeft and \a bottomRight). - + This abstract base class defines a very basic interface like visibility and clipping. Since this class is abstract, it can't be instantiated. Use one of the subclasses or create a subclass yourself to create new items. - + The built-in items are:
@@ -7611,12 +7611,12 @@ void QCPItemPosition::setPixelPoint(const QPointF &pixelPoint)
QCPItemLineA line defined by a start and an end point. May have different ending styles on each side (e.g. arrows).
QCPItemBracketA bracket which may be used to reference/highlight certain parts in the plot.
QCPItemTracerAn item that can be attached to a QCPGraph and sticks to its data points, given a key coordinate.
- + Items are by default clipped to the main axis rect. To make an item visible outside that axis rect, disable clipping via \ref setClipToAxisRect. - + \section items-using Using items - + First you instantiate the item you want to use and add it to the plot: \code QCPItemLine *line = new QCPItemLine(customPlot); @@ -7639,31 +7639,31 @@ void QCPItemPosition::setPixelPoint(const QPointF &pixelPoint) line->start->setCoords(100, 200); line->end->setCoords(450, 320); \endcode - + \section items-subclassing Creating own items - + To create an own item, you implement a subclass of QCPAbstractItem. These are the pure virtual functions, you must implement: \li \ref selectTest \li \ref draw - + See the documentation of those functions for what they need to do. - + \subsection items-positioning Allowing the item to be positioned - + As mentioned, item positions are represented by QCPItemPosition members. Let's assume the new item shall have only one point as its position (as opposed to two like a rect or multiple like a polygon). You then add a public member of type QCPItemPosition like so: - + \code QCPItemPosition * const myPosition;\endcode - + the const makes sure the pointer itself can't be modified from the user of your new item (the QCPItemPosition instance it points to, can be modified, of course). The initialization of this pointer is made easy with the \ref createPosition function. Just assign the return value of this function to each QCPItemPosition in the constructor of your item. \ref createPosition takes a string which is the name of the position, typically this is identical to the variable name. For example, the constructor of QCPItemExample could look like this: - + \code QCPItemExample::QCPItemExample(QCustomPlot *parentPlot) : QCPAbstractItem(parentPlot), @@ -7672,9 +7672,9 @@ void QCPItemPosition::setPixelPoint(const QPointF &pixelPoint) // other constructor code } \endcode - + \subsection items-drawing The draw function - + To give your item a visual representation, reimplement the \ref draw function and use the passed QCPPainter to draw the item. You can retrieve the item position in pixel coordinates from the position member(s) via \ref QCPItemPosition::pixelPoint. @@ -7682,19 +7682,19 @@ void QCPItemPosition::setPixelPoint(const QPointF &pixelPoint) To optimize performance you should calculate a bounding rect first (don't forget to take the pen width into account), check whether it intersects the \ref clipRect, and only draw the item at all if this is the case. - + \subsection items-selection The selectTest function - + Your implementation of the \ref selectTest function may use the helpers \ref distSqrToLine and \ref rectSelectTest. With these, the implementation of the selection test becomes significantly simpler for most items. See the documentation of \ref selectTest for what the function parameters mean and what the function should return. - + \subsection anchors Providing anchors - + Providing anchors (QCPItemAnchor) starts off like adding a position. First you create a public member, e.g. - + \code QCPItemAnchor * const bottom;\endcode and create it in the constructor with the \ref createAnchor function, assigning it a name and an @@ -7702,7 +7702,7 @@ void QCPItemPosition::setPixelPoint(const QPointF &pixelPoint) Since anchors can be placed anywhere, relative to the item's position(s), your item needs to provide the position of every anchor with the reimplementation of the \ref anchorPixelPoint(int anchorId) function. - + In essence the QCPItemAnchor is merely an intermediary that itself asks your item for the pixel position when anything attached to the anchor needs to know the coordinates. */ @@ -7710,17 +7710,17 @@ void QCPItemPosition::setPixelPoint(const QPointF &pixelPoint) /* start of documentation of inline functions */ /*! \fn QList QCPAbstractItem::positions() const - + Returns all positions of the item in a list. - + \see anchors, position */ /*! \fn QList QCPAbstractItem::anchors() const - + 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 positions, anchor */ @@ -7729,9 +7729,9 @@ void QCPItemPosition::setPixelPoint(const QPointF &pixelPoint) /*! \fn void QCPAbstractItem::draw(QCPPainter *painter) = 0 \internal - + Draws this item with the provided \a painter. - + The cliprect of the provided painter is set to the rect returned by \ref clipRect before this function is called. The clipRect depends on the clipping settings defined by \ref setClipToAxisRect and \ref setClipAxisRect. @@ -7773,7 +7773,7 @@ QCPAbstractItem::~QCPAbstractItem() /*! 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 \ref setClipAxisRect. - + \see setClipAxisRect */ void QCPAbstractItem::setClipToAxisRect(bool clip) @@ -7786,7 +7786,7 @@ void QCPAbstractItem::setClipToAxisRect(bool clip) /*! Sets the clip axis rect. It defines the rect that will be used to clip the item when \ref setClipToAxisRect is set to true. - + \see setClipToAxisRect */ void QCPAbstractItem::setClipAxisRect(QCPAxisRect *rect) @@ -7799,10 +7799,10 @@ void QCPAbstractItem::setClipAxisRect(QCPAxisRect *rect) /*! Sets whether the user can (de-)select this item by clicking on the QCustomPlot surface. (When \ref QCustomPlot::setInteractions contains QCustomPlot::iSelectItems.) - + However, even when \a selectable was set to false, it is possible to set the selection manually, by calling \ref setSelected. - + \see QCustomPlot::setInteractions, setSelected */ void QCPAbstractItem::setSelectable(bool selectable) @@ -7817,11 +7817,11 @@ void QCPAbstractItem::setSelectable(bool selectable) The entire selection mechanism for items is handled automatically when \ref 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 \ref setSelectable was set to false. - + emits the \ref selectionChanged signal when \a selected is different from the previous selection state. - + \see setSelectable, selectTest */ void QCPAbstractItem::setSelected(bool selected) @@ -7836,12 +7836,12 @@ void QCPAbstractItem::setSelected(bool selected) /*! Returns the QCPItemPosition with the specified \a 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 \a name). - - \see positions, anchor + + \see positions, anchor */ QCPItemPosition *QCPAbstractItem::position(const QString &name) const { @@ -7857,12 +7857,12 @@ QCPItemPosition *QCPAbstractItem::position(const QString &name) const /*! Returns the QCPItemAnchor with the specified \a 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 \a name). - - \see anchors, position + + \see anchors, position */ QCPItemAnchor *QCPAbstractItem::anchor(const QString &name) const { @@ -7877,11 +7877,11 @@ QCPItemAnchor *QCPAbstractItem::anchor(const QString &name) const /*! Returns whether this item has an anchor with the specified \a 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 anchor, position + + \see anchor, position */ bool QCPAbstractItem::hasAnchor(const QString &name) const { @@ -7894,12 +7894,12 @@ bool QCPAbstractItem::hasAnchor(const QString &name) const } /*! \internal - + Returns the rect the visual representation of this item is clipped to. This depends on the current setting of \ref setClipToAxisRect as well as the axis rect set with \ref setClipAxisRect. - + If the item is not clipped to an axis rect, the \ref QCustomPlot::viewport rect is returned. - + \see draw */ QRect QCPAbstractItem::clipRect() const @@ -7916,11 +7916,11 @@ QRect QCPAbstractItem::clipRect() const before drawing item 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 QCPAbstractItem::applyDefaultAntialiasingHint(QCPPainter *painter) const @@ -7932,12 +7932,12 @@ void QCPAbstractItem::applyDefaultAntialiasingHint(QCPPainter *painter) const Finds the shortest squared distance of \a point to the line segment defined by \a start and \a end. - + This function may be used to help with the implementation of the \ref selectTest function for specific items. - + \note This function is identical to QCPAbstractPlottable::distSqrToLine - + \see rectSelectTest */ double QCPAbstractItem::distSqrToLine(const QPointF &start, const QPointF &end, const QPointF &point) const @@ -7946,7 +7946,7 @@ double QCPAbstractItem::distSqrToLine(const QPointF &start, const QPointF &end, QVector2D b(end); QVector2D p(point); QVector2D v(b-a); - + double vLengthSqr = v.lengthSquared(); if (!qFuzzyIsNull(vLengthSqr)) { @@ -7966,16 +7966,16 @@ double QCPAbstractItem::distSqrToLine(const QPointF &start, const QPointF &end, A convenience function which returns the selectTest value for a specified \a rect and a specified click position \a pos. \a 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 \ref 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 \ref 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 \a pos doesn't hit \a rect at all). If all calls returned -1.0, return -1.0, too, because your item wasn't hit. - + \see distSqrToLine */ double QCPAbstractItem::rectSelectTest(const QRectF &rect, const QPointF &pos, bool filledRect) const @@ -7994,7 +7994,7 @@ double QCPAbstractItem::rectSelectTest(const QRectF &rect, const QPointF &pos, b minDistSqr = distSqr; } result = qSqrt(minDistSqr); - + // filled rect, allow click inside to count as hit: if (filledRect && result > mParentPlot->selectionTolerance()*0.99) { @@ -8008,10 +8008,10 @@ double QCPAbstractItem::rectSelectTest(const QRectF &rect, const QPointF &pos, b Returns the pixel position of the anchor with Id \a 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 createAnchor */ QPointF QCPAbstractItem::anchorPixelPoint(int anchorId) const @@ -8025,13 +8025,13 @@ QPointF QCPAbstractItem::anchorPixelPoint(int anchorId) const Creates a QCPItemPosition, registers it with this item and returns a pointer to it. The specified \a 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 \ref 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 \b new yourself, because they won't be registered with the item properly. - + \see createAnchor */ QCPItemPosition *QCPAbstractItem::createPosition(const QString &name) @@ -8054,18 +8054,18 @@ QCPItemPosition *QCPAbstractItem::createPosition(const QString &name) Creates a QCPItemAnchor, registers it with this item and returns a pointer to it. The specified \a 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 \ref anchor access to anchors). - + The \a 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 \b new yourself, because then they won't be registered with the item properly. - + \see createPosition */ QCPItemAnchor *QCPAbstractItem::createAnchor(const QString &name, int anchorId) @@ -8117,33 +8117,33 @@ QCP::Interaction QCPAbstractItem::selectionCategory() const /*! \mainpage %QCustomPlot 1.0.0 Documentation \image html qcp-doc-logo.png - + 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 \ref classoverview "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. \section mainpage-plottables Plottables - + \a 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. - + Since plotting graphs is such a dominant use case, QCustomPlot has a special interface for working with QCPGraph plottables, that makes it very easy to handle them:\n You create a new graph with QCustomPlot::addGraph and access them with QCustomPlot::graph. - + For all other plottables, you need to use the normal plottable interface:\n First, you create an instance of the plottable you want, e.g. \code @@ -8152,40 +8152,40 @@ QCP::Interaction QCPAbstractItem::selectionCategory() const \code customPlot->addPlottable(newCurve);\endcode 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. \section mainpage-axes Controlling the Axes - + As mentioned, QCustomPlot has four axes by default: \a xAxis (bottom), \a yAxis (left), \a xAxis2 (top), \a 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 \ref QCPAxis::setScaleType to \ref QCPAxis::stLogarithmic. The logarithm base can be set freely with \ref QCPAxis::setScaleLogBase. - + By default, an axis automatically creates and labels ticks in a sensible manner. See the following functions for tick manipulation:\n 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 \ref QCPAxisRect::setAutoMargins to exclude the respective margin sides, set the margins manually with \ref QCPAxisRect::setMargins. The main axis rect can be reached with \ref QCustomPlot::axisRect(). - + \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 @@ -8193,61 +8193,61 @@ QCP::Interaction QCPAbstractItem::selectionCategory() const 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). - + \section mainpage-userinteraction User Interactions - + QCustomPlot supports dragging axis ranges with the mouse (\ref QCPAxisRect::setRangeDrag), zooming axis ranges with the mouse wheel (\ref QCPAxisRect::setRangeZoom) and a complete selection mechanism. - + The availability of these interactions is controlled with \ref QCustomPlot::setInteractions. For details about the interaction system, see the documentation there. - + Further, QCustomPlot always emits corresponding signals, when objects are clicked or doubleClicked. See \ref QCustomPlot::plottableClick, \ref QCustomPlot::plottableDoubleClick and \ref QCustomPlot::axisClick for example. - + \section mainpage-items Items - + Apart from plottables there is another category of plot objects that are important: Items. The base class of all items is QCPAbstractItem. An item sets itself apart from plottables in that it's not necessarily bound to any axes. This means it may also be positioned in absolute pixel coordinates or placed at a relative position on an axis rect. Further, it usually doesn't represent data directly, but acts as decoration, emphasis, description etc. - + Multiple items can be arranged in a parent-child-hierarchy allowing for dynamical behaviour. For example, you could place the head of an arrow at a fixed plot coordinate, so it always points to some important area in the plot. The tail of the arrow can be anchored to a text item which always resides in the top center of the axis rect, independent of where the user drags the axis ranges. This way the arrow stretches and turns so it always points from the label to the specified plot coordinate, without any further code necessary. - + For a more detailed introduction, see the QCPAbstractItem documentation, and from there the documentations of the individual built-in items, to find out how to use them. - + \section mainpage-layoutelements Layout elements and layouts - + QCustomPlot uses an internal layout system to provide dynamic sizing and positioning of objects like 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". - + \section mainpage-performancetweaks Performance Tweaks - + Although QCustomPlot is quite fast, some features like translucent fills, antialiasing and thick lines can cause a significant slow down. If you notice this in your application, here are some thoughts on how to increase performance. By far the most time is spent in the drawing functions, specifically the drawing of graphs. For maximum performance, consider the following (most recommended/effective measures first): - + \li use Qt 4.8.0 and up. Performance has doubled or tripled with respect to Qt 4.7.4. However QPainter was broken and drawing pixel precise things, e.g. scatters, isn't possible with Qt >= 4.8.0. So it's a performance vs. plot quality tradeoff when switching to Qt 4.8. @@ -8272,9 +8272,9 @@ QCP::Interaction QCPAbstractItem::selectionCategory() const data points stay unchanged, e.g. in a running measurement. \li Set the \a copy parameter of the setData functions to false, so only pointers get transferred. (Relevant only if preparing data maps with a large number of points, i.e. over 10000) - + \section mainpage-flags Preprocessor Define Flags - + QCustomPlot understands some preprocessor defines that are useful for debugging and compilation:
\c QCUSTOMPLOT_COMPILE_LIBRARY @@ -8290,15 +8290,15 @@ QCP::Interaction QCPAbstractItem::selectionCategory() const */ /*! \page classoverview Class Overview - + The following diagrams may help to gain a deeper understanding of the relationships between classes that make up the QCustomPlot library. The diagrams are not exhaustive, so only the classes deemed most relevant are shown. - + \section classoverview-relations Class Relationship Diagram \image html RelationOverview.png "Overview of most important classes and their relations" \section classoverview-inheritance Class Inheritance Tree \image html InheritanceOverview.png "Inheritance tree of most important classes" - + */ //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -8306,10 +8306,10 @@ QCP::Interaction QCPAbstractItem::selectionCategory() const //////////////////////////////////////////////////////////////////////////////////////////////////// /*! \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/ */ @@ -8317,22 +8317,22 @@ QCP::Interaction QCPAbstractItem::selectionCategory() const /* start of documentation of inline functions */ /*! \fn QRect QCustomPlot::viewport() const - + Returns the viewport rect of this QCustomPlot instance. The viewport is the area the plot is drawn in, all mechanisms, e.g. margin caluclation take the viewport to be the outer border of the plot. The viewport normally is the rect() of the QCustomPlot widget, i.e. a rect with top left (0, 0) and size of the QCustomPlot widget. - + Don't confuse the viewport with the axis rect (QCustomPlot::axisRect). An axis rect is typically an area enclosed by four axes, where the graphs/plottables are drawn in. The viewport is larger and contains also the axes themselves, their tick numbers, their labels, the plot title etc. - + Only when saving to a file (see \ref savePng, savePdf etc.) the viewport is temporarily modified to allow saving plots with sizes independent of the current widget size. */ /*! \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. */ @@ -8348,7 +8348,7 @@ QCP::Interaction QCPAbstractItem::selectionCategory() const /*! \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. @@ -8357,11 +8357,11 @@ QCP::Interaction QCPAbstractItem::selectionCategory() const /*! \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 @@ -8371,7 +8371,7 @@ QCP::Interaction QCPAbstractItem::selectionCategory() const /*! \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. @@ -8380,150 +8380,150 @@ QCP::Interaction QCPAbstractItem::selectionCategory() const /*! \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. */ /*! \fn void QCustomPlot::plottableClick(QCPAbstractPlottable *plottable, QMouseEvent *event) - + This signal is emitted when a plottable is clicked. \a event is the mouse event that caused the click and \a plottable is the plottable that received the click. - + \see plottableDoubleClick */ /*! \fn void QCustomPlot::plottableDoubleClick(QCPAbstractPlottable *plottable, QMouseEvent *event) - + This signal is emitted when a plottable is double clicked. - + \a event is the mouse event that caused the click and \a plottable is the plottable that received the click. - + \see plottableClick */ /*! \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:: titleClick(QMouseEvent *event, QCPPlotTitle *title) This signal is emitted when a plot title is clicked. - + \a event is the mouse event that caused the click and \a title is the plot title that received the click. - + \see titleDoubleClick */ /*! \fn void QCustomPlot::titleDoubleClick(QMouseEvent *event, QCPPlotTitle *title) This signal is emitted when a plot title is double clicked. - + \a event is the mouse event that caused the click and \a title is the plot title that received the click. - + \see titleClick */ /*! \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() on an object or by calling \ref deselectAll. - + In addition to this signal, selectable objects also provide individual signals, for example QCPAxis::selectionChanged or 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 */ @@ -8562,7 +8562,7 @@ QCustomPlot::QCustomPlot(QWidget *parent) : QLocale currentLocale = locale(); currentLocale.setNumberOptions(QLocale::OmitGroupSeparator); setLocale(currentLocale); - + // create initial layers: mLayers.append(new QCPLayer(this, "background")); mLayers.append(new QCPLayer(this, "grid")); @@ -8571,7 +8571,7 @@ QCustomPlot::QCustomPlot(QWidget *parent) : mLayers.append(new QCPLayer(this, "legend")); updateLayerIndices(); setCurrentLayer("main"); - + // create initial layout, axis rect and legend: mPlotLayout = new QCPLayoutGrid; mPlotLayout->initializeParentPlot(this); @@ -8586,7 +8586,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("background"); xAxis->setLayer("axes"); yAxis->setLayer("axes"); @@ -8597,13 +8597,13 @@ QCustomPlot::QCustomPlot(QWidget *parent) : xAxis2->grid()->setLayer("grid"); yAxis2->grid()->setLayer("grid"); legend->setLayer("legend"); - + setViewport(rect()); // needs to be called after mPlotLayout has been created - + #ifdef Q_OS_WIN setPlottingHint(QCP::phForceRepaint); #endif - + replot(); } @@ -8617,7 +8617,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(); @@ -8625,25 +8625,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; @@ -8651,9 +8651,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) @@ -8662,7 +8662,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; @@ -8671,25 +8671,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; @@ -8697,9 +8697,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) @@ -8708,7 +8708,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; @@ -8717,7 +8717,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 addPlottable, addGraph, QCPLegend::addItem */ void QCustomPlot::setAutoAddPlottableToLegend(bool on) @@ -8728,13 +8728,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 selection is controlled by \ref QCP::iSelectPlottables. If \ref QCP::iSelectPlottables is set, the user may select plottables (graphs, curves, bars,...) by clicking on them or in their vicinity (\ref setSelectionTolerance). Whether the user can actually select a plottable can @@ -8743,40 +8743,40 @@ void QCustomPlot::setAutoAddPlottableToLegend(bool on) QCPAbstractPlottable::selected(). 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. QCPPlotTitle, 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) @@ -8786,9 +8786,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) @@ -8802,14 +8802,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) @@ -8823,7 +8823,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) @@ -8833,7 +8833,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) @@ -8843,7 +8843,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) @@ -8853,19 +8853,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 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) @@ -8876,7 +8876,7 @@ void QCustomPlot::setMultiSelectModifier(Qt::KeyboardModifier modifier) /*! 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 \ref toPixmap, \ref savePng, \ref savePdf, etc. by temporarily changing the viewport size. */ @@ -8895,7 +8895,7 @@ void QCustomPlot::setViewport(const QRect &rect) 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. @@ -8915,7 +8915,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. @@ -8927,7 +8927,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. @@ -8945,10 +8945,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) @@ -8959,7 +8959,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) @@ -8969,10 +8969,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, addPlottable */ QCPAbstractPlottable *QCustomPlot::plottable(int index) @@ -8988,10 +8988,10 @@ QCPAbstractPlottable *QCustomPlot::plottable(int index) } /*! \overload - + Returns the last plottable that was added with \ref addPlottable. If there are no plottables in the plot, returns 0. - + \see plottableCount, addPlottable */ QCPAbstractPlottable *QCustomPlot::plottable() @@ -9006,11 +9006,11 @@ QCPAbstractPlottable *QCustomPlot::plottable() /*! Adds the specified plottable to the plot and, if \ref setAutoAddPlottableToLegend is enabled, to the legend (QCustomPlot::legend). QCustomPlot takes ownership of the plottable. - + Returns true on success, i.e. when \a plottable isn't already in the plot and the parent plot of \a plottable is this QCustomPlot (the latter is controlled by what axes were passed in the plottable's constructor). - + \see plottable, plottableCount, removePlottable, clearPlottables */ bool QCustomPlot::addPlottable(QCPAbstractPlottable *plottable) @@ -9025,7 +9025,7 @@ bool QCustomPlot::addPlottable(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) @@ -9040,9 +9040,9 @@ bool QCustomPlot::addPlottable(QCPAbstractPlottable *plottable) /*! Removes the specified plottable from the plot and, if necessary, from the legend (QCustomPlot::legend). - + Returns true on success. - + \see addPlottable, clearPlottables */ bool QCustomPlot::removePlottable(QCPAbstractPlottable *plottable) @@ -9052,7 +9052,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: @@ -9065,7 +9065,7 @@ bool QCustomPlot::removePlottable(QCPAbstractPlottable *plottable) } /*! \overload - + Removes the plottable by its \a index. */ bool QCustomPlot::removePlottable(int index) @@ -9081,9 +9081,9 @@ bool QCustomPlot::removePlottable(int index) /*! Removes all plottables from the plot (and the QCustomPlot::legend, if necessary). - + Returns the number of plottables removed. - + \see removePlottable */ int QCustomPlot::clearPlottables() @@ -9096,7 +9096,7 @@ int QCustomPlot::clearPlottables() /*! Returns the number of currently existing plottables in the plot - + \see plottable, addPlottable */ int QCustomPlot::plottableCount() const @@ -9106,9 +9106,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::setSelected */ QList QCustomPlot::selectedPlottables() const @@ -9126,19 +9126,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 - + for (int i=0; i QCustomPlot::selectedGraphs() const @@ -9315,10 +9315,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, addItem */ QCPAbstractItem *QCustomPlot::item(int index) const @@ -9334,10 +9334,10 @@ QCPAbstractItem *QCustomPlot::item(int index) const } /*! \overload - + Returns the last item, that was added with \ref addItem. If there are no items in the plot, returns 0. - + \see itemCount, addItem */ QCPAbstractItem *QCustomPlot::item() const @@ -9351,10 +9351,10 @@ QCPAbstractItem *QCustomPlot::item() const /*! Adds the specified item to the plot. 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. - + \see item, itemCount, removeItem, clearItems */ bool QCustomPlot::addItem(QCPAbstractItem *item) @@ -9372,9 +9372,9 @@ bool QCustomPlot::addItem(QCPAbstractItem *item) /*! Removes the specified item from the plot. - + Returns true on success. - + \see addItem, clearItems */ bool QCustomPlot::removeItem(QCPAbstractItem *item) @@ -9392,7 +9392,7 @@ bool QCustomPlot::removeItem(QCPAbstractItem *item) } /*! \overload - + Removes the item by its \a index. */ bool QCustomPlot::removeItem(int index) @@ -9408,9 +9408,9 @@ bool QCustomPlot::removeItem(int index) /*! Removes all items from the plot. - + Returns the number of items removed. - + \see removeItem */ int QCustomPlot::clearItems() @@ -9423,7 +9423,7 @@ int QCustomPlot::clearItems() /*! Returns the number of currently existing items in the plot - + \see item, addItem */ int QCustomPlot::itemCount() const @@ -9433,7 +9433,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 @@ -9452,19 +9452,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 - + for (int i=0; i(layer); return false; } - + mCurrentLayer = layer; return true; } /*! Returns the number of currently existing layers in the plot - + \see layer, addLayer */ int QCustomPlot::layerCount() const @@ -9593,14 +9593,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) @@ -9617,7 +9617,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(); @@ -9626,16 +9626,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) @@ -9650,7 +9650,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; @@ -9678,10 +9678,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) @@ -9696,7 +9696,7 @@ bool QCustomPlot::moveLayer(QCPLayer *layer, QCPLayer *otherLayer, QCustomPlot:: qDebug() << Q_FUNC_INFO << "otherLayer not a layer of this QCustomPlot:" << reinterpret_cast(otherLayer); return false; } - + mLayers.move(layer->index(), otherLayer->index() + (insertMode==limAbove ? 1:0)); updateLayerIndices(); return true; @@ -9704,11 +9704,11 @@ bool QCustomPlot::moveLayer(QCPLayer *layer, QCPLayer *otherLayer, QCustomPlot:: /*! 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 @@ -9718,11 +9718,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 @@ -9740,7 +9740,7 @@ QCPAxisRect *QCustomPlot::axisRect(int index) const /*! Returns all axis rects in the plot. - + \see axisRectCount, axisRect */ QList QCustomPlot::axisRects() const @@ -9749,7 +9749,7 @@ QList QCustomPlot::axisRects() const QStack elementStack; if (mPlotLayout) elementStack.push(mPlotLayout); - + while (!elementStack.isEmpty()) { QList subElements = elementStack.pop()->elements(false); @@ -9763,17 +9763,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 @@ -9800,7 +9800,7 @@ QCPLayoutElement *QCustomPlot::layoutElementAt(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 */ @@ -9810,31 +9810,31 @@ QList QCustomPlot::selectedAxes() const QList rects = axisRects(); for (int i=0; iaxes(); - + for (int i=0; iselectedParts() != QCPAxis::spNone) result.append(allAxes.at(i)); } - + 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()) { QList subElements = elementStack.pop()->elements(false); @@ -9851,17 +9851,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() @@ -9878,10 +9878,10 @@ void QCustomPlot::deselectAll() Causes a complete replot into the internal buffer. Finally, update() is called, to redraw the buffer on the QCustomPlot widget surface. This is the method that must be called to make changes, for example on the axis ranges or data points of graphs, visible. - + Under a few circumstances, QCustomPlot causes a replot by itself. Those are resize events of the QCustomPlot widget and user interactions (object selection and range dragging/zooming). - + Before the replot happens, the signal \ref beforeReplot is emitted. After the replot, \ref afterReplot is emitted. It is safe to mutually connect the replot slot with any of those two signals on two QCustomPlots to make them replot synchronously, it won't cause an infinite @@ -9896,7 +9896,7 @@ void QCustomPlot::replot() 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) @@ -9916,17 +9916,17 @@ void QCustomPlot::replot() /*! Rescales the axes such that all plottables (like graphs) in the plot are fully visible. It does this by calling \ref QCPAbstractPlottable::rescaleAxes on all plottables. - + if \a onlyVisible 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 */ void QCustomPlot::rescaleAxes(bool onlyVisible) { if (mPlottables.isEmpty()) return; bool firstPlottable = true; - + for (int i=0; irealVisibility() || !onlyVisible) @@ -9948,13 +9948,13 @@ void QCustomPlot::rescaleAxes(bool onlyVisible) are pens with numerical width 0, which are always drawn as a one pixel wide line, no matter what zoom factor is set in the PDF-Viewer. For more information about cosmetic pens, see the QPainter and QPen documentation. - + 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 \ref deselectAll before calling this function. Returns true on success. - + \warning \li If you plan on editing the exported PDF file with a vector graphics editor like Inkscape, it is advised to set \a noCosmeticPen to true to avoid losing those cosmetic lines @@ -9965,7 +9965,7 @@ void QCustomPlot::rescaleAxes(bool onlyVisible) 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. - + \see savePng, saveBmp, saveJpg, saveRastered */ bool QCustomPlot::savePdf(const QString &fileName, bool noCosmeticPen, int width, int height) @@ -9981,7 +9981,7 @@ bool QCustomPlot::savePdf(const QString &fileName, bool noCosmeticPen, int width newWidth = width; newHeight = height; } - + QPrinter printer(QPrinter::ScreenResolution); printer.setOutputFileName(fileName); printer.setOutputFormat(QPrinter::PdfFormat); @@ -10019,7 +10019,7 @@ bool QCustomPlot::savePdf(const QString &fileName, bool noCosmeticPen, int width image file of size 200*200 in which all graphical elements are scaled up by factor 2 (line widths, texts, etc.). This scaling is not done by stretching a 100*100 image, the result will have full 200*200 pixel resolution. - + If you use a high scaling factor, it is recommended to enable antialiasing for all elements via temporarily setting \ref QCustomPlot::setAntialiasedElements to \ref QCP::aeAll as this allows QCustomPlot to place objects with sub-pixel accuracy. @@ -10030,7 +10030,7 @@ bool QCustomPlot::savePdf(const QString &fileName, bool noCosmeticPen, int width 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 \ref deselectAll before calling this function. @@ -10040,14 +10040,14 @@ bool QCustomPlot::savePdf(const QString &fileName, bool noCosmeticPen, int width PNG compression can be controlled with the \a 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 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); } @@ -10061,7 +10061,7 @@ bool QCustomPlot::savePng(const QString &fileName, int width, int height, double image file of size 200*200 in which all graphical elements are scaled up by factor 2 (line widths, texts, etc.). This scaling is not done by stretching a 100*100 image, the result will have full 200*200 pixel resolution. - + If you use a high scaling factor, it is recommended to enable antialiasing for all elements via temporarily setting \ref QCustomPlot::setAntialiasedElements to \ref QCP::aeAll as this allows QCustomPlot to place objects with sub-pixel accuracy. @@ -10079,7 +10079,7 @@ bool QCustomPlot::savePng(const QString &fileName, int width, int height, double JPG compression can be controlled with the \a 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(). @@ -10100,7 +10100,7 @@ bool QCustomPlot::saveJpg(const QString &fileName, int width, int height, double image file of size 200*200 in which all graphical elements are scaled up by factor 2 (line widths, texts, etc.). This scaling is not done by stretching a 100*100 image, the result will have full 200*200 pixel resolution. - + If you use a high scaling factor, it is recommended to enable antialiasing for all elements via temporarily setting \ref QCustomPlot::setAntialiasedElements to \ref QCP::aeAll as this allows QCustomPlot to place objects with sub-pixel accuracy. @@ -10115,7 +10115,7 @@ bool QCustomPlot::saveJpg(const QString &fileName, int width, int height, double 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 \ref 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(). @@ -10127,7 +10127,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. @@ -10140,9 +10140,9 @@ QSize QCustomPlot::minimumSizeHint() const } /*! \internal - + Returns a size hint that is the same as \ref minimumSizeHint. - + */ QSize QCustomPlot::sizeHint() const { @@ -10150,7 +10150,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. */ @@ -10162,7 +10162,7 @@ void QCustomPlot::paintEvent(QPaintEvent *event) } /*! \internal - + 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 \ref replot is performed. @@ -10176,21 +10176,21 @@ void QCustomPlot::resizeEvent(QResizeEvent *event) } /*! \internal - + Event handler for when a double click occurs. Emits the \ref mouseDoubleClick signal, then emits the specialized signals when certain objecs are clicked (e.g. \ref plottableDoubleClick, \ref axisDoubleClick, etc.). Finally determines the affected layout element and forwards the event to it. - + \see mousePressEvent, mouseReleaseEvent */ void QCustomPlot::mouseDoubleClickEvent(QMouseEvent *event) { emit mouseDoubleClick(event); - + QVariant details; QCPLayerable *clickedLayerable = layerableAt(event->pos(), false, &details); - + // emit specialized object double click signals: if (QCPAbstractPlottable *ap = qobject_cast(clickedLayerable)) emit plottableDoubleClick(ap, event); @@ -10204,48 +10204,48 @@ void QCustomPlot::mouseDoubleClickEvent(QMouseEvent *event) emit legendDoubleClick(li->parentLegend(), li, event); else if (QCPPlotTitle *pt = qobject_cast(clickedLayerable)) emit titleDoubleClick(event, pt); - + // call double click event of affected layout element: if (QCPLayoutElement *el = layoutElementAt(event->pos())) el->mouseDoubleClickEvent(event); - + // call release event of affected layout element (as in mouseReleaseEvent, since the mouseDoubleClick replaces the second release event in double click case): if (mMouseEventElement) { mMouseEventElement->mouseReleaseEvent(event); mMouseEventElement = 0; } - + //QWidget::mouseDoubleClickEvent(event); don't call base class implementation because it would just cause a mousePress/ReleaseEvent, which we don't want. } /*! \internal - + Event handler for when a mouse button is pressed. Emits the mousePress signal. Then determines the affected layout element and forwards the event to it. - + \see mouseMoveEvent, mouseReleaseEvent */ void QCustomPlot::mousePressEvent(QMouseEvent *event) { emit mousePress(event); mMousePressPos = event->pos(); // need this to determine in releaseEvent whether it was a click (no position change between press and release) - + // call event of affected layout element: mMouseEventElement = layoutElementAt(event->pos()); if (mMouseEventElement) mMouseEventElement->mousePressEvent(event); - + QWidget::mousePressEvent(event); } /*! \internal - + Event handler for when the cursor is moved. Emits the \ref mouseMove signal. 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) @@ -10255,29 +10255,29 @@ void QCustomPlot::mouseMoveEvent(QMouseEvent *event) // call event of affected layout element: if (mMouseEventElement) mMouseEventElement->mouseMoveEvent(event); - + QWidget::mouseMoveEvent(event); } /*! \internal - + Event handler for when a mouse button is released. Emits the \ref mouseRelease signal. - + If the mouse was moved less than a certain threshold in any direction since the \ref mousePressEvent, it is considered a click which causes the selection mechanism (if activated via \ref setInteractions) to possibly change selection states accordingly. Further, specialized mouse click signals are emitted (e.g. \ref plottableClick, \ref axisClick, etc.) - + If a layout element has mouse capture focus (a \ref mousePressEvent happened on top of the layout element before), the \ref mouseReleaseEvent is forwarded to that element. - + \see mousePressEvent, mouseMoveEvent */ void QCustomPlot::mouseReleaseEvent(QMouseEvent *event) { emit mouseRelease(event); bool doReplot = false; - + if ((mMousePressPos-event->pos()).manhattanLength() < 5) // determine whether it was a click operation { if (event->button() == Qt::LeftButton) @@ -10315,7 +10315,7 @@ void QCustomPlot::mouseReleaseEvent(QMouseEvent *event) if (selectionStateChanged) emit selectionChangedByUser(); } - + // emit specialized object click signals: QVariant details; QCPLayerable *clickedLayerable = layerableAt(event->pos(), false, &details); // for these signals, selectability is ignored, that's why we call this again with onlySelectable set to false @@ -10332,39 +10332,39 @@ void QCustomPlot::mouseReleaseEvent(QMouseEvent *event) else if (QCPPlotTitle *pt = qobject_cast(clickedLayerable)) emit titleClick(event, pt); } - + // call event of affected layout element: if (mMouseEventElement) { mMouseEventElement->mouseReleaseEvent(event); mMouseEventElement = 0; } - + if (doReplot || noAntialiasingOnDrag()) replot(); - + QWidget::mouseReleaseEvent(event); } /*! \internal - + Event handler for mouse wheel events. First, the \ref mouseWheel signal is emitted. Then determines the affected layout element and forwards the event to it. - + */ void QCustomPlot::wheelEvent(QWheelEvent *event) { emit mouseWheel(event); - + // call event of affected layout element: if (QCPLayoutElement *el = layoutElementAt(event->pos())) el->wheelEvent(event); - + QWidget::wheelEvent(event); } /*! \internal - + This is the main draw function. It draws the entire plot, including background pixmap, with the specified \a painter. Note that it does not fill the background with the background brush (as the user may specify with \ref setBackground(const QBrush &brush)), this is up to the respective @@ -10380,10 +10380,10 @@ void QCustomPlot::draw(QCPPainter *painter) for (int k=0; ksetupTickVectors(); } - + // recalculate layout: mPlotLayout->update(); - + // draw viewport background pixmap: drawBackground(painter); @@ -10407,9 +10407,9 @@ void QCustomPlot::draw(QCPPainter *painter) } /*! \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 @@ -10417,10 +10417,10 @@ void QCustomPlot::draw(QCPPainter *painter) 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. - + 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) @@ -10447,7 +10447,7 @@ void QCustomPlot::drawBackground(QCPPainter *painter) /*! \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. */ @@ -10461,12 +10461,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. */ @@ -10477,7 +10477,7 @@ void QCustomPlot::legendRemoved(QCPLegend *legend) } /*! \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. @@ -10489,7 +10489,7 @@ void QCustomPlot::updateLayerIndices() const } /*! \internal - + Returns the layerable at pixel position \a pos. If \a onlySelectable is set to true, only those layerables that are selectable will be considered. (Layerable subclasses communicate their selectability via the QCPLayerable::selectTest method, by returning -1.) @@ -10531,10 +10531,10 @@ QCPLayerable *QCustomPlot::layerableAt(const QPointF &pos, bool onlySelectable, 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 file with width 200.) If the \a format supports compression, \a quality may be between 0 and 100 to control it. - + Returns true on success. If this function fails, most likely the given \a format isn't supported by the system, see Qt docs about QImageWriter::supportedImageFormats(). - + \see saveBmp, saveJpg, savePng, savePdf */ bool QCustomPlot::saveRastered(const QString &fileName, int width, int height, double scale, const char *format, int quality) @@ -10548,15 +10548,15 @@ 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) { - // 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) { @@ -10600,19 +10600,19 @@ 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) { - // 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) { @@ -10646,9 +10646,9 @@ void QCustomPlot::toPainter(QCPPainter *painter, int width, int height) /*! \class QCPData \brief Holds the data of one single data point for QCPGraph. - + 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 @@ -10656,7 +10656,7 @@ void QCustomPlot::toPainter(QCPPainter *painter, int width, int height) \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 */ @@ -10695,27 +10695,27 @@ QCPData::QCPData(double key, double value) : \brief A plottable representing a graph in a plot. \image html 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 \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 - + 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. @@ -10728,23 +10728,23 @@ QCPData::QCPData(double key, double 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. - + To directly create a graph inside a plot, you can also use the simpler QCustomPlot::addGraph function. */ QCPGraph::QCPGraph(QCPAxis *keyAxis, QCPAxis *valueAxis) : QCPAbstractPlottable(keyAxis, valueAxis) { 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); - + setLineStyle(lsLine); setErrorType(etNone); setErrorBarSize(6); @@ -10759,7 +10759,7 @@ QCPGraph::~QCPGraph() /*! 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 graph takes ownership of the passed data and replaces the internal data pointer with it. This is significantly faster than copying for large datasets. @@ -10777,7 +10777,7 @@ void QCPGraph::setData(QCPDataMap *data, bool copy) } /*! \overload - + 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. @@ -10802,7 +10802,7 @@ void QCPGraph::setData(const QVector &key, const QVector &value) 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. - + For asymmetrical errors (plus different from minus), see the overloaded version of this function. */ void QCPGraph::setDataValueError(const QVector &key, const QVector &value, const QVector &valueError) @@ -10855,7 +10855,7 @@ void QCPGraph::setDataValueError(const QVector &key, const QVector &key, const QVector &value, const QVector &keyError) @@ -10908,7 +10908,7 @@ void QCPGraph::setDataKeyError(const QVector &key, const QVector 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. - + 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) @@ -10966,7 +10966,7 @@ void QCPGraph::setDataBothError(const QVector &key, const QVectorisEmpty()) return -1; - + return pointDistance(pos); } /*! \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 @@ -11191,10 +11191,10 @@ void QCPGraph::rescaleAxes(bool onlyEnlarge, bool includeErrorBars) const } /*! \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 @@ -11202,17 +11202,17 @@ 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 validRange; QCPRange newRange = getKeyRange(validRange, signDomain, includeErrorBars); - + if (validRange) { if (onlyEnlarge) @@ -11227,10 +11227,10 @@ void QCPGraph::rescaleKeyAxis(bool onlyEnlarge, bool includeErrorBars) const } /*! \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 @@ -11238,17 +11238,17 @@ 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 validRange; QCPRange newRange = getValueRange(validRange, signDomain, includeErrorBars); - + if (validRange) { if (onlyEnlarge) @@ -11268,16 +11268,16 @@ 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; - + // allocate line and (if necessary) point vectors: QVector *lineData = new QVector; QVector *pointData = 0; if (!mScatterStyle.isNone()) pointData = new QVector; - + // fill vectors with data appropriate to plot style: getPlotData(lineData, pointData); - + // check data validity if flag set: #ifdef QCUSTOMPLOT_CHECK_DATA QCPDataMap::const_iterator it; @@ -11292,17 +11292,17 @@ void QCPGraph::draw(QCPPainter *painter) // 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 - + // draw scatters: if (pointData) drawScatterPlot(painter, pointData); - + // free allocated line and point vectors: delete lineData; if (pointData) @@ -11348,17 +11348,17 @@ void QCPGraph::drawLegendIcon(QCPPainter *painter, const QRectF &rect) const 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 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. - + \see getScatterPlotData, getLinePlotData, getStepLeftPlotData, getStepRightPlotData, getStepCenterPlotData, getImpulsePlotData */ @@ -11376,14 +11376,14 @@ void QCPGraph::getPlotData(QVector *lineData, QVector *pointDa } /*! \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. - + 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 *pointData) const @@ -11391,7 +11391,7 @@ void QCPGraph::getScatterPlotData(QVector *pointData) 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; @@ -11400,7 +11400,7 @@ void QCPGraph::getScatterPlotData(QVector *pointData) const { // prepare vectors: pointData->resize(dataCount); - + // position data points: QCPDataMap::const_iterator it = lower; QCPDataMap::const_iterator upperEnd = upper+1; @@ -11415,14 +11415,14 @@ void QCPGraph::getScatterPlotData(QVector *pointData) const } /*! \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. - + \see drawLinePlot */ void QCPGraph::getLinePlotData(QVector *lineData, QVector *pointData) const @@ -11431,7 +11431,7 @@ void QCPGraph::getLinePlotData(QVector *lineData, QVector *poi 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; @@ -11442,7 +11442,7 @@ void QCPGraph::getLinePlotData(QVector *lineData, QVector *poi lineData->resize(dataCount); if (pointData) pointData->resize(dataCount); - + // position data points: QCPDataMap::const_iterator it = lower; QCPDataMap::const_iterator upperEnd = upper+1; @@ -11473,7 +11473,7 @@ void QCPGraph::getLinePlotData(QVector *lineData, QVector *poi } } -/*! +/*! \internal Places the raw data points needed for a step plot with left oriented steps in \a lineData. @@ -11481,7 +11481,7 @@ void QCPGraph::getLinePlotData(QVector *lineData, QVector *poi 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 @@ -11490,7 +11490,7 @@ void QCPGraph::getStepLeftPlotData(QVector *lineData, QVector 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; @@ -11501,7 +11501,7 @@ void QCPGraph::getStepLeftPlotData(QVector *lineData, QVector 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; @@ -11553,7 +11553,7 @@ void QCPGraph::getStepLeftPlotData(QVector *lineData, QVector } } -/*! +/*! \internal Places the raw data points needed for a step plot with right oriented steps in \a lineData. @@ -11561,7 +11561,7 @@ void QCPGraph::getStepLeftPlotData(QVector *lineData, QVector 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 @@ -11570,7 +11570,7 @@ void QCPGraph::getStepRightPlotData(QVector *lineData, QVector 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; @@ -11581,7 +11581,7 @@ void QCPGraph::getStepRightPlotData(QVector *lineData, QVector 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; @@ -11633,7 +11633,7 @@ void QCPGraph::getStepRightPlotData(QVector *lineData, QVector } } -/*! +/*! \internal Places the raw data points needed for a step plot with centered steps in \a lineData. @@ -11641,7 +11641,7 @@ void QCPGraph::getStepRightPlotData(QVector *lineData, QVector 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::getStepCenterPlotData(QVector *lineData, QVector *pointData) const @@ -11650,7 +11650,7 @@ void QCPGraph::getStepCenterPlotData(QVector *lineData, QVector *lineData, QVectorresize(dataCount*2); if (pointData) pointData->resize(dataCount); - + // position points: QCPDataMap::const_iterator it = lower; QCPDataMap::const_iterator upperEnd = upper+1; @@ -11741,7 +11741,7 @@ void QCPGraph::getStepCenterPlotData(QVector *lineData, QVector *lineData, QVector *lineData, QVector *pointData) const @@ -11758,7 +11758,7 @@ void QCPGraph::getImpulsePlotData(QVector *lineData, QVector * 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; @@ -11768,7 +11768,7 @@ void QCPGraph::getImpulsePlotData(QVector *lineData, QVector * 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; @@ -11819,23 +11819,23 @@ void QCPGraph::getImpulsePlotData(QVector *lineData, QVector * } /*! \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) { @@ -11855,12 +11855,12 @@ void QCPGraph::drawFill(QCPPainter *painter, QVector *lineData) const } /*! \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 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. - + \see drawLinePlot, drawImpulsePlot */ void QCPGraph::drawScatterPlot(QCPPainter *painter, QVector *pointData) const @@ -11868,7 +11868,7 @@ void QCPGraph::drawScatterPlot(QCPPainter *painter, QVector *pointData) 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) { @@ -11884,7 +11884,7 @@ void QCPGraph::drawScatterPlot(QCPPainter *painter, QVector *pointData) 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); @@ -11900,12 +11900,12 @@ void QCPGraph::drawScatterPlot(QCPPainter *painter, QVector *pointData) } /*! \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 @@ -11916,7 +11916,7 @@ void QCPGraph::drawLinePlot(QCPPainter *painter, QVector *lineData) con applyDefaultAntialiasingHint(painter); painter->setPen(mainPen()); painter->setBrush(Qt::NoBrush); - + /* Draws polyline in batches, currently not used: int p = 0; while (p < lineData->size()) @@ -11931,7 +11931,7 @@ void QCPGraph::drawLinePlot(QCPPainter *painter, QVector *lineData) con 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 && @@ -11941,17 +11941,17 @@ void QCPGraph::drawLinePlot(QCPPainter *painter, QVector *lineData) con 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 @@ -11969,7 +11969,7 @@ void QCPGraph::drawImpulsePlot(QCPPainter *painter, QVector *lineData) } /*! \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 @@ -11980,7 +11980,7 @@ void QCPGraph::drawError(QCPPainter *painter, double x, double y, const QCPData 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 @@ -11999,7 +11999,7 @@ void QCPGraph::drawError(QCPPainter *painter, double x, double y, const QCPData { 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) + if (y-b > skipSymbolMargin) painter->drawLine(QLineF(x, y-skipSymbolMargin, x, b)); } else painter->drawLine(QLineF(x, a, x, b)); @@ -12071,21 +12071,21 @@ void QCPGraph::drawError(QCPPainter *painter, double x, double y, const QCPData } /*! \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. - + if the graph contains no data, \a count is zero and both \a lower and \a upper point to constEnd. */ void QCPGraph::getVisibleDataBounds(QCPDataMap::const_iterator &lower, QCPDataMap::const_iterator &upper, int &count) const @@ -12098,16 +12098,16 @@ void QCPGraph::getVisibleDataBounds(QCPDataMap::const_iterator &lower, QCPDataMa 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; @@ -12119,24 +12119,24 @@ void QCPGraph::getVisibleDataBounds(QCPDataMap::const_iterator &lower, QCPDataMa } /*! \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) { @@ -12150,9 +12150,9 @@ void QCPGraph::addFillBasePoints(QVector *lineData) const } /*! \internal - + removes the two points from \a lineData that were added by \ref addFillBasePoints. - + \see addFillBasePoints, lowerFillBasePoint, upperFillBasePoint */ void QCPGraph::removeFillBasePoints(QVector *lineData) const @@ -12161,17 +12161,17 @@ void QCPGraph::removeFillBasePoints(QVector *lineData) const } /*! \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 @@ -12179,7 +12179,7 @@ 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) { @@ -12226,7 +12226,7 @@ QPointF QCPGraph::lowerFillBasePoint(double lowerKey) const } /*! \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 @@ -12236,7 +12236,7 @@ QPointF QCPGraph::lowerFillBasePoint(double lowerKey) const \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 @@ -12244,7 +12244,7 @@ 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) { @@ -12291,7 +12291,7 @@ QPointF QCPGraph::upperFillBasePoint(double upperKey) const } /*! \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 @@ -12303,15 +12303,15 @@ const QPolygonF QCPGraph::getChannelFillPolygon(const QVector *lineData { 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); @@ -12320,11 +12320,11 @@ const QPolygonF QCPGraph::getChannelFillPolygon(const QVector *lineData 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) { @@ -12358,7 +12358,7 @@ const QPolygonF QCPGraph::getChannelFillPolygon(const QVector *lineData 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); @@ -12409,7 +12409,7 @@ const QPolygonF QCPGraph::getChannelFillPolygon(const QVector *lineData 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); @@ -12427,7 +12427,7 @@ const QPolygonF QCPGraph::getChannelFillPolygon(const QVector *lineData (*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); @@ -12435,7 +12435,7 @@ const QPolygonF QCPGraph::getChannelFillPolygon(const QVector *lineData } /*! \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. @@ -12457,10 +12457,10 @@ int QCPGraph::findIndexAboveX(const QVector *data, double x) const } /*! \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 @@ -12479,10 +12479,10 @@ int QCPGraph::findIndexBelowX(const QVector *data, double x) const } /*! \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 @@ -12500,12 +12500,12 @@ int QCPGraph::findIndexAboveY(const QVector *data, double y) const return -1; } -/*! \internal - +/*! \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. @@ -12522,10 +12522,10 @@ double QCPGraph::pointDistance(const QPointF &pixelPoint) const 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) { @@ -12560,7 +12560,7 @@ double QCPGraph::pointDistance(const QPointF &pixelPoint) const if (currentDistSqr < minDistSqr) minDistSqr = currentDistSqr; } - } else + } else { // all other line plots (line and step) connect points directly: for (int i=0; isize()-1; ++i) @@ -12576,7 +12576,7 @@ double QCPGraph::pointDistance(const QPointF &pixelPoint) const } /*! \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). @@ -12615,9 +12615,9 @@ QCPRange QCPGraph::getValueRange(bool &validRange, SignDomain inSignDomain) cons } /*! \overload - + Allows to specify whether the error bars should be included in the range calculation. - + \see getKeyRange(bool &validRange, SignDomain inSignDomain) */ QCPRange QCPGraph::getKeyRange(bool &validRange, SignDomain inSignDomain, bool includeErrors) const @@ -12625,9 +12625,9 @@ QCPRange QCPGraph::getKeyRange(bool &validRange, SignDomain inSignDomain, bool i 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(); @@ -12715,15 +12715,15 @@ QCPRange QCPGraph::getKeyRange(bool &validRange, SignDomain inSignDomain, bool i ++it; } } - + validRange = haveLower && haveUpper; return range; } /*! \overload - + Allows to specify whether the error bars should be included in the range calculation. - + \see getValueRange(bool &validRange, SignDomain inSignDomain) */ QCPRange QCPGraph::getValueRange(bool &validRange, SignDomain inSignDomain, bool includeErrors) const @@ -12731,9 +12731,9 @@ QCPRange QCPGraph::getValueRange(bool &validRange, SignDomain inSignDomain, bool 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(); @@ -12821,7 +12821,7 @@ QCPRange QCPGraph::getValueRange(bool &validRange, SignDomain inSignDomain, bool ++it; } } - + validRange = haveLower && haveUpper; return range; } @@ -12833,14 +12833,14 @@ QCPRange QCPGraph::getValueRange(bool &validRange, SignDomain inSignDomain, bool /*! \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 */ @@ -12871,24 +12871,24 @@ QCPCurveData::QCPCurveData(double t, double key, double value) : /*! \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.) - + 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 @@ -12906,7 +12906,7 @@ QCPCurveData::QCPCurveData(double t, double key, double 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. */ @@ -12922,7 +12922,7 @@ QCPCurve::QCPCurve(QCPAxis *keyAxis, QCPAxis *valueAxis) : mSelectedPen.setWidthF(2.5); mSelectedPen.setColor(QColor(80, 80, 255)); // lighter than Qt::blue of mPen mSelectedBrush = mBrush; - + setScatterStyle(QCPScatterStyle()); setLineStyle(lsLine); } @@ -12934,7 +12934,7 @@ QCPCurve::~QCPCurve() /*! 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. @@ -12952,7 +12952,7 @@ void QCPCurve::setData(QCPCurveDataMap *data, bool copy) } /*! \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. @@ -12974,7 +12974,7 @@ void QCPCurve::setData(const QVector &t, const QVector &key, con } /*! \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. */ @@ -12993,11 +12993,11 @@ void QCPCurve::setData(const QVector &key, const QVector &value) } } -/*! +/*! 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) @@ -13009,7 +13009,7 @@ void QCPCurve::setScatterStyle(const QCPScatterStyle &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) @@ -13049,11 +13049,11 @@ void QCPCurve::addData(double t, double key, double value) } /*! \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) @@ -13114,7 +13114,7 @@ void QCPCurve::removeDataAfter(double t) 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) @@ -13127,12 +13127,12 @@ void QCPCurve::removeData(double fromt, double tot) } /*! \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) @@ -13155,7 +13155,7 @@ double QCPCurve::selectTest(const QPointF &pos, bool onlySelectable, QVariant *d Q_UNUSED(details) if ((onlySelectable && !mSelectable) || mData->isEmpty()) return -1; - + return pointDistance(pos); } @@ -13163,13 +13163,13 @@ double QCPCurve::selectTest(const QPointF &pos, bool onlySelectable, QVariant *d 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; @@ -13180,7 +13180,7 @@ void QCPCurve::draw(QCPPainter *painter) 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) { @@ -13189,7 +13189,7 @@ void QCPCurve::draw(QCPPainter *painter) painter->setBrush(mainBrush()); painter->drawPolygon(QPolygonF(*lineData)); } - + // draw curve line: if (mLineStyle != lsNone && mainPen().style() != Qt::NoPen && mainPen().color().alpha() != 0) { @@ -13205,15 +13205,15 @@ void QCPCurve::draw(QCPPainter *painter) 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; } @@ -13254,7 +13254,7 @@ void QCPCurve::drawLegendIcon(QCPPainter *painter, const QRectF &rect) const } /*! \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. */ @@ -13268,7 +13268,7 @@ void QCPCurve::drawScatterPlot(QCPPainter *painter, const QVector *poin } /*! \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. @@ -13276,9 +13276,9 @@ void QCPCurve::drawScatterPlot(QCPPainter *painter, const QVector *poin void QCPCurve::getCurveData(QVector *lineData) const { /* Extended sides of axis rect R divide space into 9 regions: - 1__|_4_|__7 + 1__|_4_|__7 2__|_R_|__8 - 3 | 6 | 9 + 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. @@ -13287,7 +13287,7 @@ void QCPCurve::getCurveData(QVector *lineData) const 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; @@ -13330,7 +13330,7 @@ void QCPCurve::getCurveData(QVector *lineData) const 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 @@ -13352,7 +13352,7 @@ void QCPCurve::getCurveData(QVector *lineData) const } 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 @@ -13387,8 +13387,8 @@ void QCPCurve::getCurveData(QVector *lineData) const lineData->append(coordsToPixels((mData->constEnd()-1).value().key, (mData->constEnd()-1).value().value)); } -/*! \internal - +/*! \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. @@ -13405,7 +13405,7 @@ double QCPCurve::pointDistance(const QPointF &pixelPoint) const 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); @@ -13421,7 +13421,7 @@ double QCPCurve::pointDistance(const QPointF &pixelPoint) const } /*! \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 @@ -13459,9 +13459,9 @@ 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()) { @@ -13481,7 +13481,7 @@ QCPRange QCPCurve::getKeyRange(bool &validRange, SignDomain inSignDomain) const } ++it; } - + validRange = haveLower && haveUpper; return range; } @@ -13492,9 +13492,9 @@ QCPRange QCPCurve::getValueRange(bool &validRange, SignDomain inSignDomain) cons QCPRange range; bool haveLower = false; bool haveUpper = false; - + double current; - + QCPCurveDataMap::const_iterator it = mData->constBegin(); while (it != mData->constEnd()) { @@ -13514,7 +13514,7 @@ QCPRange QCPCurve::getValueRange(bool &validRange, SignDomain inSignDomain) cons } ++it; } - + validRange = haveLower && haveUpper; return range; } @@ -13526,13 +13526,13 @@ QCPRange QCPCurve::getValueRange(bool &validRange, SignDomain inSignDomain) cons /*! \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 */ @@ -13563,23 +13563,23 @@ QCPBarData::QCPBarData(double key, double value) : \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 @@ -13595,14 +13595,14 @@ QCPBarData::QCPBarData(double key, double value) : /*! \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 */ @@ -13611,7 +13611,7 @@ QCPBarData::QCPBarData(double key, double 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 QCPBars can be added to the plot with QCustomPlot::addPlottable, QCustomPlot then takes ownership of the bar chart. */ @@ -13627,7 +13627,7 @@ QCPBars::QCPBars(QCPAxis *keyAxis, QCPAxis *valueAxis) : mSelectedPen.setWidthF(2.5); mSelectedPen.setColor(QColor(80, 80, 255)); // lighter than Qt::blue of mPen mSelectedBrush = mBrush; - + mWidth = 0.75; } @@ -13648,7 +13648,7 @@ void QCPBars::setWidth(double width) /*! 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. @@ -13666,7 +13666,7 @@ void QCPBars::setData(QCPBarDataMap *data, bool copy) } /*! \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. @@ -13689,14 +13689,14 @@ void QCPBars::setData(const QVector &key, const QVector &value) 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 */ void QCPBars::moveBelow(QCPBars *bars) @@ -13722,14 +13722,14 @@ void QCPBars::moveBelow(QCPBars *bars) 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. - + \see moveBelow, barBelow, barAbove */ void QCPBars::moveAbove(QCPBars *bars) @@ -13825,7 +13825,7 @@ void QCPBars::removeDataAfter(double key) 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 addData, clearData */ void QCPBars::removeData(double fromKey, double toKey) @@ -13838,11 +13838,11 @@ void QCPBars::removeData(double fromKey, double toKey) } /*! \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 QCPBars::removeData(double key) @@ -13865,7 +13865,7 @@ double QCPBars::selectTest(const QPointF &pos, bool onlySelectable, QVariant *de Q_UNUSED(details) if (onlySelectable && !mSelectable) return -1; - + QCPBarDataMap::ConstIterator it; double posKey, posValue; pixelsToCoords(pos, posKey, posValue); @@ -13885,7 +13885,7 @@ void QCPBars::draw(QCPPainter *painter) { 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) { @@ -13930,7 +13930,7 @@ void QCPBars::drawLegendIcon(QCPPainter *painter, const QRectF &rect) const } /*! \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). */ @@ -13946,10 +13946,10 @@ QPolygonF QCPBars::getBarPolygon(double key, double value) const } /*! \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. @@ -13979,14 +13979,14 @@ double QCPBars::getBaseValue(double key, bool positive) const 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) { if (!lower && !upper) return; - + if (!lower) // disconnect upper at bottom { // disconnect old bar below upper: @@ -14018,7 +14018,7 @@ QCPRange QCPBars::getKeyRange(bool &validRange, SignDomain inSignDomain) const QCPRange range; bool haveLower = false; bool haveUpper = false; - + double current; double barWidthHalf = mWidth*0.5; QCPBarDataMap::const_iterator it = mData->constBegin(); @@ -14040,7 +14040,7 @@ QCPRange QCPBars::getKeyRange(bool &validRange, SignDomain inSignDomain) const } ++it; } - + validRange = haveLower && haveUpper; return range; } @@ -14051,9 +14051,9 @@ QCPRange QCPBars::getValueRange(bool &validRange, SignDomain inSignDomain) 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 - + double current; - + QCPBarDataMap::const_iterator it = mData->constBegin(); while (it != mData->constEnd()) { @@ -14073,7 +14073,7 @@ QCPRange QCPBars::getValueRange(bool &validRange, SignDomain inSignDomain) const } ++it; } - + validRange = range.lower < range.upper; return range; } @@ -14087,7 +14087,7 @@ QCPRange QCPBars::getValueRange(bool &validRange, SignDomain inSignDomain) const \brief A plottable representing a single statistical box in a plot. \image html QCPStatisticalBox.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 @@ -14095,34 +14095,34 @@ QCPRange QCPBars::getValueRange(bool &validRange, SignDomain inSignDomain) const \li \ref setMedian \li \ref setUpperQuartile \li \ref setMaximum - + Additionally you can define a list of outliers, drawn as circle datapoints: \li \ref setOutliers - + \section appearance Changing the appearance - + 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). - + The median indicator line has its own pen, \ref setMedianPen. - + 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. - + 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 @@ -14141,7 +14141,7 @@ QCPRange QCPBars::getValueRange(bool &validRange, SignDomain inSignDomain) const 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. */ @@ -14157,7 +14157,7 @@ QCPStatisticalBox::QCPStatisticalBox(QCPAxis *keyAxis, QCPAxis *valueAxis) : 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)); @@ -14178,7 +14178,7 @@ void QCPStatisticalBox::setKey(double key) /*! 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) @@ -14190,7 +14190,7 @@ void QCPStatisticalBox::setMinimum(double 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. - + \see setUpperQuartile, setPen, setBrush, setWidth */ void QCPStatisticalBox::setLowerQuartile(double value) @@ -14202,7 +14202,7 @@ void QCPStatisticalBox::setLowerQuartile(double 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). - + \see setMedianPen */ void QCPStatisticalBox::setMedian(double value) @@ -14214,7 +14214,7 @@ void QCPStatisticalBox::setMedian(double 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. - + \see setLowerQuartile, setPen, setBrush, setWidth */ void QCPStatisticalBox::setUpperQuartile(double value) @@ -14225,7 +14225,7 @@ void QCPStatisticalBox::setUpperQuartile(double value) /*! 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. - + \see setMinimum, setWhiskerPen, setWhiskerBarPen, setWhiskerWidth */ void QCPStatisticalBox::setMaximum(double value) @@ -14237,7 +14237,7 @@ void QCPStatisticalBox::setMaximum(double value) 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. - + \see setOutlierStyle */ void QCPStatisticalBox::setOutliers(const QVector &values) @@ -14247,7 +14247,7 @@ void QCPStatisticalBox::setOutliers(const QVector &values) /*! 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) @@ -14262,7 +14262,7 @@ void QCPStatisticalBox::setData(double key, double minimum, double lowerQuartile /*! Sets the width of the box in key coordinates. - + \see setWhiskerWidth */ void QCPStatisticalBox::setWidth(double width) @@ -14272,7 +14272,7 @@ void QCPStatisticalBox::setWidth(double width) /*! Sets the width of the whiskers (\ref setMinimum, \ref setMaximum) in key coordinates. - + \see setWidth */ void QCPStatisticalBox::setWhiskerWidth(double width) @@ -14282,10 +14282,10 @@ void QCPStatisticalBox::setWhiskerWidth(double width) /*! Sets the pen used for drawing the whisker backbone (That's the line parallel to the value axis). - + 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 QCPStatisticalBox::setWhiskerPen(const QPen &pen) @@ -14296,7 +14296,7 @@ void QCPStatisticalBox::setWhiskerPen(const QPen &pen) /*! 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 setWhiskerPen */ void QCPStatisticalBox::setWhiskerBarPen(const QPen &pen) @@ -14314,7 +14314,7 @@ void QCPStatisticalBox::setMedianPen(const QPen &pen) /*! Sets the appearance of the outlier data points. - + \see setOutliers */ void QCPStatisticalBox::setOutlierStyle(const QCPScatterStyle &style) @@ -14341,7 +14341,7 @@ double QCPStatisticalBox::selectTest(const QPointF &pos, bool onlySelectable, QV 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: @@ -14349,11 +14349,11 @@ double QCPStatisticalBox::selectTest(const QPointF &pos, bool onlySelectable, QV 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; } @@ -14372,15 +14372,15 @@ void QCPStatisticalBox::draw(QCPPainter *painter) if (QCP::isInvalidData(mOutliers.at(i))) qDebug() << Q_FUNC_INFO << "Data point outlier at" << mKey << "of drawn range invalid." << "Plottable name:" << name(); #endif - + QRectF quartileBox; drawQuartileBox(painter, &quartileBox); - + painter->save(); painter->setClipRect(quartileBox, Qt::IntersectClip); drawMedian(painter); painter->restore(); - + drawWhiskers(painter); drawOutliers(painter); } @@ -14398,7 +14398,7 @@ void QCPStatisticalBox::drawLegendIcon(QCPPainter *painter, const QRectF &rect) } /*! \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). @@ -14417,7 +14417,7 @@ void QCPStatisticalBox::drawQuartileBox(QCPPainter *painter, QRectF *quartileBox } /*! \internal - + Draws the median line inside the quartile box. */ void QCPStatisticalBox::drawMedian(QCPPainter *painter) const @@ -14431,7 +14431,7 @@ void QCPStatisticalBox::drawMedian(QCPPainter *painter) const } /*! \internal - + Draws both whisker backbones and bars. */ void QCPStatisticalBox::drawWhiskers(QCPPainter *painter) const @@ -14451,7 +14451,7 @@ void QCPStatisticalBox::drawWhiskers(QCPPainter *painter) const } /*! \internal - + Draws the outlier scatter points. */ void QCPStatisticalBox::drawOutliers(QCPPainter *painter) const @@ -14568,7 +14568,7 @@ QCPRange QCPStatisticalBox::getValueRange(bool &validRange, SignDomain inSignDom /*! 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) : @@ -14578,7 +14578,7 @@ QCPItemStraightLine::QCPItemStraightLine(QCustomPlot *parentPlot) : { point1->setCoords(0, 0); point2->setCoords(1, 1); - + setPen(QPen(Qt::black)); setSelectedPen(QPen(Qt::blue,2)); } @@ -14589,7 +14589,7 @@ QCPItemStraightLine::~QCPItemStraightLine() /*! Sets the pen that will be used to draw the line - + \see setSelectedPen */ void QCPItemStraightLine::setPen(const QPen &pen) @@ -14599,7 +14599,7 @@ void QCPItemStraightLine::setPen(const QPen &pen) /*! Sets the pen that will be used to draw the line when selected - + \see setPen, setSelected */ void QCPItemStraightLine::setSelectedPen(const QPen &pen) @@ -14613,7 +14613,7 @@ double QCPItemStraightLine::selectTest(const QPointF &pos, bool onlySelectable, Q_UNUSED(details) if (onlySelectable && !mSelectable) return -1; - + return distToStraightLine(QVector2D(point1->pixelPoint()), QVector2D(point2->pixelPoint()-point1->pixelPoint()), QVector2D(pos)); } @@ -14637,7 +14637,7 @@ void QCPItemStraightLine::draw(QCPPainter *painter) finds the shortest distance of \a point to the straight line defined by the base point \a base and the direction vector \a vec. - + This is a helper function for \ref selectTest. */ double QCPItemStraightLine::distToStraightLine(const QVector2D &base, const QVector2D &vec, const QVector2D &point) const @@ -14649,7 +14649,7 @@ double QCPItemStraightLine::distToStraightLine(const QVector2D &base, const QVec Returns the section of the straight line defined by \a base and direction vector \a vec, that is visible in the specified \a rect. - + This is a helper function for \ref draw. */ QLineF QCPItemStraightLine::getRectClippedStraightLine(const QVector2D &base, const QVector2D &vec, const QRect &rect) const @@ -14702,7 +14702,7 @@ QLineF QCPItemStraightLine::getRectClippedStraightLine(const QVector2D &base, co 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) { @@ -14752,13 +14752,13 @@ QPen QCPItemStraightLine::mainPen() const \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. - + 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. - + The constructed item can be added to the plot with QCustomPlot::addItem. */ QCPItemLine::QCPItemLine(QCustomPlot *parentPlot) : @@ -14768,7 +14768,7 @@ QCPItemLine::QCPItemLine(QCustomPlot *parentPlot) : { start->setCoords(0, 0); end->setCoords(1, 1); - + setPen(QPen(Qt::black)); setSelectedPen(QPen(Qt::blue,2)); } @@ -14779,7 +14779,7 @@ QCPItemLine::~QCPItemLine() /*! Sets the pen that will be used to draw the line - + \see setSelectedPen */ void QCPItemLine::setPen(const QPen &pen) @@ -14789,7 +14789,7 @@ void QCPItemLine::setPen(const QPen &pen) /*! Sets the pen that will be used to draw the line when selected - + \see setPen, setSelected */ void QCPItemLine::setSelectedPen(const QPen &pen) @@ -14799,10 +14799,10 @@ void QCPItemLine::setSelectedPen(const QPen &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 */ void QCPItemLine::setHead(const QCPLineEnding &head) @@ -14812,10 +14812,10 @@ void QCPItemLine::setHead(const QCPLineEnding &head) /*! 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 */ void QCPItemLine::setTail(const QCPLineEnding &tail) @@ -14829,7 +14829,7 @@ double QCPItemLine::selectTest(const QPointF &pos, bool onlySelectable, QVariant Q_UNUSED(details) if (onlySelectable && !mSelectable) return -1; - + return qSqrt(distSqrToLine(start->pixelPoint(), end->pixelPoint(), pos)); } @@ -14861,7 +14861,7 @@ void QCPItemLine::draw(QCPPainter *painter) Returns the section of the line defined by \a start and \a end, that is visible in the specified \a rect. - + This is a helper function for \ref draw. */ QLineF QCPItemLine::getRectClippedLine(const QVector2D &start, const QVector2D &end, const QRect &rect) const @@ -14870,7 +14870,7 @@ QLineF QCPItemLine::getRectClippedLine(const QVector2D &start, const QVector2D & 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; @@ -14924,12 +14924,12 @@ QLineF QCPItemLine::getRectClippedLine(const QVector2D &start, const QVector2D & pointVectors.append(QVector2D(bx, by+gamma)); } } - + if (containsStart) pointVectors.append(start); if (containsEnd) pointVectors.append(end); - + // evaluate points: if (pointVectors.size() == 2) { @@ -14980,10 +14980,10 @@ QPen QCPItemLine::mainPen() const 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. - + 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. @@ -14991,7 +14991,7 @@ QPen QCPItemLine::mainPen() const /*! Creates a curve item and sets default values. - + The constructed item can be added to the plot with QCustomPlot::addItem. */ QCPItemCurve::QCPItemCurve(QCustomPlot *parentPlot) : @@ -15005,7 +15005,7 @@ QCPItemCurve::QCPItemCurve(QCustomPlot *parentPlot) : startDir->setCoords(0.5, 0); endDir->setCoords(0, 0.5); end->setCoords(1, 1); - + setPen(QPen(Qt::black)); setSelectedPen(QPen(Qt::blue,2)); } @@ -15016,7 +15016,7 @@ QCPItemCurve::~QCPItemCurve() /*! Sets the pen that will be used to draw the line - + \see setSelectedPen */ void QCPItemCurve::setPen(const QPen &pen) @@ -15026,7 +15026,7 @@ void QCPItemCurve::setPen(const QPen &pen) /*! Sets the pen that will be used to draw the line when selected - + \see setPen, setSelected */ void QCPItemCurve::setSelectedPen(const QPen &pen) @@ -15036,10 +15036,10 @@ void QCPItemCurve::setSelectedPen(const QPen &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 */ void QCPItemCurve::setHead(const QCPLineEnding &head) @@ -15049,10 +15049,10 @@ void QCPItemCurve::setHead(const QCPLineEnding &head) /*! 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 */ void QCPItemCurve::setTail(const QCPLineEnding &tail) @@ -15066,7 +15066,7 @@ double QCPItemCurve::selectTest(const QPointF &pos, bool onlySelectable, QVarian Q_UNUSED(details) if (onlySelectable && !mSelectable) return -1; - + QPointF startVec(start->pixelPoint()); QPointF startDirVec(startDir->pixelPoint()); QPointF endDirVec(endDir->pixelPoint()); @@ -15074,7 +15074,7 @@ double QCPItemCurve::selectTest(const QPointF &pos, bool onlySelectable, QVarian QPainterPath cubicPath(startVec); cubicPath.cubicTo(startDirVec, endDirVec, endVec); - + QPolygonF polygon = cubicPath.toSubpathPolygons().first(); double minDistSqr = std::numeric_limits::max(); for (int i=1; isetCoords(0, 1); bottomRight->setCoords(1, 0); - + setPen(QPen(Qt::black)); setSelectedPen(QPen(Qt::blue,2)); setBrush(Qt::NoBrush); @@ -15170,7 +15170,7 @@ QCPItemRect::~QCPItemRect() /*! Sets the pen that will be used to draw the line of the rectangle - + \see setSelectedPen, setBrush */ void QCPItemRect::setPen(const QPen &pen) @@ -15180,7 +15180,7 @@ void QCPItemRect::setPen(const QPen &pen) /*! Sets the pen that will be used to draw the line of the rectangle when selected - + \see setPen, setSelected */ void QCPItemRect::setSelectedPen(const QPen &pen) @@ -15191,7 +15191,7 @@ void QCPItemRect::setSelectedPen(const QPen &pen) /*! Sets the brush that will be used to fill the rectangle. To disable filling, set \a brush to Qt::NoBrush. - + \see setSelectedBrush, setPen */ void QCPItemRect::setBrush(const QBrush &brush) @@ -15202,7 +15202,7 @@ void QCPItemRect::setBrush(const QBrush &brush) /*! Sets the brush that will be used to fill the rectangle when selected. To disable filling, set \a brush to Qt::NoBrush. - + \see setBrush */ void QCPItemRect::setSelectedBrush(const QBrush &brush) @@ -15216,7 +15216,7 @@ double QCPItemRect::selectTest(const QPointF &pos, bool onlySelectable, QVariant Q_UNUSED(details) if (onlySelectable && !mSelectable) 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); @@ -15253,7 +15253,7 @@ QPointF QCPItemRect::anchorPixelPoint(int anchorId) const case aiBottomLeft: return rect.bottomLeft(); case aiLeft: return (rect.topLeft()+rect.bottomLeft())*0.5; } - + qDebug() << Q_FUNC_INFO << "invalid anchorId" << anchorId; return QPointF(); } @@ -15290,16 +15290,16 @@ QBrush QCPItemRect::mainBrush() const 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. - + The text alignment itself (i.e. left, center, right) can be controlled with \ref setTextAlignment. - + The text may be rotated around the \a position point with \ref setRotation. */ /*! Creates a text item and sets default values. - + The constructed item can be added to the plot with QCustomPlot::addItem. */ QCPItemText::QCPItemText(QCustomPlot *parentPlot) : @@ -15315,12 +15315,12 @@ QCPItemText::QCPItemText(QCustomPlot *parentPlot) : 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); @@ -15352,7 +15352,7 @@ void QCPItemText::setSelectedColor(const QColor &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) @@ -15363,7 +15363,7 @@ void QCPItemText::setPen(const QPen &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) @@ -15374,7 +15374,7 @@ void QCPItemText::setSelectedPen(const QPen &pen) /*! 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) @@ -15385,7 +15385,7 @@ void QCPItemText::setBrush(const QBrush &brush) /*! 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 setBrush */ void QCPItemText::setSelectedBrush(const QBrush &brush) @@ -15395,7 +15395,7 @@ void QCPItemText::setSelectedBrush(const QBrush &brush) /*! Sets the font of the text. - + \see setSelectedFont, setColor */ void QCPItemText::setFont(const QFont &font) @@ -15405,7 +15405,7 @@ void QCPItemText::setFont(const QFont &font) /*! Sets the font of the text that will be used when the item is selected. - + \see setFont */ void QCPItemText::setSelectedFont(const QFont &font) @@ -15416,7 +15416,7 @@ void QCPItemText::setSelectedFont(const QFont &font) /*! Sets the text that will be displayed. Multi-line texts are supported by inserting a line break character, e.g. '\n'. - + \see setFont, setColor, setTextAlignment */ void QCPItemText::setText(const QString &text) @@ -15426,13 +15426,13 @@ void QCPItemText::setText(const QString &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. - + If you want to control the alignment of (multi-lined) text within the text rect, use \ref setTextAlignment. */ @@ -15473,7 +15473,7 @@ double QCPItemText::selectTest(const QPointF &pos, bool onlySelectable, QVariant 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()); @@ -15538,7 +15538,7 @@ QPointF QCPItemText::anchorPixelPoint(int anchorId) const 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) { case aiTopLeft: return rectPoly.at(0); @@ -15550,17 +15550,17 @@ QPointF QCPItemText::anchorPixelPoint(int anchorId) const case aiBottomLeft: return rectPoly.at(3); case aiLeft: return (rectPoly.at(3)+rectPoly.at(0))*0.5; } - + qDebug() << Q_FUNC_INFO << "invalid anchorId" << anchorId; return QPointF(); } /*! \internal - + 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. @@ -15569,7 +15569,7 @@ QPointF QCPItemText::getTextDrawPoint(const QPointF &pos, const QRectF &rect, Qt { 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; @@ -15637,7 +15637,7 @@ QBrush QCPItemText::mainBrush() const /*! Creates an ellipse item and sets default values. - + The constructed item can be added to the plot with QCustomPlot::addItem. */ QCPItemEllipse::QCPItemEllipse(QCustomPlot *parentPlot) : @@ -15656,7 +15656,7 @@ QCPItemEllipse::QCPItemEllipse(QCustomPlot *parentPlot) : { topLeft->setCoords(0, 1); bottomRight->setCoords(1, 0); - + setPen(QPen(Qt::black)); setSelectedPen(QPen(Qt::blue, 2)); setBrush(Qt::NoBrush); @@ -15669,7 +15669,7 @@ QCPItemEllipse::~QCPItemEllipse() /*! Sets the pen that will be used to draw the line of the ellipse - + \see setSelectedPen, setBrush */ void QCPItemEllipse::setPen(const QPen &pen) @@ -15679,7 +15679,7 @@ void QCPItemEllipse::setPen(const QPen &pen) /*! Sets the pen that will be used to draw the line of the ellipse when selected - + \see setPen, setSelected */ void QCPItemEllipse::setSelectedPen(const QPen &pen) @@ -15690,7 +15690,7 @@ void QCPItemEllipse::setSelectedPen(const QPen &pen) /*! Sets the brush that will be used to fill the ellipse. To disable filling, set \a brush to Qt::NoBrush. - + \see setSelectedBrush, setPen */ void QCPItemEllipse::setBrush(const QBrush &brush) @@ -15701,7 +15701,7 @@ void QCPItemEllipse::setBrush(const QBrush &brush) /*! Sets the brush that will be used to fill the ellipse when selected. To disable filling, set \a brush to Qt::NoBrush. - + \see setBrush */ void QCPItemEllipse::setSelectedBrush(const QBrush &brush) @@ -15715,7 +15715,7 @@ double QCPItemEllipse::selectTest(const QPointF &pos, bool onlySelectable, QVari Q_UNUSED(details) if (onlySelectable && !mSelectable) return -1; - + double result = -1; QPointF p1 = topLeft->pixelPoint(); QPointF p2 = bottomRight->pixelPoint(); @@ -15724,7 +15724,7 @@ double QCPItemEllipse::selectTest(const QPointF &pos, bool onlySelectable, QVari 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); @@ -15781,7 +15781,7 @@ QPointF QCPItemEllipse::anchorPixelPoint(int anchorId) const 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(); } @@ -15819,7 +15819,7 @@ QBrush QCPItemEllipse::mainBrush() const 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. @@ -15827,7 +15827,7 @@ QBrush QCPItemEllipse::mainBrush() const /*! Creates a rectangle item and sets default values. - + The constructed item can be added to the plot with QCustomPlot::addItem. */ QCPItemPixmap::QCPItemPixmap(QCustomPlot *parentPlot) : @@ -15843,7 +15843,7 @@ QCPItemPixmap::QCPItemPixmap(QCustomPlot *parentPlot) : { topLeft->setCoords(0, 1); bottomRight->setCoords(1, 0); - + setPen(Qt::NoPen); setSelectedPen(QPen(Qt::blue)); setScaled(false, Qt::KeepAspectRatio); @@ -15876,7 +15876,7 @@ void QCPItemPixmap::setScaled(bool scaled, Qt::AspectRatioMode aspectRatioMode) /*! Sets the pen that will be used to draw a border around the pixmap. - + \see setSelectedPen, setBrush */ void QCPItemPixmap::setPen(const QPen &pen) @@ -15886,7 +15886,7 @@ void QCPItemPixmap::setPen(const QPen &pen) /*! Sets the pen that will be used to draw a border around the pixmap when selected - + \see setPen, setSelected */ void QCPItemPixmap::setSelectedPen(const QPen &pen) @@ -15900,7 +15900,7 @@ double QCPItemPixmap::selectTest(const QPointF &pos, bool onlySelectable, QVaria Q_UNUSED(details) if (onlySelectable && !mSelectable) return -1; - + return rectSelectTest(getFinalRect(), pos, true); } @@ -15938,7 +15938,7 @@ QPointF QCPItemPixmap::anchorPixelPoint(int anchorId) const 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; @@ -15948,29 +15948,29 @@ QPointF QCPItemPixmap::anchorPixelPoint(int anchorId) const case aiBottomLeft: return rect.bottomLeft(); case aiLeft: return (rect.topLeft()+rect.bottomLeft())*0.5;; } - + qDebug() << Q_FUNC_INFO << "invalid anchorId" << anchorId; return QPointF(); } /*! \internal - + 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. */ void QCPItemPixmap::updateScaledPixmap(QRect finalRect, bool flipHorz, bool flipVert) { if (mPixmap.isNull()) return; - + if (mScaled) { if (finalRect.isNull()) @@ -15986,16 +15986,16 @@ void QCPItemPixmap::updateScaledPixmap(QRect finalRect, bool flipHorz, bool flip } /*! \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. */ @@ -16064,19 +16064,19 @@ QPen QCPItemPixmap::mainPen() const 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). - + 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. - + 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 @@ -16085,7 +16085,7 @@ QPen QCPItemPixmap::mainPen() const /*! Creates a tracer item and sets default values. - + The constructed item can be added to the plot with QCustomPlot::addItem. */ QCPItemTracer::QCPItemTracer(QCustomPlot *parentPlot) : @@ -16111,7 +16111,7 @@ QCPItemTracer::~QCPItemTracer() /*! Sets the pen that will be used to draw the line of the tracer - + \see setSelectedPen, setBrush */ void QCPItemTracer::setPen(const QPen &pen) @@ -16121,7 +16121,7 @@ void QCPItemTracer::setPen(const QPen &pen) /*! Sets the pen that will be used to draw the line of the tracer when selected - + \see setPen, setSelected */ void QCPItemTracer::setSelectedPen(const QPen &pen) @@ -16131,7 +16131,7 @@ void QCPItemTracer::setSelectedPen(const QPen &pen) /*! Sets the brush that will be used to draw any fills of the tracer - + \see setSelectedBrush, setPen */ void QCPItemTracer::setBrush(const QBrush &brush) @@ -16141,7 +16141,7 @@ void QCPItemTracer::setBrush(const QBrush &brush) /*! Sets the brush that will be used to draw any fills of the tracer, when selected. - + \see setBrush, setSelected */ void QCPItemTracer::setSelectedBrush(const QBrush &brush) @@ -16160,7 +16160,7 @@ void QCPItemTracer::setSize(double size) /*! Sets the style/visual appearance of the tracer. - + If you only want to use the tracer \a position as an anchor for other items, set \a style to \ref tsNone. */ @@ -16172,11 +16172,11 @@ void QCPItemTracer::setStyle(QCPItemTracer::TracerStyle style) /*! 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. - + \see setGraphKey */ void QCPItemTracer::setGraph(QCPGraph *graph) @@ -16200,10 +16200,10 @@ void QCPItemTracer::setGraph(QCPGraph *graph) /*! 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) @@ -16214,12 +16214,12 @@ void QCPItemTracer::setGraphKey(double key) /*! 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) @@ -16334,13 +16334,13 @@ void QCPItemTracer::draw(QCPPainter *painter) /*! 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() @@ -16423,21 +16423,21 @@ QBrush QCPItemTracer::mainBrush() const 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.
- + 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. */ /*! Creates a bracket item and sets default values. - + The constructed item can be added to the plot with QCustomPlot::addItem. */ QCPItemBracket::QCPItemBracket(QCustomPlot *parentPlot) : @@ -16448,7 +16448,7 @@ QCPItemBracket::QCPItemBracket(QCustomPlot *parentPlot) : { left->setCoords(0, 0); right->setCoords(1, 1); - + setPen(QPen(Qt::black)); setSelectedPen(QPen(Qt::blue, 2)); setLength(8); @@ -16461,11 +16461,11 @@ QCPItemBracket::~QCPItemBracket() /*! 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. - + \see setSelectedPen */ void QCPItemBracket::setPen(const QPen &pen) @@ -16475,7 +16475,7 @@ void QCPItemBracket::setPen(const QPen &pen) /*! Sets the pen that will be used to draw the bracket when selected - + \see setPen, setSelected */ void QCPItemBracket::setSelectedPen(const QPen &pen) @@ -16486,7 +16486,7 @@ void QCPItemBracket::setSelectedPen(const QPen &pen) /*! 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.
@@ -16498,7 +16498,7 @@ void QCPItemBracket::setLength(double length) /*! Sets the style of the bracket, i.e. the shape/visual appearance. - + \see setPen */ void QCPItemBracket::setStyle(QCPItemBracket::BracketStyle style) @@ -16512,17 +16512,17 @@ double QCPItemBracket::selectTest(const QPointF &pos, bool onlySelectable, QVari 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.5; QVector2D lengthVec(-widthVec.y(), widthVec.x()); lengthVec = lengthVec.normalized()*mLength; QVector2D centerVec = (rightVec+leftVec)*0.5-lengthVec; - + return qSqrt(distSqrToLine((centerVec-widthVec).toPointF(), (centerVec+widthVec).toPointF(), pos)); } @@ -16533,7 +16533,7 @@ void QCPItemBracket::draw(QCPPainter *painter) QVector2D rightVec(right->pixelPoint()); if (leftVec.toPoint() == rightVec.toPoint()) return; - + QVector2D widthVec = (rightVec-leftVec)*0.5; QVector2D lengthVec(-widthVec.y(), widthVec.x()); lengthVec = lengthVec.normalized()*mLength; @@ -16570,8 +16570,8 @@ void QCPItemBracket::draw(QCPPainter *painter) 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()); + path.cubicTo((centerVec+widthVec*1-lengthVec*0.8f).toPointF(), (centerVec+0.4f*widthVec+1*lengthVec).toPointF(), centerVec.toPointF()); + path.cubicTo((centerVec-0.4f*widthVec+1*lengthVec).toPointF(), (centerVec-widthVec*1-lengthVec*0.8f).toPointF(), (centerVec-widthVec+lengthVec).toPointF()); painter->drawPath(path); break; } @@ -16581,13 +16581,13 @@ void QCPItemBracket::draw(QCPPainter *painter) 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()); - + + path.cubicTo((centerVec+widthVec*1-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*1-lengthVec*0.8f).toPointF(), (centerVec-widthVec+lengthVec).toPointF()); + + path.cubicTo((centerVec-widthVec*1-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*1-lengthVec*0.5f).toPointF(), (centerVec+widthVec+lengthVec).toPointF()); + painter->drawPath(path); break; } @@ -16602,12 +16602,12 @@ QPointF QCPItemBracket::anchorPixelPoint(int anchorId) const 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; - + switch (anchorId) { case aiCenter: @@ -16634,36 +16634,36 @@ QPen QCPItemBracket::mainPen() const /*! \class QCPAxisRect \brief Holds multiple axes and arranges them in a rectangular shape. - + 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.
@@ -16672,81 +16672,81 @@ QPen QCPItemBracket::mainPen() const /* 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 */ /*! \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. */ /*! \fn int QCPAxisRect::right() const - + 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. */ /*! \fn int QCPAxisRect::top() const - + 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. */ /*! \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. */ /*! \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. */ /*! \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. */ /*! \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. */ /*! \fn QPoint QCPAxisRect::topLeft() const - + 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 - + 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. */ /*! \fn QPoint QCPAxisRect::bottomLeft() const - + 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. */ /*! \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. */ /*! \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. */ @@ -16772,14 +16772,14 @@ QCPAxisRect::QCPAxisRect(QCustomPlot *parentPlot, bool setupDefaultAxes) : 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); @@ -16805,7 +16805,7 @@ QCPAxisRect::~QCPAxisRect() { delete mInsetLayout; mInsetLayout = 0; - + QList axesList = axes(); for (int i=0; ior-combination, to get the axes of multiple sides. - + \see axis */ QList QCPAxisRect::axes(QCPAxis::AxisTypes types) const @@ -16862,7 +16862,7 @@ QList QCPAxisRect::axes(QCPAxis::AxisTypes types) const } /*! \overload - + Returns all axes of this axis rect. */ QList QCPAxisRect::axes() const @@ -16879,11 +16879,11 @@ QList QCPAxisRect::axes() const /*! 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 */ QCPAxis *QCPAxisRect::addAxis(QCPAxis::AxisType type) @@ -16902,9 +16902,9 @@ QCPAxis *QCPAxisRect::addAxis(QCPAxis::AxisType type) /*! 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. - + Returns a list of the added axes. - + \see addAxis, setupFullAxesBox */ QList QCPAxisRect::addAxes(QCPAxis::AxisTypes types) @@ -16923,9 +16923,9 @@ QList QCPAxisRect::addAxes(QCPAxis::AxisTypes types) /*! 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. - + \see addAxis */ bool QCPAxisRect::removeAxis(QCPAxis *axis) @@ -16952,7 +16952,7 @@ bool QCPAxisRect::removeAxis(QCPAxis *axis) 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) @@ -16963,7 +16963,7 @@ bool QCPAxisRect::removeAxis(QCPAxis *axis) \li auto sub ticks (\ref QCPAxis::setAutoSubTicks) \li tick step (\ref QCPAxis::setTickStep) \li auto tick step (\ref QCPAxis::setAutoTickStep) - + 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 @@ -16976,22 +16976,22 @@ void QCPAxisRect::setupFullAxesBox(bool connectRanges) 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) @@ -17007,7 +17007,7 @@ void QCPAxisRect::setupFullAxesBox(bool connectRanges) xAxis2->setRange(xAxis->range()); xAxis2->setRangeReversed(xAxis->rangeReversed()); } - + yAxis2->setVisible(true); yAxis2->setTickLabels(false); if (yAxis) @@ -17023,7 +17023,7 @@ void QCPAxisRect::setupFullAxesBox(bool connectRanges) yAxis2->setRange(yAxis->range()); yAxis2->setRangeReversed(yAxis->rangeReversed()); } - + if (connectRanges) { connect(xAxis, SIGNAL(rangeChanged(QCPRange)), xAxis2, SLOT(setRange(QCPRange))); @@ -17033,10 +17033,10 @@ void QCPAxisRect::setupFullAxesBox(bool connectRanges) /*! Returns a list of all the plottables that are associated with this axis rect. - + A plottable is considered associated with an axis rect if its key or value axis (or both) is in this axis rect. - + \see graphs, items */ QList QCPAxisRect::plottables() const @@ -17053,10 +17053,10 @@ QList QCPAxisRect::plottables() const /*! Returns a list of all the graphs that are associated with this axis rect. - + A graph is considered associated with an axis rect if its key or value axis (or both) is in this axis rect. - + \see plottables, items */ QList QCPAxisRect::graphs() const @@ -17073,12 +17073,12 @@ QList QCPAxisRect::graphs() const /*! 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. - + \see plottables, graphs */ QList QCPAxisRect::items() const @@ -17111,7 +17111,7 @@ QList QCPAxisRect::items() const /*! 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. @@ -17119,7 +17119,7 @@ QList QCPAxisRect::items() const 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(); @@ -17162,7 +17162,7 @@ void QCPAxisRect::draw(QCPPainter *painter) Below the pixmap, the axis rect may be optionally filled with a brush, if specified with \ref setBackground(const QBrush &brush). - + \see setBackgroundScaled, setBackgroundScaledMode, setBackground(const QBrush &brush) */ void QCPAxisRect::setBackground(const QPixmap &pm) @@ -17172,7 +17172,7 @@ void QCPAxisRect::setBackground(const QPixmap &pm) } /*! \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. @@ -17181,7 +17181,7 @@ void QCPAxisRect::setBackground(const QPixmap &pm) setBackground(const QPixmap &pm). To disable drawing of a background brush, set \a brush to Qt::NoBrush. - + \see setBackground(const QPixmap &pm) */ void QCPAxisRect::setBackground(const QBrush &brush) @@ -17190,7 +17190,7 @@ void QCPAxisRect::setBackground(const QBrush &brush) } /*! \overload - + Allows setting the background pixmap of the axis rect, whether it shall be scaled and how it shall be scaled in one call. @@ -17208,10 +17208,10 @@ void QCPAxisRect::setBackground(const QPixmap &pm, bool scaled, Qt::AspectRatioM 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.) - + \see setBackground, setBackgroundScaledMode */ void QCPAxisRect::setBackgroundScaled(bool scaled) @@ -17231,7 +17231,7 @@ void QCPAxisRect::setBackgroundScaledMode(Qt::AspectRatioMode mode) /*! Returns the range drag axis of the \a orientation provided. - + \see setRangeDragAxes */ QCPAxis *QCPAxisRect::rangeDragAxis(Qt::Orientation orientation) @@ -17241,7 +17241,7 @@ QCPAxis *QCPAxisRect::rangeDragAxis(Qt::Orientation orientation) /*! Returns the range zoom axis of the \a orientation provided. - + \see setRangeZoomAxes */ QCPAxis *QCPAxisRect::rangeZoomAxis(Qt::Orientation orientation) @@ -17251,7 +17251,7 @@ QCPAxis *QCPAxisRect::rangeZoomAxis(Qt::Orientation orientation) /*! Returns the range zoom factor of the \a orientation provided. - + \see setRangeZoomFactor */ double QCPAxisRect::rangeZoomFactor(Qt::Orientation orientation) @@ -17265,14 +17265,14 @@ double QCPAxisRect::rangeZoomFactor(Qt::Orientation orientation) \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 */ void QCPAxisRect::setRangeDrag(Qt::Orientations orientations) @@ -17289,10 +17289,10 @@ void QCPAxisRect::setRangeDrag(Qt::Orientations orientations) 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 */ void QCPAxisRect::setRangeZoom(Qt::Orientations orientations) @@ -17303,7 +17303,7 @@ void QCPAxisRect::setRangeZoom(Qt::Orientations orientations) /*! Sets the axes whose range will be dragged when \ref setRangeDrag enables mouse range dragging on the QCustomPlot widget. - + \see setRangeZoomAxes */ void QCPAxisRect::setRangeDragAxes(QCPAxis *horizontal, QCPAxis *vertical) @@ -17316,7 +17316,7 @@ void QCPAxisRect::setRangeDragAxes(QCPAxis *horizontal, QCPAxis *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). - + \see setRangeDragAxes */ void QCPAxisRect::setRangeZoomAxes(QCPAxis *horizontal, QCPAxis *vertical) @@ -17342,7 +17342,7 @@ void QCPAxisRect::setRangeZoomFactor(double horizontalFactor, double verticalFac } /*! \overload - + Sets both the horizontal and vertical zoom \a factor. */ void QCPAxisRect::setRangeZoomFactor(double factor) @@ -17352,13 +17352,13 @@ void QCPAxisRect::setRangeZoomFactor(double factor) } /*! \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 @@ -17366,7 +17366,7 @@ void QCPAxisRect::setRangeZoomFactor(double factor) 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) @@ -17374,7 +17374,7 @@ 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()) { @@ -17394,13 +17394,13 @@ void QCPAxisRect::drawBackground(QCPPainter *painter) } /*! \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) @@ -17415,9 +17415,9 @@ 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) @@ -17427,14 +17427,14 @@ int QCPAxisRect::calculateAutoMargin(QCP::MarginSide side) } /*! \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) @@ -17461,10 +17461,10 @@ void QCPAxisRect::mousePressEvent(QMouseEvent *event) } /*! \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) @@ -17524,13 +17524,13 @@ void QCPAxisRect::mouseReleaseEvent(QMouseEvent *event) } /*! \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 @@ -17570,16 +17570,16 @@ void QCPAxisRect::wheelEvent(QWheelEvent *event) /*! \class QCPAbstractLegendItem \brief The abstract base class for all entries in a QCPLegend. - + It defines a very basic interface for entries in a QCPLegend. For representing plottables in the legend, the subclass \ref QCPPlottableLegendItem is more suitable. - + 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). You must implement the following pure virtual functions: \li \ref draw (from QCPLayerable) - + You inherit the following members you may use: @@ -17595,7 +17595,7 @@ void QCPAxisRect::wheelEvent(QWheelEvent *event) /* start of documentation of signals */ /*! \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. */ @@ -17606,7 +17606,7 @@ void QCPAxisRect::wheelEvent(QWheelEvent *event) 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. */ -QCPAbstractLegendItem::QCPAbstractLegendItem(QCPLegend *parent) : +QCPAbstractLegendItem::QCPAbstractLegendItem(QCPLegend *parent) : QCPLayoutElement(parent->parentPlot()), mParentLegend(parent), mFont(parent->font()), @@ -17622,7 +17622,7 @@ QCPAbstractLegendItem::QCPAbstractLegendItem(QCPLegend *parent) : /*! Sets the default font of this specific legend item to \a font. - + \see setTextColor, QCPLegend::setFont */ void QCPAbstractLegendItem::setFont(const QFont &font) @@ -17632,7 +17632,7 @@ void QCPAbstractLegendItem::setFont(const QFont &font) /*! Sets the default text color of this specific legend item to \a color. - + \see setFont, QCPLegend::setTextColor */ void QCPAbstractLegendItem::setTextColor(const QColor &color) @@ -17643,7 +17643,7 @@ void QCPAbstractLegendItem::setTextColor(const QColor &color) /*! When this legend item is selected, \a font is used to draw generic text, instead of the normal font set with \ref setFont. - + \see setFont, QCPLegend::setSelectedFont */ void QCPAbstractLegendItem::setSelectedFont(const QFont &font) @@ -17654,7 +17654,7 @@ void QCPAbstractLegendItem::setSelectedFont(const QFont &font) /*! When this legend item is selected, \a color is used to draw generic text, instead of the normal color set with \ref setTextColor. - + \see setTextColor, QCPLegend::setSelectedTextColor */ void QCPAbstractLegendItem::setSelectedTextColor(const QColor &color) @@ -17664,7 +17664,7 @@ void QCPAbstractLegendItem::setSelectedTextColor(const QColor &color) /*! Sets whether this specific legend item is selectable. - + \see setSelectedParts, QCustomPlot::setInteractions */ void QCPAbstractLegendItem::setSelectable(bool selectable) @@ -17674,10 +17674,10 @@ void QCPAbstractLegendItem::setSelectable(bool selectable) /*! 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 setSelectableParts, QCustomPlot::setInteractions */ void QCPAbstractLegendItem::setSelected(bool selected) @@ -17696,7 +17696,7 @@ double QCPAbstractLegendItem::selectTest(const QPointF &pos, bool onlySelectable if (!mParentPlot) return -1; if (onlySelectable && (!mSelectable || !mParentLegend->selectableParts().testFlag(QCPLegend::spItems))) return -1; - + if (mRect.contains(pos.toPoint())) return mParentPlot->selectionTolerance()*0.99; else @@ -17747,13 +17747,13 @@ void QCPAbstractLegendItem::deselectEvent(bool *selectionStateChanged) /*! \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 @@ -17763,7 +17763,7 @@ void QCPAbstractLegendItem::deselectEvent(bool *selectionStateChanged) 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 @@ -17772,9 +17772,9 @@ void QCPAbstractLegendItem::deselectEvent(bool *selectionStateChanged) /*! 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. */ @@ -17785,7 +17785,7 @@ QCPPlottableLegendItem::QCPPlottableLegendItem(QCPLegend *parent, QCPAbstractPlo } /*! \internal - + Returns the pen that shall be used to draw the icon border, taking into account the selection state of this item. */ @@ -17795,7 +17795,7 @@ QPen QCPPlottableLegendItem::getIconBorderPen() const } /*! \internal - + Returns the text color that shall be used to draw text, taking into account the selection state of this item. */ @@ -17805,7 +17805,7 @@ QColor QCPPlottableLegendItem::getTextColor() const } /*! \internal - + Returns the font that shall be used to draw text, taking into account the selection state of this item. */ @@ -17815,7 +17815,7 @@ QFont QCPPlottableLegendItem::getFont() const } /*! \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. @@ -17845,7 +17845,7 @@ void QCPPlottableLegendItem::draw(QCPPainter *painter) } /*! \internal - + Calculates and returns the size of this item. This includes the icon, the text and the padding in between. */ @@ -17871,12 +17871,12 @@ QSize QCPPlottableLegendItem::minimumSizeHint() const \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 @@ -17896,7 +17896,7 @@ QSize QCPPlottableLegendItem::minimumSizeHint() const /*! \fn void QCPLegend::selectionChanged(QCPLegend::SelectableParts selection); This signal is emitted when the selection state of this legend has changed. - + \see setSelectedParts, setSelectableParts */ @@ -17904,7 +17904,7 @@ QSize QCPPlottableLegendItem::minimumSizeHint() const /*! 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 */ @@ -17915,12 +17915,12 @@ QCPLegend::QCPLegend() setMargins(QMargins(2, 3, 2, 2)); setAntialiased(false); setIconSize(32, 18); - + setIconTextPadding(7); - + setSelectableParts(spLegendBox | spItems); setSelectedParts(spNone); - + setBorderPen(QPen(Qt::black)); setSelectedBorderPen(QPen(Qt::blue, 2)); setIconBorderPen(Qt::NoPen); @@ -17977,9 +17977,9 @@ void QCPLegend::setBrush(const QBrush &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. - + \see QCPAbstractLegendItem::setFont */ void QCPLegend::setFont(const QFont &font) @@ -17996,9 +17996,9 @@ void QCPLegend::setFont(const QFont &font) 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. - + This function will also set \a color on all already existing legend items. - + \see QCPAbstractLegendItem::setTextColor */ void QCPLegend::setTextColor(const QColor &color) @@ -18041,7 +18041,7 @@ void QCPLegend::setIconTextPadding(int 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. - + If no border is wanted, set this to \a Qt::NoPen. */ void QCPLegend::setIconBorderPen(const QPen &pen) @@ -18052,11 +18052,11 @@ void QCPLegend::setIconBorderPen(const QPen &pen) /*! 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. - + \see SelectablePart, setSelectedParts */ void QCPLegend::setSelectableParts(const SelectableParts &selectable) @@ -18068,20 +18068,20 @@ void QCPLegend::setSelectableParts(const SelectableParts &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. - + \see SelectablePart, setSelectableParts, selectTest, setSelectedBorderPen, setSelectedIconBorderPen, setSelectedBrush, setSelectedFont */ @@ -18144,7 +18144,7 @@ void QCPLegend::setSelectedBrush(const QBrush &brush) /*! Sets the default font that is used by legend items when they are selected. - + This function will also set \a font on all already existing legend items. \see setFont, QCPAbstractLegendItem::setSelectedFont @@ -18161,7 +18161,7 @@ void QCPLegend::setSelectedFont(const QFont &font) /*! Sets the default text color that is used by legend items when they are selected. - + This function will also set \a color on all already existing legend items. \see setTextColor, QCPAbstractLegendItem::setSelectedTextColor @@ -18178,7 +18178,7 @@ void QCPLegend::setSelectedTextColor(const QColor &color) /*! Returns the item with index \a i. - + \see itemCount */ QCPAbstractLegendItem *QCPLegend::item(int index) const @@ -18189,7 +18189,7 @@ QCPAbstractLegendItem *QCPLegend::item(int index) const /*! 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. - + \see hasItemWithPlottable */ QCPPlottableLegendItem *QCPLegend::itemWithPlottable(const QCPAbstractPlottable *plottable) const @@ -18230,7 +18230,7 @@ bool QCPLegend::hasItem(QCPAbstractLegendItem *item) const /*! 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 */ bool QCPLegend::hasItemWithPlottable(const QCPAbstractPlottable *plottable) const @@ -18240,9 +18240,9 @@ bool QCPLegend::hasItemWithPlottable(const QCPAbstractPlottable *plottable) cons /*! 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. */ bool QCPLegend::addItem(QCPAbstractLegendItem *item) @@ -18258,7 +18258,7 @@ bool QCPLegend::addItem(QCPAbstractLegendItem *item) Removes the item with index \a index from the legend. Returns true, if successful. - + \see itemCount, clearItems */ bool QCPLegend::removeItem(int index) @@ -18273,11 +18273,11 @@ bool QCPLegend::removeItem(int index) } /*! \overload - + Removes \a item from the legend. Returns true, if successful. - + \see clearItems */ bool QCPLegend::removeItem(QCPAbstractLegendItem *item) @@ -18299,7 +18299,7 @@ void QCPLegend::clearItems() /*! Returns the legend items that are currently selected. If no items are selected, the list is empty. - + \see QCPAbstractLegendItem::setSelected, setSelectable */ QList QCPLegend::selectedItems() const @@ -18322,11 +18322,11 @@ QList QCPLegend::selectedItems() const 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 QCPLegend::applyDefaultAntialiasingHint(QCPPainter *painter) const @@ -18335,7 +18335,7 @@ void QCPLegend::applyDefaultAntialiasingHint(QCPPainter *painter) const } /*! \internal - + Returns the pen used to paint the border of the legend, taking into account the selection state of the legend box. */ @@ -18345,7 +18345,7 @@ QPen QCPLegend::getBorderPen() const } /*! \internal - + Returns the brush used to paint the background of the legend, taking into account the selection state of the legend box. */ @@ -18355,7 +18355,7 @@ QBrush QCPLegend::getBrush() const } /*! \internal - + Draws the legend box with the provided \a painter. The individual legend items are layerables themselves, thus are drawn independently. */ @@ -18373,7 +18373,7 @@ double QCPLegend::selectTest(const QPointF &pos, bool onlySelectable, QVariant * if (!mParentPlot) return -1; if (onlySelectable && !mSelectableParts.testFlag(spLegendBox)) return -1; - + if (mOuterRect.contains(pos.toPoint())) { if (details) details->setValue(spLegendBox); @@ -18434,16 +18434,16 @@ void QCPLegend::parentPlotInitialized(QCustomPlot *parentPlot) /*! \class QCPPlotTitle \brief A layout element displaying a plot title text - + A simple layout element which shows a text. The text may be specified with \ref setText, the formatting 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 @@ -18453,10 +18453,10 @@ void QCPLegend::parentPlotInitialized(QCustomPlot *parentPlot) /* 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 */ @@ -18464,10 +18464,10 @@ void QCPLegend::parentPlotInitialized(QCustomPlot *parentPlot) /*! 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). */ -QCPPlotTitle::QCPPlotTitle(QCustomPlot *parentPlot) : +QCPPlotTitle::QCPPlotTitle(QCustomPlot *parentPlot) : QCPLayoutElement(parentPlot), mFont(QFont("sans serif", 13*1.5, QFont::Bold)), mTextColor(Qt::black), @@ -18486,7 +18486,7 @@ QCPPlotTitle::QCPPlotTitle(QCustomPlot *parentPlot) : } /*! \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) : @@ -18505,7 +18505,7 @@ QCPPlotTitle::QCPPlotTitle(QCustomPlot *parentPlot, const QString &text) : /*! Sets the text that will be displayed to \a text. Multiple lines can be created by insertion of "\n". - + \see setFont, setTextColor */ void QCPPlotTitle::setText(const QString &text) @@ -18515,7 +18515,7 @@ void QCPPlotTitle::setText(const QString &text) /*! Sets the \a font of the title text. - + \see setTextColor, setSelectedFont */ void QCPPlotTitle::setFont(const QFont &font) @@ -18525,7 +18525,7 @@ void QCPPlotTitle::setFont(const QFont &font) /*! Sets the \a color of the title text. - + \see setFont, setSelectedTextColor */ void QCPPlotTitle::setTextColor(const QColor &color) @@ -18535,7 +18535,7 @@ void QCPPlotTitle::setTextColor(const QColor &color) /*! Sets the \a font of the title text that will be used if the plot title is selected (\ref setSelected). - + \see setFont */ void QCPPlotTitle::setSelectedFont(const QFont &font) @@ -18545,7 +18545,7 @@ void QCPPlotTitle::setSelectedFont(const QFont &font) /*! Sets the \a color of the title text that will be used if the plot title is selected (\ref setSelected). - + \see setTextColor */ void QCPPlotTitle::setSelectedTextColor(const QColor &color) @@ -18567,7 +18567,7 @@ void QCPPlotTitle::setSelectable(bool selectable) /*! Sets the selection state of this plot title to \a selected. If the selection has changed, \ref selectionChanged is emitted. - + Note that this function can change the selection state independently of the current \ref setSelectable state. */ @@ -18646,7 +18646,7 @@ double QCPPlotTitle::selectTest(const QPointF &pos, bool onlySelectable, QVarian Q_UNUSED(details) if (onlySelectable && !mSelectable) return -1; - + if (mTextBoundingRect.contains(pos.toPoint())) return mParentPlot->selectionTolerance()*0.99; else @@ -18654,7 +18654,7 @@ double QCPPlotTitle::selectTest(const QPointF &pos, bool onlySelectable, QVarian } /*! \internal - + Returns the main font to be used. This is mSelectedFont if \ref setSelected is set to true, else mFont is returned. */ @@ -18664,7 +18664,7 @@ QFont QCPPlotTitle::mainFont() const } /*! \internal - + Returns the main color to be used. This is mSelectedTextColor if \ref setSelected is set to true, else mTextColor is returned. */