QXRD  0.11.16
Public Slots | Public Member Functions | Private Member Functions | Private Attributes | List of all members
QcepScatterPlotGraphController Class Reference

#include <qcepscatterplotgraphcontroller.h>

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

Public Slots

virtual void updateDisplay ()
 
void onPlotDataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight)
 
- Public Slots inherited from QcepDataObjectGraphController
virtual void updateDisplay ()
 

Public Member Functions

 QcepScatterPlotGraphController (QcepDataObjectGraphWindow *window, int mode, QcepDataObjectWPtr object)
 
virtual ~QcepScatterPlotGraphController ()
 
virtual void activate ()
 
- Public Member Functions inherited from QcepDataObjectGraphController
 QcepDataObjectGraphController (QcepDataObjectGraphWindow *window, int mode, QcepDataObjectWPtr object)
 
virtual ~QcepDataObjectGraphController ()
 

Private Member Functions

void appendCurve (QString name, int axis, int curveNumber, const double *x, const double *y, int npts)
 
void appendCurve (QString name, int axis, int curveNumber, QcepDataColumnPtr x, QcepDataColumnPtr y)
 

Private Attributes

QcepScatterPlotGraphModelWPtr m_Model
 

Additional Inherited Members

- Protected Attributes inherited from QcepDataObjectGraphController
QcepDataObjectGraphWindowm_Window
 
int m_Mode
 
QcepDataObjectWPtr m_Object
 
QWidget * m_Widget
 

Detailed Description

Definition at line 8 of file qcepscatterplotgraphcontroller.h.

Constructor & Destructor Documentation

QcepScatterPlotGraphController::QcepScatterPlotGraphController ( QcepDataObjectGraphWindow window,
int  mode,
QcepDataObjectWPtr  object 
)

Definition at line 16 of file qcepscatterplotgraphcontroller.cpp.

17  : QcepDataObjectGraphController(window, mode, object)
18 {
19 
20 }
QcepDataObjectGraphController(QcepDataObjectGraphWindow *window, int mode, QcepDataObjectWPtr object)
QcepScatterPlotGraphController::~QcepScatterPlotGraphController ( )
virtual

Member Function Documentation

void QcepScatterPlotGraphController::activate ( )
virtual

Reimplemented from QcepDataObjectGraphController.

Definition at line 27 of file qcepscatterplotgraphcontroller.cpp.

References QcepDataObjectGraphController::activate(), QcepDataObjectGraphController::m_Mode, m_Model, QcepDataObjectGraphController::m_Object, QcepDataObjectGraphController::m_Widget, QcepDataObjectGraphController::m_Window, QcepScatterPlotGraphControls::model(), and onPlotDataChanged().

28 {
30 
31  if (ctrl) {
32  m_Widget = ctrl;
33 
34  m_Window->m_Splitter->addWidget(m_Widget);
35 
36  m_Model = ctrl->model();
37 
39 
40  if (m) {
41  connect(m.data(), &QAbstractItemModel::dataChanged,
43  }
44  }
45 
47 }
QSharedPointer< QcepScatterPlotGraphModel > QcepScatterPlotGraphModelPtr
QcepScatterPlotGraphModelPtr model()
void onPlotDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)

Here is the call graph for this function:

void QcepScatterPlotGraphController::appendCurve ( QString  name,
int  axis,
int  curveNumber,
const double *  x,
const double *  y,
int  npts 
)
private

Definition at line 144 of file qcepscatterplotgraphcontroller.cpp.

References QcepDataObjectGraphWindow::appendCurve(), and QcepDataObjectGraphController::m_Window.

Referenced by appendCurve(), and updateDisplay().

146 {
147  QwtPlotCurve *curve = new QwtPlotPiecewiseCurve(m_Window->m_ImagePlot, name);
148 
149  curve->setSamples(x, y, npts);
150 
151  m_Window->m_ImagePlot->setPlotCurveStyle(curveNumber, curve);
152 
153  if (axis == 0) {
154  curve->setYAxis(QwtPlot::yLeft);
155  } else if (axis == 1) {
156  curve->setYAxis(QwtPlot::yRight);
157 
158  m_Window->m_ImagePlot->enableAxis(QwtPlot::yRight, true);
159  }
160 
161  m_Window->appendCurve(curve);
162 }
void appendCurve(QwtPlotCurve *curve)
A class which draws piecewise curves.

Here is the call graph for this function:

Here is the caller graph for this function:

void QcepScatterPlotGraphController::appendCurve ( QString  name,
int  axis,
int  curveNumber,
QcepDataColumnPtr  x,
QcepDataColumnPtr  y 
)
private

Definition at line 164 of file qcepscatterplotgraphcontroller.cpp.

References appendCurve().

