CFEL - ASG Software Suite  2.5.0
CASS
curve_plot.cpp
Go to the documentation of this file.
1 // Copyright (C) 2014 Lutz Foucar
2 
3 /**
4  * @file curve_plot.cpp contains an alternative curve plot
5  *
6  * @author Lutz Foucar
7  */
8 
9 #include <cmath>
10 
11 #include <QtCore/QDebug>
12 
13 #include <qwt_scale_map.h>
14 
15 #include "curve_plot.h"
16 
17 using namespace jocassview;
18 
20 {
21 
22 }
23 
25  : QwtPlotCurve(title)
26 {
27 
28 }
29 
30 /** extract point coordinates and check if they are valid
31  *
32  * @return true when both coordinates are finite numbers
33  * @param sample the point to check
34  * @param xMap
35  * @param yMap
36  *
37  * @author Lutz Foucar
38  */
39 bool validate(const QPointF& sample,
40  const QwtScaleMap &xMap, const QwtScaleMap &yMap)
41 {
42  double xi(xMap.transform(sample.x()));
43  double yi(yMap.transform(sample.y()));
44  return (std::isfinite(xi) && std::isfinite(yi));
45 
46 }
47 
49  const QwtScaleMap &xMap, const QwtScaleMap &yMap,
50  const QRectF &canvasRect,int from, int to) const
51 {
52  if (to < 0)
53  to = dataSize() - 1;
54  int i(from);
55  while(i<=to)
56  {
57  /** find the first point that is valid */
58  while(!validate(data()->sample(i),xMap,yMap) && i <= to)
59  ++i;
60  const int firstValid(i);
61 
62  /** find the last point that is valid */
63  while(validate(data()->sample(i),xMap,yMap) && i <= to)
64  ++i;
65  const int lastValid(i-1);
66 
67  /** plot that valid subrange */
68  QwtPlotCurve::drawSeries(painter,xMap,yMap,canvasRect,firstValid,lastValid);
69  }
70 
71 }
auxiliary data[Processor]
void drawSeries(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
draw the curve
Definition: curve_plot.cpp:48
PlotCurve()
default constructor
Definition: curve_plot.cpp:19
contains an alternative curve plot
bool validate(const QPointF &sample, const QwtScaleMap &xMap, const QwtScaleMap &yMap)
extract point coordinates and check if they are valid
Definition: curve_plot.cpp:39