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

#include <qcepscatterplotgraphmodel.h>

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

Public Member Functions

 QcepScatterPlotGraphModel (QcepDataObjectWPtr object)
 
int rowCount (const QModelIndex &parent) const
 
int columnCount (const QModelIndex &parent) const
 
QVariant headerData (int section, Qt::Orientation orientation, int role) const
 
QVariant data (const QModelIndex &index, int role) const
 
void toggle (const QModelIndex &index)
 
bool getX (int row) const
 
bool getY (int row) const
 
bool getY2 (int row) const
 
void toggleX (int row)
 
void toggleY (int row)
 
void toggleY2 (int row)
 
int checkState (bool val) const
 

Private Attributes

QcepDataObjectWPtr m_Object
 
QVector< bool > m_X
 
QVector< bool > m_Y
 
QVector< bool > m_Y2
 

Detailed Description

Definition at line 7 of file qcepscatterplotgraphmodel.h.

Constructor & Destructor Documentation

QcepScatterPlotGraphModel::QcepScatterPlotGraphModel ( QcepDataObjectWPtr  object)

Definition at line 7 of file qcepscatterplotgraphmodel.cpp.

References m_X, m_Y, and m_Y2.

7  :
8  m_Object(object)
9 {
10  m_X.resize(1000);
11  m_Y.resize(1000);
12  m_Y2.resize(1000);
13 }

Member Function Documentation

int QcepScatterPlotGraphModel::checkState ( bool  val) const

Definition at line 202 of file qcepscatterplotgraphmodel.cpp.

Referenced by data().

203 {
204  if (val) {
205  return Qt::Checked;
206  } else {
207  return Qt::Unchecked;
208  }
209 }

Here is the caller graph for this function:

int QcepScatterPlotGraphModel::columnCount ( const QModelIndex &  parent) const

Definition at line 39 of file qcepscatterplotgraphmodel.cpp.

Referenced by toggle().

41 {
42  return 4;
43 }

Here is the caller graph for this function:

QVariant QcepScatterPlotGraphModel::data ( const QModelIndex &  index,
int  role 
) const

Definition at line 73 of file qcepscatterplotgraphmodel.cpp.

References checkState(), getX(), getY(), getY2(), and m_Object.

75 {
76  int r = index.row();
77  int c = index.column();
78 
79  QVariant res;
80 
82 
83  if (p) {
84  QcepDataGroupPtr dg = qSharedPointerDynamicCast<QcepDataGroup>(p);
85 
86  if (dg) {
87  QcepDataObjectPtr o = dg->item(r);
88 
89  if (o) {
90  if (role == Qt::DisplayRole && c == 0) {
91  res = o->objectName();
92  } else if (role == Qt::CheckStateRole) {
93  if (c == 1) {
94  res = checkState(getX(r));
95  } else if (c == 2) {
96  res = checkState(getY(r));
97  } else if (c == 3) {
98  res = checkState(getY2(r));
99  }
100  }
101  }
102  } else {
103  QcepIntegratedDataPtr integ = qSharedPointerDynamicCast<QcepIntegratedData>(p);
104 
105  if (integ) {
106  if (role == Qt::DisplayRole && c == 0) {
107  switch(r) {
108  case 0:
109  res = integ->get_XUnitsLabel();
110  break;
111 
112  case 1:
113  res = "Intensity";
114  break;
115  }
116  } else if (role == Qt::CheckStateRole) {
117  if (c == 1) {
118  res = checkState(getX(r));
119  } else if (c == 2) {
120  res = checkState(getY(r));
121  } else if (c == 3) {
122  res = checkState(getY2(r));
123  }
124  }
125  }
126  }
127  }
128 
129  return res;
130 }
QSharedPointer< QcepDataGroup > QcepDataGroupPtr
QSharedPointer< QcepIntegratedData > QcepIntegratedDataPtr
QSharedPointer< QcepDataObject > QcepDataObjectPtr

Here is the call graph for this function:

bool QcepScatterPlotGraphModel::getX ( int  row) const

Definition at line 150 of file qcepscatterplotgraphmodel.cpp.

References m_X.

Referenced by data().

151 {
152  return m_X.value(row);
153 }

Here is the caller graph for this function:

bool QcepScatterPlotGraphModel::getY ( int  row) const

Definition at line 155 of file qcepscatterplotgraphmodel.cpp.

References m_Y.

Referenced by data().

156 {
157  return m_Y.value(row);
158 }

Here is the caller graph for this function:

bool QcepScatterPlotGraphModel::getY2 ( int  row) const

Definition at line 160 of file qcepscatterplotgraphmodel.cpp.

References m_Y2.

Referenced by data().

161 {
162  return m_Y2.value(row);
163 }

Here is the caller graph for this function:

QVariant QcepScatterPlotGraphModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role 
) const

Definition at line 45 of file qcepscatterplotgraphmodel.cpp.

