A plottable representing a graph in a plot. More...
Public Types | |
enum | LineStyle |
Public Functions | |
QCPGraph (QCPAxis *keyAxis, QCPAxis *valueAxis) | |
QSharedPointer< QCPGraphDataContainer > | data () const |
LineStyle | lineStyle () const |
QCPScatterStyle | scatterStyle () const |
int | scatterSkip () const |
QCPGraph * | channelFillGraph () const |
bool | adaptiveSampling () const |
void | setData (QSharedPointer< QCPGraphDataContainer > data) |
void | setData (const QVector< double > &keys, const QVector< double > &values, bool alreadySorted=false) |
void | setLineStyle (LineStyle ls) |
void | setScatterStyle (const QCPScatterStyle &style) |
void | setScatterSkip (int skip) |
void | setChannelFillGraph (QCPGraph *targetGraph) |
void | setAdaptiveSampling (bool enabled) |
void | addData (const QVector< double > &keys, const QVector< double > &values, bool alreadySorted=false) |
void | addData (double key, double value) |
virtual double | selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const |
virtual QCPRange | getKeyRange (bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const |
virtual QCPRange | getValueRange (bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const |
Public Functions inherited from QCPAbstractPlottable1D< QCPGraphData > | |
QCPAbstractPlottable1D (QCPAxis *keyAxis, QCPAxis *valueAxis) | |
virtual int | dataCount () const |
virtual double | dataMainKey (int index) const |
virtual double | dataSortKey (int index) const |
virtual double | dataMainValue (int index) const |
virtual QCPRange | dataValueRange (int index) const |
virtual QPointF | dataPixelPosition (int index) const |
virtual bool | sortKeyIsMainKey () const |
virtual QCPDataSelection | selectTestRect (const QRectF &rect, bool onlySelectable) const |
virtual int | findBegin (double sortKey, bool expandedRange=true) const |
virtual int | findEnd (double sortKey, bool expandedRange=true) const |
virtual QCPPlottableInterface1D * | interface1D () |
Public Functions inherited from QCPAbstractPlottable | |
QCPAbstractPlottable (QCPAxis *keyAxis, QCPAxis *valueAxis) | |
QString | name () const |
bool | antialiasedFill () const |
bool | antialiasedScatters () const |
QPen | pen () const |
QBrush | brush () const |
QCPAxis * | keyAxis () const |
QCPAxis * | valueAxis () const |
QCP::SelectionType | selectable () const |
bool | selected () const |
QCPDataSelection | selection () const |
QCPSelectionDecorator * | selectionDecorator () const |
void | setName (const QString &name) |
void | setAntialiasedFill (bool enabled) |
void | setAntialiasedScatters (bool enabled) |
void | setPen (const QPen &pen) |
void | setBrush (const QBrush &brush) |
void | setKeyAxis (QCPAxis *axis) |
void | setValueAxis (QCPAxis *axis) |
Q_SLOT void | setSelectable (QCP::SelectionType selectable) |
Q_SLOT void | setSelection (QCPDataSelection selection) |
void | setSelectionDecorator (QCPSelectionDecorator *decorator) |
void | coordsToPixels (double key, double value, double &x, double &y) const |
const QPointF | coordsToPixels (double key, double value) const |
void | pixelsToCoords (double x, double y, double &key, double &value) const |
void | pixelsToCoords (const QPointF &pixelPos, double &key, double &value) const |
void | rescaleAxes (bool onlyEnlarge=false) const |
void | rescaleKeyAxis (bool onlyEnlarge=false) const |
void | rescaleValueAxis (bool onlyEnlarge=false, bool inKeyRange=false) const |
bool | addToLegend (QCPLegend *legend) |
bool | addToLegend () |
bool | removeFromLegend (QCPLegend *legend) const |
bool | removeFromLegend () const |
Public Functions inherited from QCPLayerable | |
QCPLayerable (QCustomPlot *plot, QString targetLayer=QString(), QCPLayerable *parentLayerable=nullptr) | |
bool | visible () const |
QCustomPlot * | parentPlot () const |
QCPLayerable * | parentLayerable () const |
QCPLayer * | layer () const |
bool | antialiased () const |
void | setVisible (bool on) |
Q_SLOT bool | setLayer (QCPLayer *layer) |
bool | setLayer (const QString &layerName) |
void | setAntialiased (bool enabled) |
bool | realVisibility () const |
Protected Functions | |
virtual void | draw (QCPPainter *painter) |
virtual void | drawLegendIcon (QCPPainter *painter, const QRectF &rect) const |
virtual void | drawFill (QCPPainter *painter, QVector< QPointF > *lines) const |
virtual void | drawScatterPlot (QCPPainter *painter, const QVector< QPointF > &scatters, const QCPScatterStyle &style) const |
virtual void | drawLinePlot (QCPPainter *painter, const QVector< QPointF > &lines) const |
virtual void | drawImpulsePlot (QCPPainter *painter, const QVector< QPointF > &lines) const |
virtual void | getOptimizedLineData (QVector< QCPGraphData > *lineData, const QCPGraphDataContainer::const_iterator &begin, const QCPGraphDataContainer::const_iterator &end) const |
virtual void | getOptimizedScatterData (QVector< QCPGraphData > *scatterData, QCPGraphDataContainer::const_iterator begin, QCPGraphDataContainer::const_iterator end) const |
void | getVisibleDataBounds (QCPGraphDataContainer::const_iterator &begin, QCPGraphDataContainer::const_iterator &end, const QCPDataRange &rangeRestriction) const |
void | getLines (QVector< QPointF > *lines, const QCPDataRange &dataRange) const |
void | getScatters (QVector< QPointF > *scatters, const QCPDataRange &dataRange) const |
QVector< QPointF > | dataToLines (const QVector< QCPGraphData > &data) const |
QVector< QPointF > | dataToStepLeftLines (const QVector< QCPGraphData > &data) const |
QVector< QPointF > | dataToStepRightLines (const QVector< QCPGraphData > &data) const |
QVector< QPointF > | dataToStepCenterLines (const QVector< QCPGraphData > &data) const |
QVector< QPointF > | dataToImpulseLines (const QVector< QCPGraphData > &data) const |
QVector< QCPDataRange > | getNonNanSegments (const QVector< QPointF > *lineData, Qt::Orientation keyOrientation) const |
QVector< QPair< QCPDataRange, QCPDataRange > > | getOverlappingSegments (QVector< QCPDataRange > thisSegments, const QVector< QPointF > *thisData, QVector< QCPDataRange > otherSegments, const QVector< QPointF > *otherData) const |
bool | segmentsIntersect (double aLower, double aUpper, double bLower, double bUpper, int &bPrecedence) const |
QPointF | getFillBasePoint (QPointF matchingDataPoint) const |
const QPolygonF | getFillPolygon (const QVector< QPointF > *lineData, QCPDataRange segment) const |
const QPolygonF | getChannelFillPolygon (const QVector< QPointF > *thisData, QCPDataRange thisSegment, const QVector< QPointF > *otherData, QCPDataRange otherSegment) const |
int | findIndexBelowX (const QVector< QPointF > *data, double x) const |
int | findIndexAboveX (const QVector< QPointF > *data, double x) const |
int | findIndexBelowY (const QVector< QPointF > *data, double y) const |
int | findIndexAboveY (const QVector< QPointF > *data, double y) const |
double | pointDistance (const QPointF &pixelPoint, QCPGraphDataContainer::const_iterator &closestData) const |
Protected Functions inherited from QCPAbstractPlottable1D< QCPGraphData > | |
void | getDataSegments (QList< QCPDataRange > &selectedSegments, QList< QCPDataRange > &unselectedSegments) const |
void | drawPolyline (QCPPainter *painter, const QVector< QPointF > &lineData) const |
Protected Functions inherited from QCPAbstractPlottable | |
virtual QRect | clipRect () const |
virtual QCP::Interaction | selectionCategory () const |
void | applyDefaultAntialiasingHint (QCPPainter *painter) const |
virtual void | selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) |
virtual void | deselectEvent (bool *selectionStateChanged) |
void | applyFillAntialiasingHint (QCPPainter *painter) const |
void | applyScattersAntialiasingHint (QCPPainter *painter) const |
Protected Functions inherited from QCPLayerable | |
virtual void | parentPlotInitialized (QCustomPlot *parentPlot) |
virtual void | mousePressEvent (QMouseEvent *event, const QVariant &details) |
virtual void | mouseMoveEvent (QMouseEvent *event, const QPointF &startPos) |
virtual void | mouseReleaseEvent (QMouseEvent *event, const QPointF &startPos) |
virtual void | mouseDoubleClickEvent (QMouseEvent *event, const QVariant &details) |
virtual void | wheelEvent (QWheelEvent *event) |
void | initializeParentPlot (QCustomPlot *parentPlot) |
void | setParentLayerable (QCPLayerable *parentLayerable) |
bool | moveToLayer (QCPLayer *layer, bool prepend) |
void | applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const |
Additional Inherited Members | |
Signals inherited from QCPAbstractPlottable | |
void | selectionChanged (bool selected) |
void | selectionChanged (const QCPDataSelection &selection) |
void | selectableChanged (QCP::SelectionType selectable) |
Signals inherited from QCPLayerable | |
void | layerChanged (QCPLayer *newLayer) |
A plottable representing a graph in a plot.
Usually you create new graphs by calling QCustomPlot::addGraph. The resulting instance can be accessed via QCustomPlot::graph.
To plot data, assign it with the setData or addData functions. Alternatively, you can also access and modify the data via the data method, which returns a pointer to the internal QCPGraphDataContainer.
Graphs are used to display single-valued data. Single-valued means that there should only be one data point per unique key coordinate. In other words, the graph can't have loops. If you do want to plot non-single-valued curves, rather use the QCPCurve plottable.
Gaps in the graph line can be created by adding data points with NaN as value (qQNaN()
or std::numeric_limits<double>::quiet_NaN()
) in between the two data points that shall be separated.
The appearance of the graph is mainly determined by the line style, scatter style, brush and pen of the graph (setLineStyle, setScatterStyle, setBrush, setPen).
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 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 setChannelFillGraph with the other graph as parameter.
enum QCPGraph::LineStyle |
Defines how the graph's line is represented visually in the plot. The line is drawn with the current pen of the graph (setPen).
Enumerator | |
---|---|
lsNone | data points are not connected with any lines (e.g. data only represented with symbols according to the scatter style, see setScatterStyle) |
lsLine | data points are connected by a straight line |
lsStepLeft | line is drawn as steps where the step height is the value of the left data point |
lsStepRight | line is drawn as steps where the step height is the value of the right data point |
lsStepCenter | line is drawn as steps where the step is in between two data points |
lsImpulse | each data point is represented by a line parallel to the value axis, which reaches from the data point to the zero-value-line |
Constructs a graph which uses keyAxis as its key axis ("x") and valueAxis as its value axis ("y"). keyAxis and 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 created QCPGraph is automatically registered with the QCustomPlot instance inferred from keyAxis. This QCustomPlot instance takes ownership of the QCPGraph, so do not delete it manually but use QCustomPlot::removePlottable() instead.
To directly create a graph inside a plot, you can also use the simpler QCustomPlot::addGraph function.
|
inline |
Returns a shared pointer to the internal data storage of type QCPGraphDataContainer. You may use it to directly manipulate the data, which may be more convenient and faster than using the regular setData or addData methods.
void QCPGraph::setData | ( | QSharedPointer< QCPGraphDataContainer > | data | ) |
This is an overloaded function.
Replaces the current data container with the provided data container.
Since a QSharedPointer is used, multiple QCPGraphs may share the same data container safely. Modifying the data in the container will then affect all graphs that share the container. Sharing can be achieved by simply exchanging the data containers wrapped in shared pointers:
If you do not wish to share containers, but create a copy from an existing container, rather use the QCPDataContainer<DataType>::set method on the graph's data container directly:
void QCPGraph::setData | ( | const QVector< double > & | keys, |
const QVector< double > & | values, | ||
bool | alreadySorted = false |
||
) |
This is an overloaded function.
Replaces the current data with the provided points in keys and values. The provided vectors should have equal length. Else, the number of added points will be the size of the smallest vector.
If you can guarantee that the passed data points are sorted by keys in ascending order, you can set alreadySorted to true, to improve performance by saving a sorting run.
void QCPGraph::setLineStyle | ( | LineStyle | ls | ) |
Sets how the single data points are connected in the plot. For scatter-only plots, set ls to lsNone and setScatterStyle to the desired scatter style.
void QCPGraph::setScatterStyle | ( | const QCPScatterStyle & | style | ) |
Sets the visual appearance of single data points in the plot. If set to QCPScatterStyle::ssNone, no scatter points are drawn (e.g. for line-only-plots with appropriate line style).
void QCPGraph::setScatterSkip | ( | int | skip | ) |
If scatters are displayed (scatter style not QCPScatterStyle::ssNone), skip number of scatter points are skipped/not drawn after every drawn scatter point.
This can be used to make the data appear sparser while for example still having a smooth line, and to improve performance for very high density plots.
If skip is set to 0 (default), all scatter points are drawn.
void QCPGraph::setChannelFillGraph | ( | QCPGraph * | targetGraph | ) |
void QCPGraph::setAdaptiveSampling | ( | bool | enabled | ) |
Sets whether adaptive sampling shall be used when plotting this graph. QCustomPlot's adaptive sampling technique can drastically improve the replot performance for graphs with a larger number of points (e.g. above 10,000), without notably changing the appearance of the graph.
By default, adaptive sampling is enabled. Even if enabled, QCustomPlot decides whether adaptive sampling shall actually be used on a per-graph basis. So leaving adaptive sampling enabled has no disadvantage in almost all cases.
As can be seen, line plots experience no visual degradation from adaptive sampling. Outliers are reproduced reliably, as well as the overall shape of the data set. The replot time reduces dramatically though. This allows QCustomPlot to display large amounts of data in realtime.
Care must be taken when using high-density scatter plots in combination with adaptive sampling. The adaptive sampling algorithm treats scatter plots more carefully than line plots which still gives a significant reduction of replot times, but not quite as much as for line plots. This is because scatter plots inherently need more data points to be preserved in order to still resemble the original, non-adaptive-sampling plot. As shown above, the results still aren't quite identical, as banding occurs for the outer data points. This is in fact intentional, such that the boundaries of the data cloud stay visible to the viewer. How strong the banding appears, depends on the point density, i.e. the number of points in the plot.
For some situations with scatter plots it might thus be desirable to manually turn adaptive sampling off. For example, when saving the plot to disk. This can be achieved by setting enabled to false before issuing a command like QCustomPlot::savePng, and setting enabled back to true afterwards.
void QCPGraph::addData | ( | const QVector< double > & | keys, |
const QVector< double > & | values, | ||
bool | alreadySorted = false |
||
) |
This is an overloaded function.
Adds the provided points in keys and values to the current data. The provided vectors should have equal length. Else, the number of added points will be the size of the smallest vector.
If you can guarantee that the passed data points are sorted by keys in ascending order, you can set alreadySorted to true, to improve performance by saving a sorting run.
Alternatively, you can also access and modify the data directly via the data method, which returns a pointer to the internal data container.
void QCPGraph::addData | ( | double | key, |
double | value | ||
) |
This is an overloaded function.
Adds the provided data point as key and value to the current data.
Alternatively, you can also access and modify the data directly via the data method, which returns a pointer to the internal data container.
|
virtual |
Implements a selectTest specific to this plottable's point geometry.
If details is not 0, it will be set to a QCPDataSelection, describing the closest data point to pos.
For general information about this virtual method, see the base class implementation. QCPAbstractPlottable::selectTest
Reimplemented from QCPAbstractPlottable1D< QCPGraphData >.
|
virtual |
Returns the coordinate range that all data in this plottable span in the key axis dimension. For logarithmic plots, one can set inSignDomain to either QCP::sdNegative or QCP::sdPositive in order to restrict the returned range to that sign domain. E.g. when only negative range is wanted, set inSignDomain to QCP::sdNegative and all positive points will be ignored for range calculation. For no restriction, just set inSignDomain to QCP::sdBoth (default). foundRange is an output parameter that indicates whether a range could be found or not. If this is false, you shouldn't use the returned range (e.g. no points in data).
Note that foundRange is not the same as QCPRange::validRange, since the range returned by this function may have size zero (e.g. when there is only one data point). In this case foundRange would return true, but the returned range is not a valid range in terms of QCPRange::validRange.
Implements QCPAbstractPlottable.
|
virtual |
Returns the coordinate range that the data points in the specified key range (inKeyRange) span in the value axis dimension. For logarithmic plots, one can set inSignDomain to either QCP::sdNegative or QCP::sdPositive in order to restrict the returned range to that sign domain. E.g. when only negative range is wanted, set inSignDomain to QCP::sdNegative and all positive points will be ignored for range calculation. For no restriction, just set inSignDomain to QCP::sdBoth (default). foundRange is an output parameter that indicates whether a range could be found or not. If this is false, you shouldn't use the returned range (e.g. no points in data).
If inKeyRange has both lower and upper bound set to zero (is equal to QCPRange()
), all data points are considered, without any restriction on the keys.
Note that foundRange is not the same as QCPRange::validRange, since the range returned by this function may have size zero (e.g. when there is only one data point). In this case foundRange would return true, but the returned range is not a valid range in terms of QCPRange::validRange.
Implements QCPAbstractPlottable.
|
protectedvirtual |
This function draws the layerable with the specified painter. It is only called by QCustomPlot, if the layerable is visible (setVisible).
Before this function is called, the painter's antialiasing state is set via applyDefaultAntialiasingHint, see the documentation there. Further, the clipping rectangle was set to clipRect.
Implements QCPAbstractPlottable.
|
protectedvirtual |
called by QCPLegend::draw (via QCPPlottableLegendItem::draw) to create a graphical representation of this plottable inside rect, next to the plottable name.
The passed painter has its cliprect set to rect, so painting outside of rect won't appear outside the legend icon border.
Implements QCPAbstractPlottable.
|
protectedvirtual |
Draws the fill of the graph using the specified painter, with the currently set brush.
Depending on whether a normal fill or a channel fill (setChannelFillGraph) is needed, getFillPolygon or getChannelFillPolygon are used to find the according fill polygons.
In order to handle NaN Data points correctly (the fill needs to be split into disjoint areas), this method first determines a list of non-NaN segments with getNonNanSegments, on which to operate. In the channel fill case, getOverlappingSegments is used to consolidate the non-NaN segments of the two involved graphs, before passing the overlapping pairs to getChannelFillPolygon.
Pass the points of this graph's line as lines, in pixel coordinates.
|
protectedvirtual |
Draws scatter symbols at every point passed in scatters, given in pixel coordinates. The scatters will be drawn with painter and have the appearance as specified in style.
|
protectedvirtual |
Draws lines between the points in lines, given in pixel coordinates.
|
protectedvirtual |
Draws impulses from the provided data, i.e. it connects all line pairs in lines, given in pixel coordinates. The lines necessary for impulses are generated by dataToImpulseLines from the regular graph data points.
|
protectedvirtual |
Returns via lineData the data points that need to be visualized for this graph when plotting graph lines, taking into consideration the currently visible axis ranges and, if setAdaptiveSampling is enabled, local point densities. The considered data can be restricted further by begin and end, e.g. to only plot a certain segment of the data (see getDataSegments).
This method is used by getLines to retrieve the basic working set of data.
|
protectedvirtual |
Returns via scatterData the data points that need to be visualized for this graph when plotting scatter points, taking into consideration the currently visible axis ranges and, if setAdaptiveSampling is enabled, local point densities. The considered data can be restricted further by begin and end, e.g. to only plot a certain segment of the data (see getDataSegments).
This method is used by getScatters to retrieve the basic working set of data.
|
protected |
This method outputs the currently visible data range via begin and end. The returned range will also never exceed rangeRestriction.
This method takes into account that the drawing of data lines at the axis rect border always requires the points just outside the visible axis range. So begin and end may actually indicate a range that contains one additional data point to the left and right of the visible axis range.
|
protected |
This method retrieves an optimized set of data points via getOptimizedLineData, and branches out to the line style specific functions such as dataToLines, dataToStepLeftLines, etc. according to the line style of the graph.
lines will be filled with points in pixel coordinates, that can be drawn with the according draw functions like drawLinePlot and drawImpulsePlot. The points returned in lines aren't necessarily the original data points. For example, step line styles require additional points to form the steps when drawn. If the line style of the graph is lsNone, the lines vector will be empty.
dataRange specifies the beginning and ending data indices that will be taken into account for conversion. In this function, the specified range may exceed the total data bounds without harm: a correspondingly trimmed data range will be used. This takes the burden off the user of this function to check for valid indices in dataRange, e.g. when extending ranges coming from getDataSegments.
|
protected |
This method retrieves an optimized set of data points via getOptimizedScatterData and then converts them to pixel coordinates. The resulting points are returned in scatters, and can be passed to drawScatterPlot.
dataRange specifies the beginning and ending data indices that will be taken into account for conversion. In this function, the specified range may exceed the total data bounds without harm: a correspondingly trimmed data range will be used. This takes the burden off the user of this function to check for valid indices in dataRange, e.g. when extending ranges coming from getDataSegments.
|
protected |
Takes raw data points in plot coordinates as data, and returns a vector containing pixel coordinate points which are suitable for drawing the line style lsLine.
The source of data is usually getOptimizedLineData, and this method is called in getLines if the line style is set accordingly.
|
protected |
Takes raw data points in plot coordinates as data, and returns a vector containing pixel coordinate points which are suitable for drawing the line style lsStepLeft.
The source of data is usually getOptimizedLineData, and this method is called in getLines if the line style is set accordingly.
|
protected |
Takes raw data points in plot coordinates as data, and returns a vector containing pixel coordinate points which are suitable for drawing the line style lsStepRight.
The source of data is usually getOptimizedLineData, and this method is called in getLines if the line style is set accordingly.
|
protected |
Takes raw data points in plot coordinates as data, and returns a vector containing pixel coordinate points which are suitable for drawing the line style lsStepCenter.
The source of data is usually getOptimizedLineData, and this method is called in getLines if the line style is set accordingly.
|
protected |
Takes raw data points in plot coordinates as data, and returns a vector containing pixel coordinate points which are suitable for drawing the line style lsImpulse.
The source of data is usually getOptimizedLineData, and this method is called in getLines if the line style is set accordingly.
|
protected |
This method goes through the passed points in lineData and returns a list of the segments which don't contain NaN data points.
keyOrientation defines whether the x or y member of the passed QPointF is used to check for NaN. If keyOrientation is Qt::Horizontal
, the y member is checked, if it is Qt::Vertical
, the x member is checked.
|
protected |
This method takes two segment lists (e.g. created by getNonNanSegments) thisSegments and otherSegments, and their associated point data thisData and otherData.
It returns all pairs of segments (the first from thisSegments, the second from otherSegments), which overlap in plot coordinates.
This method is useful in the case of a channel fill between two graphs, when only those non-NaN segments which actually overlap in their key coordinate shall be considered for drawing a channel fill polygon.
It is assumed that the passed segments in thisSegments are ordered ascending by index, and that the segments don't overlap themselves. The same is assumed for the segments in otherSegments. This is fulfilled when the segments are obtained via getNonNanSegments.
|
protected |
Returns whether the segments defined by the coordinates (aLower, aUpper) and (bLower, bUpper) have overlap.
The output parameter bPrecedence indicates whether the b segment reaches farther than the a segment or not. If bPrecedence returns 1, segment b reaches the farthest to higher coordinates (i.e. bUpper > aUpper). If it returns -1, segment a reaches the farthest. Only if both segment's upper bounds are identical, 0 is returned as bPrecedence.
It is assumed that the lower bounds always have smaller or equal values than the upper bounds.
|
protected |
Returns the point which closes the fill polygon on 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.
matchingDataPoint will provide the key (in pixels) of the returned point. Depending on whether the key axis of this graph is horizontal or vertical, matchingDataPoint will provide the x or y value of the returned point, respectively.
|
protected |
Returns the polygon needed for drawing normal fills between this graph and the key axis.
Pass the graph's data points (in pixel coordinates) as lineData, and specify the segment which shall be used for the fill. The collection of lineData points described by segment must not contain NaN data points (see getNonNanSegments).
The returned fill polygon will be closed at the key axis (the zero-value line) for linear value axes. For logarithmic value axes the polygon will reach just beyond the corresponding axis rect side (see getFillBasePoint).
For increased performance (due to implicit sharing), keep the returned QPolygonF const.
|
protected |
Returns the polygon needed for drawing (partial) channel fills between this graph and the graph specified by setChannelFillGraph.
The data points of this graph are passed as pixel coordinates via thisData, the data of the other graph as otherData. The returned polygon will be calculated for the specified data segments thisSegment and otherSegment, pertaining to the respective thisData and otherData, respectively.
The passed thisSegment and otherSegment should correspond to the segment pairs returned by getOverlappingSegments, to make sure only segments that actually have key coordinate overlap need to be processed here.
For increased performance due to implicit sharing, keep the returned QPolygonF const.
|
protected |
Finds the highest index of data, whose points x value is just below x. Assumes x values in data points are ordered ascending, as is ensured by getLines/getScatters if the key axis is horizontal.
Used to calculate the channel fill polygon, see getChannelFillPolygon.
|
protected |
Finds the smallest index of data, whose points x value is just above x. Assumes x values in data points are ordered ascending, as is ensured by getLines/getScatters if the key axis is horizontal.
Used to calculate the channel fill polygon, see getChannelFillPolygon.
|
protected |
Finds the highest index of data, whose points y value is just below y. Assumes y values in data points are ordered ascending, as is ensured by getLines/getScatters if the key axis is vertical.
Used to calculate the channel fill polygon, see getChannelFillPolygon.
|
protected |
Finds the smallest index of data, whose points y value is just above y. Assumes y values in data points are ordered ascending, as is ensured by getLines/getScatters if the key axis is vertical.
Used to calculate the channel fill polygon, see getChannelFillPolygon.
|
protected |
Calculates the minimum distance in pixels the graph's representation has from the given pixelPoint. This is used to determine whether the graph was clicked or not, e.g. in selectTest. The closest data point to pixelPoint is returned in closestData. Note that if the graph has a line representation, the returned distance may be smaller than the distance to the closestData point, since the distance to the graph line is also taken into account.
If either the graph has no data or if the line style is lsNone and the scatter style's shape is QCPScatterStyle::ssNone (i.e. there is no visual representation of the graph), returns -1.0.