166 {
167  if (x && y) {
168  const double *xp = x->data(), *yp = y->data();
169  int np = qMin(x->count(), y->count());
170 
171  appendCurve(name, axis, curveNumber, xp, yp, np);
172  }
173 }
void appendCurve(QString name, int axis, int curveNumber, const double *x, const double *y, int npts)

Here is the call graph for this function:

void QcepScatterPlotGraphController::onPlotDataChanged ( const QModelIndex &  topLeft,
const QModelIndex &  bottomRight 
)
slot

Definition at line 49 of file qcepscatterplotgraphcontroller.cpp.

References updateDisplay().

Referenced by activate().

51 {
52 // QcepExperimentPtr exp(m_Window->experiment());
53 
54 // if (exp) {
55 // exp->printMessage(tr("QcepScatterPlotGraphController::onPlotDataChanged([%1,%2],[%3,%4])")
56 // .arg(topLeft.column()).arg(topLeft.row())
57 // .arg(bottomRight.column()).arg(bottomRight.row()));
58 // }
59 
60  updateDisplay();
61 }

Here is the call graph for this function:

Here is the caller graph for this function:

void QcepScatterPlotGraphController::updateDisplay ( )
virtualslot

Definition at line 63 of file qcepscatterplotgraphcontroller.cpp.

References appendCurve(), m_Model, QcepDataObjectGraphController::m_Object, QcepDataObjectGraphController::m_Window, object, and QcepDataObjectGraphController::updateDisplay().

Referenced by onPlotDataChanged().

64 {
65  m_Window -> clearPlot();
66  m_Window -> m_ImagePlot -> enableAxis(QwtPlot::yRight, false);
67 
68  int curveNumber = 0;
69 
72  QcepIntegratedDataPtr integ = qSharedPointerDynamicCast<QcepIntegratedData>(m_Object);
73  QcepDataColumnScanPtr scan = qSharedPointerDynamicCast<QcepDataColumnScan>(m_Object);
74 
75  if (model) {
76  int xcol = -1;
77  int nr = model->rowCount(QModelIndex());
78 
79  for (int i=0; i<nr; i++) {
80  if (model->getX(i)) {
81  xcol = i;
82  }
83  }
84 
85  if (integ) {
86  const double *cols[2];
87  QString labels[2];
88 
89  cols[0] = integ->x();
90  cols[1] = integ->y();
91  int nr = integ->size();
92  labels[0] = integ->get_XUnitsLabel();
93  labels[1] = "Y";
94 
95  if (xcol >= 0) {
96  const double *xc = cols[xcol];
97 
98  m_Window->m_ImagePlot -> setAxisTitle(QwtPlot::xBottom, labels[xcol]);
99 
100  for (int i=0; i<2; i++) {
101  if (model->getY(i)) {
102  appendCurve(labels[i], 0, curveNumber++, xc, cols[i], nr);
103  }
104 
105  if (model->getY2(i)) {
106  appendCurve(labels[i], 1, curveNumber++, xc, cols[i], nr);
107  }
108  }
109  }
110  } else if (scan) {
111  if (xcol >= 0) {
112  QcepDataColumnPtr xCol = scan->column(xcol);
113 
114  if (xCol) {
115  m_Window->m_ImagePlot -> setAxisTitle(QwtPlot::xBottom, xCol->get_Name());
116 
117  for (int i=0; i<nr; i++) {
118  if (model->getY(i)) {
119  QcepDataColumnPtr yCol = scan->column(i);
120 
121  if (yCol) {
122  appendCurve(yCol->get_Name(), 0, curveNumber++, xCol, yCol);
123  }
124  }
125 
126  if (model->getY2(i)) {
127  QcepDataColumnPtr y2Col = scan->column(i);
128 
129  if (y2Col) {
130  appendCurve(y2Col->get_Name(), 1, curveNumber++, xCol, y2Col);
131  }
132  }
133  }
134  }
135  }
136  }
137  }
138 
139  m_Window -> m_ImagePlot -> replot();
140 
142 }
QSharedPointer< QcepScatterPlotGraphModel > QcepScatterPlotGraphModelPtr
QSharedPointer< QcepDataColumnScan > QcepDataColumnScanPtr
QSharedPointer< QcepDataColumn > QcepDataColumnPtr
JSON Parse a string as a JSON object
QSharedPointer< QcepIntegratedData > QcepIntegratedDataPtr
QSharedPointer< QcepDataObject > QcepDataObjectPtr
void appendCurve(QString name, int axis, int curveNumber, const double *x, const double *y, int npts)

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

QcepScatterPlotGraphModelWPtr QcepScatterPlotGraphController::m_Model
private

Definition at line 28 of file qcepscatterplotgraphcontroller.h.

Referenced by activate(), and updateDisplay().


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