QXRD  0.11.16
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
QwtPlotPiecewiseCurve Class Reference

A class which draws piecewise curves. More...

#include <qwt_plot_piecewise_curve.h>

Inheritance diagram for QwtPlotPiecewiseCurve:
Inheritance graph
[legend]
Collaboration diagram for QwtPlotPiecewiseCurve:
Collaboration graph
[legend]

Public Member Functions

 QwtPlotPiecewiseCurve ()
 
 QwtPlotPiecewiseCurve (QcepPlot *plot, const QwtText &title)
 
 QwtPlotPiecewiseCurve (QcepPlot *plot, const QString &title)
 
virtual QRectF boundingRect () const
 
virtual void drawSeries (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
 

Private Member Functions

bool ignorePoint (double x, double y) const
 
double x (int n) const
 
double y (int n) const
 

Static Private Member Functions

static bool isNaN (double x)
 

Private Attributes

QcepPlotm_Plot
 

Detailed Description

A class which draws piecewise curves.

This class can be used to display data with missing (NaN) values as a piecewise curve in the x-y plane.

Definition at line 23 of file qwt_plot_piecewise_curve.h.

Constructor & Destructor Documentation

QwtPlotPiecewiseCurve::QwtPlotPiecewiseCurve ( )
explicit

Definition at line 14 of file qwt_plot_piecewise_curve.cpp.

14  : QwtPlotCurve(),
15  m_Plot(NULL)
16 {
17 }
QwtPlotPiecewiseCurve::QwtPlotPiecewiseCurve ( QcepPlot plot,
const QwtText &  title 
)
explicit

Definition at line 19 of file qwt_plot_piecewise_curve.cpp.

19  :
20  QwtPlotCurve(title),
21  m_Plot(plot)
22 {
23 }
QwtPlotPiecewiseCurve::QwtPlotPiecewiseCurve ( QcepPlot plot,
const QString &  title 
)
explicit

Definition at line 25 of file qwt_plot_piecewise_curve.cpp.

25  :
26  QwtPlotCurve(title),
27  m_Plot(plot)
28 {
29 }

Member Function Documentation

QRectF QwtPlotPiecewiseCurve::boundingRect ( ) const
virtual

Definition at line 79 of file qwt_plot_piecewise_curve.cpp.

References ignorePoint(), x(), and y().

80 {
81  if (dataSize() <= 0) {
82  return QRectF(1.0, 1.0, 2.0, 2.0); // Empty data.
83  }
84 
85  size_t first = 0;
86  while (first < dataSize() && ignorePoint(x(first),y(first))) {
87  ++first;
88  }
89 
90  if (first == dataSize()) {
91  return QRectF(1.0, 1.0, 2.0, 2.0); // Empty data.
92  }
93 
94  double minX, maxX, minY, maxY;
95  minX = maxX = x(first);
96  minY = maxY = y(first);
97  for (size_t i = first + 1; i < dataSize(); ++i) {
98  const double xv = x(i);
99  const double yv = y(i);
100 
101  if (!ignorePoint(xv,yv)) {
102  if (xv < minX)
103  minX = xv;
104  if (xv > maxX)
105  maxX = xv;
106  if (yv < minY)
107  minY = yv;
108  if (yv > maxY)
109  maxY = yv;
110  }
111  }
112 
113  return QRectF(minX, minY, maxX - minX, maxY - minY);
114 }
bool ignorePoint(double x, double y) const

Here is the call graph for this function:

void QwtPlotPiecewiseCurve::drawSeries ( QPainter *  p,
const QwtScaleMap &  xMap,
const QwtScaleMap &  yMap,
const QRectF &  canvasRect,
int  from,
int  to 
) const
virtual

Definition at line 51 of file qwt_plot_piecewise_curve.cpp.

References ignorePoint(), x(), and y().

54 {
55  if (to < 0) {
56  to = dataSize() - 1;
57  }
58 
59  int first, last = from;
60  while (last <= to) {
61  first = last;
62  while (first <= to && ignorePoint(x(first),y(first))) {
63  ++first;
64  }
65 
66  last = first;
67  while (last <= to && !ignorePoint(x(last),y(last))) {
68  ++last;
69  }
70 
71  if (first <= to) {
72  QwtPlotCurve::drawSeries(painter, xMap, yMap, canvasRect, first, last - 1);
73  }
74  }
75 }
bool ignorePoint(double x, double y) const

Here is the call graph for this function:

bool QwtPlotPiecewiseCurve::ignorePoint ( double  x,
double  y 
) const
private

Definition at line 36 of file qwt_plot_piecewise_curve.cpp.

References isNaN(), QcepPlot::logAxis(), and m_Plot.

Referenced by boundingRect(), and drawSeries().

37 {
38  if (isNaN(x)) return true;
39 
40  if (isNaN(y)) return true;
41 
42  if (m_Plot) {
43  if (m_Plot->logAxis(xAxis()) && (x <= 0)) return true;
44  if (m_Plot->logAxis(yAxis()) && (y <= 0)) return true;
45  }
46 
47  return false;
48 }
int logAxis(int axis)
Definition: qcepplot.cpp:389

Here is the call graph for this function:

Here is the caller graph for this function:

bool QwtPlotPiecewiseCurve::isNaN ( double  x)
staticprivate

Definition at line 31 of file qwt_plot_piecewise_curve.cpp.

References x().

Referenced by ignorePoint().

32 {
33  return x != x;
34 }

Here is the call graph for this function:

Here is the caller graph for this function:

double QwtPlotPiecewiseCurve::x ( int  n) const
private

Definition at line 116 of file qwt_plot_piecewise_curve.cpp.

Referenced by boundingRect(), drawSeries(), and isNaN().

117 {
118  QPointF s = sample(n);
119 
120  return s.x();
121 }

Here is the caller graph for this function:

double QwtPlotPiecewiseCurve::y ( int  n) const
private

Definition at line 123 of file qwt_plot_piecewise_curve.cpp.

Referenced by boundingRect(), and drawSeries().

124 {
125  QPointF s = sample(n);
126 
127  return s.y();
128 }

Here is the caller graph for this function:

Member Data Documentation

QcepPlot* QwtPlotPiecewiseCurve::m_Plot
private

Definition at line 41 of file qwt_plot_piecewise_curve.h.

Referenced by ignorePoint().


The documentation for this class was generated from the following files: