Kstars
qcustomplot.cpp
32////////////////////////////////////////////////////////////////////////////////////////////////////
34////////////////////////////////////////////////////////////////////////////////////////////////////
77 Returns the angle of the vector in radians. The angle is measured between the positive x line and
99 Returns whether this vector is null. A vector is null if \c qIsNull returns true for both x and y
185 Returns the squared shortest distance of this vector (interpreted as a point) to the finite line
190double QCPVector2D::distanceSquaredToLine(const QCPVector2D &start, const QCPVector2D &end) const
209 Returns the squared shortest distance of this vector (interpreted as a point) to the finite line
225double QCPVector2D::distanceToStraightLine(const QCPVector2D &base, const QCPVector2D &direction) const
277////////////////////////////////////////////////////////////////////////////////////////////////////
279////////////////////////////////////////////////////////////////////////////////////////////////////
284 This QPainter subclass is used to provide some extended functionality e.g. for tweaking position
288 \warning This class intentionally hides non-virtual functions of QPainter, e.g. setPen, save and
290 QPainter pointer, some of the workarounds and tweaks will be unavailable to the function (because
306 Creates a new QCPPainter instance on the specified paint \a device and sets default values. Just
337 Sets the pen (by color) of the painter and applies certain fixes to it, depending on the mode of
351 Sets the pen (by style) of the painter and applies certain fixes to it, depending on the mode of
382 antialiased and non-antialiased painting (Since Qt < 5.0 uses slightly different coordinate systems for
391 if (!mModes.testFlag(pmVectorized)) // antialiasing half-pixel shift only needed for rasterized outputs
411 Sets the QPainter::NonCosmeticDefaultPen in Qt versions before Qt5 after beginning painting on \a
412 device. This is necessary to get cosmetic pen consistency across Qt versions, because since Qt5,
494////////////////////////////////////////////////////////////////////////////////////////////////////
496////////////////////////////////////////////////////////////////////////////////////////////////////
508 clean up if necessary. Before rendering a frame, each paint buffer is usually filled with a color
543 Fills the entire buffer with the provided \a color. To have an empty transparent buffer, use the
546 This method must not be called if there is currently a painter (acquired with \ref startPainting)
570 paint buffer subclasses may use this method to perform any type of cleanup that is necessary. The
579 Subclasses must call their \ref reallocateBuffer implementation in their respective constructors.
595 The buffer is reallocated (by calling \ref reallocateBuffer), so any painters that were obtained
614 layer, i.e. an isolated repaint of only that layer (and its dedicated paint buffer) is requested,
615 QCustomPlot will decide depending on the invalidated flags of other paint buffers whether it also
619 were added or removed from this buffer, or if they were reordered. It is set to false as soon as
631 The ratio is automatically set to the device pixel ratio used by the parent QCustomPlot instance.
633 The buffer is reallocated (by calling \ref reallocateBuffer), so any painters that were obtained
652////////////////////////////////////////////////////////////////////////////////////////////////////
654////////////////////////////////////////////////////////////////////////////////////////////////////
724////////////////////////////////////////////////////////////////////////////////////////////////////
726////////////////////////////////////////////////////////////////////////////////////////////////////
735 The OpenGL paint buffers are used if \ref QCustomPlot::setOpenGl is set to true, and if they are
747QCPPaintBufferGlPbuffer::QCPPaintBufferGlPbuffer(const QSize &size, double devicePixelRatio, int multisamples) :
766 qDebug() << Q_FUNC_INFO << "OpenGL frame buffer object doesn't exist, reallocateBuffer was not called?";
819////////////////////////////////////////////////////////////////////////////////////////////////////
821////////////////////////////////////////////////////////////////////////////////////////////////////
824 \brief A paint buffer based on OpenGL frame buffers objects, using hardware accelerated rendering
830 The OpenGL paint buffers are used if \ref QCustomPlot::setOpenGl is set to true, and if they are
838 All frame buffer objects shall share one OpenGL context and paint device, which need to be set up
843QCPPaintBufferGlFbo::QCPPaintBufferGlFbo(const QSize &size, double devicePixelRatio, QWeakPointer<QOpenGLContext> glContext, QWeakPointer<QOpenGLPaintDevice> glPaintDevice) :
875 qDebug() << Q_FUNC_INFO << "OpenGL frame buffer object doesn't exist, reallocateBuffer was not called?";
908 qDebug() << Q_FUNC_INFO << "OpenGL frame buffer object doesn't exist, reallocateBuffer was not called?";
925 qDebug() << Q_FUNC_INFO << "OpenGL frame buffer object doesn't exist, reallocateBuffer was not called?";
981////////////////////////////////////////////////////////////////////////////////////////////////////
983////////////////////////////////////////////////////////////////////////////////////////////////////
1002 "overlay" (in that order). On top is the "overlay" layer, which only contains the QCustomPlot's
1003 selection rect (\ref QCustomPlot::selectionRect). The next two layers "axes" and "legend" contain
1004 the default axes and legend, so they will be drawn above plottables. In the middle, there is the
1007 layer by default. Then comes the "grid" layer which contains the QCPGrid instances (which belong
1016 you want the layerable to be in, e.g. above "main", with \ref QCustomPlot::addLayer. Then set the
1019 setting. Alternatively you could have also ignored the current layer setting and just moved the
1022 It is also possible to move whole layers. For example, If you want the grid to be shown in front
1029 When a layer is deleted, the objects on it are not deleted with it, but fall on the layer below
1035 layer by calling \ref replot. In certain situations this can provide better replot performance,
1051 Returns the index this layer has in the QCustomPlot. The index is the integer number by which this layer can be
1081 // If child layerables are still on this layer, detach them, so they don't try to reach back to this
1082 // then invalid layer once they get deleted/moved themselves. This only happens when layers are deleted
1083 // directly, like in the QCustomPlot destructor. (The regular layer removal procedure for the user is to
1084 // call QCustomPlot::removeLayer, which moves all layerables off this layer before deleting it.)
1090 qDebug() << Q_FUNC_INFO << "The parent plot's mCurrentLayer will be a dangling pointer. Should have been set to a valid layer or nullptr beforehand.";
1094 Sets whether this layer is visible or not. If \a visible is set to false, all layerables on this
1098 QCPLayerable::setVisible), but the \ref QCPLayerable::realVisibility of each layerable takes the
1113 Layers which are set to \ref lmLogical (the default) are used only to define the rendering order
1120 example would be a layer which contains certain layerables (e.g. items) that need to be changed
1121 and thus replotted regularly, while all other layerables on other layers stay static. By default,
1160 Draws the contents of this layer into the paint buffer which is associated with this layer. The
1161 association is established by the parent QCustomPlot, which manages all paint buffers (see \ref
1186 the layerables on this specific layer, without the need to replot all other layers (as a call to
1189 QCustomPlot also makes sure to replot all layers instead of only this one, if the layer ordering
1193 If the layer mode is \ref lmLogical however, this method simply calls \ref QCustomPlot::replot on
1216 Adds the \a layerable to the list of this layer. If \a prepend is set to true, the layerable will
1242 This function does not change the \a mLayer member of \a layerable. (Use QCPLayerable::setLayer
1258////////////////////////////////////////////////////////////////////////////////////////////////////
1260////////////////////////////////////////////////////////////////////////////////////////////////////
1268 Every layerable is on a layer (QCPLayer) which allows controlling the rendering order by stacking
1279 visibility hierarchies in conjunction with the method \ref realVisibility. This way, layerables
1298 \ref draw is called on the layerable. If the layerable has multiple entities whose antialiasing
1300 most prominent entity. In this case however, the \ref draw function usually calls the specialized
1301 versions of this function before drawing each entity, effectively overriding the setting of the
1304 <b>First example:</b> QCPGraph has multiple entities that have an antialiasing setting: The graph
1306 QCPGraph::setAntialiasedFill and QCPGraph::setAntialiasedScatters. Consequently, there isn't only
1309 QCPGraph::applyScattersAntialiasingHint. So before drawing one of those entities, QCPGraph::draw
1313 setting which can be controlled with QCPItemLine::setAntialiased. (This function is inherited by
1314 all layerables. The specialized functions, as seen on QCPGraph, must be added explicitly to the
1317 care about setting any antialiasing states, because the default antialiasing hint is already set
1318 on the painter when the \ref draw function is called, and that's the state it wants to draw the
1338 This signal is emitted when the layer of this layerable changes, i.e. this layerable is moved to
1349 Since QCPLayerable is an abstract base class, it can't be instantiated directly. Use one of the
1352 If \a plot is provided, it automatically places itself on the layer named \a targetLayer. If \a
1356 It is possible to provide \c nullptr as \a plot. In that case, you should assign a parent plot at
1362 parentLayerable does not become the QObject-parent (for memory management) of this layerable, \a
1363 plot does. It is not uncommon to set the QObject-parent to something else in the constructors of
1366QCPLayerable::QCPLayerable(QCustomPlot *plot, QString targetLayer, QCPLayerable *parentLayerable) :
1393 Sets the visibility of this layerable object. If an object is not visible, it will not be drawn
1403 Sets the \a layer of this layerable object. The object will be placed on top of the other objects
1450 Returns whether this layerable is visible, taking the visibility of the layerable parent and the
1451 visibility of this layerable's layer into account. This is the method that is consulted to decide
1455 subclasses, like in the case of \ref QCPLayoutElement), this function returns true only if this
1456 layerable has its visibility set to true and the parent layerable's \ref realVisibility returns
1461 return mVisible && (!mLayer || mLayer->visible()) && (!mParentLayerable || mParentLayerable.data()->realVisibility());
1469 distance couldn't be determined, -1.0 is returned. Further, if \a onlySelectable is true and the
1474 these cases this function thus returns a constant value greater zero but still below the parent
1482 parent QCustomPlot when the mouseReleaseEvent occurs, and the finally selected object is notified
1489 objects (like QCPAxis). This way, a possibly complex calculation to decide which part was clicked
1494 In the case of 1D Plottables (\ref QCPAbstractPlottable1D, like \ref QCPGraph or \ref QCPBars) \a
1497 You may pass \c nullptr as \a details to indicate that you are not interested in those selection
1503double QCPLayerable::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const
1513 Sets the parent plot of this layerable. Use this function once to set the parent plot if you have
1514 passed \c nullptr in the constructor. It can not be used to move a layerable from one QCustomPlot
1524 The parent plot change will be propagated to subclasses via a call to \ref parentPlotInitialized
1545 Sets the parent layerable of this layerable to \a parentLayerable. Note that \a parentLayerable does not
1549 layerables with a fully visible parent tree will return true for \ref realVisibility, and thus be
1561 Moves this layerable object to \a layer. If \a prepend is true, this object will be prepended to
1594 localAntialiased value as well as the overrides \ref QCustomPlot::setAntialiasedElements and \ref
1595 QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is
1598void QCPLayerable::applyAntialiasingHint(QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
1610 This function is called by \ref initializeParentPlot, to allow subclasses to react on the setting
1611 of a parent plot. This is the case when \c nullptr was passed as parent plot in the constructor,
1615 QCustomPlot at first. When they are then added to a layout inside the QCustomPlot, the top level
1617 propagate the parent plot to all the children of the hierarchy, the top level element then uses
1631 Returns the selection category this layerable shall belong to. The selection category is used in
1647 Returns the clipping rectangle of this layerable object. By default, this is the viewport of the
1665 user. Subclasses should react to it by setting their selection state appropriately. The default
1670 QCustomPlot::setMultiSelectModifier). if \a additive is true, the selection state must be toggled
1673 Every selectEvent is preceded by a call to \ref selectTest, which has returned positively (i.e.
1674 returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot).
1677 selectEvent. Usually \a details is used to transfer which part was clicked, if it is a layerable
1678 that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need
1681 \a selectionStateChanged is an output parameter. If the pointer is non-null, this function must
1682 set the value either to true or false, depending on whether the selection state of this layerable
1683 was actually changed. For layerables that only are selectable as a whole and not in parts, this
1684 is simple: if \a additive is true, \a selectionStateChanged must also be set to true, because the
1685 selection toggles. If \a additive is false, \a selectionStateChanged is only set to true, if the
1690void QCPLayerable::selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
1721 event->pos(). The parameter \a details contains layerable-specific details about the hit, which
1722 were generated in the previous call to \ref selectTest. For example, One-dimensional plottables
1723 like \ref QCPGraph or \ref QCPBars convey the clicked data point in the \a details parameter, as
1728 layerable doesn't reimplement the \ref mousePressEvent or explicitly calls \c event->ignore() in
1729 its reimplementation, the event will be propagated to the next layerable in the stacking order.
1732 will receive all following calls to \ref mouseMoveEvent or \ref mouseReleaseEvent for this mouse
1765 This event gets called when the user releases the mouse button, after this layerable has become
1792 event->pos(). The parameter \a details contains layerable-specific details about the hit, which
1793 were generated in the previous call to \ref selectTest. For example, One-dimensional plottables
1794 like \ref QCPGraph or \ref QCPBars convey the clicked data point in the \a details parameter, as
1798 Similarly to \ref mousePressEvent, once a layerable has accepted the \ref mouseDoubleClickEvent,
1800 and \ref mouseReleaseEvent for this mouse interaction (a "mouse interaction" in this context ends
1822 The \c event->angleDelta() indicates how far the mouse wheel was turned, which is usually +/- 120
1824 accumulate to one event, making the delta larger. On the other hand, if the wheel has very smooth
1841////////////////////////////////////////////////////////////////////////////////////////////////////
1843////////////////////////////////////////////////////////////////////////////////////////////////////
1867 Makes sure \a lower is numerically smaller than \a upper. If this is not the case, the values are
1904 values that will appear in the plot)! It is intended only as a bound to compare against, e.g. to
1913 Larger absolute values would cause errors due to the 11-bit exponent of double precision numbers,
1917 values that will appear in the plot)! It is intended only as a bound to compare against, e.g. to
1949 Expands this range such that \a otherRange is contained in the new range. It is assumed that both
1952 If this range contains NaN as lower or upper bound, it will be replaced by the respective bound
1993 If this range contains NaN as lower or upper bound, the returned range's bound will be taken from
2010 If this range contains NaN as lower or upper bound, the returned range's bound will be set to \a
2023 Returns this range, possibly modified to not exceed the bounds provided as \a lowerBound and \a
2062 \a rangeFac *\a upper, whichever is closer to zero. Same procedure is used if the negative interval
2070 // can't have range spanning negative and positive values in log plot, so change range to fix it
2089 // find out whether negative or positive interval is wider to decide which sign domain will be chosen
2163////////////////////////////////////////////////////////////////////////////////////////////////////
2165////////////////////////////////////////////////////////////////////////////////////////////////////
2170 QCPDataRange holds two integers describing the begin (\ref setBegin) and end (\ref setEnd) index
2171 of a contiguous set of data points. The \a end index corresponds to the data point just after the
2174 Data Ranges are not bound to a certain plottable, thus they can be freely exchanged, created and
2176 used, which holds and manages multiple instances of \ref QCPDataRange. In most situations, \ref
2181 contains. Further, addition and subtraction operators (defined in \ref QCPDataSelection) can be
2182 used to join/subtract data ranges and data selections (or mixtures), to retrieve a corresponding
2185 %QCustomPlot's \ref dataselection "data selection mechanism" is based on \ref QCPDataSelection and
2188 \note Do not confuse \ref QCPDataRange with \ref QCPRange. A \ref QCPRange describes an interval
2209 Sets the begin of this data range. The \a begin index points to the first data point that is part
2229 Returns whether this range is valid. A valid range has a begin index greater or equal to 0, and
2232 \note Invalid ranges should be avoided and are never the result of any of QCustomPlot's methods
2233 (unless they are themselves fed with invalid ranges). Do not pass invalid ranges to QCustomPlot's
2235 invalid begin/end values while manipulating the range. An invalid range is not necessarily empty
2278 This method is very similar to \ref intersection, with one distinction: If this range and the \a
2279 other range share no intersection, the returned data range will be empty with begin and end set
2280 to the respective boundary side of \a other, at which this range is residing. (\ref intersection
2286 if (result.isEmpty()) // no intersection, preserve respective bounding side of otherRange as both begin and end of return value
2307 This method is very similar to \ref bounded, with one distinction: If this range and the \a other
2308 range share no intersection, the returned data range will be empty with begin and end set to 0.
2309 (\ref bounded would return a range with begin and end set to one of the boundaries of \a other,
2346////////////////////////////////////////////////////////////////////////////////////////////////////
2348////////////////////////////////////////////////////////////////////////////////////////////////////
2353 QCPDataSelection manages multiple instances of QCPDataRange in order to represent any (possibly
2358 \ref clear. Read access is provided by \ref dataRange, \ref dataRanges, \ref dataRangeCount, etc.
2363 addDataRange, with the parameter \a simplify explicitly set to false. This is useful if many data
2368 Use \ref enforceType to bring the data selection into a state complying with the constraints for
2387 Returns the number of ranges that make up the data selection. The ranges can be accessed by \ref
2395 Returns all data ranges that make up the data selection. If the data selection is simplified (the
2396 usual state of the selection, see \ref simplify), the ranges are sorted by ascending data point
2431 Note that both data selections must be in simplified state (the usual state of the selection, see
2458 Adds the data range \a other to this data selection, and then simplifies this data selection (see
2493 break; // since data ranges are sorted after the simplify() call, no ranges which contain other will come after this
2495 if (thisEnd > other.begin()) // ranges which don't fulfill this are entirely before other and can be ignored
2571 performance if adding a very large amount of data ranges successively. In this case, make sure to
2592 Sorts all data ranges by range begin index in ascending order, and then joins directly adjacent
2593 or overlapping ranges. This can reduce the number of individual data ranges in the selection, and
2596 This method is automatically called when using the addition/subtraction operators. The only case
2597 when \ref simplify is left to the user, is when calling \ref addDataRange, with the parameter \a
2628 Makes sure this data selection conforms to the specified \a type selection type. Before the type
2631 Depending on \a type, enforcing means adding new data points that were previously not part of the
2632 selection, or removing data points from the selection. If the current selection already conforms
2649 // whole selection isn't defined by data range, so don't change anything (is handled in plottable methods)
2701 Returns a data selection containing the points which are both in this data selection and in the
2704 A common use case is to limit an unknown data selection to the valid range of a data container,
2705 using \ref QCPDataContainer::dataRange as \a other. One can then safely iterate over the returned
2718 Returns a data selection containing the points which are both in this data selection and in the
2735 For example, this method can be used to retrieve all unselected segments by setting \a outerRange
2736 to the full data range of the plottable, and calling this method on a data selection holding the
2751 result.addDataRange(QCPDataRange(mDataRanges.at(i-1).end(), mDataRanges.at(i).begin()), false);
2764////////////////////////////////////////////////////////////////////////////////////////////////////
2766////////////////////////////////////////////////////////////////////////////////////////////////////
2774 according rect shape is drawn. At the begin, during, and after completion of the interaction, it
2777 The QCustomPlot instance connects own slots to the current selection rect instance, in order to
2785 If you wish to provide custom behaviour, e.g. a different visual representation of the selection
2814 Note that \a rect may have a negative width or height, if the selection is being dragged to the
2823 The user may cancel the selection interaction by pressing the escape key. In this case, \a event
2826 Note that \a rect may have a negative width or height, if the selection is being dragged to the
2835 Note that \a rect may have a negative width or height, if the selection is being dragged to the
2889 Sets the brush that will be used to fill the selection rect. By default the selection rect is not
2914 This method is called by QCustomPlot to indicate that a selection rect interaction was initiated.
2927 This method is called by QCustomPlot to indicate that an ongoing selection rect interaction needs
2940 This method is called by QCustomPlot to indicate that an ongoing selection rect interaction has
2953 This method is called by QCustomPlot when a key has been pressed by the user while the selection
2954 rect interaction is active. The default implementation allows to \ref cancel the interaction by
2993////////////////////////////////////////////////////////////////////////////////////////////////////
2995////////////////////////////////////////////////////////////////////////////////////////////////////
2998 \brief A margin group allows synchronization of margin sides if working with multiple layout elements.
3000 QCPMarginGroup allows you to tie a margin side of two or more layout elements together, such that
3008 layout elements. For example, if one QCPAxisRect is below another one in a grid layout, it will
3009 provide a cleaner look to the user if the left and right margins of the two axis rects are of the
3010 same size. The left axis of the top axis rect will then be at the same horizontal position as the
3015 QCPLayoutElement::setMarginGroup method. To completely break apart the margin group, either call
3032 Returns a list of all layout elements that have their margin \a side associated with this margin
3057 Returns whether this margin group is empty. If this function returns true, no layout elements use
3073 Clears this margin group. The synchronization of the margin sides that use this margin group is
3091 Returns the synchronized common margin for \a side. This is the margin value that will be used by
3096 group, and choosing the largest returned value. (QCPLayoutElement::minimumMargins is taken into
3141////////////////////////////////////////////////////////////////////////////////////////////////////
3143////////////////////////////////////////////////////////////////////////////////////////////////////
3146 \brief The abstract base class for all objects that form \ref thelayoutsystem "the layout system".
3148 This is an abstract base class. As such, it can't be instantiated directly, rather use one of its subclasses.
3152 between outer and inner rect is called its margin. The margin can either be set to automatic or
3153 manual (\ref setAutoMargins) on a per-side basis. If a side is set to manual, that margin can be
3154 set explicitly with \ref setMargins and will stay fixed at that value. If it's set to automatic,
3157 Layout elements can be placed in layouts (base class QCPLayout) like QCPLayoutGrid. The top level
3165 something. For example, QCPAxisRect, QCPLegend and QCPTextElement are of this category. This does
3180 Returns the inner rect of this layout element. The inner rect is the outer rect (\ref outerRect, \ref
3184 area is used to display peripheral graphics while the main content is in the inner rect. This is
3195 Returns the outer rect of this layout element. The outer rect is the inner rect expanded by the
3208 QCPLayerable(parentPlot), // parenthood is changed as soon as layout element gets inserted into a layout (except for top level layout)
3225 if (qobject_cast<QCPLayout*>(mParentLayout)) // the qobject_cast is just a safeguard in case the layout forgets to call clear() in its dtor and this dtor is called by QObject dtor
3230 Sets the outer rect of this layout element. If the layout element is inside a layout, the layout
3236 The layout element will adapt its inner \ref rect by applying the margins inward to the outer rect.
3251 sides, this function is used to manually set the margin on those sides. Sides that are still set
3273 The minimum values are not enforced on margin sides that were set to be under manual control via
3288 automatically, a minimum margin value may be provided with \ref setMinimumMargins. If a side is
3291 Margin sides that are under automatic control may participate in a \ref QCPMarginGroup (see \ref
3302 Sets the minimum size of this layout element. A parent layout tries to respect the \a size here
3305 If the parent layout size is not sufficient to satisfy all minimum size constraints of its child
3307 propagates the layout's size constraints to the outside by setting its own minimum QWidget size
3336 Sets the maximum size of this layout element. A parent layout tries to respect the \a size here
3368 The outer rect (\ref outerRect) includes the margins (e.g. in the case of a QCPAxisRect the axis
3386 Margin groups allow synchronizing specified margins across layout elements, see the documentation
3425 Updates the layout element and sub-elements. This function is automatically called before every
3427 UpdatePhase. The phases are run through in the order of the enum values. For details about what
3433 The default implementation executes the automatic margin mechanism in the \ref upMargins phase.
3442 // set the margins of this layout element according to automatic margin calculation, either directly or via a margin group:
3444 const QList<QCP::MarginSide> allMarginSides = QList<QCP::MarginSide>() << QCP::msLeft << QCP::msRight << QCP::msTop << QCP::msBottom;
3450 QCP::setMarginValue(newMargins, side, mMarginGroups[side]->commonMargin(side)); // this side is part of a margin group, so get the margin value from that group
3452 QCP::setMarginValue(newMargins, side, calculateAutoMargin(side)); // this side is not part of a group, so calculate the value directly
3464 Returns the suggested minimum size this layout element (the \ref outerRect) may be compressed to,
3467 if a minimum size (\ref setMinimumSize) was not set manually, parent layouts use the returned size
3473 The default implementation simply returns the sum of the horizontal margins for the width and the
3483 Returns the suggested maximum size this layout element (the \ref outerRect) may be expanded to,
3492 The default implementation simply returns \c QWIDGETSIZE_MAX for both width and height, implying
3522 QCPLayoutElement subclasses may reimplement this method to provide more specific selection test
3525double QCPLayoutElement::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const
3561 Returns the margin size for this \a side. It is used if automatic margins is enabled for this \a
3588////////////////////////////////////////////////////////////////////////////////////////////////////
3590////////////////////////////////////////////////////////////////////////////////////////////////////
3595 This is an abstract base class for layout elements whose main purpose is to define the position
3601 QCPLayout introduces a common interface for accessing and manipulating the child elements. Those
3603 simplify, \ref removeAt, \ref remove and \ref clear. Individual subclasses may add more functions
3605 QCPLayoutGrid adds functions that take row and column indices to access cells of the layout grid
3630 QCPLayoutGrid), so this function may return \c nullptr in those cases. You may use this function
3642 Note that some layouts don't remove the respective cell right away but leave an empty cell after
3654 Note that some layouts don't remove the respective cell right away but leave an empty cell after
3729 Removes and deletes the element at the provided \a index. Returns true on success. If \a index is
3732 This function internally uses \ref takeAt to remove the element from the layout and then deletes
3733 the returned element. Note that some layouts don't remove the respective cell right away but leave an
3750 Removes and deletes the provided \a element. Returns true on success. If \a element is not in the
3753 This function internally uses \ref takeAt to remove the element from the layout and then deletes
3771 Removes and deletes all layout elements in this layout. Finally calls \ref simplify to make sure
3790 sizeConstraintsChanged. If the parent is a QWidget (i.e. is the \ref QCustomPlot::plotLayout of
3791 QCustomPlot), calls QWidget::updateGeometry, so if the QCustomPlot widget is inside a Qt QLayout,
3804 Subclasses reimplement this method to update the position and sizes of the child elements/cells
3805 via calling their \ref QCPLayoutElement::setOuterRect. The default implementation does nothing.
3807 The geometry used as a reference is the inner \ref rect of this layout. Child elements should stay
3821 Associates \a el with this layout. This is done by setting the \ref QCPLayoutElement::layout, the
3827 This method is used by subclass specific methods that add elements to the layout. Note that this
3828 method only changes properties in \a el. The removal from the old layout and the insertion into
3847 Disassociates \a el from this layout. This is done by setting the \ref QCPLayoutElement::layout
3851 This method is used by subclass specific methods that remove elements from the layout (e.g. \ref
3871 It calculates the sizes of one-dimensional sections with provided constraints on maximum section
3872 sizes, minimum section sizes, relative stretch factors and the final total size of all sections.
3880 imposed, set all vector values to zero. If the \a minSizes entries add up to a value greater than
3881 \a totalSize, sections will be scaled smaller than the proposed minimum sizes. (In other words,
3882 not exceeding the allowed total size is taken to be more important than not going below minimum
3886 shall be scaled equally, set all values equal. If the first section shall be double the size of
3887 each individual other section, set the first number of \a stretchFactors to double the value of
3896QVector<int> QCPLayout::getSectionSizes(QVector<int> maxSizes, QVector<int> minSizes, QVector<double> stretchFactors, int totalSize) const
3900 qDebug() << Q_FUNC_INFO << "Passed vector sizes aren't equal:" << maxSizes << minSizes << stretchFactors;
3907 // if provided total size is forced smaller than total minimum size, ignore minimum sizes (squeeze sections):
3928 while (!unfinishedSections.isEmpty() && outerIterations < sectionCount*2) // the iteration check ist just a failsafe in case something really strange happens
3932 while (!unfinishedSections.isEmpty() && innerIterations < sectionCount*2) // the iteration check ist just a failsafe in case something really strange happens
3947 // check if that maximum is actually within the bounds of the total size (i.e. can we stretch all remaining sections so far that the found section
3953 if (nextMax < nextMaxLimit) // next maximum is actually hit, move forward to that point and fix the size of that section
3960 unfinishedSections.removeOne(nextId); // exclude the section that is now at maximum from further changes
3969 qDebug() << Q_FUNC_INFO << "Exceeded maximum expected inner iteration count, layouting aborted. Input was:" << maxSizes << minSizes << stretchFactors << totalSize;
3989 if (!minimumLockedSections.contains(i)) // only put sections that haven't hit their minimum back into the pool
3992 freeSize -= sectionSizes.at(i); // remove size of minimum locked sections from available space in next round
3994 // reset all section sizes to zero that are in unfinished sections (all others have been set to their minimum):
4012 It returns the minimum size that should finally be used for the outer rect of the passed layout
4017 QCPLayoutElement::setSizeConstraintRect), as well as the minimum size hint, if no manual minimum
4023 QSize minOuter = el->minimumSize(); // depending on sizeConstraitRect this might be with respect to inner rect, so possibly add margins in next four lines (preserving unset minimum of 0)
4037 It returns the maximum size that should finally be used for the outer rect of the passed layout
4042 QCPLayoutElement::setSizeConstraintRect), as well as the maximum size hint, if no manual maximum
4048 QSize maxOuter = el->maximumSize(); // depending on sizeConstraitRect this might be with respect to inner rect, so possibly add margins in next four lines (preserving unset maximum of QWIDGETSIZE_MAX)
4049 if (maxOuter.width() < QWIDGETSIZE_MAX && el->sizeConstraintRect() == QCPLayoutElement::scrInnerRect)
4051 if (maxOuter.height() < QWIDGETSIZE_MAX && el->sizeConstraintRect() == QCPLayoutElement::scrInnerRect)
4059////////////////////////////////////////////////////////////////////////////////////////////////////
4061////////////////////////////////////////////////////////////////////////////////////////////////////
4066 Elements are laid out in a grid with configurable stretch factors (\ref setColumnStretchFactor,
4069 Elements can be added to cells via \ref addElement. The grid is expanded if the specified row or
4070 column doesn't exist yet. Whether a cell contains a valid layout element can be checked with \ref
4071 hasElement, that element can be retrieved with \ref element. If rows and columns that only have
4077 column, the grid layout will choose the position according to the current \ref setFillOrder and
4114 // clear all child layout elements. This is important because only the specific layouts know how
4122 Returns \c nullptr if either the row/column is invalid or if the cell is empty. In those cases, a
4123 qDebug message is printed. To check whether a cell exists and isn't empty, use \ref hasElement.
4147 Adds the \a element to cell with \a row and \a column. If \a element is already in a layout, it
4154 Use the overload of this method without explicit row/column index to place the element according
4216 Returns whether the cell at \a row and \a column exists and contains a valid element, i.e. isn't
4232 Stretch factors control the relative sizes of rows and columns. Cells will not be resized beyond
4256 Stretch factors control the relative sizes of rows and columns. Cells will not be resized beyond
4274 qDebug() << Q_FUNC_INFO << "Invalid stretch factor, must be positive:" << mColumnStretchFactors.at(i);
4285 Stretch factors control the relative sizes of rows and columns. Cells will not be resized beyond
4309 Stretch factors control the relative sizes of rows and columns. Cells will not be resized beyond
4357 addElement(QCPLayoutElement*) will start to fill the next row or column, respectively. It depends
4363 rearrange set to true (the actual fill order doesn't need to be changed for the rearranging to be
4381 The specified \a order defines whether rows or columns are filled first. Using \ref setWrap, you
4382 can control at which row/column count wrapping into the next column/row will occur. If you set it
4387 If you want to have all current elements arranged in the new order, set \a rearrange to true. The
4428 Expands the layout to have \a newRowCount rows and \a newColumnCount columns. So the last valid
4431 If the current column/row count is already larger or equal to \a newColumnCount/\a newRowCount,
4488 newIndex range from 0 (inserts a column at the left) to \a columnCount (appends a column at the
4516 indices increase left to right and then top to bottom. If it is \ref foColumnsFirst, the indices
4519 For the returned index to be valid, \a row and \a column must be valid indices themselves, i.e.
4547 indices increase left to right and then top to bottom. If it is \ref foColumnsFirst, the indices
4597 QVector<int> colWidths = getSectionSizes(maxColWidths, minColWidths, mColumnStretchFactors.toVector(), mRect.width()-totalColSpacing);
4598 QVector<int> rowHeights = getSectionSizes(maxRowHeights, minRowHeights, mRowStretchFactors.toVector(), mRect.height()-totalRowSpacing);
4799void QCPLayoutGrid::getMinimumRowColSizes(QVector<int> *minColWidths, QVector<int> *minRowHeights) const
4825 row. The maximum width of a column is the smallest maximum width of any element's outer rect in
4832void QCPLayoutGrid::getMaximumRowColSizes(QVector<int> *maxColWidths, QVector<int> *maxRowHeights) const
4853////////////////////////////////////////////////////////////////////////////////////////////////////
4855////////////////////////////////////////////////////////////////////////////////////////////////////
4864 addElement(QCPLayoutElement *element, const QRectF &rect). If the first method is used, the inset
4865 placement will default to \ref ipBorderAligned and the element will be aligned according to the
4866 \a alignment parameter. The second method defaults to \ref ipFree and allows placing elements at
4869 The alignment or rect can be set via \ref setInsetAlignment or \ref setInsetRect, respectively.
4893 // clear all child layout elements. This is important because only the specific layouts know how
4976 If the inset placement (\ref setInsetPlacement) is \ref ipFree, this function is used to set the
4979 \a rect is given in fractions of the whole inset layout rect. So an inset with rect (0, 0, 1, 1)
4980 will span the entire layout. An inset with rect (0.6, 0.1, 0.35, 0.35) will be in the top right
5023 else insetRect.moveLeft(int( rect().x()+rect().width()*0.5-finalMinSize.width()*0.5 )); // default to Qt::AlignHCenter
5026 else insetRect.moveTop(int( rect().y()+rect().height()*0.5-finalMinSize.height()*0.5 )); // default to Qt::AlignVCenter
5029 }
5030}
5086 sensitive. If the selectTest method of any of the child elements returns a positive number for \a
5088 tolerance. The inset layout is not selectable itself by default. So if \a onlySelectable is true,
5093double QCPLayoutInset::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const
5140 \a rect is given in fractions of the whole inset layout rect. So an inset with rect (0, 0, 1, 1)
5141 will span the entire layout. An inset with rect (0.6, 0.1, 0.35, 0.35) will be in the top right
5166////////////////////////////////////////////////////////////////////////////////////////////////////
5168////////////////////////////////////////////////////////////////////////////////////////////////////
5175 For every ending a line-like item has, an instance of this class exists. For example, QCPItemLine
5178 The styles themselves are defined via the enum QCPLineEnding::EndingStyle. Most decorations can
5180 the ending decoration (e.g. direction an arrow is pointing) is controlled by the line-like item.
5181 For example, when both endings of a QCPItemLine are set to be arrows, they will point to opposite
5204QCPLineEnding::QCPLineEnding(QCPLineEnding::EndingStyle style, double width, double length, bool inverted) :
5232 Sets the length of the ending decoration, if the style supports it. On arrows, for example, the
5243 Sets whether the ending decoration shall be inverted. For example, an arrow decoration will point
5246 Note that also the \a width direction is inverted. For symmetrical ending styles like arrows or
5260 This is relevant for clipping. Only omit painting of the decoration when the position where the
5293 both have the same \ref setLength value, because the spike arrow has an inward curved back, which
5326 Draws the line ending with the specified \a painter at the position \a pos. The direction of the
5329void QCPLineEnding::draw(QCPPainter *painter, const QCPVector2D &pos, const QCPVector2D &dir) const
5435 if (!qFuzzyIsNull(painter->pen().widthF()) || painter->modes().testFlag(QCPPainter::pmNonCosmetic))
5461////////////////////////////////////////////////////////////////////////////////////////////////////
5463////////////////////////////////////////////////////////////////////////////////////////////////////
5573void QCPLabelPainterPrivate::drawTickLabel(QCPPainter *painter, const QPointF &tickPos, const QString &text)
5578 // for circular axes, the anchor side is determined depending on the quadrant of tickPos with respect to mCircularReference
5582 } else if (mAnchorMode == amSkewedRotated) // in this mode every label is individually rotated to match circle tangent
5590 realSide = rotationCorrectedSide(realSide, realRotation); // rotation angles may change the true anchor side of the label
5591 drawLabelMaybeCached(painter, mFont, mColor, getAnchorPos(tickPos), realSide, realRotation, text);
5596 Returns the size ("margin" in QCPAxisRect context, so measured perpendicular to the axis backbone
5615 result += QCPAxis::orientation(type) == Qt::Horizontal ? tickLabelsSize.height() : tickLabelsSize.width();
5620 // calculate size of axis label (only height needed, because left/right labels are rotated by 90 degrees):
5625 bounds = fontMetrics.boundingRect(0, 0, 0, 0, Qt::TextDontClip | Qt::AlignHCenter | Qt::AlignVCenter, label);
5636 method is called automatically if any parameters have changed that invalidate the cached labels,
5648 return value of this method hasn't changed since the last redraw, the respective label parameters
5670 for the bottom axis, \a position would indicate the horizontal pixel position (not coordinate),
5673 In order to later draw the axis label in a place that doesn't overlap with the tick labels, the