QXRD  0.11.16
qxrdacquisitionextrainputsplot.cpp
Go to the documentation of this file.
2 #include "qwt_symbol.h"
3 
5  QcepPlot(parent)
6 {
7  m_Colors << Qt::black
8  << QColor(170,110,40)
9  << Qt::red
10  << QColor(255,180,60)
11  << Qt::yellow
12  << Qt::green
13  << Qt::blue
14  << Qt::magenta
15  << Qt::gray;
16 }
17 
19 {
20  QcepPlot::init(settings);
21 
22  if (m_Legend) {
23  insertLegend(m_Legend, QwtPlot::BottomLegend);
24  }
25 }
26 
28 {
29  if (m_RawData.count() > nch) {
30  for (int i=nch; i<m_RawData.count(); i++) {
31  m_RawData[i]->detach();
32  delete m_RawData[i];
33  }
34 
35  m_RawData.resize(nch);
36  } else if (m_RawData.count() < nch) {
37  for (int i=m_RawData.count(); i<nch; i++) {
38  QwtPlotCurve *pc = new QwtPlotCurve(tr("Chan %1").arg(i));
39  m_RawData.append(pc);
40 
41  pc->setPen(QPen(m_Colors[i % m_Colors.count()]));
42 
43  pc->attach(this);
44  }
45  }
46 
47  if (m_Selections.count() > nch) {
48  for (int i=nch; i<m_Selections.count(); i++) {
49  m_Selections[i]->detach();
50  delete m_Selections[i];
51  }
52 
53  m_Selections.resize(nch);
54  } else if (m_Selections.count() < nch) {
55  for (int i=m_Selections.count(); i<nch; i++) {
56  QwtPlotCurve *pc = new QwtPlotCurve(tr("Chan %1").arg(i));
57  m_Selections.append(pc);
58 
59  QPen pen(m_Colors[i % m_Colors.count()]);
60  QBrush brush(m_Colors[i % m_Colors.count()]);
61 
62  QwtSymbol *a = new QwtSymbol(QwtSymbol::Rect, brush, pen, QSize(3,3));
63 
64  pc->setStyle(QwtPlotCurve::NoCurve);
65  pc->setSymbol(a);
66 
67  pc->attach(this);
68  }
69  }
70 }
71 
73 {
74  QwtPlotCurve *pc = m_RawData.value(ch);
75 
76  if (pc) {
77  pc -> setSamples(x, y);
78  }
79 
80  QwtPlotCurve *pc2 = m_Selections.value(ch);
81 
82  if (pc2) {
83  pc2->setSamples(x.mid(i0, i1-i0), y.mid(i0, i1-i0));
84  }
85 }
QWeakPointer< QcepPlotSettings > QcepPlotSettingsWPtr
QwtLegend * m_Legend
Definition: qcepplot.h:58
QVector< double > QcepDoubleVector
Definition: qcepmacros.h:19
void init(QcepPlotSettingsWPtr settings)
Definition: qcepplot.cpp:36
void init(QcepPlotSettingsWPtr settings)
void plotChannel(int ch, int i0, int i1, QcepDoubleVector x, QcepDoubleVector y)