QXRD  0.11.16
qxrdplotvectorfieldcurve.cpp
Go to the documentation of this file.
2 #include "qwt_painter.h"
3 #include"qwt_scale_map.h"
4 
6 {
7  init();
8 }
9 
11 {
12  setData(data);
13 }
14 
16  (QPainter *painter,
17  const QwtScaleMap &xMap,
18  const QwtScaleMap &yMap,
19  const QRectF &/*canvasRect*/,
20  int from, int to) const
21 {
22  if (to < 0) {
23  to = dataSize() - 1;
24  }
25 
26  if (from < 0) {
27  from = 0;
28  }
29 
30  if (from > to) {
31  return;
32  }
33 
34  painter->save();
35 
36  const QwtSeriesData<QxrdPoint4D> *series = data();
37 
38  for (int i=from; i<=to; i++) {
39  const QxrdPoint4D sample = series->sample(i);
40 
41  double x0 = xMap.transform(sample.x());
42  double y0 = yMap.transform(sample.y());
43  double x1 = xMap.transform(sample.x()+sample.z()*50.0);
44  double y1 = yMap.transform(sample.y()+sample.t()*50.0);
45 
46  double th = atan2(y1-y0, x1-x0);
47  double thp = th+0.2;
48  double thm = th-0.2;
49  double xp = x1 - 5.0*cos(thp);
50  double yp = y1 - 5.0*sin(thp);
51 
52  double xm = x1 - 5.0*cos(thm);
53  double ym = y1 - 5.0*sin(thm);
54 
55  QwtPainter::drawLine(painter, x0, y0, x1, y1);
56  QwtPainter::drawLine(painter, x1, y1, xp, yp);
57  QwtPainter::drawLine(painter, x1, y1, xm, ym);
58  }
59 
60  painter->restore();
61 }
62 
64 {
65  const QwtSeriesData<QxrdPoint4D> *series = data();
66 
67  if (series) {
68  return series->boundingRect();
69  } else {
70  return QRectF();
71  }
72 }
73 
75 {
76  const QwtSeriesData<QxrdPoint4D> *series = data();
77 
78  if (series) {
79  return series->boundingRect();
80  } else {
81  return QRectF();
82  }
83 }
84 
86 {
87  setItemAttribute( QwtPlotItem::AutoScale, true );
88  setItemAttribute( QwtPlotItem::Legend, false );
89 }
double t() const
Definition: qxrdpoint4d.h:67
double y() const
Definition: qxrdpoint4d.h:57
void setSamples(QxrdPlotVectorFieldData *data)
void drawSeries(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
double x() const
Definition: qxrdpoint4d.h:52
double z() const
Definition: qxrdpoint4d.h:62