47 {
48  QVariant res;
49 
50  if (orientation==Qt::Horizontal && role==Qt::DisplayRole) {
51  switch (section) {
52  case 0:
53  res = "Column";
54  break;
55 
56  case 1:
57  res = "X?";
58  break;
59 
60  case 2:
61  res = "Y?";
62  break;
63 
64  case 3:
65  res = "Y2?";
66  break;
67  }
68  }
69 
70  return res;
71 }
int QcepScatterPlotGraphModel::rowCount ( const QModelIndex &  parent) const

Definition at line 15 of file qcepscatterplotgraphmodel.cpp.

References m_Object.

Referenced by toggle(), toggleX(), toggleY(), and toggleY2().

17 {
18  int res = 0;
19 
21 
22  if (p) {
23  QcepDataGroupPtr dg = qSharedPointerDynamicCast<QcepDataGroup>(p);
24 
25  if (dg) {
26  res = dg->childCount();
27  } else {
28  QcepIntegratedDataPtr integ = qSharedPointerDynamicCast<QcepIntegratedData>(p);
29 
30  if (integ) {
31  res = 2;
32  }
33  }
34  }
35 
36  return res;
37 }
QSharedPointer< QcepDataGroup > QcepDataGroupPtr
QSharedPointer< QcepIntegratedData > QcepIntegratedDataPtr
QSharedPointer< QcepDataObject > QcepDataObjectPtr

Here is the caller graph for this function:

void QcepScatterPlotGraphModel::toggle ( const QModelIndex &  index)

Definition at line 132 of file qcepscatterplotgraphmodel.cpp.

References columnCount(), rowCount(), toggleX(), toggleY(), and toggleY2().

Referenced by QcepScatterPlotGraphControls::QcepScatterPlotGraphControls().

133 {
134  int r = index.row();
135  int c = index.column();
136  int nr = rowCount(QModelIndex());
137  int nc = columnCount(QModelIndex());
138 
139  if (r >= 0 && r < nr) {
140  if (c == 1) { // 'X' column:
141  toggleX(r);
142  } else if (c == 2) { // 'Y' column
143  toggleY(r);
144  } else if (c == 3) { // 'Y2' column
145  toggleY2(r);
146  }
147  }
148 }
int columnCount(const QModelIndex &parent) const
int rowCount(const QModelIndex &parent) const

Here is the call graph for this function:

Here is the caller graph for this function:

void QcepScatterPlotGraphModel::toggleX ( int  row)

Definition at line 165 of file qcepscatterplotgraphmodel.cpp.

References m_X, and rowCount().

Referenced by toggle().

166 {
167  int nr = rowCount(QModelIndex());
168 
169  if (row >= 0 && row < nr) {
170  for (int i=0; i<nr; i++) {
171  m_X[i] = false;
172  }
173 
174  m_X[row] = true;
175 
176  emit dataChanged(index(0,1), index(nr-1,1));
177  }
178 }
int rowCount(const QModelIndex &parent) const

Here is the call graph for this function:

Here is the caller graph for this function:

void QcepScatterPlotGraphModel::toggleY ( int  row)

Definition at line 180 of file qcepscatterplotgraphmodel.cpp.

References m_Y, and rowCount().

Referenced by toggle().

181 {
182  int nr = rowCount(QModelIndex());
183 
184  if (row >= 0 && row < nr) {
185  m_Y[row] = !m_Y[row];
186 
187  emit dataChanged(index(row,2), index(row,2));
188  }
189 }
int rowCount(const QModelIndex &parent) const

Here is the call graph for this function:

Here is the caller graph for this function:

void QcepScatterPlotGraphModel::toggleY2 ( int  row)

Definition at line 191 of file qcepscatterplotgraphmodel.cpp.

References m_Y2, and rowCount().

Referenced by toggle().

192 {
193  int nr = rowCount(QModelIndex());
194 
195  if (row >= 0 && row < nr) {
196  m_Y2[row] = !m_Y2[row];
197 
198  emit dataChanged(index(row,3), index(row,3));
199  }
200 }
int rowCount(const QModelIndex &parent) const

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

QcepDataObjectWPtr QcepScatterPlotGraphModel::m_Object
private

Definition at line 34 of file qcepscatterplotgraphmodel.h.

Referenced by data(), and rowCount().

QVector<bool> QcepScatterPlotGraphModel::m_X
private

Definition at line 35 of file qcepscatterplotgraphmodel.h.

Referenced by getX(), QcepScatterPlotGraphModel(), and toggleX().

QVector<bool> QcepScatterPlotGraphModel::m_Y
private

Definition at line 35 of file qcepscatterplotgraphmodel.h.

Referenced by getY(), QcepScatterPlotGraphModel(), and toggleY().

QVector<bool> QcepScatterPlotGraphModel::m_Y2
private

Definition at line 35 of file qcepscatterplotgraphmodel.h.

Referenced by getY2(), QcepScatterPlotGraphModel(), and toggleY2().


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