7 : QAbstractListModel(),
24 int n = settings->beginReadArray(section+
"/roi");
28 for (
int i=0; i<n; i++) {
29 settings->setArrayIndex(i);
31 int roiType = settings->value(
"roiType", 0).toInt();
36 roi->readSettings(settings,
"");
53 settings->beginWriteArray(section+
"/roi");
56 settings->setArrayIndex(i);
61 roi->writeSettings(settings,
"");
70 return engine->newQObject(coords.data());
75 QObject *qobj = obj.toQObject();
103 int row = index.row();
104 int col = index.column();
109 if (role == Qt::DisplayRole || role == Qt::EditRole) {
112 }
else if (col ==
SumCol) {
115 return c->get_Average();
117 return c->get_Minimum();
119 return c->get_Maximum();
121 return c->get_NPixels();
123 return c->get_Background();
125 return c->get_XGradient();
127 return c->get_YGradient();
129 return c->get_RoiTypeName();
131 return c->get_Coords().center().x();
133 return c->get_Coords().center().y();
135 return c->get_Coords().width();
137 return c->get_Coords().height();
139 return c->get_Width2();
141 return c->get_Height2();
151 if (orientation == Qt::Horizontal) {
152 if (role == Qt::DisplayRole) {
155 }
else if (section ==
SumCol) {
171 }
else if (section ==
TypeCol) {
186 }
else if (role == Qt::TextAlignmentRole) {
187 return Qt::AlignHCenter;
196 int row = index.row();
197 int col = index.column();
206 return QAbstractListModel::flags(index) | Qt::ItemIsEditable;
208 return QAbstractListModel::flags(index);
214 int row = index.row();
215 int col = index.column();
220 if (role == Qt::EditRole || role == Qt::DisplayRole) {
222 c->set_Sum(value.toDouble());
224 c->set_Average(value.toDouble());
226 c->set_Minimum(value.toDouble());
228 c->set_Maximum(value.toDouble());
230 c->set_NPixels(value.toDouble());
232 c->set_Background(value.toDouble());
234 c->set_XGradient(value.toDouble());
236 c->set_YGradient(value.toDouble());
238 c->selectNamedROIType(value.toString());
240 c->setCenterX(value.toDouble());
242 c->setCenterY(value.toDouble());
244 c->setWidth(value.toDouble());
246 c->setHeight(value.toDouble());
248 c->setWidth2(value.toDouble());
250 c->setHeight2(value.toDouble());
257 emit dataChanged(index, index);
284 beginRemoveRows(QModelIndex(), row, row);
295 if (row >= 0 && row < (nRows-1)) {
296 beginMoveRows(QModelIndex(), row+1, row+1, QModelIndex(), row);
312 if (row >= 1 && row < nRows) {
313 beginMoveRows(QModelIndex(), row, row, QModelIndex(), row-1);
339 emit dataChanged(index(row,0), index(row,
ColCount));
348 roi->setCenter(QPointF(x,y));
350 emit dataChanged(index(i,0), index(i,
ColCount));
358 QObject *s = sender();
366 if (r && r.data() == c) {
369 emit dataChanged(index(i,0), index(i,
columnCount(QModelIndex())));
386 r->recalculate(img, mask);
398 r->visualizeBackground(img, mask);
407 r->visualizePeak(img, mask);
void visualizePeak(int n, QcepImageDataBasePtr img, QcepMaskDataPtr mask)
int rowCount(const QModelIndex &parent) const
QSharedPointer< QxrdROICoordinates > QxrdROICoordinatesPtr
QVariant headerData(int section, Qt::Orientation orientation, int role) const
void recalculate(QcepImageDataBasePtr img, QcepMaskDataPtr mask)
Qt::ItemFlags flags(const QModelIndex &index) const
QxrdExperimentWPtr m_Experiment
QWeakPointer< QxrdExperiment > QxrdExperimentWPtr
void append(QxrdROICoordinatesPtr coords)
virtual ~QxrdROICoordinatesListModel()
QVariant data(const QModelIndex &index, int role) const
void readSettings(QSettings *settings, QString section)
void writeSettings(QSettings *settings, QString section)
int columnCount(const QModelIndex &parent) const
void visualizeBackground(int n, QcepImageDataBasePtr img, QcepMaskDataPtr mask)
QcepSettingsSaverWPtr m_Saver
void moveROIDown(int row)
QxrdROICoordinatesPtr newROI(int roiType)
QxrdROICoordinatesListModel(QcepSettingsSaverWPtr saver, QxrdExperimentWPtr exp)
static void fromScriptValue(const QScriptValue &obj, QxrdROICoordinatesListModelPtr &coords)
static QScriptValue toScriptValue(QScriptEngine *engine, const QxrdROICoordinatesListModelPtr &coords)
bool setData(const QModelIndex &index, const QVariant &value, int role)
void moveROICenter(int row, double x, double y)
QVector< QxrdROICoordinatesPtr > m_ROICoordinates
QSharedPointer< QcepImageDataBase > QcepImageDataBasePtr
QSharedPointer< QcepMaskData > QcepMaskDataPtr
QSharedPointer< QxrdROICoordinatesListModel > QxrdROICoordinatesListModelPtr
QxrdROICoordinatesPtr roi(int row) const
void setRoi(int row, QxrdROICoordinatesPtr c)
QWeakPointer< QcepSettingsSaver > QcepSettingsSaverWPtr