{
protected:
};
curve = new MyQwtPlotCurve();
curve->attach(this); // "this" is the QwtPlot
int preceding_from = from;
bool is_gap = true;
// Scan all data to identify gaps
for (int i = from; i <= to; i++){
const QPointF sample
= d_series
->sample
(i
);
// In a gap
if(sample.y() >= 0 && is_gap){ // wait for the curve to be positive again
preceding_from = i;
is_gap = false;
}
// At the beginning of a gap (or the end of the serie) : draw the preceding interval
if((sample.y() < 0 && !is_gap) || (i == to && sample.y() >= 0)){
drawSteps(painter, xMap, yMap, canvasRect, preceding_from, i>from ? i-1 : i); // or drawLines, drawSticks, drawDots
is_gap = true;
}
}
}
class MyQwtPlotCurve : public QwtPlotCurve
{
protected:
virtual void drawCurve( QPainter *p, int style, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to ) const;
};
curve = new MyQwtPlotCurve();
curve->attach(this); // "this" is the QwtPlot
void MyQwtPlotCurve::drawCurve( QPainter *painter, int style, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to ) const{
int preceding_from = from;
bool is_gap = true;
// Scan all data to identify gaps
for (int i = from; i <= to; i++){
const QPointF sample = d_series->sample(i);
// In a gap
if(sample.y() >= 0 && is_gap){ // wait for the curve to be positive again
preceding_from = i;
is_gap = false;
}
// At the beginning of a gap (or the end of the serie) : draw the preceding interval
if((sample.y() < 0 && !is_gap) || (i == to && sample.y() >= 0)){
drawSteps(painter, xMap, yMap, canvasRect, preceding_from, i>from ? i-1 : i); // or drawLines, drawSticks, drawDots
is_gap = true;
}
}
}
To copy to clipboard, switch view to plain text mode
Thanks a lot for your help !
Bookmarks